thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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