]> xenbits.xensource.com Git - seabios.git/commitdiff
smbios: Support SMBIOS 3.0 entry point at smbios_romfile_setup()
authorEduardo Habkost <ehabkost@redhat.com>
Thu, 10 Dec 2020 19:11:34 +0000 (14:11 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 18 Dec 2021 16:39:13 +0000 (11:39 -0500)
Support SMBIOS 3.0 entry points if exposed by QEMU in fw_cfg.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
src/fw/biostables.c

index 5ff1b0ed1ad01f506ae693a2af4784fb6d33f9d8..1c09a785bac946d6b2dbb645f12fd63eead38130 100644 (file)
@@ -588,19 +588,46 @@ smbios_21_setup_entry_point(struct romfile_s *f_tables,
     return 1;
 }
 
+static int
+smbios_30_setup_entry_point(struct romfile_s *f_tables,
+                            struct smbios_30_entry_point *ep)
+{
+    if (!smbios_build_tables(f_tables,
+                             &ep->structure_table_address,
+                             &ep->structure_table_max_size,
+                             NULL, NULL))
+        return 0;
+
+    ep->checksum -= checksum(ep, sizeof(*ep));
+    copy_smbios_30(ep);
+    return 1;
+}
+
 static int
 smbios_romfile_setup(void)
 {
     struct romfile_s *f_anchor = romfile_find("etc/smbios/smbios-anchor");
     struct romfile_s *f_tables = romfile_find("etc/smbios/smbios-tables");
-    struct smbios_21_entry_point ep;
+    union {
+        struct smbios_21_entry_point ep21;
+        struct smbios_30_entry_point ep30;
+    } ep;
 
-    if (!f_anchor || !f_tables || f_anchor->size != sizeof(ep))
+    if (!f_anchor || !f_tables || f_anchor->size > sizeof(ep))
         return 0;
 
     f_anchor->copy(f_anchor, &ep, f_anchor->size);
 
-    return smbios_21_setup_entry_point(f_tables, &ep);
+    if (f_anchor->size == sizeof(ep.ep21) &&
+        ep.ep21.signature == SMBIOS_21_SIGNATURE) {
+        return smbios_21_setup_entry_point(f_tables, &ep.ep21);
+    } else if (f_anchor->size == sizeof(ep.ep30) &&
+               valid_smbios_30_signature(&ep.ep30)) {
+        return smbios_30_setup_entry_point(f_tables, &ep.ep30);
+    } else {
+        dprintf(1, "Invalid SMBIOS signature at etc/smbios/smbios-anchor\n");
+        return 0;
+    }
 }
 
 void