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)
331 lines
13 KiB
Diff
331 lines
13 KiB
Diff
From 36b0256e27f9d5268c5413891b4a7322819ae9db Mon Sep 17 00:00:00 2001
|
|
From: Igor Mammedov <imammedo@redhat.com>
|
|
Date: Mon, 4 Mar 2024 15:56:19 +0100
|
|
Subject: [PATCH 12/20] smbios: rename/expose structures/bitmaps used by both
|
|
legacy and modern code
|
|
|
|
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: [10/18] 59fe438d5b7f6e584a6bb02597e4d4724fe2cece
|
|
|
|
JIRA: https://issues.redhat.com/browse/RHEL-21705
|
|
|
|
As a preparation to move legacy handling into a separate file,
|
|
add prefix 'smbios_' to type0/type1/have_binfile_bitmap/have_fields_bitmap
|
|
and expose them in smbios.h so that they can be reused in
|
|
legacy and modern code.
|
|
|
|
Doing it as a separate patch to avoid rename cluttering follow-up
|
|
patch which will move legacy code into a separate file.
|
|
|
|
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
|
|
Reviewed-by: Ani Sinha <anisinha@redhat.com>
|
|
|
|
Conflicts: hw/smbios/smbios.c
|
|
due to setting downstream type1.family/type1.sku defaults
|
|
|
|
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
|
|
---
|
|
hw/smbios/smbios.c | 117 ++++++++++++++++-------------------
|
|
include/hw/firmware/smbios.h | 16 +++++
|
|
2 files changed, 71 insertions(+), 62 deletions(-)
|
|
|
|
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
|
|
index c48a290478..eb9927335d 100644
|
|
--- a/hw/smbios/smbios.c
|
|
+++ b/hw/smbios/smbios.c
|
|
@@ -81,19 +81,11 @@ static int smbios_type4_count = 0;
|
|
static bool smbios_have_defaults;
|
|
static uint32_t smbios_cpuid_version, smbios_cpuid_features;
|
|
|
|
-static DECLARE_BITMAP(have_binfile_bitmap, SMBIOS_MAX_TYPE+1);
|
|
-static DECLARE_BITMAP(have_fields_bitmap, SMBIOS_MAX_TYPE+1);
|
|
+DECLARE_BITMAP(smbios_have_binfile_bitmap, SMBIOS_MAX_TYPE + 1);
|
|
+DECLARE_BITMAP(smbios_have_fields_bitmap, SMBIOS_MAX_TYPE + 1);
|
|
|
|
-static struct {
|
|
- const char *vendor, *version, *date;
|
|
- bool have_major_minor, uefi;
|
|
- uint8_t major, minor;
|
|
-} type0;
|
|
-
|
|
-static struct {
|
|
- const char *manufacturer, *product, *version, *serial, *sku, *family;
|
|
- /* uuid is in qemu_uuid */
|
|
-} type1;
|
|
+smbios_type0_t smbios_type0;
|
|
+smbios_type1_t smbios_type1;
|
|
|
|
static struct {
|
|
const char *manufacturer, *product, *version, *serial, *asset, *location;
|
|
@@ -584,36 +576,36 @@ static void smbios_maybe_add_str(int type, int offset, const char *data)
|
|
static void smbios_build_type_0_fields(void)
|
|
{
|
|
smbios_maybe_add_str(0, offsetof(struct smbios_type_0, vendor_str),
|
|
- type0.vendor);
|
|
+ smbios_type0.vendor);
|
|
smbios_maybe_add_str(0, offsetof(struct smbios_type_0, bios_version_str),
|
|
- type0.version);
|
|
+ smbios_type0.version);
|
|
smbios_maybe_add_str(0, offsetof(struct smbios_type_0,
|
|
bios_release_date_str),
|
|
- type0.date);
|
|
- if (type0.have_major_minor) {
|
|
+ smbios_type0.date);
|
|
+ if (smbios_type0.have_major_minor) {
|
|
smbios_add_field(0, offsetof(struct smbios_type_0,
|
|
system_bios_major_release),
|
|
- &type0.major, 1);
|
|
+ &smbios_type0.major, 1);
|
|
smbios_add_field(0, offsetof(struct smbios_type_0,
|
|
system_bios_minor_release),
|
|
- &type0.minor, 1);
|
|
+ &smbios_type0.minor, 1);
|
|
}
|
|
}
|
|
|
|
static void smbios_build_type_1_fields(void)
|
|
{
|
|
smbios_maybe_add_str(1, offsetof(struct smbios_type_1, manufacturer_str),
|
|
- type1.manufacturer);
|
|
+ smbios_type1.manufacturer);
|
|
smbios_maybe_add_str(1, offsetof(struct smbios_type_1, product_name_str),
|
|
- type1.product);
|
|
+ smbios_type1.product);
|
|
smbios_maybe_add_str(1, offsetof(struct smbios_type_1, version_str),
|
|
- type1.version);
|
|
+ smbios_type1.version);
|
|
smbios_maybe_add_str(1, offsetof(struct smbios_type_1, serial_number_str),
|
|
- type1.serial);
|
|
+ smbios_type1.serial);
|
|
smbios_maybe_add_str(1, offsetof(struct smbios_type_1, sku_number_str),
|
|
- type1.sku);
|
|
+ smbios_type1.sku);
|
|
smbios_maybe_add_str(1, offsetof(struct smbios_type_1, family_str),
|
|
- type1.family);
|
|
+ smbios_type1.family);
|
|
if (qemu_uuid_set) {
|
|
/* We don't encode the UUID in the "wire format" here because this
|
|
* function is for legacy mode and needs to keep the guest ABI, and
|
|
@@ -631,14 +623,14 @@ uint8_t *smbios_get_table_legacy(size_t *length)
|
|
size_t usr_offset;
|
|
|
|
/* also complain if fields were given for types > 1 */
|
|
- if (find_next_bit(have_fields_bitmap,
|
|
+ if (find_next_bit(smbios_have_fields_bitmap,
|
|
SMBIOS_MAX_TYPE + 1, 2) < SMBIOS_MAX_TYPE + 1) {
|
|
error_report("can't process fields for smbios "
|
|
"types > 1 on machine versions < 2.1!");
|
|
exit(1);
|
|
}
|
|
|
|
- if (test_bit(4, have_binfile_bitmap)) {
|
|
+ if (test_bit(4, smbios_have_binfile_bitmap)) {
|
|
error_report("can't process table for smbios "
|
|
"type 4 on machine versions < 2.1!");
|
|
exit(1);
|
|
@@ -679,10 +671,10 @@ uint8_t *smbios_get_table_legacy(size_t *length)
|
|
|
|
bool smbios_skip_table(uint8_t type, bool required_table)
|
|
{
|
|
- if (test_bit(type, have_binfile_bitmap)) {
|
|
+ if (test_bit(type, smbios_have_binfile_bitmap)) {
|
|
return true; /* user provided their own binary blob(s) */
|
|
}
|
|
- if (test_bit(type, have_fields_bitmap)) {
|
|
+ if (test_bit(type, smbios_have_fields_bitmap)) {
|
|
return false; /* user provided fields via command line */
|
|
}
|
|
if (smbios_have_defaults && required_table) {
|
|
@@ -710,25 +702,25 @@ static void smbios_build_type_0_table(void)
|
|
{
|
|
SMBIOS_BUILD_TABLE_PRE(0, T0_BASE, false); /* optional, leave up to BIOS */
|
|
|
|
- SMBIOS_TABLE_SET_STR(0, vendor_str, type0.vendor);
|
|
- SMBIOS_TABLE_SET_STR(0, bios_version_str, type0.version);
|
|
+ SMBIOS_TABLE_SET_STR(0, vendor_str, smbios_type0.vendor);
|
|
+ SMBIOS_TABLE_SET_STR(0, bios_version_str, smbios_type0.version);
|
|
|
|
t->bios_starting_address_segment = cpu_to_le16(0xE800); /* from SeaBIOS */
|
|
|
|
- SMBIOS_TABLE_SET_STR(0, bios_release_date_str, type0.date);
|
|
+ SMBIOS_TABLE_SET_STR(0, bios_release_date_str, smbios_type0.date);
|
|
|
|
t->bios_rom_size = 0; /* hardcoded in SeaBIOS with FIXME comment */
|
|
|
|
t->bios_characteristics = cpu_to_le64(0x08); /* Not supported */
|
|
t->bios_characteristics_extension_bytes[0] = 0;
|
|
t->bios_characteristics_extension_bytes[1] = 0x14; /* TCD/SVVP | VM */
|
|
- if (type0.uefi) {
|
|
+ if (smbios_type0.uefi) {
|
|
t->bios_characteristics_extension_bytes[1] |= 0x08; /* |= UEFI */
|
|
}
|
|
|
|
- if (type0.have_major_minor) {
|
|
- t->system_bios_major_release = type0.major;
|
|
- t->system_bios_minor_release = type0.minor;
|
|
+ if (smbios_type0.have_major_minor) {
|
|
+ t->system_bios_major_release = smbios_type0.major;
|
|
+ t->system_bios_minor_release = smbios_type0.minor;
|
|
} else {
|
|
t->system_bios_major_release = 0;
|
|
t->system_bios_minor_release = 0;
|
|
@@ -758,18 +750,18 @@ static void smbios_build_type_1_table(void)
|
|
{
|
|
SMBIOS_BUILD_TABLE_PRE(1, T1_BASE, true); /* required */
|
|
|
|
- SMBIOS_TABLE_SET_STR(1, manufacturer_str, type1.manufacturer);
|
|
- SMBIOS_TABLE_SET_STR(1, product_name_str, type1.product);
|
|
- SMBIOS_TABLE_SET_STR(1, version_str, type1.version);
|
|
- SMBIOS_TABLE_SET_STR(1, serial_number_str, type1.serial);
|
|
+ SMBIOS_TABLE_SET_STR(1, manufacturer_str, smbios_type1.manufacturer);
|
|
+ SMBIOS_TABLE_SET_STR(1, product_name_str, smbios_type1.product);
|
|
+ SMBIOS_TABLE_SET_STR(1, version_str, smbios_type1.version);
|
|
+ SMBIOS_TABLE_SET_STR(1, serial_number_str, smbios_type1.serial);
|
|
if (qemu_uuid_set) {
|
|
smbios_encode_uuid(&t->uuid, &qemu_uuid);
|
|
} else {
|
|
memset(&t->uuid, 0, 16);
|
|
}
|
|
t->wake_up_type = 0x06; /* power switch */
|
|
- SMBIOS_TABLE_SET_STR(1, sku_number_str, type1.sku);
|
|
- SMBIOS_TABLE_SET_STR(1, family_str, type1.family);
|
|
+ SMBIOS_TABLE_SET_STR(1, sku_number_str, smbios_type1.sku);
|
|
+ SMBIOS_TABLE_SET_STR(1, family_str, smbios_type1.family);
|
|
|
|
SMBIOS_BUILD_TABLE_POST;
|
|
}
|
|
@@ -1184,12 +1176,12 @@ void smbios_set_defaults(const char *manufacturer, const char *product,
|
|
*
|
|
* We get 'System Manufacturer' and 'Baseboard Manufacturer'
|
|
*/
|
|
- SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer);
|
|
- SMBIOS_SET_DEFAULT(type1.product, product);
|
|
- SMBIOS_SET_DEFAULT(type1.version, version);
|
|
- SMBIOS_SET_DEFAULT(type1.family, "Red Hat Enterprise Linux");
|
|
+ SMBIOS_SET_DEFAULT(smbios_type1.manufacturer, manufacturer);
|
|
+ SMBIOS_SET_DEFAULT(smbios_type1.product, product);
|
|
+ SMBIOS_SET_DEFAULT(smbios_type1.version, version);
|
|
+ SMBIOS_SET_DEFAULT(smbios_type1.family, "Red Hat Enterprise Linux");
|
|
if (stream_version != NULL) {
|
|
- SMBIOS_SET_DEFAULT(type1.sku, stream_version);
|
|
+ SMBIOS_SET_DEFAULT(smbios_type1.sku, stream_version);
|
|
}
|
|
SMBIOS_SET_DEFAULT(type2.manufacturer, manufacturer);
|
|
if (stream_product != NULL) {
|
|
@@ -1468,13 +1460,13 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
|
|
}
|
|
|
|
if (header->type <= SMBIOS_MAX_TYPE) {
|
|
- if (test_bit(header->type, have_fields_bitmap)) {
|
|
+ if (test_bit(header->type, smbios_have_fields_bitmap)) {
|
|
error_setg(errp,
|
|
"can't load type %d struct, fields already specified!",
|
|
header->type);
|
|
return;
|
|
}
|
|
- set_bit(header->type, have_binfile_bitmap);
|
|
+ set_bit(header->type, smbios_have_binfile_bitmap);
|
|
}
|
|
|
|
if (header->type == 4) {
|
|
@@ -1505,41 +1497,42 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
|
|
return;
|
|
}
|
|
|
|
- if (test_bit(type, have_binfile_bitmap)) {
|
|
+ if (test_bit(type, smbios_have_binfile_bitmap)) {
|
|
error_setg(errp, "can't add fields, binary file already loaded!");
|
|
return;
|
|
}
|
|
- set_bit(type, have_fields_bitmap);
|
|
+ set_bit(type, smbios_have_fields_bitmap);
|
|
|
|
switch (type) {
|
|
case 0:
|
|
if (!qemu_opts_validate(opts, qemu_smbios_type0_opts, errp)) {
|
|
return;
|
|
}
|
|
- save_opt(&type0.vendor, opts, "vendor");
|
|
- save_opt(&type0.version, opts, "version");
|
|
- save_opt(&type0.date, opts, "date");
|
|
- type0.uefi = qemu_opt_get_bool(opts, "uefi", false);
|
|
+ save_opt(&smbios_type0.vendor, opts, "vendor");
|
|
+ save_opt(&smbios_type0.version, opts, "version");
|
|
+ save_opt(&smbios_type0.date, opts, "date");
|
|
+ smbios_type0.uefi = qemu_opt_get_bool(opts, "uefi", false);
|
|
|
|
val = qemu_opt_get(opts, "release");
|
|
if (val) {
|
|
- if (sscanf(val, "%hhu.%hhu", &type0.major, &type0.minor) != 2) {
|
|
+ if (sscanf(val, "%hhu.%hhu", &smbios_type0.major,
|
|
+ &smbios_type0.minor) != 2) {
|
|
error_setg(errp, "Invalid release");
|
|
return;
|
|
}
|
|
- type0.have_major_minor = true;
|
|
+ smbios_type0.have_major_minor = true;
|
|
}
|
|
return;
|
|
case 1:
|
|
if (!qemu_opts_validate(opts, qemu_smbios_type1_opts, errp)) {
|
|
return;
|
|
}
|
|
- save_opt(&type1.manufacturer, opts, "manufacturer");
|
|
- save_opt(&type1.product, opts, "product");
|
|
- save_opt(&type1.version, opts, "version");
|
|
- save_opt(&type1.serial, opts, "serial");
|
|
- save_opt(&type1.sku, opts, "sku");
|
|
- save_opt(&type1.family, opts, "family");
|
|
+ save_opt(&smbios_type1.manufacturer, opts, "manufacturer");
|
|
+ save_opt(&smbios_type1.product, opts, "product");
|
|
+ save_opt(&smbios_type1.version, opts, "version");
|
|
+ save_opt(&smbios_type1.serial, opts, "serial");
|
|
+ save_opt(&smbios_type1.sku, opts, "sku");
|
|
+ save_opt(&smbios_type1.family, opts, "family");
|
|
|
|
val = qemu_opt_get(opts, "uuid");
|
|
if (val) {
|
|
diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h
|
|
index d55018e5e3..333de0d5fc 100644
|
|
--- a/include/hw/firmware/smbios.h
|
|
+++ b/include/hw/firmware/smbios.h
|
|
@@ -2,6 +2,7 @@
|
|
#define QEMU_SMBIOS_H
|
|
|
|
#include "qapi/qapi-types-machine.h"
|
|
+#include "qemu/bitmap.h"
|
|
|
|
/*
|
|
* SMBIOS Support
|
|
@@ -16,8 +17,23 @@
|
|
*
|
|
*/
|
|
|
|
+typedef struct {
|
|
+ const char *vendor, *version, *date;
|
|
+ bool have_major_minor, uefi;
|
|
+ uint8_t major, minor;
|
|
+} smbios_type0_t;
|
|
+extern smbios_type0_t smbios_type0;
|
|
+
|
|
+typedef struct {
|
|
+ const char *manufacturer, *product, *version, *serial, *sku, *family;
|
|
+ /* uuid is in qemu_uuid */
|
|
+} smbios_type1_t;
|
|
+extern smbios_type1_t smbios_type1;
|
|
|
|
#define SMBIOS_MAX_TYPE 127
|
|
+extern DECLARE_BITMAP(smbios_have_binfile_bitmap, SMBIOS_MAX_TYPE + 1);
|
|
+extern DECLARE_BITMAP(smbios_have_fields_bitmap, SMBIOS_MAX_TYPE + 1);
|
|
+
|
|
#define offsetofend(TYPE, MEMBER) \
|
|
(offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER))
|
|
|
|
--
|
|
2.39.3
|
|
|