Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

x86/CPU/AMD: Print AGESA string from DMI additional information entry

Type 40 entries (Additional Information) are summarized in section 7.41 as
part of the SMBIOS specification. Generally, these entries aren't interesting
to save.

However on some AMD Zen systems, the AGESA version is stored here. This is
useful to save to the kernel message logs for debugging. It can be used to
cross-reference issues.

Implement an iterator for the Additional Information entries. Use this to find
and print the AGESA string. Do so in AMD code, since the use case is
AMD-specific.

[ bp: Match only "AGESA". ]

Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
Co-developed-by: "Mario Limonciello (AMD)" <superm1@kernel.org>
Signed-off-by: "Mario Limonciello (AMD)" <superm1@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Link: https://patch.msgid.link/20260307141024.819807-6-superm1@kernel.org

authored by

Yazen Ghannam and committed by
Borislav Petkov (AMD)
bc91133e da55ebe1

+69 -1
+49
arch/x86/kernel/cpu/amd.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 #include <linux/export.h> 3 3 #include <linux/bitops.h> 4 + #include <linux/dmi.h> 4 5 #include <linux/elf.h> 5 6 #include <linux/mm.h> 6 7 #include <linux/kvm_types.h> ··· 1381 1380 return 0; 1382 1381 } 1383 1382 late_initcall(print_s5_reset_status_mmio); 1383 + 1384 + static void __init dmi_scan_additional(const struct dmi_header *d, void *p) 1385 + { 1386 + struct dmi_a_info *info = (struct dmi_a_info *)d; 1387 + void *next, *end; 1388 + 1389 + if (!IS_ENABLED(CONFIG_DMI)) 1390 + return; 1391 + 1392 + if (info->header.type != DMI_ENTRY_ADDITIONAL || 1393 + info->header.length < DMI_A_INFO_MIN_SIZE || 1394 + info->count < 1) 1395 + return; 1396 + 1397 + next = (void *)(info + 1); 1398 + end = (void *)info + info->header.length; 1399 + 1400 + do { 1401 + struct dmi_a_info_entry *entry; 1402 + const char *string_ptr; 1403 + 1404 + entry = (struct dmi_a_info_entry *)next; 1405 + 1406 + /* 1407 + * Not much can be done to validate data. At least the entry 1408 + * length shouldn't be 0. 1409 + */ 1410 + if (!entry->length) 1411 + return; 1412 + 1413 + string_ptr = dmi_string_nosave(&info->header, entry->str_num); 1414 + 1415 + /* Sample string: AGESA!V9 StrixKrackanPI-FP8 1.1.0.0c */ 1416 + if (!strncmp(string_ptr, "AGESA", 5)) { 1417 + pr_info("AGESA: %s\n", string_ptr); 1418 + break; 1419 + } 1420 + 1421 + next += entry->length; 1422 + } while (end - next >= DMI_A_INFO_ENT_MIN_SIZE); 1423 + } 1424 + 1425 + static __init int print_dmi_agesa(void) 1426 + { 1427 + dmi_walk(dmi_scan_additional, NULL); 1428 + return 0; 1429 + } 1430 + late_initcall(print_dmi_agesa);
+2 -1
drivers/firmware/dmi_scan.c
··· 47 47 static int dmi_memdev_nr; 48 48 static int dmi_memdev_populated_nr __initdata; 49 49 50 - static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s) 50 + const char *dmi_string_nosave(const struct dmi_header *dm, u8 s) 51 51 { 52 52 const u8 *bp = ((u8 *) dm) + dm->length; 53 53 const u8 *nsp; ··· 66 66 67 67 return dmi_empty_string; 68 68 } 69 + EXPORT_SYMBOL_GPL(dmi_string_nosave); 69 70 70 71 static const char * __init dmi_string(const struct dmi_header *dm, u8 s) 71 72 {
+18
include/linux/dmi.h
··· 91 91 void *device_data; /* Type specific data */ 92 92 }; 93 93 94 + #define DMI_A_INFO_ENT_MIN_SIZE 0x6 95 + struct dmi_a_info_entry { 96 + u8 length; 97 + u16 handle; 98 + u8 offset; 99 + u8 str_num; 100 + u8 value[]; 101 + } __packed; 102 + 103 + #define DMI_A_INFO_MIN_SIZE 0xB 104 + struct dmi_a_info { 105 + struct dmi_header header; 106 + u8 count; 107 + } __packed; 108 + 94 109 #ifdef CONFIG_DMI 95 110 96 111 struct dmi_dev_onboard { ··· 135 120 extern u64 dmi_memdev_size(u16 handle); 136 121 extern u8 dmi_memdev_type(u16 handle); 137 122 extern u16 dmi_memdev_handle(int slot); 123 + const char *dmi_string_nosave(const struct dmi_header *dm, u8 s); 138 124 139 125 #else 140 126 ··· 169 153 static inline u16 dmi_memdev_handle(int slot) { return 0xffff; } 170 154 static inline const struct dmi_system_id * 171 155 dmi_first_match(const struct dmi_system_id *list) { return NULL; } 156 + static inline const char * 157 + dmi_string_nosave(const struct dmi_header *dm, u8 s) { return ""; } 172 158 173 159 #endif 174 160