From 869dc39b548550c0b7b6a2bd8ab13746ec1b50c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Wed, 3 Jul 2024 13:44:41 +0100 Subject: Add downstream x86_64 versioned 'pc' & 'q35' machine types Adding changes to add RHEL machine types for x86_64 architecture. Signed-off-by: Miroslav Rezanina --- Rebase notes (9.1.0): - Merged pc_q35_machine_rhel_options back into pc_q35_machine_options to reduce delta to upstream - Convert to new DEFINE_(I440FX|Q35)_MACHINE macros - Moved x86 cpu deprecation note to device disable patch Rebase notes (10.0.0 rc0): - Do not use bugfix macro for q35 - Use upstream compat - Add downstream specific compat - Fixing rhel-9.4 compat issue Merged patches (9.1.0): - 043ad5ce97 Add upstream compatibility bits (partial) Merged patches (10.0.0 rc0): - 03502faf70 Add upstream compatibility bits - 6be70c681b x86: ensure compatibility of pc-q35-rhel9* - d6b6ae511c x86: create new pc-q35 machine type for rhel 9.6 - fcf4da60bd x86: create pc-i440fx machine type for rhel10 - 4acb295fa2 x86: create pc-q35 machine type for rhel10 - 0489497df8 x86: remove deprecated rhel machine types - f53dbf7532 remove stale compat definitions (partial) - 379e14ba88 pc: q35: Bump max_cpus to 4096 vcpus - d93fcb3940 virtio-net: disable USO for all RHEL9 (partial) --- hw/i386/fw_cfg.c | 2 +- hw/i386/pc.c | 63 +++++++++++++++++++- hw/i386/pc_piix.c | 49 +++++++++++++-- hw/i386/pc_q35.c | 119 ++++++++++++++++++++++++++++++++++--- include/hw/boards.h | 2 + include/hw/i386/pc.h | 18 ++++++ target/i386/kvm/kvm-cpu.c | 1 + target/i386/kvm/kvm.c | 4 ++ tests/qtest/meson.build | 2 +- tests/qtest/pvpanic-test.c | 5 +- 10 files changed, 247 insertions(+), 18 deletions(-) diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index 07df7281d2..8009f5f31f 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -75,7 +75,7 @@ void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg, if (pcmc->smbios_defaults) { /* These values are guest ABI, do not change */ - smbios_set_defaults("QEMU", mc->desc, mc->name, + smbios_set_defaults("Red Hat", "KVM", mc->desc, pcmc->smbios_stream_product, pcmc->smbios_stream_version); } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 01d0581f62..5ae388789b 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -287,6 +287,65 @@ const size_t pc_compat_2_4_len = G_N_ELEMENTS(pc_compat_2_4); */ #define PC_FW_DATA (0x20000 + 0x8000) +/* This macro is for changes to properties that are RHEL specific, + * different to the current upstream and to be applied to the latest + * machine type. + */ +GlobalProperty pc_rhel_compat[] = { + /* we don't support s3/s4 suspend */ + { "PIIX4_PM", "disable_s3", "1" }, + { "PIIX4_PM", "disable_s4", "1" }, + { "ICH9-LPC", "disable_s3", "1" }, + { "ICH9-LPC", "disable_s4", "1" }, + + { TYPE_X86_CPU, "host-phys-bits", "on" }, + { TYPE_X86_CPU, "host-phys-bits-limit", "48" }, + { TYPE_X86_CPU, "vmx-entry-load-perf-global-ctrl", "off" }, + { TYPE_X86_CPU, "vmx-exit-load-perf-global-ctrl", "off" }, + /* bz 1508330 */ + { "vfio-pci", "x-no-geforce-quirks", "on" }, + /* bz 1941397 */ + { TYPE_X86_CPU, "kvm-asyncpf-int", "on" }, +}; +const size_t pc_rhel_compat_len = G_N_ELEMENTS(pc_rhel_compat); + +GlobalProperty pc_rhel_10_1_compat[] = { + /* pc_rhel_10_1_compat from pc_compat_9_1 */ + { "ICH9-LPC", "x-smi-swsmi-timer", "off" }, + { "ICH9-LPC", "x-smi-periodic-timer", "off" }, + { TYPE_INTEL_IOMMU_DEVICE, "stale-tm", "on" }, + { TYPE_INTEL_IOMMU_DEVICE, "aw-bits", "39" }, +}; +const size_t pc_rhel_10_1_compat_len = G_N_ELEMENTS(pc_rhel_10_1_compat); + +GlobalProperty pc_rhel_10_0_compat[] = { + /* pc_rhel_10_0_compat from pc_compat_9_0 */ + { TYPE_X86_CPU, "x-amd-topoext-features-only", "false" }, + { TYPE_X86_CPU, "x-l1-cache-per-thread", "false" }, + { TYPE_X86_CPU, "guest-phys-bits", "0" }, + { "sev-guest", "legacy-vm-type", "on" }, + { TYPE_X86_CPU, "legacy-multi-node", "on" }, +}; +const size_t pc_rhel_10_0_compat_len = G_N_ELEMENTS(pc_rhel_10_0_compat); + +GlobalProperty pc_rhel_9_3_compat[] = { + /* pc_rhel_9_3_compat from pc_compat_8_0 */ + { "virtio-mem", "unplugged-inaccessible", "auto" }, +}; +const size_t pc_rhel_9_3_compat_len = G_N_ELEMENTS(pc_rhel_9_3_compat); + +GlobalProperty pc_rhel_9_2_compat[] = { + /* pc_rhel_9_2_compat from pc_compat_7_2 */ + { "ICH9-LPC", "noreboot", "true" }, +}; +const size_t pc_rhel_9_2_compat_len = G_N_ELEMENTS(pc_rhel_9_2_compat); + +GlobalProperty pc_rhel_9_0_compat[] = { + /* pc_rhel_9_0_compat from pc_compat_6_2 */ + { "virtio-mem", "unplugged-inaccessible", "off" }, +}; +const size_t pc_rhel_9_0_compat_len = G_N_ELEMENTS(pc_rhel_9_0_compat); + GSIState *pc_gsi_create(qemu_irq **irqs, bool pci_enabled) { GSIState *s; @@ -1780,6 +1839,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pcmc->kvmclock_create_always = true; x86mc->apic_xrupt_override = true; assert(!mc->get_hotplug_handler); + mc->async_pf_vmexit_disable = false; mc->get_hotplug_handler = pc_get_hotplug_handler; mc->hotplug_allowed = pc_hotplug_allowed; mc->auto_enable_numa_with_memhp = true; @@ -1787,7 +1847,8 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) mc->has_hotpluggable_cpus = true; mc->default_boot_order = "cad"; mc->block_default_type = IF_IDE; - mc->max_cpus = 255; + /* 240: max CPU count for RHEL */ + mc->max_cpus = 240; mc->reset = pc_machine_reset; mc->wakeup = pc_machine_wakeup; hc->pre_plug = pc_machine_device_pre_plug_cb; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 1b58988c9a..78e9534a2c 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -52,6 +52,7 @@ #include "qapi/error.h" #include "qemu/error-report.h" #include "system/xen.h" +#include "migration/migration.h" #ifdef CONFIG_XEN #include #include "hw/xen/xen_pt.h" @@ -446,11 +447,11 @@ static void pc_i440fx_init(MachineState *machine) pc_init1(machine, TYPE_I440FX_PCI_DEVICE); } -#define DEFINE_I440FX_MACHINE(major, minor) \ - DEFINE_PC_VER_MACHINE(pc_i440fx, "pc-i440fx", pc_i440fx_init, false, NULL, major, minor); +#define DEFINE_I440FX_MACHINE(major, minor, micro) \ + DEFINE_PC_VER_MACHINE(pc_i440fx, "pc-i440fx", pc_i440fx_init, false, NULL, major, minor, micro); -#define DEFINE_I440FX_MACHINE_AS_LATEST(major, minor) \ - DEFINE_PC_VER_MACHINE(pc_i440fx, "pc-i440fx", pc_i440fx_init, true, "pc", major, minor); +#define DEFINE_I440FX_MACHINE_AS_LATEST(major, minor, micro) \ + DEFINE_PC_VER_MACHINE(pc_i440fx, "pc-i440fx", pc_i440fx_init, true, "pc", major, minor, micro); #if 0 /* Disabled for Red Hat Enterprise Linux */ static void pc_i440fx_machine_options(MachineClass *m) @@ -845,3 +846,43 @@ static void xenfv_machine_3_1_options(MachineClass *m) DEFINE_PC_MACHINE(xenfv, "xenfv-3.1", pc_xen_hvm_init, xenfv_machine_3_1_options); #endif + +/* Red Hat Enterprise Linux machine types */ + +static void pc_machine_rhel10_options(MachineClass *m) +{ + PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + ObjectClass *oc = OBJECT_CLASS(m); + pcmc->default_south_bridge = TYPE_PIIX3_DEVICE; + pcmc->pci_root_uid = 0; + pcmc->default_cpu_version = 1; + + m->family = "pc_piix_Y"; + m->default_machine_opts = "firmware=bios-256k.bin"; + m->default_display = "std"; + m->default_nic = "e1000"; + m->no_parallel = 1; + m->no_floppy = 1; + machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE); + + object_class_property_add_enum(oc, "x-south-bridge", "PCSouthBridgeOption", + &PCSouthBridgeOption_lookup, + pc_get_south_bridge, + pc_set_south_bridge); + object_class_property_set_description(oc, "x-south-bridge", + "Use a different south bridge than PIIX3"); +} + +static void pc_i440fx_rhel_machine_10_0_0_options(MachineClass *m) +{ + pc_machine_rhel10_options(m); + + m->desc = "RHEL 10.0.0 PC (i440FX + PIIX, 1996)"; + m->deprecation_reason = rhel_old_machine_deprecation; + + compat_props_add(m->compat_props, hw_compat_rhel_10_1, + hw_compat_rhel_10_1_len); + compat_props_add(m->compat_props, pc_rhel_10_1_compat, + pc_rhel_10_1_compat_len); +} +DEFINE_I440FX_MACHINE_AS_LATEST(10, 0, 0); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 97a40a3a9c..2f19204304 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -327,11 +327,11 @@ static void pc_q35_init(MachineState *machine) } } -#define DEFINE_Q35_MACHINE(major, minor) \ - DEFINE_PC_VER_MACHINE(pc_q35, "pc-q35", pc_q35_init, false, NULL, major, minor); +#define DEFINE_Q35_MACHINE(major, minor, micro) \ + DEFINE_PC_VER_MACHINE(pc_q35, "pc-q35", pc_q35_init, false, NULL, major, minor, micro); -#define DEFINE_Q35_MACHINE_AS_LATEST(major, minor) \ - DEFINE_PC_VER_MACHINE(pc_q35, "pc-q35", pc_q35_init, false, "q35", major, minor); +#define DEFINE_Q35_MACHINE_AS_LATEST(major, minor, micro) \ + DEFINE_PC_VER_MACHINE(pc_q35, "pc-q35", pc_q35_init, false, "q35", major, minor, micro); #define DEFINE_Q35_MACHINE_BUGFIX(major, minor, micro) \ DEFINE_PC_VER_MACHINE(pc_q35, "pc-q35", pc_q35_init, false, NULL, major, minor, micro); @@ -342,21 +342,21 @@ static void pc_q35_machine_options(MachineClass *m) pcmc->pci_root_uid = 0; pcmc->default_cpu_version = 1; - m->family = "pc_q35"; - m->desc = "Standard PC (Q35 + ICH9, 2009)"; + m->family = "pc_q35_Z"; m->units_per_default_bus = 1; - m->default_machine_opts = "firmware=bios-256k.bin"; + m->default_machine_opts = "firmware=bios-256k.bin,hpet=off"; m->default_display = "std"; m->default_nic = "e1000e"; - m->default_kernel_irqchip_split = false; m->no_floppy = 1; m->max_cpus = 4096; - m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL); + m->no_parallel = 1; + m->alias = "q35"; machine_class_allow_dynamic_sysbus_dev(m, TYPE_AMD_IOMMU_DEVICE); machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE); machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE); machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE); machine_class_allow_dynamic_sysbus_dev(m, TYPE_UEFI_VARS_X64); + compat_props_add(m->compat_props, pc_rhel_compat, pc_rhel_compat_len); compat_props_add(m->compat_props, pc_q35_compat_defaults, pc_q35_compat_defaults_len); } @@ -691,3 +691,104 @@ static void pc_q35_machine_2_4_options(MachineClass *m) DEFINE_Q35_MACHINE(2, 4); #endif /* Disabled for Red Hat Enterprise Linux */ + +/* Red Hat Enterprise Linux machine types */ + +static void pc_q35_rhel_machine_10_0_0_options(MachineClass *m) +{ + PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_q35_machine_options(m); + m->desc = "RHEL-10.0.0 PC (Q35 + ICH9, 2009)"; + pcmc->smbios_stream_product = "RHEL"; + pcmc->smbios_stream_version = "10.0.0"; + + compat_props_add(m->compat_props, hw_compat_rhel_10_1, + hw_compat_rhel_10_1_len); + compat_props_add(m->compat_props, pc_rhel_10_1_compat, + pc_rhel_10_1_compat_len); +} +DEFINE_Q35_MACHINE_AS_LATEST(10, 0, 0); + +static void pc_q35_rhel_machine_9_6_0_options(MachineClass *m) +{ + PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_q35_rhel_machine_10_0_0_options(m); + m->desc = "RHEL-9.6.0 PC (Q35 + ICH9, 2009)"; + pcmc->smbios_stream_product = "RHEL"; + pcmc->smbios_stream_version = "9.6.0"; + + /* NB: remember to move this line to the *latest* RHEL 9 machine */ + compat_props_add(m->compat_props, hw_compat_rhel_9, hw_compat_rhel_9_len); +} + +DEFINE_Q35_MACHINE(9, 6, 0); + +static void pc_q35_rhel_machine_9_4_0_options(MachineClass *m) +{ + PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_q35_rhel_machine_9_6_0_options(m); + + /* older RHEL machines continue to support 710 vcpus */ + m->max_cpus = 710; + m->desc = "RHEL-9.4.0 PC (Q35 + ICH9, 2009)"; + pcmc->smbios_stream_product = "RHEL"; + pcmc->smbios_stream_version = "9.4.0"; + + /* From pc_q35_machine_9_0_options() */ + pcmc->isa_bios_alias = false; + m->smbios_memory_device_size = 16 * GiB; + + compat_props_add(m->compat_props, hw_compat_rhel_10_0, + hw_compat_rhel_10_0_len); + compat_props_add(m->compat_props, hw_compat_rhel_9_5, + hw_compat_rhel_9_5_len); + compat_props_add(m->compat_props, pc_rhel_10_0_compat, + pc_rhel_10_0_compat_len); +} + +DEFINE_Q35_MACHINE(9, 4, 0); + +static void pc_q35_rhel_machine_9_2_0_options(MachineClass *m) +{ + PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_q35_rhel_machine_9_4_0_options(m); + m->desc = "RHEL-9.2.0 PC (Q35 + ICH9, 2009)"; + pcmc->smbios_stream_product = "RHEL"; + pcmc->smbios_stream_version = "9.2.0"; + + /* From pc_q35_8_0_machine_options() */ + pcmc->default_smbios_ep_type = SMBIOS_ENTRY_POINT_TYPE_32; + /* From pc_q35_8_1_machine_options() */ + pcmc->broken_32bit_mem_addr_check = true; + + compat_props_add(m->compat_props, hw_compat_rhel_9_4, + hw_compat_rhel_9_4_len); + compat_props_add(m->compat_props, hw_compat_rhel_9_3, + hw_compat_rhel_9_3_len); + compat_props_add(m->compat_props, pc_rhel_9_3_compat, + pc_rhel_9_3_compat_len); + compat_props_add(m->compat_props, hw_compat_rhel_9_2, + hw_compat_rhel_9_2_len); + compat_props_add(m->compat_props, pc_rhel_9_2_compat, + pc_rhel_9_2_compat_len); +} + +DEFINE_Q35_MACHINE(9, 2, 0); + +static void pc_q35_rhel_machine_9_0_0_options(MachineClass *m) +{ + PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_q35_rhel_machine_9_2_0_options(m); + m->desc = "RHEL-9.0.0 PC (Q35 + ICH9, 2009)"; + pcmc->smbios_stream_product = "RHEL"; + pcmc->smbios_stream_version = "9.0.0"; + pcmc->enforce_amd_1tb_hole = false; + compat_props_add(m->compat_props, hw_compat_rhel_9_1, + hw_compat_rhel_9_1_len); + compat_props_add(m->compat_props, hw_compat_rhel_9_0, + hw_compat_rhel_9_0_len); + compat_props_add(m->compat_props, pc_rhel_9_0_compat, + pc_rhel_9_0_compat_len); +} + +DEFINE_Q35_MACHINE(9, 0, 0); diff --git a/include/hw/boards.h b/include/hw/boards.h index 182c11dc2c..a43847767f 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -309,6 +309,8 @@ struct MachineClass { strList *allowed_dynamic_sysbus_devices; bool auto_enable_numa_with_memhp; bool auto_enable_numa_with_memdev; + /* RHEL only */ + bool async_pf_vmexit_disable; bool ignore_boot_device_suffixes; bool smbus_no_migration_support; bool nvdimm_supported; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index e4d32f8aea..5306b6d7cb 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -305,6 +305,24 @@ extern const size_t pc_compat_2_5_len; extern GlobalProperty pc_compat_2_4[]; extern const size_t pc_compat_2_4_len; +extern GlobalProperty pc_rhel_compat[]; +extern const size_t pc_rhel_compat_len; + +extern GlobalProperty pc_rhel_10_1_compat[]; +extern const size_t pc_rhel_10_1_compat_len; + +extern GlobalProperty pc_rhel_10_0_compat[]; +extern const size_t pc_rhel_10_0_compat_len; + +extern GlobalProperty pc_rhel_9_3_compat[]; +extern const size_t pc_rhel_9_3_compat_len; + +extern GlobalProperty pc_rhel_9_2_compat[]; +extern const size_t pc_rhel_9_2_compat_len; + +extern GlobalProperty pc_rhel_9_0_compat[]; +extern const size_t pc_rhel_9_0_compat_len; + #define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \ static void pc_machine_##suffix##_class_init(ObjectClass *oc, void *data) \ { \ diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index 6269fa8045..8f455c24e9 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -174,6 +174,7 @@ static PropValue kvm_default_props[] = { { "acpi", "off" }, { "monitor", "off" }, { "svm", "off" }, + { "kvm-pv-unhalt", "on" }, { NULL, NULL }, }; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 6c749d4ee8..9cb2512c7c 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -4366,6 +4366,7 @@ static int kvm_get_msrs(X86CPU *cpu) struct kvm_msr_entry *msrs = cpu->kvm_msr_buf->entries; int ret, i; uint64_t mtrr_top_bits; + MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); kvm_msr_buf_reset(cpu); @@ -4763,6 +4764,9 @@ static int kvm_get_msrs(X86CPU *cpu) break; case MSR_KVM_ASYNC_PF_EN: env->async_pf_en_msr = msrs[i].data; + if (mc->async_pf_vmexit_disable) { + env->async_pf_en_msr &= ~(1ULL << 2); + } break; case MSR_KVM_ASYNC_PF_INT: env->async_pf_int_msr = msrs[i].data; diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 3136d15e0f..7749ec4b2f 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -49,6 +49,7 @@ qtests_filter = \ (get_option('default_devices') and host_os != 'windows' ? ['test-filter-mirror'] : []) + \ (get_option('default_devices') and host_os != 'windows' ? ['test-filter-redirector'] : []) +# RHEL: Removed intel-iommu-test as it's not working with 10.0 machine type qtests_i386 = \ (slirp.found() ? ['pxe-test'] : []) + \ qtests_filter + \ @@ -94,7 +95,6 @@ qtests_i386 = \ (config_all_devices.has_key('CONFIG_SB16') ? ['fuzz-sb16-test'] : []) + \ (config_all_devices.has_key('CONFIG_SDHCI_PCI') ? ['fuzz-sdcard-test'] : []) + \ (config_all_devices.has_key('CONFIG_ESP_PCI') ? ['am53c974-test'] : []) + \ - (config_all_devices.has_key('CONFIG_VTD') ? ['intel-iommu-test'] : []) + \ (host_os != 'windows' and \ config_all_devices.has_key('CONFIG_ACPI_ERST') ? ['erst-test'] : []) + \ (config_all_devices.has_key('CONFIG_PCIE_PORT') and \ diff --git a/tests/qtest/pvpanic-test.c b/tests/qtest/pvpanic-test.c index 5606baf47b..094c56b0cd 100644 --- a/tests/qtest/pvpanic-test.c +++ b/tests/qtest/pvpanic-test.c @@ -18,7 +18,7 @@ static void test_panic_nopause(void) QDict *response, *data; QTestState *qts; - qts = qtest_init("-device pvpanic -action panic=none"); + qts = qtest_init("-M q35 -device pvpanic -action panic=none"); val = qtest_inb(qts, 0x505); g_assert_cmpuint(val, ==, PVPANIC_EVENTS); @@ -41,7 +41,8 @@ static void test_panic(void) QDict *response, *data; QTestState *qts; - qts = qtest_init("-device pvpanic -action panic=pause"); + /* RHEL: Use q35 */ + qts = qtest_init("-M q35 -device pvpanic -action panic=pause"); val = qtest_inb(qts, 0x505); g_assert_cmpuint(val, ==, PVPANIC_EVENTS); -- 2.39.3