Skip to contentSkip to conversation

hw/smbios: fix offset of type 3 sku field

PATCH In review Daniel P. Berrangé 3 participants 3 messages Feb 15, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/smbios: fix offset of type 3 sku field

The type 3 SMBIOS structure[1] ends with fields

...

  0x14  - contained element count
  0x15  - contained element record length
  0x16  - sku number

The smbios_type_3 struct missed the contained element record length field, causing sku number to be reported at the wrong offset.

[1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.1.1.pdf

---
 hw/smbios/smbios.c           | 1 +
 include/hw/firmware/smbios.h | 1 +
 2 files changed, 2 insertions(+)
hw/smbios/smbios.c +1 -0
index 818be8a838..47be9071fa 100644
@@ -563,6 +563,7 @@ static void smbios_build_type_3_table(void)
     t->height = 0;
     t->number_of_power_cords = 0;
     t->contained_element_count = 0;
+    t->contained_element_record_length = 0;
     SMBIOS_TABLE_SET_STR(3, sku_number_str, type3.sku);
 
     SMBIOS_BUILD_TABLE_POST;
include/hw/firmware/smbios.h +1 -0
index eeb5a4d7b6..6fef32a3c9 100644
@@ -162,6 +162,7 @@ struct smbios_type_3 {
     uint8_t height;
     uint8_t number_of_power_cords;
     uint8_t contained_element_count;
+    uint8_t contained_element_record_length;
     uint8_t sku_number_str;
     /* contained elements follow */
 } QEMU_PACKED;
Signature · 1 line
2.19.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · On Fri, 15 Feb 2019 15:36:00 +0000 Daniel P. Berrangé <[email protected]>…

The type 3 SMBIOS structure[1] ends with fields

...

  0x14  - contained element count
  0x15  - contained element record length
  0x16  - sku number
Quoted 7 lines

The smbios_type_3 struct missed the contained element record length field, causing sku number to be reported at the wrong offset.

[1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.1.1.pdf

Quoted 29 lines
---
 hw/smbios/smbios.c           | 1 +
 include/hw/firmware/smbios.h | 1 +
 2 files changed, 2 insertions(+)
hw/smbios/smbios.c +1 -0
index 818be8a838..47be9071fa 100644
@@ -563,6 +563,7 @@ static void smbios_build_type_3_table(void)
     t->height = 0;
     t->number_of_power_cords = 0;
     t->contained_element_count = 0;
+    t->contained_element_record_length = 0;
     SMBIOS_TABLE_SET_STR(3, sku_number_str, type3.sku);
 
     SMBIOS_BUILD_TABLE_POST;
include/hw/firmware/smbios.h +1 -0
index eeb5a4d7b6..6fef32a3c9 100644
@@ -162,6 +162,7 @@ struct smbios_type_3 {
     uint8_t height;
     uint8_t number_of_power_cords;
     uint8_t contained_element_count;
+    uint8_t contained_element_record_length;
     uint8_t sku_number_str;
     /* contained elements follow */
 } QEMU_PACKED;
Reviewed-by on v1 1/1
#2 lore raw
In reply to Daniel P. Berrangé
Quoted 7 lines · Daniel P. Berrangé

The type 3 SMBIOS structure[1] ends with fields

...

  0x14  - contained element count
  0x15  - contained element record length
  0x16  - sku number
Quoted 6 lines

The smbios_type_3 struct missed the contained element record length field, causing sku number to be reported at the wrong offset.

[1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.1.1.pdf

Fixes e41fca3da72
Quoted 1 line
Quoted 30 lines
---
 hw/smbios/smbios.c           | 1 +
 include/hw/firmware/smbios.h | 1 +
 2 files changed, 2 insertions(+)
hw/smbios/smbios.c +1 -0
index 818be8a838..47be9071fa 100644
@@ -563,6 +563,7 @@ static void smbios_build_type_3_table(void)
     t->height = 0;
     t->number_of_power_cords = 0;
     t->contained_element_count = 0;
+    t->contained_element_record_length = 0;
     SMBIOS_TABLE_SET_STR(3, sku_number_str, type3.sku);
 
     SMBIOS_BUILD_TABLE_POST;
include/hw/firmware/smbios.h +1 -0
index eeb5a4d7b6..6fef32a3c9 100644
@@ -162,6 +162,7 @@ struct smbios_type_3 {
     uint8_t height;
     uint8_t number_of_power_cords;
     uint8_t contained_element_count;
+    uint8_t contained_element_record_length;
     uint8_t sku_number_str;
     /* contained elements follow */
 } QEMU_PACKED;