yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-hw-smbios-set-new-default-SMBIOS-fields-for-Windows-.patch

ddf19c
From e6c3fbfc82863180007569cf2a9132c28a47bf1f Mon Sep 17 00:00:00 2001
ddf19c
From: "Daniel P. Berrange" <berrange@redhat.com>
ddf19c
Date: Mon, 20 Jan 2020 16:13:08 +0000
ddf19c
Subject: [PATCH 01/18] hw/smbios: set new default SMBIOS fields for Windows
ddf19c
 driver support
ddf19c
MIME-Version: 1.0
ddf19c
Content-Type: text/plain; charset=UTF-8
ddf19c
Content-Transfer-Encoding: 8bit
ddf19c
ddf19c
RH-Author: Daniel P. Berrange <berrange@redhat.com>
ddf19c
Message-id: <20200120161308.584989-2-berrange@redhat.com>
ddf19c
Patchwork-id: 93422
ddf19c
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 1/1] hw/smbios: set new default SMBIOS fields for Windows driver support
ddf19c
Bugzilla: 1782529
ddf19c
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
ddf19c
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
ddf19c
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
ddf19c
ddf19c
For Windows driver support, we have to follow this doc in order to
ddf19c
enable Windows to automatically determine the right drivers to install
ddf19c
for a given guest / host combination:
ddf19c
ddf19c
 https://docs.microsoft.com/en-us/windows-hardware/drivers/install/specifying-hardware-ids-for-a-computer
ddf19c
ddf19c
Out of the choices available, it was decided that the Windows drivers
ddf19c
will be written to expect use of the scheme documented as "HardwareID-6"
ddf19c
against Windows 10. This uses SMBIOS System (Type 1) and Base Board
ddf19c
(Type 2) tables and will match on
ddf19c
ddf19c
      System Manufacturer = Red Hat
ddf19c
      System SKU Number = 8.2.0
ddf19c
      Baseboard Manufacturer = Red Hat
ddf19c
      Baseboard Product = RHEL-AV
ddf19c
ddf19c
The new SMBIOS fields will be tied to machine type and only reported for
ddf19c
pc-q35-8.2.0 machine and later.
ddf19c
ddf19c
The old SMBIOS fields, previously reported by all machines were:
ddf19c
ddf19c
      System Manufacturer: Red Hat
ddf19c
      System Product Name: KVM
ddf19c
      System Version: RHEL-8.2.0 PC (Q35 + ICH9, 2009)
ddf19c
      System Family: Red Hat Enterprise Linux
ddf19c
      Baseboard Manufacturer: Red Hat
ddf19c
      Baseboard Product Name: KVM
ddf19c
      Baseboard Version: RHEL-8.2.0 PC (Q35 + ICH9, 2009)
ddf19c
      Chassis Manufacturer: Red Hat
ddf19c
      Chassis Product Name: KVM
ddf19c
      Chassis Version: RHEL-8.2.0 PC (Q35 + ICH9, 2009)
ddf19c
      Processor Manufacturer: Red Hat
ddf19c
      Processor Product Name: KVM
ddf19c
      Processor Version: RHEL-8.2.0 PC (Q35 + ICH9, 2009)
ddf19c
ddf19c
This information will continue to be reported for all machines, except
ddf19c
where it conflicts with the requirement of the new SMBIOS data. IOW,
ddf19c
the "Baseboard Product Name" will change to "RHEL-AV" for pc-q35-8.2.0
ddf19c
machine types and later.
ddf19c
ddf19c
Management applications MUST NEVER override the 4 new SMBIOS fields that
ddf19c
are used for Windows driver matching, with differing values. Aside from
ddf19c
this, they are free to override any other field, including those from
ddf19c
the old SMBIOS field data.
ddf19c
ddf19c
In particular if a management application wants to report its own
ddf19c
product name and version, it is recommended to use "System product"
ddf19c
and "System version" as identifying fields, as these avoid a clash with
ddf19c
the new SMBIOS fields used for Windows drivers.
ddf19c
ddf19c
Note that until now the Baseboard (type 2) table has only been generated
ddf19c
by QEMU if explicitly asked for on the CLI. This patch makes it always
ddf19c
present for new machine types.
ddf19c
ddf19c
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 hw/arm/virt.c                |  2 +-
ddf19c
 hw/i386/pc_piix.c            |  2 ++
ddf19c
 hw/i386/pc_q35.c             |  8 ++++++++
ddf19c
 hw/smbios/smbios.c           | 45 +++++++++++++++++++++++++++++++++++++++++---
ddf19c
 include/hw/firmware/smbios.h |  5 ++++-
ddf19c
 include/hw/i386/pc.h         |  3 +++
ddf19c
 6 files changed, 60 insertions(+), 5 deletions(-)
ddf19c
ddf19c
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
ddf19c
index d30d38c..2dcf6e7 100644
ddf19c
--- a/hw/arm/virt.c
ddf19c
+++ b/hw/arm/virt.c
ddf19c
@@ -1423,7 +1423,7 @@ static void virt_build_smbios(VirtMachineState *vms)
ddf19c
 
ddf19c
     smbios_set_defaults("QEMU", product,
ddf19c
                         vmc->smbios_old_sys_ver ? "1.0" : mc->name, false,
ddf19c
-                        true, SMBIOS_ENTRY_POINT_30);
ddf19c
+                        true, NULL, NULL, SMBIOS_ENTRY_POINT_30);
ddf19c
 
ddf19c
     smbios_get_tables(MACHINE(vms), NULL, 0, &smbios_tables, &smbios_tables_len,
ddf19c
                       &smbios_anchor, &smbios_anchor_len);
ddf19c
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
ddf19c
index bd7fdb9..2ac94d5 100644
ddf19c
--- a/hw/i386/pc_piix.c
ddf19c
+++ b/hw/i386/pc_piix.c
ddf19c
@@ -177,6 +177,8 @@ static void pc_init1(MachineState *machine,
ddf19c
         smbios_set_defaults("Red Hat", "KVM",
ddf19c
                             mc->desc, pcmc->smbios_legacy_mode,
ddf19c
                             pcmc->smbios_uuid_encoded,
ddf19c
+                            pcmc->smbios_stream_product,
ddf19c
+                            pcmc->smbios_stream_version,
ddf19c
                             SMBIOS_ENTRY_POINT_21);
ddf19c
     }
ddf19c
 
ddf19c
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
ddf19c
index 7531d8e..e975643 100644
ddf19c
--- a/hw/i386/pc_q35.c
ddf19c
+++ b/hw/i386/pc_q35.c
ddf19c
@@ -200,6 +200,8 @@ static void pc_q35_init(MachineState *machine)
ddf19c
         smbios_set_defaults("Red Hat", "KVM",
ddf19c
                             mc->desc, pcmc->smbios_legacy_mode,
ddf19c
                             pcmc->smbios_uuid_encoded,
ddf19c
+                            pcmc->smbios_stream_product,
ddf19c
+                            pcmc->smbios_stream_version,
ddf19c
                             SMBIOS_ENTRY_POINT_21);
ddf19c
     }
ddf19c
 
ddf19c
@@ -565,8 +567,11 @@ static void pc_q35_init_rhel820(MachineState *machine)
ddf19c
 
ddf19c
 static void pc_q35_machine_rhel820_options(MachineClass *m)
ddf19c
 {
ddf19c
+    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
ddf19c
     pc_q35_machine_rhel_options(m);
ddf19c
     m->desc = "RHEL-8.2.0 PC (Q35 + ICH9, 2009)";
ddf19c
+    pcmc->smbios_stream_product = "RHEL-AV";
ddf19c
+    pcmc->smbios_stream_version = "8.2.0";
ddf19c
 }
ddf19c
 
ddf19c
 DEFINE_PC_MACHINE(q35_rhel820, "pc-q35-rhel8.2.0", pc_q35_init_rhel820,
ddf19c
@@ -579,9 +584,12 @@ static void pc_q35_init_rhel810(MachineState *machine)
ddf19c
 
ddf19c
 static void pc_q35_machine_rhel810_options(MachineClass *m)
ddf19c
 {
ddf19c
+    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
ddf19c
     pc_q35_machine_rhel820_options(m);
ddf19c
     m->desc = "RHEL-8.1.0 PC (Q35 + ICH9, 2009)";
ddf19c
     m->alias = NULL;
ddf19c
+    pcmc->smbios_stream_product = NULL;
ddf19c
+    pcmc->smbios_stream_version = NULL;
ddf19c
     compat_props_add(m->compat_props, hw_compat_rhel_8_1, hw_compat_rhel_8_1_len);
ddf19c
     compat_props_add(m->compat_props, pc_rhel_8_1_compat, pc_rhel_8_1_compat_len);
ddf19c
 }
ddf19c
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
ddf19c
index e6e9355..d65c149 100644
ddf19c
--- a/hw/smbios/smbios.c
ddf19c
+++ b/hw/smbios/smbios.c
ddf19c
@@ -57,6 +57,9 @@ static bool smbios_legacy = true;
ddf19c
 static bool smbios_uuid_encoded = true;
ddf19c
 /* end: legacy structures & constants for <= 2.0 machines */
ddf19c
 
ddf19c
+/* Set to true for modern Windows 10 HardwareID-6 compat */
ddf19c
+static bool smbios_type2_required;
ddf19c
+
ddf19c
 
ddf19c
 uint8_t *smbios_tables;
ddf19c
 size_t smbios_tables_len;
ddf19c
@@ -532,7 +535,7 @@ static void smbios_build_type_1_table(void)
ddf19c
 
ddf19c
 static void smbios_build_type_2_table(void)
ddf19c
 {
ddf19c
-    SMBIOS_BUILD_TABLE_PRE(2, 0x200, false); /* optional */
ddf19c
+    SMBIOS_BUILD_TABLE_PRE(2, 0x200, smbios_type2_required);
ddf19c
 
ddf19c
     SMBIOS_TABLE_SET_STR(2, manufacturer_str, type2.manufacturer);
ddf19c
     SMBIOS_TABLE_SET_STR(2, product_str, type2.product);
ddf19c
@@ -753,7 +756,10 @@ void smbios_set_cpuid(uint32_t version, uint32_t features)
ddf19c
 
ddf19c
 void smbios_set_defaults(const char *manufacturer, const char *product,
ddf19c
                          const char *version, bool legacy_mode,
ddf19c
-                         bool uuid_encoded, SmbiosEntryPointType ep_type)
ddf19c
+                         bool uuid_encoded,
ddf19c
+                         const char *stream_product,
ddf19c
+                         const char *stream_version,
ddf19c
+                         SmbiosEntryPointType ep_type)
ddf19c
 {
ddf19c
     smbios_have_defaults = true;
ddf19c
     smbios_legacy = legacy_mode;
ddf19c
@@ -774,12 +780,45 @@ void smbios_set_defaults(const char *manufacturer, const char *product,
ddf19c
         g_free(smbios_entries);
ddf19c
     }
ddf19c
 
ddf19c
+    /*
ddf19c
+     * If @stream_product & @stream_version are non-NULL, then
ddf19c
+     * we're following rules for new Windows driver support.
ddf19c
+     * The data we have to report is defined in this doc:
ddf19c
+     *
ddf19c
+     * https://docs.microsoft.com/en-us/windows-hardware/drivers/install/specifying-hardware-ids-for-a-computer
ddf19c
+     *
ddf19c
+     * The Windows drivers are written to expect use of the
ddf19c
+     * scheme documented as "HardwareID-6" against Windows 10,
ddf19c
+     * which uses SMBIOS System (Type 1) and Base Board (Type 2)
ddf19c
+     * tables and will match on
ddf19c
+     *
ddf19c
+     *   System Manufacturer = Red Hat     (@manufacturer)
ddf19c
+     *   System SKU Number = 8.2.0         (@stream_version)
ddf19c
+     *   Baseboard Manufacturer = Red Hat  (@manufacturer)
ddf19c
+     *   Baseboard Product = RHEL-AV       (@stream_product)
ddf19c
+     *
ddf19c
+     * NB, SKU must be changed with each RHEL-AV release
ddf19c
+     *
ddf19c
+     * Other fields can be freely used by applications using
ddf19c
+     * QEMU. For example apps can use the "System product"
ddf19c
+     * and "System version" to identify themselves.
ddf19c
+     *
ddf19c
+     * We get 'System Manufacturer' and 'Baseboard Manufacturer'
ddf19c
+     */
ddf19c
     SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer);
ddf19c
     SMBIOS_SET_DEFAULT(type1.product, product);
ddf19c
     SMBIOS_SET_DEFAULT(type1.version, version);
ddf19c
     SMBIOS_SET_DEFAULT(type1.family, "Red Hat Enterprise Linux");
ddf19c
+    if (stream_version != NULL) {
ddf19c
+        SMBIOS_SET_DEFAULT(type1.sku, stream_version);
ddf19c
+    }
ddf19c
     SMBIOS_SET_DEFAULT(type2.manufacturer, manufacturer);
ddf19c
-    SMBIOS_SET_DEFAULT(type2.product, product);
ddf19c
+    if (stream_product != NULL) {
ddf19c
+        SMBIOS_SET_DEFAULT(type2.product, stream_product);
ddf19c
+        smbios_type2_required = true;
ddf19c
+    } else {
ddf19c
+        SMBIOS_SET_DEFAULT(type2.product, product);
ddf19c
+    }
ddf19c
     SMBIOS_SET_DEFAULT(type2.version, version);
ddf19c
     SMBIOS_SET_DEFAULT(type3.manufacturer, manufacturer);
ddf19c
     SMBIOS_SET_DEFAULT(type3.version, version);
ddf19c
diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h
ddf19c
index 02a0ced..67e38a1 100644
ddf19c
--- a/include/hw/firmware/smbios.h
ddf19c
+++ b/include/hw/firmware/smbios.h
ddf19c
@@ -267,7 +267,10 @@ void smbios_entry_add(QemuOpts *opts, Error **errp);
ddf19c
 void smbios_set_cpuid(uint32_t version, uint32_t features);
ddf19c
 void smbios_set_defaults(const char *manufacturer, const char *product,
ddf19c
                          const char *version, bool legacy_mode,
ddf19c
-                         bool uuid_encoded, SmbiosEntryPointType ep_type);
ddf19c
+                         bool uuid_encoded,
ddf19c
+                         const char *stream_product,
ddf19c
+                         const char *stream_version,
ddf19c
+                         SmbiosEntryPointType ep_type);
ddf19c
 uint8_t *smbios_get_table_legacy(MachineState *ms, size_t *length);
ddf19c
 void smbios_get_tables(MachineState *ms,
ddf19c
                        const struct smbios_phys_mem_area *mem_array,
ddf19c
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
ddf19c
index 2e362c8..b9f29ba 100644
ddf19c
--- a/include/hw/i386/pc.h
ddf19c
+++ b/include/hw/i386/pc.h
ddf19c
@@ -109,6 +109,9 @@ typedef struct PCMachineClass {
ddf19c
     bool smbios_defaults;
ddf19c
     bool smbios_legacy_mode;
ddf19c
     bool smbios_uuid_encoded;
ddf19c
+    /* New fields needed for Windows HardwareID-6 matching */
ddf19c
+    const char *smbios_stream_product;
ddf19c
+    const char *smbios_stream_version;
ddf19c
 
ddf19c
     /* RAM / address space compat: */
ddf19c
     bool gigabyte_align;
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c