xref: /illumos-gate/usr/src/test/util-tests/tests/smbios/smbios_test_pinfo.c (revision dd72704bd9e794056c558153663c739e2012d721)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2019 Robert Mustacchi
14  * Copyright 2021 Oxide Computer Company
15  */
16 
17 /*
18  * Tests for SMBIOS type 44 - SMB_TYPE_PROCESSOR_INFO and the per-CPU type
19  * follow ups.
20  */
21 
22 #include "smbios_test.h"
23 
24 static uint16_t smbios_pinfo_phandle = 0x1;
25 static uint64_t smbios_pinfo_isa = 0x4010d;
26 static uint8_t smbios_pinfo_hartid[16];
27 static uint8_t smbios_pinfo_vendid[16];
28 static uint8_t smbios_pinfo_archid[16];
29 static uint8_t smbios_pinfo_machid[16];
30 static uint8_t smbios_pinfo_metdi[16];
31 static uint8_t smbios_pinfo_mitdi[16];
32 
33 boolean_t
34 smbios_test_pinfo_mktable_amd64(smbios_test_table_t *table)
35 {
36 	smb_processor_info_t pi;
37 
38 	pi.smbpai_hdr.smbh_type = SMB_TYPE_PROCESSOR_INFO;
39 	pi.smbpai_hdr.smbh_len = sizeof (smb_processor_info_t);
40 	pi.smbpai_proc = htole16(smbios_pinfo_phandle);
41 	pi.smbpai_len = 0;
42 	pi.smbpai_type = SMB_PROCINFO_T_AMD64;
43 
44 	(void) smbios_test_table_append(table, &pi, sizeof (pi));
45 	smbios_test_table_append_eot(table);
46 
47 	return (B_TRUE);
48 }
49 
50 boolean_t
51 smbios_test_pinfo_verify_amd64(smbios_hdl_t *hdl)
52 {
53 	smbios_struct_t sp;
54 	smbios_processor_info_t pinfo;
55 	smbios_processor_info_riscv_t rv;
56 	boolean_t ret = B_TRUE;
57 
58 	if (smbios_lookup_type(hdl, SMB_TYPE_PROCESSOR_INFO, &sp) == -1) {
59 		warnx("failed to lookup SMBIOS processor additional "
60 		    "information: %s", smbios_errmsg(smbios_errno(hdl)));
61 		return (B_FALSE);
62 	}
63 
64 	if (smbios_info_processor_info(hdl, sp.smbstr_id, &pinfo) != 0) {
65 
66 		warnx("failed to get SMBIOS processor additional "
67 		    "information: %s", smbios_errmsg(smbios_errno(hdl)));
68 		return (B_FALSE);
69 	}
70 
71 	if (pinfo.smbpi_processor != smbios_pinfo_phandle) {
72 		warnx("processor handle incorrect, found 0x%x",
73 		    pinfo.smbpi_processor);
74 		ret = B_FALSE;
75 	}
76 
77 	if (pinfo.smbpi_ptype != SMB_PROCINFO_T_AMD64) {
78 		warnx("processor type incorrect, found 0x%x",
79 		    pinfo.smbpi_ptype);
80 		ret = B_FALSE;
81 	}
82 
83 	if (strcmp(smbios_processor_info_type_desc(pinfo.smbpi_ptype),
84 	    "X64 (x86-64, Intel64, AMD64, EMT64)") != 0) {
85 		warnx("processor type incorrect, found %s",
86 		    smbios_processor_info_type_desc(pinfo.smbpi_ptype));
87 		ret = B_FALSE;
88 	}
89 
90 	if (smbios_info_processor_riscv(hdl, sp.smbstr_id, &rv) != -1) {
91 		warnx("accidentally got riscv info on non-riscv handle");
92 		ret = B_FALSE;
93 	}
94 
95 	if (smbios_errno(hdl) != ESMB_TYPE) {
96 		warnx("encountered wrong errno for RISC-V info, found: 0x%x",
97 		    smbios_errno(hdl));
98 		ret = B_FALSE;
99 	}
100 
101 	return (ret);
102 }
103 
104 boolean_t
105 smbios_test_pinfo_mktable_riscv(smbios_test_table_t *table)
106 {
107 	smb_processor_info_t pi;
108 	smb_processor_info_riscv_t rv;
109 
110 	pi.smbpai_hdr.smbh_type = SMB_TYPE_PROCESSOR_INFO;
111 	pi.smbpai_hdr.smbh_len = sizeof (smb_processor_info_t) +
112 	    sizeof (smb_processor_info_riscv_t);
113 	pi.smbpai_proc = htole16(smbios_pinfo_phandle);
114 	pi.smbpai_len = sizeof (smb_processor_info_riscv_t);
115 	pi.smbpai_type = SMB_PROCINFO_T_RV64;
116 
117 	(void) smbios_test_table_append(table, &pi, sizeof (pi));
118 
119 	rv.smbpairv_vers = 1;
120 	rv.smbpairv_len = sizeof (smb_processor_info_riscv_t);
121 	arc4random_buf(smbios_pinfo_hartid, sizeof (smbios_pinfo_hartid));
122 	bcopy(smbios_pinfo_hartid, rv.smbpairv_hartid,
123 	    sizeof (smbios_pinfo_hartid));
124 	rv.smbpairv_boot = 1;
125 	arc4random_buf(smbios_pinfo_vendid, sizeof (smbios_pinfo_vendid));
126 	bcopy(smbios_pinfo_vendid, rv.smbpairv_vendid,
127 	    sizeof (smbios_pinfo_vendid));
128 	arc4random_buf(smbios_pinfo_archid, sizeof (smbios_pinfo_archid));
129 	bcopy(smbios_pinfo_archid, rv.smbpairv_archid,
130 	    sizeof (smbios_pinfo_archid));
131 	arc4random_buf(smbios_pinfo_machid, sizeof (smbios_pinfo_machid));
132 	bcopy(smbios_pinfo_machid, rv.smbpairv_machid,
133 	    sizeof (smbios_pinfo_machid));
134 	rv.smbpairv_boot = 1;
135 	rv.smbpairv_isa = htole64(smbios_pinfo_isa);
136 	rv.smbpairv_privlvl = SMB_RV_PRIV_M | SMB_RV_PRIV_S;
137 	arc4random_buf(smbios_pinfo_metdi, sizeof (smbios_pinfo_metdi));
138 	bcopy(smbios_pinfo_metdi, rv.smbpairv_metdi,
139 	    sizeof (smbios_pinfo_metdi));
140 	arc4random_buf(smbios_pinfo_mitdi, sizeof (smbios_pinfo_mitdi));
141 	bcopy(smbios_pinfo_mitdi, rv.smbpairv_mitdi,
142 	    sizeof (smbios_pinfo_mitdi));
143 	rv.smbpairv_xlen = SMB_RV_WIDTH_64B;
144 	rv.smbpairv_mxlen = SMB_RV_WIDTH_64B;
145 	rv.smbpairv_sxlen = SMB_RV_WIDTH_128B;
146 	rv.smbpairv_uxlen = SMB_RV_WIDTH_32B;
147 
148 	smbios_test_table_append_raw(table, &rv, sizeof (rv));
149 	smbios_test_table_append_eot(table);
150 
151 	return (B_TRUE);
152 }
153 
154 static void
155 smbios_test_pinfo_id_mismatch(uint8_t *act, uint8_t *exp)
156 {
157 	uint_t i;
158 	(void) fprintf(stderr, "found:    ");
159 	for (i = 0; i < 16; i++) {
160 		(void) fprintf(stderr, " %02x", act[i]);
161 	}
162 	(void) fprintf(stderr, "\nexpected: ");
163 	for (i = 0; i < 16; i++) {
164 		(void) fprintf(stderr, " %02x", exp[i]);
165 	}
166 	(void) fprintf(stderr, "\n");
167 }
168 
169 boolean_t
170 smbios_test_pinfo_verify_riscv(smbios_hdl_t *hdl)
171 {
172 	smbios_struct_t sp;
173 	smbios_processor_info_t pinfo;
174 	smbios_processor_info_riscv_t rv;
175 	boolean_t ret = B_TRUE;
176 
177 	if (smbios_lookup_type(hdl, SMB_TYPE_PROCESSOR_INFO, &sp) == -1) {
178 		warnx("failed to lookup SMBIOS processor additional "
179 		    "information: %s", smbios_errmsg(smbios_errno(hdl)));
180 		return (B_FALSE);
181 	}
182 
183 	if (smbios_info_processor_info(hdl, sp.smbstr_id, &pinfo) != 0) {
184 		warnx("failed to get SMBIOS processor additional "
185 		    "information: %s", smbios_errmsg(smbios_errno(hdl)));
186 		return (B_FALSE);
187 	}
188 
189 	if (pinfo.smbpi_processor != smbios_pinfo_phandle) {
190 		warnx("processor handle incorrect, found 0x%x",
191 		    pinfo.smbpi_processor);
192 		ret = B_FALSE;
193 	}
194 
195 	if (pinfo.smbpi_ptype != SMB_PROCINFO_T_RV64) {
196 		warnx("processor type incorrect, found 0x%x",
197 		    pinfo.smbpi_ptype);
198 		ret = B_FALSE;
199 	}
200 
201 	if (strcmp(smbios_processor_info_type_desc(pinfo.smbpi_ptype),
202 	    "64-bit RISC-V (RV64)") != 0) {
203 		warnx("processor type incorrect, found %s",
204 		    smbios_processor_info_type_desc(pinfo.smbpi_ptype));
205 		ret = B_FALSE;
206 	}
207 
208 	if (smbios_info_processor_riscv(hdl, sp.smbstr_id, &rv) != 0) {
209 
210 		warnx("failed to get SMBIOS processor additional "
211 		    "information for RISC-V: %s",
212 		    smbios_errmsg(smbios_errno(hdl)));
213 		return (B_FALSE);
214 	}
215 
216 	if (bcmp(rv.smbpirv_hartid, smbios_pinfo_hartid,
217 	    sizeof (smbios_pinfo_hartid)) != 0) {
218 		warnx("RISC-V hart id's don't match");
219 		smbios_test_pinfo_id_mismatch(rv.smbpirv_hartid,
220 		    smbios_pinfo_hartid);
221 		ret = B_FALSE;
222 	}
223 
224 	if (bcmp(rv.smbpirv_vendid, smbios_pinfo_vendid,
225 	    sizeof (smbios_pinfo_vendid)) != 0) {
226 		warnx("RISC-V vend id's don't match");
227 		smbios_test_pinfo_id_mismatch(rv.smbpirv_vendid,
228 		    smbios_pinfo_vendid);
229 		ret = B_FALSE;
230 	}
231 
232 	if (bcmp(rv.smbpirv_archid, smbios_pinfo_archid,
233 	    sizeof (smbios_pinfo_archid)) != 0) {
234 		warnx("RISC-V arch id's don't match");
235 		smbios_test_pinfo_id_mismatch(rv.smbpirv_archid,
236 		    smbios_pinfo_archid);
237 		ret = B_FALSE;
238 	}
239 
240 	if (bcmp(rv.smbpirv_machid, smbios_pinfo_machid,
241 	    sizeof (smbios_pinfo_machid)) != 0) {
242 		warnx("RISC-V mach id's don't match");
243 		smbios_test_pinfo_id_mismatch(rv.smbpirv_machid,
244 		    smbios_pinfo_machid);
245 		ret = B_FALSE;
246 	}
247 
248 	if (bcmp(rv.smbpirv_metdi, smbios_pinfo_metdi,
249 	    sizeof (smbios_pinfo_metdi)) != 0) {
250 		warnx("RISC-V METDI don't match");
251 		smbios_test_pinfo_id_mismatch(rv.smbpirv_metdi,
252 		    smbios_pinfo_metdi);
253 		ret = B_FALSE;
254 	}
255 
256 	if (bcmp(rv.smbpirv_mitdi, smbios_pinfo_mitdi,
257 	    sizeof (smbios_pinfo_mitdi)) != 0) {
258 		warnx("RISC-V METDI don't match");
259 		smbios_test_pinfo_id_mismatch(rv.smbpirv_mitdi,
260 		    smbios_pinfo_mitdi);
261 		ret = B_FALSE;
262 	}
263 
264 	if (rv.smbpirv_isa != smbios_pinfo_isa) {
265 		warnx("RISC-V ISA mismatch");
266 		ret = B_FALSE;
267 	}
268 
269 	if (rv.smbpirv_privlvl != (SMB_RV_PRIV_M | SMB_RV_PRIV_S)) {
270 		warnx("RISC-V privilege level mismatch, found: 0x%x",
271 		    rv.smbpirv_privlvl);
272 		ret = B_FALSE;
273 	}
274 
275 	if (rv.smbpirv_xlen != SMB_RV_WIDTH_64B) {
276 		warnx("RISC-V xlen mismatch, found: 0x%x", rv.smbpirv_xlen);
277 		ret = B_FALSE;
278 	}
279 
280 	if (rv.smbpirv_mxlen != SMB_RV_WIDTH_64B) {
281 		warnx("RISC-V mxlen mismatch, found: 0x%x", rv.smbpirv_mxlen);
282 		ret = B_FALSE;
283 	}
284 
285 	if (rv.smbpirv_sxlen != SMB_RV_WIDTH_128B) {
286 		warnx("RISC-V sxlen mismatch, found: 0x%x", rv.smbpirv_sxlen);
287 		ret = B_FALSE;
288 	}
289 
290 	if (rv.smbpirv_uxlen != SMB_RV_WIDTH_32B) {
291 		warnx("RISC-V uxlen mismatch, found: 0x%x", rv.smbpirv_uxlen);
292 		ret = B_FALSE;
293 	}
294 
295 	/*
296 	 * Finally, use this to spot check several of the different RISC-V
297 	 * strings.
298 	 */
299 	if (strcmp(smbios_riscv_priv_desc(SMB_RV_PRIV_M), "Machine Mode") !=
300 	    0) {
301 		warnx("SMB_RV_PRIV_M string desc mismatch, found %s",
302 		    smbios_riscv_priv_desc(SMB_RV_PRIV_M));
303 		ret = B_FALSE;
304 	}
305 
306 	if (strcmp(smbios_riscv_priv_name(SMB_RV_PRIV_U), "SMB_RV_PRIV_U") !=
307 	    0) {
308 		warnx("SMB_RV_PRIV_U string name mismatch, found %s",
309 		    smbios_riscv_priv_name(SMB_RV_PRIV_U));
310 		ret = B_FALSE;
311 	}
312 
313 	if (strcmp(smbios_riscv_width_desc(SMB_RV_WIDTH_64B), "64-bit") !=
314 	    0) {
315 		warnx("SMB_RV_WIDTH_64B string desc mismatch, found %s",
316 		    smbios_riscv_width_desc(SMB_RV_WIDTH_64B));
317 		ret = B_FALSE;
318 	}
319 
320 	if (strcmp(smbios_riscv_width_desc(SMB_RV_WIDTH_128B), "128-bit") !=
321 	    0) {
322 		warnx("SMB_RV_WIDTH_128B string desc mismatch, found %s",
323 		    smbios_riscv_width_desc(SMB_RV_WIDTH_128B));
324 		ret = B_FALSE;
325 	}
326 
327 	if (strcmp(smbios_riscv_isa_desc(SMB_RV_ISA_A), "Atomic") != 0) {
328 		warnx("SMB_RV_ISA_A string desc mismatch, found %s",
329 		    smbios_riscv_isa_desc(SMB_RV_ISA_A));
330 		ret = B_FALSE;
331 	}
332 
333 	if (strcmp(smbios_riscv_isa_desc(SMB_RV_ISA_C), "Compressed") != 0) {
334 		warnx("SMB_RV_ISA_C string desc mismatch, found %s",
335 		    smbios_riscv_isa_desc(SMB_RV_ISA_C));
336 		ret = B_FALSE;
337 	}
338 
339 	if (strcmp(smbios_riscv_isa_desc(SMB_RV_ISA_Q),
340 	    "Quad-precision floating-point") != 0) {
341 		warnx("SMB_RV_ISA_Q string desc mismatch, found %s",
342 		    smbios_riscv_isa_desc(SMB_RV_ISA_Q));
343 		ret = B_FALSE;
344 	}
345 
346 	if (strcmp(smbios_riscv_isa_name(SMB_RV_ISA_A), "SMB_RV_ISA_A") != 0) {
347 		warnx("SMB_RV_ISA_A string name mismatch, found %s",
348 		    smbios_riscv_isa_name(SMB_RV_ISA_A));
349 		ret = B_FALSE;
350 	}
351 
352 	if (strcmp(smbios_riscv_isa_name(SMB_RV_ISA_C), "SMB_RV_ISA_C") != 0) {
353 		warnx("SMB_RV_ISA_Q string name mismatch, found %s",
354 		    smbios_riscv_isa_name(SMB_RV_ISA_C));
355 		ret = B_FALSE;
356 	}
357 
358 	if (strcmp(smbios_riscv_isa_name(SMB_RV_ISA_Q), "SMB_RV_ISA_Q") != 0) {
359 		warnx("SMB_RV_ISA_Q string name mismatch, found %s",
360 		    smbios_riscv_isa_name(SMB_RV_ISA_Q));
361 		ret = B_FALSE;
362 	}
363 
364 	return (ret);
365 }
366 
367 /*
368  * This shows having an invalid table length.
369  */
370 boolean_t
371 smbios_test_pinfo_mktable_invlen1(smbios_test_table_t *table)
372 {
373 	smb_processor_info_t pi;
374 
375 	pi.smbpai_hdr.smbh_type = SMB_TYPE_PROCESSOR_INFO;
376 	pi.smbpai_hdr.smbh_len = 2;
377 	pi.smbpai_proc = htole16(smbios_pinfo_phandle);
378 	pi.smbpai_len = 0;
379 	pi.smbpai_type = SMB_PROCINFO_T_AMD64;
380 
381 	(void) smbios_test_table_append(table, &pi, sizeof (pi));
382 	smbios_test_table_append_eot(table);
383 
384 	return (B_TRUE);
385 }
386 
387 /*
388  * This sets the internal length of the additional processor information data to
389  * go beyond the length of the basic structure.
390  */
391 boolean_t
392 smbios_test_pinfo_mktable_invlen2(smbios_test_table_t *table)
393 {
394 	smb_processor_info_t pi;
395 	smb_processor_info_riscv_t rv;
396 
397 	pi.smbpai_hdr.smbh_type = SMB_TYPE_PROCESSOR_INFO;
398 	pi.smbpai_hdr.smbh_len = sizeof (smb_processor_info_t);
399 	pi.smbpai_proc = htole16(smbios_pinfo_phandle);
400 	pi.smbpai_len = sizeof (smb_processor_info_riscv_t);
401 	pi.smbpai_type = SMB_PROCINFO_T_RV64;
402 
403 	(void) smbios_test_table_append(table, &pi, sizeof (pi));
404 
405 	arc4random_buf(&rv, sizeof (rv));
406 	rv.smbpairv_vers = 1;
407 	rv.smbpairv_len = sizeof (smb_processor_info_riscv_t);
408 
409 	smbios_test_table_append_raw(table, &rv, sizeof (rv));
410 	smbios_test_table_append_eot(table);
411 
412 	return (B_TRUE);
413 }
414 
415 /*
416  * This verifies that we can detect a header length that doesn't properly
417  * contain both the risc-v and base structure.
418  */
419 boolean_t
420 smbios_test_pinfo_mktable_invlen3(smbios_test_table_t *table)
421 {
422 	smb_processor_info_t pi;
423 	smb_processor_info_riscv_t rv;
424 
425 	pi.smbpai_hdr.smbh_type = SMB_TYPE_PROCESSOR_INFO;
426 	pi.smbpai_hdr.smbh_len = sizeof (smb_processor_info_t);
427 	pi.smbpai_proc = htole16(smbios_pinfo_phandle);
428 	pi.smbpai_len = 0;
429 	pi.smbpai_type = SMB_PROCINFO_T_RV64;
430 
431 	(void) smbios_test_table_append(table, &pi, sizeof (pi));
432 
433 	arc4random_buf(&rv, sizeof (rv));
434 	rv.smbpairv_vers = 1;
435 	rv.smbpairv_len = sizeof (smb_processor_info_riscv_t);
436 
437 	smbios_test_table_append_raw(table, &rv, sizeof (rv));
438 	smbios_test_table_append_eot(table);
439 
440 	return (B_TRUE);
441 }
442 
443 /*
444  * This verifies that we can detect an inner risc-v additional processor
445  * information section that declares its size to be beyond the header of the
446  * structure.
447  */
448 boolean_t
449 smbios_test_pinfo_mktable_invlen4(smbios_test_table_t *table)
450 {
451 	smb_processor_info_t pi;
452 	smb_processor_info_riscv_t rv;
453 
454 	pi.smbpai_hdr.smbh_type = SMB_TYPE_PROCESSOR_INFO;
455 	pi.smbpai_hdr.smbh_len = sizeof (smb_processor_info_t) +
456 	    sizeof (smb_processor_info_riscv_t);
457 	pi.smbpai_proc = htole16(smbios_pinfo_phandle);
458 	pi.smbpai_len = sizeof (smb_processor_info_riscv_t);
459 	pi.smbpai_type = SMB_PROCINFO_T_RV64;
460 
461 	(void) smbios_test_table_append(table, &pi, sizeof (pi));
462 
463 	arc4random_buf(&rv, sizeof (rv));
464 	rv.smbpairv_vers = 1;
465 	rv.smbpairv_len = sizeof (smb_processor_info_riscv_t) * 2;
466 
467 	smbios_test_table_append_raw(table, &rv, sizeof (rv));
468 	smbios_test_table_append_eot(table);
469 
470 	return (B_TRUE);
471 }
472 static boolean_t
473 smbios_test_pinfo_verify_badtable(smbios_hdl_t *hdl, int smberr,
474     boolean_t valid_pinfo)
475 {
476 	smbios_struct_t sp;
477 	smbios_processor_info_t pinfo;
478 	smbios_processor_info_riscv_t rv;
479 	boolean_t ret = B_TRUE;
480 
481 	if (smbios_lookup_type(hdl, SMB_TYPE_PROCESSOR_INFO, &sp) == -1) {
482 		warnx("failed to lookup SMBIOS processor additional "
483 		    "information: %s", smbios_errmsg(smbios_errno(hdl)));
484 		return (B_FALSE);
485 	}
486 
487 	if (!valid_pinfo) {
488 		if (smbios_info_processor_info(hdl, sp.smbstr_id, &pinfo) !=
489 		    -1) {
490 			warnx("accidentally parsed invalid processor "
491 			    "additional information as valid");
492 			ret = B_FALSE;
493 		}
494 
495 		if (smbios_errno(hdl) != smberr) {
496 			warnx("encountered wrong error for processor info, "
497 			    "found: 0x%x", smbios_errno(hdl));
498 			ret = B_FALSE;
499 		}
500 	} else {
501 		if (smbios_info_processor_info(hdl, sp.smbstr_id, &pinfo) !=
502 		    0) {
503 			warnx("failed to get SMBIOS processor additional "
504 			    "information: %s",
505 			    smbios_errmsg(smbios_errno(hdl)));
506 			ret = B_FALSE;
507 		}
508 	}
509 
510 	if (smbios_info_processor_riscv(hdl, sp.smbstr_id, &rv) != -1) {
511 		warnx("accidentally got riscv info on invalid handle");
512 		ret = B_FALSE;
513 	}
514 
515 	if (smbios_errno(hdl) != smberr) {
516 		warnx("encountered wrong error for amd64 info, found: 0x%x",
517 		    smbios_errno(hdl));
518 		ret = B_FALSE;
519 	}
520 
521 	return (ret);
522 }
523 
524 boolean_t
525 smbios_test_pinfo_verify_invlen1(smbios_hdl_t *hdl)
526 {
527 	return (smbios_test_pinfo_verify_badtable(hdl, ESMB_SHORT, B_FALSE));
528 }
529 
530 boolean_t
531 smbios_test_pinfo_verify_invlen2(smbios_hdl_t *hdl)
532 {
533 	return (smbios_test_pinfo_verify_badtable(hdl, ESMB_CORRUPT, B_FALSE));
534 }
535 
536 boolean_t
537 smbios_test_pinfo_verify_invlen3(smbios_hdl_t *hdl)
538 {
539 	return (smbios_test_pinfo_verify_badtable(hdl, ESMB_SHORT, B_TRUE));
540 }
541 
542 boolean_t
543 smbios_test_pinfo_verify_invlen4(smbios_hdl_t *hdl)
544 {
545 	return (smbios_test_pinfo_verify_badtable(hdl, ESMB_CORRUPT, B_TRUE));
546 }
547 
548 boolean_t
549 smbios_test_pinfo_verify_badtype(smbios_hdl_t *hdl)
550 {
551 	smbios_struct_t sp;
552 	smbios_processor_info_t pinfo;
553 	smbios_processor_info_riscv_t rv;
554 	boolean_t ret = B_TRUE;
555 
556 	if (smbios_lookup_type(hdl, SMB_TYPE_MEMDEVICE, &sp) == -1) {
557 		warnx("failed to lookup SMBIOS memory device information: %s",
558 		    smbios_errmsg(smbios_errno(hdl)));
559 		return (B_FALSE);
560 	}
561 
562 	if (smbios_info_processor_info(hdl, sp.smbstr_id, &pinfo) != -1) {
563 		warnx("accidentally parsed invalid processor additional "
564 		    "information as valid");
565 		ret = B_FALSE;
566 	}
567 
568 	if (smbios_errno(hdl) != ESMB_TYPE) {
569 		warnx("encountered wrong error for processor info, found: 0x%x",
570 		    smbios_errno(hdl));
571 		ret = B_FALSE;
572 	}
573 
574 	if (smbios_info_processor_riscv(hdl, sp.smbstr_id, &rv) != -1) {
575 		warnx("accidentally got riscv info on invalid handle");
576 		ret = B_FALSE;
577 	}
578 
579 	if (smbios_errno(hdl) != ESMB_TYPE) {
580 		warnx("encountered wrong error for processor info, found: 0x%x",
581 		    smbios_errno(hdl));
582 		ret = B_FALSE;
583 	}
584 
585 	return (ret);
586 }
587