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