[PATCH 3/5] firmware: dmi: Read additional information when decoding DMI table

Mario Limonciello (AMD) posted 5 patches 1 day, 12 hours ago
[PATCH 3/5] firmware: dmi: Read additional information when decoding DMI table
Posted by Mario Limonciello (AMD) 1 day, 12 hours ago
Type 40 entries (Additional information) are summarized in section
7.41 as part of the SMBIOS specification.  Save these entries when
decoding the DMI tables.

Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
 drivers/firmware/dmi_scan.c | 46 +++++++++++++++++++++++++++++++++++++
 include/linux/dmi.h         |  7 ++++++
 2 files changed, 53 insertions(+)

diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 80aded4c778bc..f7b7ed1d872e8 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -393,6 +393,48 @@ static void __init dmi_save_dev_pciaddr(int instance, int segment, int bus,
 	list_add(&dev->dev.list, &dmi_devices);
 }
 
+static void __init dmi_save_additional(const struct dmi_additional_info *info)
+{
+	const char *strings;
+	const u8 *data;
+	int count = 0;
+	int i;
+
+	if (!info || info->header.length < 5 + info->count * 5)
+		return;
+
+	data = info->entries;
+	strings = (const char *)(data + info->count * 5);
+
+	for (i = 0; i < info->count; i++) {
+		u8 entry_length = data[i * 5];
+		u8 string_num = data[i * 5 + 4];
+		const char *string_ptr;
+		char *value;
+		int len;
+
+		if (entry_length < 5 || string_num == 0)
+			continue;
+
+		string_ptr = dmi_string_nosave(&info->header, string_num);
+		if (!string_ptr || !*string_ptr)
+			continue;
+
+		len = strlen(string_ptr);
+		if (len == 0)
+			continue;
+
+		value = dmi_alloc(len + 1);
+		if (!value)
+			continue;
+
+		strscpy(value, string_ptr, len + 1);
+
+		dmi_save_one_device(DMI_DEV_TYPE_ADDITIONAL, value);
+		count++;
+	}
+}
+
 static void __init dmi_save_extended_devices(const struct dmi_header *dm)
 {
 	const char *name;
@@ -526,8 +568,12 @@ static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
 	case DMI_ENTRY_IPMI_DEV:
 		dmi_save_ipmi_device(dm);
 		break;
+	case DMI_ENTRY_ADDITIONAL:
+		dmi_save_additional((const struct dmi_additional_info *)dm);
+		break;
 	case DMI_ENTRY_ONBOARD_DEV_EXT:
 		dmi_save_extended_devices(dm);
+		break;
 	}
 }
 
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index a809b5095c259..3fc3d334b321d 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -24,6 +24,7 @@ enum dmi_device_type {
 	DMI_DEV_TYPE_OEM_STRING = -2,
 	DMI_DEV_TYPE_DEV_ONBOARD = -3,
 	DMI_DEV_TYPE_DEV_SLOT = -4,
+	DMI_DEV_TYPE_ADDITIONAL = -5,
 };
 
 enum dmi_entry_type {
@@ -87,6 +88,12 @@ struct dmi_device {
 	void *device_data;	/* Type specific data */
 };
 
+struct dmi_additional_info {
+	struct dmi_header header;
+	u8 count;
+	u8 entries[];
+} __packed;
+
 #ifdef CONFIG_DMI
 
 struct dmi_dev_onboard {
-- 
2.43.0
Re: [PATCH 3/5] firmware: dmi: Read additional information when decoding DMI table
Posted by kernel test robot 18 hours ago
Hi Mario,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/master]
[also build test WARNING on linus/master tip/auto-latest v6.19-rc1 next-20251215]
[cannot apply to tip/x86/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello-AMD/firmware-dmi-Correct-an-indexing-error-in-dmi-h/20251215-025606
base:   tip/master
patch link:    https://lore.kernel.org/r/20251214185309.152614-4-superm1%40kernel.org
patch subject: [PATCH 3/5] firmware: dmi: Read additional information when decoding DMI table
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20251215/202512151357.ZGpOppn5-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251215/202512151357.ZGpOppn5-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512151357.ZGpOppn5-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/firmware/dmi_scan.c:398:14: warning: variable 'strings' set but not used [-Wunused-but-set-variable]
     398 |         const char *strings;
         |                     ^
>> drivers/firmware/dmi_scan.c:400:6: warning: variable 'count' set but not used [-Wunused-but-set-variable]
     400 |         int count = 0;
         |             ^
   2 warnings generated.


vim +/strings +398 drivers/firmware/dmi_scan.c

   395	
   396	static void __init dmi_save_additional(const struct dmi_additional_info *info)
   397	{
 > 398		const char *strings;
   399		const u8 *data;
 > 400		int count = 0;
   401		int i;
   402	
   403		if (!info || info->header.length < 5 + info->count * 5)
   404			return;
   405	
   406		data = info->entries;
   407		strings = (const char *)(data + info->count * 5);
   408	
   409		for (i = 0; i < info->count; i++) {
   410			u8 entry_length = data[i * 5];
   411			u8 string_num = data[i * 5 + 4];
   412			const char *string_ptr;
   413			char *value;
   414			int len;
   415	
   416			if (entry_length < 5 || string_num == 0)
   417				continue;
   418	
   419			string_ptr = dmi_string_nosave(&info->header, string_num);
   420			if (!string_ptr || !*string_ptr)
   421				continue;
   422	
   423			len = strlen(string_ptr);
   424			if (len == 0)
   425				continue;
   426	
   427			value = dmi_alloc(len + 1);
   428			if (!value)
   429				continue;
   430	
   431			strscpy(value, string_ptr, len + 1);
   432	
   433			dmi_save_one_device(DMI_DEV_TYPE_ADDITIONAL, value);
   434			count++;
   435		}
   436	}
   437	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH 3/5] firmware: dmi: Read additional information when decoding DMI table
Posted by kernel test robot 1 day, 2 hours ago
Hi Mario,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/master]
[also build test WARNING on linus/master tip/auto-latest v6.19-rc1 next-20251215]
[cannot apply to tip/x86/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello-AMD/firmware-dmi-Correct-an-indexing-error-in-dmi-h/20251215-025606
base:   tip/master
patch link:    https://lore.kernel.org/r/20251214185309.152614-4-superm1%40kernel.org
patch subject: [PATCH 3/5] firmware: dmi: Read additional information when decoding DMI table
config: x86_64-allnoconfig (https://download.01.org/0day-ci/archive/20251215/202512151555.bDb36bV2-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251215/202512151555.bDb36bV2-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512151555.bDb36bV2-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/firmware/dmi_scan.c:398:14: warning: variable 'strings' set but not used [-Wunused-but-set-variable]
     398 |         const char *strings;
         |                     ^
>> drivers/firmware/dmi_scan.c:400:6: warning: variable 'count' set but not used [-Wunused-but-set-variable]
     400 |         int count = 0;
         |             ^
   2 warnings generated.


vim +/count +400 drivers/firmware/dmi_scan.c

   395	
   396	static void __init dmi_save_additional(const struct dmi_additional_info *info)
   397	{
   398		const char *strings;
   399		const u8 *data;
 > 400		int count = 0;
   401		int i;
   402	
   403		if (!info || info->header.length < 5 + info->count * 5)
   404			return;
   405	
   406		data = info->entries;
   407		strings = (const char *)(data + info->count * 5);
   408	
   409		for (i = 0; i < info->count; i++) {
   410			u8 entry_length = data[i * 5];
   411			u8 string_num = data[i * 5 + 4];
   412			const char *string_ptr;
   413			char *value;
   414			int len;
   415	
   416			if (entry_length < 5 || string_num == 0)
   417				continue;
   418	
   419			string_ptr = dmi_string_nosave(&info->header, string_num);
   420			if (!string_ptr || !*string_ptr)
   421				continue;
   422	
   423			len = strlen(string_ptr);
   424			if (len == 0)
   425				continue;
   426	
   427			value = dmi_alloc(len + 1);
   428			if (!value)
   429				continue;
   430	
   431			strscpy(value, string_ptr, len + 1);
   432	
   433			dmi_save_one_device(DMI_DEV_TYPE_ADDITIONAL, value);
   434			count++;
   435		}
   436	}
   437	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH 3/5] firmware: dmi: Read additional information when decoding DMI table
Posted by kernel test robot 1 day, 3 hours ago
Hi Mario,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/master]
[also build test WARNING on linus/master tip/auto-latest v6.19-rc1 next-20251215]
[cannot apply to tip/x86/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello-AMD/firmware-dmi-Correct-an-indexing-error-in-dmi-h/20251215-025606
base:   tip/master
patch link:    https://lore.kernel.org/r/20251214185309.152614-4-superm1%40kernel.org
patch subject: [PATCH 3/5] firmware: dmi: Read additional information when decoding DMI table
config: i386-allnoconfig (https://download.01.org/0day-ci/archive/20251215/202512151248.aV3iuNkX-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251215/202512151248.aV3iuNkX-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512151248.aV3iuNkX-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/firmware/dmi_scan.c: In function 'dmi_save_additional':
>> drivers/firmware/dmi_scan.c:398:21: warning: variable 'strings' set but not used [-Wunused-but-set-variable]
     398 |         const char *strings;
         |                     ^~~~~~~


vim +/strings +398 drivers/firmware/dmi_scan.c

   395	
   396	static void __init dmi_save_additional(const struct dmi_additional_info *info)
   397	{
 > 398		const char *strings;
   399		const u8 *data;
   400		int count = 0;
   401		int i;
   402	
   403		if (!info || info->header.length < 5 + info->count * 5)
   404			return;
   405	
   406		data = info->entries;
   407		strings = (const char *)(data + info->count * 5);
   408	
   409		for (i = 0; i < info->count; i++) {
   410			u8 entry_length = data[i * 5];
   411			u8 string_num = data[i * 5 + 4];
   412			const char *string_ptr;
   413			char *value;
   414			int len;
   415	
   416			if (entry_length < 5 || string_num == 0)
   417				continue;
   418	
   419			string_ptr = dmi_string_nosave(&info->header, string_num);
   420			if (!string_ptr || !*string_ptr)
   421				continue;
   422	
   423			len = strlen(string_ptr);
   424			if (len == 0)
   425				continue;
   426	
   427			value = dmi_alloc(len + 1);
   428			if (!value)
   429				continue;
   430	
   431			strscpy(value, string_ptr, len + 1);
   432	
   433			dmi_save_one_device(DMI_DEV_TYPE_ADDITIONAL, value);
   434			count++;
   435		}
   436	}
   437	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki