9d3ce7cd74
- kvm-ui-clipboard-mark-type-as-not-available-when-there-i.patch [RHEL-19629] - kvm-ui-clipboard-add-asserts-for-update-and-request.patch [RHEL-19629] - kvm-hw-i386-pc-Defer-smbios_set_defaults-to-machine_done.patch [RHEL-21705] - kvm-Implement-base-of-SMBIOS-type-9-descriptor.patch [RHEL-21705] - kvm-Implement-SMBIOS-type-9-v2.6.patch [RHEL-21705] - kvm-smbios-cleanup-smbios_get_tables-from-legacy-handlin.patch [RHEL-21705] - kvm-smbios-get-rid-of-smbios_smp_sockets-global.patch [RHEL-21705] - kvm-smbios-get-rid-of-smbios_legacy-global.patch [RHEL-21705] - kvm-smbios-avoid-mangling-user-provided-tables.patch [RHEL-21705] - kvm-smbios-don-t-check-type4-structures-in-legacy-mode.patch [RHEL-21705] - kvm-smbios-add-smbios_add_usr_blob_size-helper.patch [RHEL-21705] - kvm-smbios-rename-expose-structures-bitmaps-used-by-both.patch [RHEL-21705] - kvm-smbios-build-legacy-mode-code-only-for-pc-machine.patch [RHEL-21705] - kvm-smbios-handle-errors-consistently.patch [RHEL-21705] - kvm-smbios-get-rid-of-global-smbios_ep_type.patch [RHEL-21705] - kvm-smbios-clear-smbios_type4_count-before-building-tabl.patch [RHEL-21705] - kvm-smbios-extend-smbios-entry-point-type-with-auto-valu.patch [RHEL-21705] - kvm-smbios-in-case-of-entry-point-is-auto-try-to-build-v.patch [RHEL-21705] - kvm-smbios-error-out-when-building-type-4-table-is-not-p.patch [RHEL-21705] - kvm-pc-q35-set-SMBIOS-entry-point-type-to-auto-by-defaul.patch [RHEL-21705] - Resolves: RHEL-19629 (CVE-2023-6683 qemu-kvm: QEMU: VNC: NULL pointer dereference in qemu_clipboard_request() [rhel-9]) - Resolves: RHEL-21705 (pc-q35-rhel9.4.0 does not provide proper computer information)
282 lines
11 KiB
Diff
282 lines
11 KiB
Diff
From be0abbf3f7845847b46486704c46c5de5a2b2323 Mon Sep 17 00:00:00 2001
|
|
From: Igor Mammedov <imammedo@redhat.com>
|
|
Date: Mon, 26 Feb 2024 13:49:14 +0100
|
|
Subject: [PATCH 15/20] smbios: get rid of global smbios_ep_type
|
|
|
|
RH-Author: Igor Mammedov <imammedo@redhat.com>
|
|
RH-MergeRequest: 230: Workaround Windows failing to find 64bit SMBIOS entry point with SeaBIOS
|
|
RH-Jira: RHEL-21705
|
|
RH-Acked-by: MST <mst@redhat.com>
|
|
RH-Acked-by: Ani Sinha <None>
|
|
RH-Commit: [13/18] 2e838ed0d03989e2e4ee08041b5ba64d5d7f5820
|
|
|
|
JIRA: https://issues.redhat.com/browse/RHEL-21705
|
|
|
|
Conflicts: hw/arm/virt.c, hw/i386/fw_cfg.c, hw/riscv/virt.c, hw/smbios/smbios.c,
|
|
include/hw/firmware/smbios.h
|
|
due to downstream specific smbios_set_defaults()
|
|
|
|
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
|
|
Acked-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
|
|
Reviewed-by: Ani Sinha <anisinha@redhat.com>
|
|
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
|
|
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
|
|
---
|
|
hw/arm/virt.c | 4 ++--
|
|
hw/i386/fw_cfg.c | 6 +++---
|
|
hw/i386/fw_cfg.h | 3 ++-
|
|
hw/i386/pc.c | 2 +-
|
|
hw/loongarch/virt.c | 7 ++++---
|
|
hw/smbios/smbios.c | 26 ++++++++++++++------------
|
|
hw/smbios/smbios_legacy.c | 2 +-
|
|
include/hw/firmware/smbios.h | 4 ++--
|
|
8 files changed, 29 insertions(+), 25 deletions(-)
|
|
|
|
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
|
|
index e5cfc19c08..e4a66affcb 100644
|
|
--- a/hw/arm/virt.c
|
|
+++ b/hw/arm/virt.c
|
|
@@ -1695,14 +1695,14 @@ static void virt_build_smbios(VirtMachineState *vms)
|
|
|
|
smbios_set_defaults("QEMU", product,
|
|
vmc->smbios_old_sys_ver ? "1.0" : mc->name,
|
|
- true, SMBIOS_ENTRY_POINT_TYPE_64,
|
|
+ true,
|
|
NULL, NULL);
|
|
|
|
/* build the array of physical mem area from base_memmap */
|
|
mem_array.address = vms->memmap[VIRT_MEM].base;
|
|
mem_array.length = ms->ram_size;
|
|
|
|
- smbios_get_tables(ms, &mem_array, 1,
|
|
+ smbios_get_tables(ms, SMBIOS_ENTRY_POINT_TYPE_64, &mem_array, 1,
|
|
&smbios_tables, &smbios_tables_len,
|
|
&smbios_anchor, &smbios_anchor_len,
|
|
&error_fatal);
|
|
diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c
|
|
index bdc3cc4556..58429bb78d 100644
|
|
--- a/hw/i386/fw_cfg.c
|
|
+++ b/hw/i386/fw_cfg.c
|
|
@@ -48,7 +48,8 @@ const char *fw_cfg_arch_key_name(uint16_t key)
|
|
return NULL;
|
|
}
|
|
|
|
-void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg)
|
|
+void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg,
|
|
+ SmbiosEntryPointType ep_type)
|
|
{
|
|
#ifdef CONFIG_SMBIOS
|
|
uint8_t *smbios_tables, *smbios_anchor;
|
|
@@ -64,7 +65,6 @@ void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg)
|
|
/* These values are guest ABI, do not change */
|
|
smbios_set_defaults("QEMU", mc->desc, mc->name,
|
|
pcmc->smbios_uuid_encoded,
|
|
- pcms->smbios_entry_point_type,
|
|
pcmc->smbios_stream_product,
|
|
pcmc->smbios_stream_version);
|
|
}
|
|
@@ -91,7 +91,7 @@ void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg)
|
|
array_count++;
|
|
}
|
|
}
|
|
- smbios_get_tables(ms, mem_array, array_count,
|
|
+ smbios_get_tables(ms, ep_type, mem_array, array_count,
|
|
&smbios_tables, &smbios_tables_len,
|
|
&smbios_anchor, &smbios_anchor_len,
|
|
&error_fatal);
|
|
diff --git a/hw/i386/fw_cfg.h b/hw/i386/fw_cfg.h
|
|
index 1e1de6b4a3..92e310f5fd 100644
|
|
--- a/hw/i386/fw_cfg.h
|
|
+++ b/hw/i386/fw_cfg.h
|
|
@@ -23,7 +23,8 @@
|
|
FWCfgState *fw_cfg_arch_create(MachineState *ms,
|
|
uint16_t boot_cpus,
|
|
uint16_t apic_id_limit);
|
|
-void fw_cfg_build_smbios(PCMachineState *ms, FWCfgState *fw_cfg);
|
|
+void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg,
|
|
+ SmbiosEntryPointType ep_type);
|
|
void fw_cfg_build_feature_control(MachineState *ms, FWCfgState *fw_cfg);
|
|
void fw_cfg_add_acpi_dsdt(Aml *scope, FWCfgState *fw_cfg);
|
|
|
|
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
|
|
index 16de2a59e8..ae6777fc1a 100644
|
|
--- a/hw/i386/pc.c
|
|
+++ b/hw/i386/pc.c
|
|
@@ -847,7 +847,7 @@ void pc_machine_done(Notifier *notifier, void *data)
|
|
|
|
acpi_setup();
|
|
if (x86ms->fw_cfg) {
|
|
- fw_cfg_build_smbios(pcms, x86ms->fw_cfg);
|
|
+ fw_cfg_build_smbios(pcms, x86ms->fw_cfg, pcms->smbios_entry_point_type);
|
|
fw_cfg_build_feature_control(MACHINE(pcms), x86ms->fw_cfg);
|
|
/* update FW_CFG_NB_CPUS to account for -device added CPUs */
|
|
fw_cfg_modify_i16(x86ms->fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus);
|
|
diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
|
|
index 7358a023d3..77956b5ada 100644
|
|
--- a/hw/loongarch/virt.c
|
|
+++ b/hw/loongarch/virt.c
|
|
@@ -320,10 +320,11 @@ static void virt_build_smbios(LoongArchMachineState *lams)
|
|
return;
|
|
}
|
|
|
|
- smbios_set_defaults("QEMU", product, mc->name,
|
|
- true, SMBIOS_ENTRY_POINT_TYPE_64);
|
|
+ smbios_set_defaults("QEMU", product, mc->name, true);
|
|
|
|
- smbios_get_tables(ms, NULL, 0, &smbios_tables, &smbios_tables_len,
|
|
+ smbios_get_tables(ms, SMBIOS_ENTRY_POINT_TYPE_64,
|
|
+ NULL, 0,
|
|
+ &smbios_tables, &smbios_tables_len,
|
|
&smbios_anchor, &smbios_anchor_len, &error_fatal);
|
|
|
|
if (smbios_anchor) {
|
|
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
|
|
index b5745c6c2d..7e32430b85 100644
|
|
--- a/hw/smbios/smbios.c
|
|
+++ b/hw/smbios/smbios.c
|
|
@@ -47,7 +47,6 @@ uint8_t *smbios_tables;
|
|
size_t smbios_tables_len;
|
|
unsigned smbios_table_max;
|
|
unsigned smbios_table_cnt;
|
|
-static SmbiosEntryPointType smbios_ep_type = SMBIOS_ENTRY_POINT_TYPE_32;
|
|
|
|
static SmbiosEntryPoint ep;
|
|
|
|
@@ -506,9 +505,9 @@ static bool smbios_check_type4_count(uint32_t expected_t4_count, Error **errp)
|
|
return true;
|
|
}
|
|
|
|
-bool smbios_validate_table(Error **errp)
|
|
+bool smbios_validate_table(SmbiosEntryPointType ep_type, Error **errp)
|
|
{
|
|
- if (smbios_ep_type == SMBIOS_ENTRY_POINT_TYPE_32 &&
|
|
+ if (ep_type == SMBIOS_ENTRY_POINT_TYPE_32 &&
|
|
smbios_tables_len > SMBIOS_21_MAX_TABLES_LEN) {
|
|
error_setg(errp, "SMBIOS 2.1 table length %zu exceeds %d",
|
|
smbios_tables_len, SMBIOS_21_MAX_TABLES_LEN);
|
|
@@ -655,14 +654,15 @@ static void smbios_build_type_3_table(void)
|
|
SMBIOS_BUILD_TABLE_POST;
|
|
}
|
|
|
|
-static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
|
|
+static void smbios_build_type_4_table(MachineState *ms, unsigned instance,
|
|
+ SmbiosEntryPointType ep_type)
|
|
{
|
|
char sock_str[128];
|
|
size_t tbl_len = SMBIOS_TYPE_4_LEN_V28;
|
|
unsigned threads_per_socket;
|
|
unsigned cores_per_socket;
|
|
|
|
- if (smbios_ep_type == SMBIOS_ENTRY_POINT_TYPE_64) {
|
|
+ if (ep_type == SMBIOS_ENTRY_POINT_TYPE_64) {
|
|
tbl_len = SMBIOS_TYPE_4_LEN_V30;
|
|
}
|
|
|
|
@@ -991,13 +991,11 @@ void smbios_set_cpuid(uint32_t version, uint32_t features)
|
|
void smbios_set_defaults(const char *manufacturer, const char *product,
|
|
const char *version,
|
|
bool uuid_encoded,
|
|
- SmbiosEntryPointType ep_type,
|
|
const char *stream_product,
|
|
const char *stream_version)
|
|
{
|
|
smbios_have_defaults = true;
|
|
smbios_uuid_encoded = uuid_encoded;
|
|
- smbios_ep_type = ep_type;
|
|
|
|
/*
|
|
* If @stream_product & @stream_version are non-NULL, then
|
|
@@ -1048,9 +1046,9 @@ void smbios_set_defaults(const char *manufacturer, const char *product,
|
|
SMBIOS_SET_DEFAULT(type17.manufacturer, manufacturer);
|
|
}
|
|
|
|
-static void smbios_entry_point_setup(void)
|
|
+static void smbios_entry_point_setup(SmbiosEntryPointType ep_type)
|
|
{
|
|
- switch (smbios_ep_type) {
|
|
+ switch (ep_type) {
|
|
case SMBIOS_ENTRY_POINT_TYPE_32:
|
|
memcpy(ep.ep21.anchor_string, "_SM_", 4);
|
|
memcpy(ep.ep21.intermediate_anchor_string, "_DMI_", 5);
|
|
@@ -1100,6 +1098,7 @@ static void smbios_entry_point_setup(void)
|
|
}
|
|
|
|
void smbios_get_tables(MachineState *ms,
|
|
+ SmbiosEntryPointType ep_type,
|
|
const struct smbios_phys_mem_area *mem_array,
|
|
const unsigned int mem_array_size,
|
|
uint8_t **tables, size_t *tables_len,
|
|
@@ -1108,6 +1107,9 @@ void smbios_get_tables(MachineState *ms,
|
|
{
|
|
unsigned i, dimm_cnt, offset;
|
|
|
|
+ assert(ep_type == SMBIOS_ENTRY_POINT_TYPE_32 ||
|
|
+ ep_type == SMBIOS_ENTRY_POINT_TYPE_64);
|
|
+
|
|
g_free(smbios_tables);
|
|
smbios_tables = g_memdup2(usr_blobs, usr_blobs_len);
|
|
smbios_tables_len = usr_blobs_len;
|
|
@@ -1122,7 +1124,7 @@ void smbios_get_tables(MachineState *ms,
|
|
assert(ms->smp.sockets >= 1);
|
|
|
|
for (i = 0; i < ms->smp.sockets; i++) {
|
|
- smbios_build_type_4_table(ms, i);
|
|
+ smbios_build_type_4_table(ms, i, ep_type);
|
|
}
|
|
|
|
smbios_build_type_8_table();
|
|
@@ -1171,10 +1173,10 @@ void smbios_get_tables(MachineState *ms,
|
|
if (!smbios_check_type4_count(ms->smp.sockets, errp)) {
|
|
goto err_exit;
|
|
}
|
|
- if (!smbios_validate_table(errp)) {
|
|
+ if (!smbios_validate_table(ep_type, errp)) {
|
|
goto err_exit;
|
|
}
|
|
- smbios_entry_point_setup();
|
|
+ smbios_entry_point_setup(ep_type);
|
|
|
|
/* return tables blob and entry point (anchor), and their sizes */
|
|
*tables = smbios_tables;
|
|
diff --git a/hw/smbios/smbios_legacy.c b/hw/smbios/smbios_legacy.c
|
|
index a6544bf55a..06907cd16c 100644
|
|
--- a/hw/smbios/smbios_legacy.c
|
|
+++ b/hw/smbios/smbios_legacy.c
|
|
@@ -173,7 +173,7 @@ uint8_t *smbios_get_table_legacy(size_t *length, Error **errp)
|
|
|
|
smbios_build_type_0_fields();
|
|
smbios_build_type_1_fields();
|
|
- if (!smbios_validate_table(errp)) {
|
|
+ if (!smbios_validate_table(SMBIOS_ENTRY_POINT_TYPE_32, errp)) {
|
|
goto err_exit;
|
|
}
|
|
|
|
diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h
|
|
index 44af3a0d82..781298f594 100644
|
|
--- a/include/hw/firmware/smbios.h
|
|
+++ b/include/hw/firmware/smbios.h
|
|
@@ -326,18 +326,18 @@ struct smbios_type_127 {
|
|
struct smbios_structure_header header;
|
|
} QEMU_PACKED;
|
|
|
|
-bool smbios_validate_table(Error **errp);
|
|
+bool smbios_validate_table(SmbiosEntryPointType ep_type, Error **errp);
|
|
void smbios_add_usr_blob_size(size_t size);
|
|
void smbios_entry_add(QemuOpts *opts, Error **errp);
|
|
void smbios_set_cpuid(uint32_t version, uint32_t features);
|
|
void smbios_set_defaults(const char *manufacturer, const char *product,
|
|
const char *version,
|
|
bool uuid_encoded,
|
|
- SmbiosEntryPointType ep_type,
|
|
const char *stream_product,
|
|
const char *stream_version);
|
|
uint8_t *smbios_get_table_legacy(size_t *length, Error **errp);
|
|
void smbios_get_tables(MachineState *ms,
|
|
+ SmbiosEntryPointType ep_type,
|
|
const struct smbios_phys_mem_area *mem_array,
|
|
const unsigned int mem_array_size,
|
|
uint8_t **tables, size_t *tables_len,
|
|
--
|
|
2.39.3
|
|
|