From 68460abb11ff9a65c7e9d988609954c2845d32e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Wed, 3 Jul 2024 13:44:36 +0100 Subject: Add downstream s390x versioned 's390-ccw-virtio' machine types Adding changes to add RHEL machine types for s390x architecture. Signed-off-by: Miroslav Rezanina -- Rebase notes(9.1.0): - Convert to new DEFINE_CCW_MACHINE macros Rebase notes (10.0.0): - Use upstream compat - Disabled relaxed-translation for older types Merged patches (9.1.0): - 043ad5ce97 Add upstream compatibility bits (partial) - 04596b496e s390x: remove deprecated rhel machine types Merged patches (10.0.0 rc0): - 03502faf70 Add upstream compatibility bits (partial) - d27437e5ba redhat: Add QEMU 9.1 compat handling to the s390x machine types - 926a9d0ca2 redhat: Add rhel9.6.0 and rhel10.0.0 machine types - d93fcb3940 virtio-net: disable USO for all RHEL9 (partial) --- hw/s390x/s390-virtio-ccw.c | 103 +++++++++++++++++++++++++++++-- target/s390x/cpu_models.c | 11 ++++ target/s390x/cpu_models.h | 2 + target/s390x/cpu_models_system.c | 2 + 4 files changed, 113 insertions(+), 5 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 5aa5910399..59b545740e 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -696,6 +696,7 @@ static void s390_nmi(NMIState *n, int cpu_index, Error **errp) s390_cpu_restart(S390_CPU(cs)); } +#if 0 /* Disabled for Red Hat Enterprise Linux */ static ram_addr_t s390_fixup_ram_size(ram_addr_t sz) { /* same logic as in sclp.c */ @@ -715,6 +716,7 @@ static ram_addr_t s390_fixup_ram_size(ram_addr_t sz) } return newsz; } +#endif /* disabled for RHEL */ static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp) { @@ -893,7 +895,7 @@ static const TypeInfo ccw_machine_info = { { \ MachineClass *mc = MACHINE_CLASS(oc); \ MACHINE_VER_SYM(class_options, ccw, __VA_ARGS__)(mc); \ - mc->desc = "Virtual s390x machine (version " MACHINE_VER_STR(__VA_ARGS__) ")"; \ + mc->desc = "Virtual s390x machine (version rhel" MACHINE_VER_STR(__VA_ARGS__) ")"; \ mc->init = MACHINE_VER_SYM(mach_init, ccw, __VA_ARGS__); \ MACHINE_VER_DEPRECATION(__VA_ARGS__); \ if (latest) { \ @@ -914,11 +916,11 @@ static const TypeInfo ccw_machine_info = { } \ type_init(MACHINE_VER_SYM(register, ccw, __VA_ARGS__)) -#define DEFINE_CCW_MACHINE_AS_LATEST(major, minor) \ - DEFINE_CCW_MACHINE_IMPL(true, major, minor) +#define DEFINE_CCW_MACHINE_AS_LATEST(major, minor, micro) \ + DEFINE_CCW_MACHINE_IMPL(true, major, minor, micro) -#define DEFINE_CCW_MACHINE(major, minor) \ - DEFINE_CCW_MACHINE_IMPL(false, major, minor) +#define DEFINE_CCW_MACHINE(major, minor, micro) \ + DEFINE_CCW_MACHINE_IMPL(false, major, minor, micro) #if 0 /* Disabled for Red Hat Enterprise Linux */ @@ -1298,6 +1300,97 @@ DEFINE_CCW_MACHINE(2, 9); #endif #endif /* disabled for RHEL */ +static void ccw_rhel_machine_10_0_0_instance_options(MachineState *machine) +{ +} + +static void ccw_rhel_machine_10_0_0_class_options(MachineClass *mc) +{ + static GlobalProperty compat[] = { + { TYPE_S390_PCI_DEVICE, "relaxed-translation", "off", }, + }; + + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); + compat_props_add(mc->compat_props, hw_compat_rhel_10_1, hw_compat_rhel_10_1_len); +} +DEFINE_CCW_MACHINE_AS_LATEST(10, 0, 0); + +static void ccw_rhel_machine_9_6_0_instance_options(MachineState *machine) +{ + ccw_rhel_machine_10_0_0_instance_options(machine); +} + +static void ccw_rhel_machine_9_6_0_class_options(MachineClass *mc) +{ + ccw_rhel_machine_10_0_0_class_options(mc); + + /* NB: remember to move this line to the *latest* RHEL 9 machine */ + compat_props_add(mc->compat_props, hw_compat_rhel_9, hw_compat_rhel_9_len); +} +DEFINE_CCW_MACHINE(9, 6, 0); + +static void ccw_rhel_machine_9_4_0_instance_options(MachineState *machine) +{ + ccw_rhel_machine_9_6_0_instance_options(machine); +} + +static void ccw_rhel_machine_9_4_0_class_options(MachineClass *mc) +{ + static GlobalProperty compat[] = { + { TYPE_QEMU_S390_FLIC, "migrate-all-state", "off", }, + }; + + ccw_rhel_machine_9_6_0_class_options(mc); + + compat_props_add(mc->compat_props, hw_compat_rhel_10_0, hw_compat_rhel_10_0_len); + compat_props_add(mc->compat_props, hw_compat_rhel_9_5, hw_compat_rhel_9_5_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); +} +DEFINE_CCW_MACHINE(9, 4, 0); + +static void ccw_rhel_machine_9_2_0_instance_options(MachineState *machine) +{ + ccw_rhel_machine_9_4_0_instance_options(machine); +} + +static void ccw_rhel_machine_9_2_0_class_options(MachineClass *mc) +{ + ccw_rhel_machine_9_4_0_class_options(mc); + compat_props_add(mc->compat_props, hw_compat_rhel_9_4, hw_compat_rhel_9_4_len); + compat_props_add(mc->compat_props, hw_compat_rhel_9_3, hw_compat_rhel_9_3_len); + compat_props_add(mc->compat_props, hw_compat_rhel_9_2, hw_compat_rhel_9_2_len); + mc->smp_props.drawers_supported = false; /* from ccw_machine_8_1 */ + mc->smp_props.books_supported = false; /* from ccw_machine_8_1 */ +} +DEFINE_CCW_MACHINE(9, 2, 0); + +static void ccw_rhel_machine_9_0_0_instance_options(MachineState *machine) +{ + static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V6_2 }; + + ccw_rhel_machine_9_2_0_instance_options(machine); + + s390_set_qemu_cpu_model(0x3906, 14, 2, qemu_cpu_feat); + s390_cpudef_featoff_greater(16, 1, S390_FEAT_PAIE); +} + +static void ccw_rhel_machine_9_0_0_class_options(MachineClass *mc) +{ + S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc); + static GlobalProperty compat[] = { + { TYPE_S390_PCI_DEVICE, "interpret", "off", }, + { TYPE_S390_PCI_DEVICE, "forwarding-assist", "off", }, + }; + + ccw_rhel_machine_9_2_0_class_options(mc); + + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); + compat_props_add(mc->compat_props, hw_compat_rhel_9_1, hw_compat_rhel_9_1_len); + compat_props_add(mc->compat_props, hw_compat_rhel_9_0, hw_compat_rhel_9_0_len); + s390mc->max_threads = S390_MAX_CPUS; +} +DEFINE_CCW_MACHINE(9, 0, 0); + static void ccw_machine_register_types(void) { type_register_static(&ccw_machine_info); diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 111d46a59a..156bcf0d22 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -47,6 +47,9 @@ * of a following release have been a superset of the previous release. With * generation 15 one base feature and one optional feature have been deprecated. */ + +#define RHEL_CPU_DEPRECATION "use at least 'z14', or 'host' / 'qemu' / 'max'" + static S390CPUDef s390_cpu_defs[] = { /* * Linux requires at least z10 nowadays, and IBM only supports recent CPUs @@ -932,22 +935,30 @@ static void s390_host_cpu_model_class_init(ObjectClass *oc, void *data) static void s390_base_cpu_model_class_init(ObjectClass *oc, void *data) { S390CPUClass *xcc = S390_CPU_CLASS(oc); + CPUClass *cc = CPU_CLASS(oc); /* all base models are migration safe */ xcc->cpu_def = (const S390CPUDef *) data; xcc->is_migration_safe = true; xcc->is_static = true; xcc->desc = xcc->cpu_def->desc; + if (xcc->cpu_def->gen < 14) { + cc->deprecation_note = RHEL_CPU_DEPRECATION; + } } static void s390_cpu_model_class_init(ObjectClass *oc, void *data) { S390CPUClass *xcc = S390_CPU_CLASS(oc); + CPUClass *cc = CPU_CLASS(oc); /* model that can change between QEMU versions */ xcc->cpu_def = (const S390CPUDef *) data; xcc->is_migration_safe = true; xcc->desc = xcc->cpu_def->desc; + if (xcc->cpu_def->gen < 14) { + cc->deprecation_note = RHEL_CPU_DEPRECATION; + } } static void s390_qemu_cpu_model_class_init(ObjectClass *oc, void *data) diff --git a/target/s390x/cpu_models.h b/target/s390x/cpu_models.h index 71d4bc2dd4..d6c7c2cb50 100644 --- a/target/s390x/cpu_models.h +++ b/target/s390x/cpu_models.h @@ -38,6 +38,8 @@ typedef struct S390CPUDef { S390FeatBitmap full_feat; /* used to init full_feat from generated data */ S390FeatInit full_init; + /* if deprecated, provides a suggestion */ + const char *deprecation_note; } S390CPUDef; /* CPU model based on a CPU definition */ diff --git a/target/s390x/cpu_models_system.c b/target/s390x/cpu_models_system.c index 4351182f72..4074124c44 100644 --- a/target/s390x/cpu_models_system.c +++ b/target/s390x/cpu_models_system.c @@ -56,6 +56,7 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque) CpuDefinitionInfo *info; char *name = g_strdup(object_class_get_name(klass)); S390CPUClass *scc = S390_CPU_CLASS(klass); + CPUClass *cc = CPU_CLASS(klass); /* strip off the -s390x-cpu */ g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0; @@ -65,6 +66,7 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque) info->migration_safe = scc->is_migration_safe; info->q_static = scc->is_static; info->q_typename = g_strdup(object_class_get_name(klass)); + info->deprecated = !!cc->deprecation_note; /* check for unavailable features */ if (cpu_list_data->model) { Object *obj; -- 2.39.3