SMBIOS Type 8 (Port Connector) tables currently use T0_BASE (0x0) for handle allocation. This can lead to handle collisions with other table types that also start at T0_BASE. Types 2, 3, 4, 9, and 11 already have dedicated handle ranges (T2_BASE=0x200, T3_BASE=0x300, T4_BASE=0x400, T9_BASE=0x900, T11_BASE=0xe00), but Type 8 was missed. Add T8_BASE (0x800) to fill the gap in the handle range allocation. Introduce a static flag and smbios_set_type8_handle_t8_base() setter to allow machine types to opt in to the new range. When the flag is false (the default), the old T0_BASE behavior is preserved.
Signed-off-by: Alexander Gryanko <[email protected]> --- hw/i386/fw_cfg.c | 1 + hw/smbios/smbios.c | 10 +++++++++- include/hw/firmware/smbios.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index 2876490f06..0b3a14cdb1 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -77,6 +77,7 @@ 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); } + smbios_set_type8_handle_t8_base(pcmc->smbios_type8_handle_t8_base); /* tell smbios about cpuid version and features */ smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]); diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 7d7141851b..0e0200600e 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -49,6 +49,7 @@ static SmbiosEntryPoint ep; static int smbios_type4_count = 0; static bool smbios_have_defaults; static uint32_t smbios_cpuid_version, smbios_cpuid_features; +static bool smbios_type8_t8_base; DECLARE_BITMAP(smbios_have_binfile_bitmap, SMBIOS_MAX_TYPE + 1); DECLARE_BITMAP(smbios_have_fields_bitmap, SMBIOS_MAX_TYPE + 1); @@ -553,6 +554,7 @@ bool smbios_skip_table(uint8_t type, bool required_table) #define T2_BASE 0x200 #define T3_BASE 0x300 #define T4_BASE 0x400 +#define T8_BASE 0x800 #define T9_BASE 0x900 #define T11_BASE 0xe00 @@ -742,13 +744,19 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance, smbios_type4_count++; } +void smbios_set_type8_handle_t8_base(bool t8_base) +{ + smbios_type8_t8_base = t8_base; +} + static void smbios_build_type_8_table(void) { unsigned instance = 0; struct type8_instance *t8; + uint16_t base = smbios_type8_t8_base ? T8_BASE : T0_BASE; QTAILQ_FOREACH(t8, &type8, next) { - SMBIOS_BUILD_TABLE_PRE(8, T0_BASE + instance, true); + SMBIOS_BUILD_TABLE_PRE(8, base + instance, true); SMBIOS_TABLE_SET_STR(8, internal_reference_str, t8->internal_reference); SMBIOS_TABLE_SET_STR(8, external_reference_str, t8->external_reference); diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index 3ea732f4e6..62e728b69c 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -333,6 +333,7 @@ void smbios_set_cpuid(uint32_t version, uint32_t features); void smbios_set_defaults(const char *manufacturer, const char *product, const char *version); void smbios_set_default_processor_family(uint16_t processor_family); +void smbios_set_type8_handle_t8_base(bool t8_base); uint8_t *smbios_get_table_legacy(size_t *length, Error **errp); void smbios_get_tables(MachineState *ms, SmbiosEntryPointType ep_type, -- 2.39.5 (Apple Git-154)
