[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v1 1/1] hvmloader: allow overriding SMBIOS type 2 info



Extend smbios type 2 struct to match specification, add support to
override strings from toolstack.

Signed-off-by: Xin Li <xin.li@xxxxxxxxxx>

---
CC: Igor Druzhinin <igor.druzhinin@xxxxxxxxxx>
CC: Sergey Dyasli <sergey.dyasli@xxxxxxxxxx>
CC: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

---
 tools/firmware/hvmloader/smbios.c       | 64 ++++++++++++++++++++++++-
 tools/firmware/hvmloader/smbios_types.h |  6 +++
 xen/include/public/hvm/hvm_xs_strings.h | 30 +++++++-----
 3 files changed, 87 insertions(+), 13 deletions(-)

diff --git a/tools/firmware/hvmloader/smbios.c 
b/tools/firmware/hvmloader/smbios.c
index 40d8399be1..90cfe9fd10 100644
--- a/tools/firmware/hvmloader/smbios.c
+++ b/tools/firmware/hvmloader/smbios.c
@@ -497,9 +497,11 @@ static void *
 smbios_type_2_init(void *start)
 {
     struct smbios_type_2 *p = (struct smbios_type_2 *)start;
+    const char *s;
     uint8_t *ptr;
     void *pts;
     uint32_t length;
+    uint32_t counter = 0;
 
     pts = get_smbios_pt_struct(2, &length);
     if ( (pts != NULL)&&(length > 0) )
@@ -518,7 +520,67 @@ smbios_type_2_init(void *start)
         return (start + length);
     }
 
-    /* Only present when passed in */
+    s = xenstore_read(HVM_XS_BASEBOARD_MANUFACTURER, NULL);
+    if ( (s != NULL) && (*s != '\0') )
+    {
+        memset(p, 0, sizeof(*p));
+        p->header.type = 2;
+        p->header.length = sizeof(struct smbios_type_2);
+        p->header.handle = SMBIOS_HANDLE_TYPE2;
+        p->feature_flags = 0x09; /* Board is a hosting board and replaceable */
+        p->chassis_handle = SMBIOS_HANDLE_TYPE3;
+        p->board_type = 0x0a; /* Motherboard */
+        start += sizeof(struct smbios_type_2);
+
+        strcpy((char *)start, s);
+        start += strlen(s) + 1;
+        p->manufacturer_str = ++counter;
+
+        s = xenstore_read(HVM_XS_BASEBOARD_PRODUCT_NAME, NULL);
+        if ( (s != NULL) && (*s != '\0') )
+        {
+            strcpy((char *)start, s);
+            start += strlen(s) + 1;
+            p->product_name_str = ++counter;
+        }
+
+        s = xenstore_read(HVM_XS_BASEBOARD_VERSION, NULL);
+        if ( (s != NULL) && (*s != '\0') )
+        {
+            strcpy((char *)start, s);
+            start += strlen(s) + 1;
+            p->version_str = ++counter;
+        }
+
+        s = xenstore_read(HVM_XS_BASEBOARD_SERIAL_NUMBER, NULL);
+        if ( (s != NULL) && (*s != '\0') )
+        {
+            strcpy((char *)start, s);
+            start += strlen(s) + 1;
+            p->serial_number_str = ++counter;
+        }
+
+        s = xenstore_read(HVM_XS_BASEBOARD_ASSET_TAG, NULL);
+        if ( (s != NULL) && (*s != '\0') )
+        {
+            strcpy((char *)start, s);
+            start += strlen(s) + 1;
+            p->asset_tag_str = ++counter;
+        }
+
+        s = xenstore_read(HVM_XS_BASEBOARD_LOCATION_IN_CHASSIS, NULL);
+        if ( (s != NULL) && (*s != '\0') )
+        {
+            strcpy((char *)start, s);
+            start += strlen(s) + 1;
+            p->location_in_chassis_str = ++counter;
+        }
+
+        *((uint8_t *)start) = 0;
+        return start + 1;
+    }
+   
+    /* Only present when passed in or overriden */
     return start;
 }
 
diff --git a/tools/firmware/hvmloader/smbios_types.h 
b/tools/firmware/hvmloader/smbios_types.h
index acb63e2fe9..834ef38fba 100644
--- a/tools/firmware/hvmloader/smbios_types.h
+++ b/tools/firmware/hvmloader/smbios_types.h
@@ -90,6 +90,12 @@ struct smbios_type_2 {
     uint8_t product_name_str;
     uint8_t version_str;
     uint8_t serial_number_str;
+    uint8_t asset_tag_str;
+    uint8_t feature_flags;
+    uint8_t location_in_chassis_str;
+    uint16_t chassis_handle;
+    uint8_t board_type;
+    uint8_t contained_handle_count;
 } __attribute__ ((packed));
 
 /* System Enclosure - Contained Elements */
diff --git a/xen/include/public/hvm/hvm_xs_strings.h 
b/xen/include/public/hvm/hvm_xs_strings.h
index fea1dd4407..e3b328321d 100644
--- a/xen/include/public/hvm/hvm_xs_strings.h
+++ b/xen/include/public/hvm/hvm_xs_strings.h
@@ -62,18 +62,24 @@
 /* The following xenstore values are used to override some of the default
  * string values in the SMBIOS table constructed in hvmloader.
  */
-#define HVM_XS_BIOS_STRINGS            "bios-strings"
-#define HVM_XS_BIOS_VENDOR             "bios-strings/bios-vendor"
-#define HVM_XS_BIOS_VERSION            "bios-strings/bios-version"
-#define HVM_XS_SYSTEM_MANUFACTURER     "bios-strings/system-manufacturer"
-#define HVM_XS_SYSTEM_PRODUCT_NAME     "bios-strings/system-product-name"
-#define HVM_XS_SYSTEM_VERSION          "bios-strings/system-version"
-#define HVM_XS_SYSTEM_SERIAL_NUMBER    "bios-strings/system-serial-number"
-#define HVM_XS_ENCLOSURE_MANUFACTURER  "bios-strings/enclosure-manufacturer"
-#define HVM_XS_ENCLOSURE_SERIAL_NUMBER "bios-strings/enclosure-serial-number"
-#define HVM_XS_ENCLOSURE_ASSET_TAG     "bios-strings/enclosure-asset-tag"
-#define HVM_XS_BATTERY_MANUFACTURER    "bios-strings/battery-manufacturer"
-#define HVM_XS_BATTERY_DEVICE_NAME     "bios-strings/battery-device-name"
+#define HVM_XS_BIOS_STRINGS                  "bios-strings"
+#define HVM_XS_BIOS_VENDOR                   "bios-strings/bios-vendor"
+#define HVM_XS_BIOS_VERSION                  "bios-strings/bios-version"
+#define HVM_XS_SYSTEM_MANUFACTURER           "bios-strings/system-manufacturer"
+#define HVM_XS_SYSTEM_PRODUCT_NAME           "bios-strings/system-product-name"
+#define HVM_XS_SYSTEM_VERSION                "bios-strings/system-version"
+#define HVM_XS_SYSTEM_SERIAL_NUMBER          
"bios-strings/system-serial-number"
+#define HVM_XS_BASEBOARD_MANUFACTURER        
"bios-strings/baseboard-manufacturer"
+#define HVM_XS_BASEBOARD_PRODUCT_NAME        
"bios-strings/baseboard-product-name"
+#define HVM_XS_BASEBOARD_VERSION             "bios-strings/baseboard-version"
+#define HVM_XS_BASEBOARD_SERIAL_NUMBER       
"bios-strings/baseboard-serial-number"
+#define HVM_XS_BASEBOARD_ASSET_TAG           "bios-strings/baseboard-asset-tag"
+#define HVM_XS_BASEBOARD_LOCATION_IN_CHASSIS 
"bios-strings/baseboard-location-in-chassis"
+#define HVM_XS_ENCLOSURE_MANUFACTURER        
"bios-strings/enclosure-manufacturer"
+#define HVM_XS_ENCLOSURE_SERIAL_NUMBER       
"bios-strings/enclosure-serial-number"
+#define HVM_XS_ENCLOSURE_ASSET_TAG           "bios-strings/enclosure-asset-tag"
+#define HVM_XS_BATTERY_MANUFACTURER          
"bios-strings/battery-manufacturer"
+#define HVM_XS_BATTERY_DEVICE_NAME           "bios-strings/battery-device-name"
 
 /* 1 to 99 OEM strings can be set in xenstore using values of the form
  * below. These strings will be loaded into the SMBIOS type 11 structure.
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.