Message ID | 20240125011128.1176557-1-masahisa.kojima@linaro.org |
---|---|
State | Accepted |
Commit | b92d0f78dc04f6f7dd8b67cb9ea1bc1dc3b51aa6 |
Headers | show |
Series | smbios: use struct_table_length to get SMBIOS 2.1 total table length | expand |
On 1/25/24 02:11, Masahisa Kojima wrote: > The current code convert the SMBIOS 2.1 entry point structure to > SMBIOS 3.0 entry point structure. The max_struct_size member in > SMBIOS 2.1 entry point structure indicates > "Size of the largest SMBIOS structure, in bytes". > We need to use struct_table_length instead. > > Fixes: 1c5aab803c0b ("smbios: copy QEMU tables") > Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> > --- > drivers/misc/qfw_smbios.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/misc/qfw_smbios.c b/drivers/misc/qfw_smbios.c > index 9019345783..a898cb4eea 100644 > --- a/drivers/misc/qfw_smbios.c > +++ b/drivers/misc/qfw_smbios.c > @@ -90,7 +90,7 @@ static int qfw_parse_smbios_anchor(struct udevice *dev, > entry->length = sizeof(struct smbios3_entry); > entry->major_ver = entry2->major_ver; > entry->minor_ver = entry2->minor_ver; > - entry->max_struct_size = entry2->max_struct_size; > + entry->max_struct_size = entry2->struct_table_length; Thank you for catching this. These are the definitions: SMBIOS 2.1 (offset 0x08): Maximum Structure Size: Size of the largest SMBIOS structure, in bytes, and encompasses the structure’s formatted area and text strings SMBIOS 2.1 (offset 0x16): Structure Table Length: Total length of SMBIOS Structure Table, pointed to by the Structure Table Address, in bytes SMBIOS 3 (offset 0x0c) - Structure table maximum size Maximum size of SMBIOS Structure Table, pointed to by the Structure Table Address, in bytes. The actual size is guaranteed to be less or equal to the maximum size. SmbiosCreateTable() in EDK has this logic: EntryPointStructure->TableLength = (UINT16)(EntryPointStructure->TableLength + RecordSize); if (RecordSize > EntryPointStructure->MaxStructureSize) { EntryPointStructure->MaxStructureSize = (UINT16)RecordSize; } qemu-system-x86 gives me these values: entry2->max_struct_size: 81 entry2->struct_table_length: 321 I think we should rename the field in the SMBIOS3 header (e.g. to table_max_size) to avoid future confusion. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> > } else { > ret = -ENOENT; > goto out;
diff --git a/drivers/misc/qfw_smbios.c b/drivers/misc/qfw_smbios.c index 9019345783..a898cb4eea 100644 --- a/drivers/misc/qfw_smbios.c +++ b/drivers/misc/qfw_smbios.c @@ -90,7 +90,7 @@ static int qfw_parse_smbios_anchor(struct udevice *dev, entry->length = sizeof(struct smbios3_entry); entry->major_ver = entry2->major_ver; entry->minor_ver = entry2->minor_ver; - entry->max_struct_size = entry2->max_struct_size; + entry->max_struct_size = entry2->struct_table_length; } else { ret = -ENOENT; goto out;
The current code convert the SMBIOS 2.1 entry point structure to SMBIOS 3.0 entry point structure. The max_struct_size member in SMBIOS 2.1 entry point structure indicates "Size of the largest SMBIOS structure, in bytes". We need to use struct_table_length instead. Fixes: 1c5aab803c0b ("smbios: copy QEMU tables") Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> --- drivers/misc/qfw_smbios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)