diff --git a/files/2001-Add-ppc64-support.patch b/files/2001-Add-ppc64-support.patch index 539f024..39f4058 100644 --- a/files/2001-Add-ppc64-support.patch +++ b/files/2001-Add-ppc64-support.patch @@ -1,19 +1,20 @@ -From eb742e8a7c75e3be5c158cb19185d9cf6ae4862c Mon Sep 17 00:00:00 2001 +From 9928955dc717c10f4c1084ef1ba71308fef68376 Mon Sep 17 00:00:00 2001 From: eabdullin Date: Tue, 15 Oct 2024 10:48:05 +0300 Subject: [PATCH] Add ppc64 support --- .../ppc64-softmmu/ppc64-rh-devices.mak | 39 ++++++ - hw/ppc/spapr.c | 125 +++++++++++++++++- - hw/ppc/spapr_cpu_core.c | 16 +++ + hw/ppc/spapr.c | 128 +++++++++++++++++- + hw/ppc/spapr_cpu_core.c | 15 ++ include/hw/ppc/spapr.h | 3 + target/ppc/compat.c | 11 ++ - target/ppc/cpu-models.c | 9 +- + target/ppc/cpu-models.c | 8 ++ target/ppc/cpu.h | 1 + target/ppc/kvm.c | 27 ++++ target/ppc/kvm_ppc.h | 13 ++ - 9 files changed, 237 insertions(+), 7 deletions(-) + target/ppc/misc_helper.c | 8 -- + 10 files changed, 240 insertions(+), 13 deletions(-) create mode 100644 configs/devices/ppc64-softmmu/ppc64-rh-devices.mak diff --git a/configs/devices/ppc64-softmmu/ppc64-rh-devices.mak b/configs/devices/ppc64-softmmu/ppc64-rh-devices.mak @@ -62,13 +63,14 @@ index 000000000..4b801b126 +CONFIG_VHOST_VSOCK=y +CONFIG_VHOST_USER_VSOCK=y diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c -index 370d7c35d..aed36a4de 100644 +index b0a0f8c68..5369bbba4 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c -@@ -1746,6 +1746,13 @@ static void spapr_machine_reset(MachineState *machine, ShutdownCause reason) +@@ -1717,7 +1717,13 @@ static void spapr_machine_reset(MachineState *machine, ResetType type) } spapr_caps_apply(spapr); spapr_nested_reset(spapr); +- + if (spapr->svm_allowed) { +#ifdef CONFIG_KVM + kvmppc_svm_allow(&error_fatal); @@ -76,10 +78,10 @@ index 370d7c35d..aed36a4de 100644 + error_setg(&error_fatal, "No PEF support in tcg, try x-svm-allowed=off"); +#endif + } - first_ppc_cpu = POWERPC_CPU(first_cpu); if (kvm_enabled() && kvmppc_has_cap_mmu_radix() && -@@ -3452,6 +3459,20 @@ static void spapr_set_host_serial(Object *obj, const char *value, Error **errp) + ppc_type_check_compat(machine->cpu_type, CPU_POWERPC_LOGICAL_3_00, 0, +@@ -3408,6 +3414,21 @@ static void spapr_set_host_serial(Object *obj, const char *value, Error **errp) spapr->host_serial = g_strdup(value); } @@ -96,11 +98,12 @@ index 370d7c35d..aed36a4de 100644 + + spapr->svm_allowed = value; +} ++ + static void spapr_instance_init(Object *obj) { SpaprMachineState *spapr = SPAPR_MACHINE(obj); -@@ -3530,6 +3551,12 @@ static void spapr_instance_init(Object *obj) +@@ -3486,6 +3507,12 @@ static void spapr_instance_init(Object *obj) spapr_get_host_serial, spapr_set_host_serial); object_property_set_description(obj, "host-serial", "Host serial number to advertise in guest device tree"); @@ -113,7 +116,7 @@ index 370d7c35d..aed36a4de 100644 } static void spapr_machine_finalizefn(Object *obj) -@@ -4775,6 +4802,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) +@@ -4706,6 +4733,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data) vmc->client_architecture_support = spapr_vof_client_architecture_support; vmc->quiesce = spapr_vof_quiesce; vmc->setprop = spapr_vof_setprop; @@ -121,7 +124,7 @@ index 370d7c35d..aed36a4de 100644 } static const TypeInfo spapr_machine_info = { -@@ -4830,13 +4858,14 @@ static void spapr_machine_latest_class_options(MachineClass *mc) +@@ -4761,11 +4789,12 @@ static void spapr_machine_latest_class_options(MachineClass *mc) } \ type_init(MACHINE_VER_SYM(register, spapr, __VA_ARGS__)) @@ -129,33 +132,19 @@ index 370d7c35d..aed36a4de 100644 - DEFINE_SPAPR_MACHINE_IMPL(true, major, minor) -#define DEFINE_SPAPR_MACHINE(major, minor) \ - DEFINE_SPAPR_MACHINE_IMPL(false, major, minor) --#define DEFINE_SPAPR_MACHINE_TAGGED(major, minor, tag) \ -- DEFINE_SPAPR_MACHINE_IMPL(false, major, minor, _, tag) +#define DEFINE_SPAPR_MACHINE_AS_LATEST(major, minor, micro) \ + DEFINE_SPAPR_MACHINE_IMPL(true, major, minor, micro) +#define DEFINE_SPAPR_MACHINE(major, minor, micro) \ + DEFINE_SPAPR_MACHINE_IMPL(false, major, minor, micro) -+#define DEFINE_SPAPR_MACHINE_TAGGED(major, minor, micro, tag) \ -+ DEFINE_SPAPR_MACHINE_IMPL(false, major, minor, micro, _, tag) +#if 0 /* Disabled for Red Hat Enterprise Linux */ /* - * pseries-9.1 + * pseries-10.0 */ -@@ -5056,6 +5085,9 @@ static bool phb_placement_4_0(SpaprMachineState *spapr, uint32_t index, - } - return true; +@@ -5060,6 +5089,95 @@ static void spapr_machine_3_0_class_options(MachineClass *mc) } -+#endif -+ -+#if 0 /* Disabled for Red Hat Enterprise Linux */ - static void spapr_machine_4_0_class_options(MachineClass *mc) - { - SpaprMachineClass *smc = SPAPR_MACHINE_CLASS(mc); -@@ -5380,6 +5412,87 @@ static void spapr_machine_2_1_class_options(MachineClass *mc) - compat_props_add(mc->compat_props, hw_compat_2_1, hw_compat_2_1_len); - } - DEFINE_SPAPR_MACHINE(2, 1); + + DEFINE_SPAPR_MACHINE(3, 0); +#endif /* disabled for RHEL */ + +static void spapr_rhel_machine_default_class_options(MachineClass *mc) @@ -183,9 +172,18 @@ index 370d7c35d..aed36a4de 100644 + +DEFINE_SPAPR_MACHINE_AS_LATEST(10, 0, 0); + -+static void spapr_rhel_machine_9_5_0_class_options(MachineClass *mc) ++static void spapr_rhel_machine_9_6_0_class_options(MachineClass *mc) +{ + spapr_rhel_machine_10_0_0_class_options(mc); ++ compat_props_add(mc->compat_props, hw_compat_rhel_9, ++ hw_compat_rhel_9_len); ++} ++ ++DEFINE_SPAPR_MACHINE(9, 6, 0); ++ ++static void spapr_rhel_machine_9_5_0_class_options(MachineClass *mc) ++{ ++ spapr_rhel_machine_9_6_0_class_options(mc); + compat_props_add(mc->compat_props, hw_compat_rhel_9_5, + hw_compat_rhel_9_5_len); +} @@ -236,23 +234,22 @@ index 370d7c35d..aed36a4de 100644 +} + +DEFINE_SPAPR_MACHINE(9, 0, 0); -+ static void spapr_machine_register_types(void) { diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c -index 56090abcd..e3371b24f 100644 +index faf9170ba..df3bde0db 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -25,6 +25,7 @@ - #include "sysemu/reset.h" - #include "sysemu/hw_accel.h" + #include "system/reset.h" + #include "system/hw_accel.h" #include "qemu/error-report.h" +#include "cpu-models.h" static void spapr_reset_vcpu(PowerPCCPU *cpu) { -@@ -264,6 +265,7 @@ static bool spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr, +@@ -268,6 +269,7 @@ static bool spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr, { CPUPPCState *env = &cpu->env; CPUState *cs = CPU(cpu); @@ -260,7 +257,7 @@ index 56090abcd..e3371b24f 100644 if (!qdev_realize(DEVICE(cpu), NULL, errp)) { return false; -@@ -280,6 +282,18 @@ static bool spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr, +@@ -286,6 +288,17 @@ static bool spapr_realize_vcpu(PowerPCCPU *cpu, SpaprMachineState *spapr, /* Set time-base frequency to 512 MHz. vhyp must be set first. */ cpu_ppc_tb_init(env, SPAPR_TIMEBASE_FREQ); @@ -274,12 +271,11 @@ index 56090abcd..e3371b24f 100644 + "POWER9 CPU is not supported by this machine class"); + return false; + } -+ + if (spapr_irq_cpu_intc_create(spapr, cpu, errp) < 0) { qdev_unrealize(DEVICE(cpu)); return false; -@@ -399,10 +413,12 @@ static const TypeInfo spapr_cpu_core_type_infos[] = { +@@ -401,10 +414,12 @@ static const TypeInfo spapr_cpu_core_type_infos[] = { .instance_size = sizeof(SpaprCpuCore), .class_size = sizeof(SpaprCpuCoreClass), }, @@ -293,10 +289,10 @@ index 56090abcd..e3371b24f 100644 DEFINE_SPAPR_CPU_CORE_TYPE("power7p_v2.1"), DEFINE_SPAPR_CPU_CORE_TYPE("power8_v2.0"), diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h -index f6de3e997..3cc7ef0c0 100644 +index 39bd5bd5e..e50e8328d 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h -@@ -157,6 +157,7 @@ struct SpaprMachineClass { +@@ -156,6 +156,7 @@ struct SpaprMachineClass { bool pre_5_2_numa_associativity; bool pre_6_2_numa_affinity; @@ -314,10 +310,10 @@ index f6de3e997..3cc7ef0c0 100644 /*< public >*/ char *kvm_type; diff --git a/target/ppc/compat.c b/target/ppc/compat.c -index ebef2ccce..ab7ed7680 100644 +index 55de3bd5d..1bf6994da 100644 --- a/target/ppc/compat.c +++ b/target/ppc/compat.c -@@ -114,6 +114,17 @@ static const CompatInfo *compat_by_pvr(uint32_t pvr) +@@ -121,6 +121,17 @@ static const CompatInfo *compat_by_pvr(uint32_t pvr) return NULL; } @@ -336,7 +332,7 @@ index ebef2ccce..ab7ed7680 100644 uint32_t min_compat_pvr, uint32_t max_compat_pvr) { diff --git a/target/ppc/cpu-models.c b/target/ppc/cpu-models.c -index f2301b43f..4c38fa517 100644 +index ece348178..6cfa71eec 100644 --- a/target/ppc/cpu-models.c +++ b/target/ppc/cpu-models.c @@ -66,6 +66,7 @@ @@ -366,7 +362,7 @@ index f2301b43f..4c38fa517 100644 POWERPC_DEF("power7_v2.3", CPU_POWERPC_POWER7_v23, POWER7, "POWER7 v2.3") POWERPC_DEF("power7p_v2.1", CPU_POWERPC_POWER7P_v21, POWER7, -@@ -895,12 +899,14 @@ PowerPCCPUAlias ppc_cpu_aliases[] = { +@@ -897,12 +901,14 @@ PowerPCCPUAlias ppc_cpu_aliases[] = { { "7457a", "7457a_v1.2" }, { "apollo7pm", "7457a_v1.0" }, #if defined(TARGET_PPC64) @@ -381,11 +377,10 @@ index f2301b43f..4c38fa517 100644 { "power7", "power7_v2.3" }, { "power7+", "power7p_v2.1" }, { "power7+_v2.1", "power7p_v2.1" }, -@@ -910,13 +916,14 @@ PowerPCCPUAlias ppc_cpu_aliases[] = { - { "power9", "power9_v2.2" }, - { "power10", "power10_v2.0" }, +@@ -914,12 +920,14 @@ PowerPCCPUAlias ppc_cpu_aliases[] = { + { "power11", "power11_v2.0" }, #endif -- + +#if 0 /* Disabled for Red Hat Enterprise Linux */ /* Generic PowerPCs */ #if defined(TARGET_PPC64) @@ -398,10 +393,10 @@ index f2301b43f..4c38fa517 100644 { NULL, NULL } }; diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h -index 321ed2da7..e35a99762 100644 +index 3ee83517d..121e57482 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h -@@ -1673,6 +1673,7 @@ static inline int ppc_env_mmu_index(CPUPPCState *env, bool ifetch) +@@ -1686,6 +1686,7 @@ static inline int ppc_env_mmu_index(CPUPPCState *env, bool ifetch) /* Compatibility modes */ #if defined(TARGET_PPC64) @@ -410,26 +405,26 @@ index 321ed2da7..e35a99762 100644 uint32_t min_compat_pvr, uint32_t max_compat_pvr); bool ppc_type_check_compat(const char *cputype, uint32_t compat_pvr, diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c -index 907dba60d..c942ff55b 100644 +index 992356cb7..43c468343 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c -@@ -92,6 +92,7 @@ static int cap_large_decr; - static int cap_fwnmi; +@@ -93,6 +93,7 @@ static int cap_fwnmi; static int cap_rpt_invalidate; static int cap_ail_mode_3; + static int cap_dawr1; +static int cap_ppc_secure_guest; #ifdef CONFIG_PSERIES static int cap_papr; -@@ -150,6 +151,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) +@@ -151,6 +152,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_resize_hpt = kvm_vm_check_extension(s, KVM_CAP_SPAPR_RESIZE_HPT); kvmppc_get_cpu_characteristics(s); cap_ppc_nested_kvm_hv = kvm_vm_check_extension(s, KVM_CAP_PPC_NESTED_HV); + cap_ppc_secure_guest = kvm_vm_check_extension(s, KVM_CAP_PPC_SECURE_GUEST); cap_large_decr = kvmppc_get_dec_bits(); cap_fwnmi = kvm_vm_check_extension(s, KVM_CAP_PPC_FWNMI); - /* -@@ -2597,6 +2599,16 @@ bool kvmppc_supports_ail_3(void) + cap_dawr1 = kvm_vm_check_extension(s, KVM_CAP_PPC_DAWR1); +@@ -2609,6 +2611,16 @@ bool kvmppc_supports_ail_3(void) return cap_ail_mode_3; } @@ -446,7 +441,7 @@ index 907dba60d..c942ff55b 100644 PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void) { uint32_t host_pvr = mfpvr(); -@@ -3012,3 +3024,18 @@ static void kvm_cpu_accel_register_types(void) +@@ -3024,3 +3036,18 @@ static void kvm_cpu_accel_register_types(void) type_register_static(&kvm_cpu_accel_type_info); } type_init(kvm_cpu_accel_register_types); @@ -466,7 +461,7 @@ index 907dba60d..c942ff55b 100644 + } +} diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h -index 1975fb5ee..d1017f98b 100644 +index a8768c1df..59f50cb79 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -46,6 +46,7 @@ int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu); @@ -477,7 +472,7 @@ index 1975fb5ee..d1017f98b 100644 bool kvmppc_spapr_use_multitce(void); int kvmppc_spapr_enable_inkernel_multitce(void); void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift, -@@ -79,6 +80,8 @@ int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable); +@@ -81,6 +82,8 @@ int kvmppc_enable_cap_large_decr(PowerPCCPU *cpu, int enable); int kvmppc_has_cap_rpt_invalidate(void); bool kvmppc_supports_ail_3(void); int kvmppc_enable_hwrng(void); @@ -486,7 +481,7 @@ index 1975fb5ee..d1017f98b 100644 int kvmppc_put_books_sregs(PowerPCCPU *cpu); PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void); void kvmppc_check_papr_resize_hpt(Error **errp); -@@ -427,6 +430,16 @@ static inline bool kvmppc_supports_ail_3(void) +@@ -439,6 +442,16 @@ static inline bool kvmppc_supports_ail_3(void) return false; } @@ -503,5 +498,32 @@ index 1975fb5ee..d1017f98b 100644 static inline int kvmppc_enable_hwrng(void) { return -1; +diff --git a/target/ppc/misc_helper.c b/target/ppc/misc_helper.c +index 46ae454af..607ed3735 100644 +--- a/target/ppc/misc_helper.c ++++ b/target/ppc/misc_helper.c +@@ -332,10 +332,6 @@ target_ulong helper_load_sprd(CPUPPCState *env) + PnvCore *pc = pnv_cpu_state(cpu)->pnv_core; + target_ulong sprc = env->spr[SPR_POWER_SPRC]; + +- if (pc->big_core) { +- pc = pnv_chip_find_core(pc->chip, CPU_CORE(pc)->core_id & ~0x1); +- } +- + switch (sprc & 0x3e0) { + case 0: /* SCRATCH0-3 */ + case 1: /* SCRATCH4-7 */ +@@ -372,10 +368,6 @@ void helper_store_sprd(CPUPPCState *env, target_ulong val) + PnvCore *pc = pnv_cpu_state(cpu)->pnv_core; + int nr; + +- if (pc->big_core) { +- pc = pnv_chip_find_core(pc->chip, CPU_CORE(pc)->core_id & ~0x1); +- } +- + switch (sprc & 0x3e0) { + case 0: /* SCRATCH0-3 */ + case 1: /* SCRATCH4-7 */ -- 2.39.5 (Apple Git-154) +