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

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