ppc-for-2.13 queue 20180504
The following changes since commit 59255887e6cafeff747250d2613003a41d1d9dff:
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180502' into staging (2018-05-03 11:25:14 +0100)
are available in the Git repository at:
git://github.com/dgibson/qemu.git tags/ppc-for-2.13-20180504
for you to fetch changes up to 0550b1206a91d66051a21441a02c4ff126b531fe:
spapr: don't advertise radix GTSE if max-compat-cpu < power9 (2018-05-04 15:00:37 +1000)
----------------------------------------------------------------
ppc patch queue 2018-05-04
Second patch of patches for qemu-2.13 (or whatever the version ends up being called). Highlights are:
* Preliminary patches for POWER9 hash MMU support for powernv
* A number of cleanups fo pseries startup and LPCR handling
* Remove support for explicitly allocated RMAs (which require kernel support that's been gone for 3+ years)
* Some mac_newworld cleanups
* A few bugfixes
----------------------------------------------------------------
Cédric Le Goater (2):
target/ppc: return a nil HPT base address on sPAPR machines target/ppc: add basic support for PTCR on POWER9
David Gibson (9):
spapr: Remove support for explicitly allocated RMAs target/ppc: Add ppc_store_lpcr() helper
spapr: Clean up rtas_start_cpu() & rtas_stop_self()
spapr: Remove unhelpful helpers from rtas_start_cpu()
spapr: Make a helper to set up cpu entry point state
spapr: Clean up LPCR updates from hypercalls target/ppc: Delay initialization of LPCR_UPRT for secondary cpus
spapr: Move PAPR mode cpu setup fully to spapr code
spapr: Clean up handling of LPCR power-saving exit bits
Greg Kurz (3):
target/ppc: always set PPC_MEM_TLBIE in pre 2.8 migration hack
spapr: don't migrate "spapr_option_vector_ov5_cas" to pre 2.8 machines
spapr: don't advertise radix GTSE if max-compat-cpu < power9
Mark Cave-Ayland (3):
uninorth: create new uninorth device
mac_newworld: remove pics IRQ array and wire up macio to OpenPIC directly
mac_newworld: move wiring of macio IRQs to macio_newworld_realize()
hw/misc/macio/macio.c | 39 +++++++++------ hw/pci-host/trace-events | 2 + hw/pci-host/uninorth.c | 58 +++++++++++++++++++++ hw/ppc/mac.h | 9 ++++ hw/ppc/mac_newworld.c | 56 +++------------------ hw/ppc/spapr.c | 84 ++++++++++++------------------- hw/ppc/spapr_cpu_core.c | 47 ++++++++++++++--- hw/ppc/spapr_hcall.c | 50 ++++++++----------- hw/ppc/spapr_rtas.c | 108 ++++++++++++++++++++-------------------- hw/ppc/trace-events | 4 -- include/hw/misc/macio/macio.h | 1 - include/hw/pci-host/uninorth.h | 11 ++++ include/hw/ppc/spapr_cpu_core.h | 3 ++ target/ppc/cpu.h | 4 +- target/ppc/helper.h | 1 + target/ppc/kvm.c | 46 ++--------------- target/ppc/kvm_ppc.h | 6 --- target/ppc/machine.c | 5 ++ target/ppc/misc_helper.c | 12 +++++ target/ppc/mmu-book3s-v3.h | 6 +++ target/ppc/mmu-hash64.c | 15 ++++-- target/ppc/mmu-hash64.h | 6 ++- target/ppc/mmu_helper.c | 29 +++++++++++ target/ppc/translate.c | 3 ++ target/ppc/translate_init.c | 80 +++++++---------------------- 25 files changed, 355 insertions(+), 330 deletions(-)
[Qemu-devel] [PULL 02/17] target/ppc: add basic support for PTCR on POWER9
From: Cédric Le Goater <[email protected]>
The Partition Table Control Register (PTCR) is a hypervisor privileged SPR. It contains the host real address of the Partition Table and its size.
--- target/ppc/cpu.h | 2 ++ target/ppc/helper.h | 1 + target/ppc/misc_helper.c | 12 ++++++++++++ target/ppc/mmu-book3s-v3.h | 6 ++++++ target/ppc/mmu_helper.c | 29 +++++++++++++++++++++++++++++ target/ppc/translate.c | 3 +++ target/ppc/translate_init.c | 18 ++++++++++++++++++ 7 files changed, 71 insertions(+)
target/ppc/cpu.h +2 -0
@@ -1295,6 +1295,7 @@ int ppc_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw,#if !defined(CONFIG_USER_ONLY )void ppc_store_sdr1 (CPUPPCState *env,target_ulong value); +void ppc_store_ptcr (CPUPPCState *env,target_ulong value);#endif /* !defined(CONFIG_USER_ONLY) */ void ppc_store_msr (CPUPPCState *env,target_ulong value);
@@ -1585,6 +1586,7 @@ void ppc_compat_add_property(Object *obj, const char *name,#define SPR_BOOKE_GIVOR13 (0x1BC)#define SPR_BOOKE_GIVOR14 (0x1BD)#define SPR_TIR (0x1BE) +#define SPR_PTCR (0x1D0)#define SPR_BOOKE_SPEFSCR (0x200)#define SPR_Exxx_BBEAR (0x201)#define SPR_Exxx_BBTAR (0x202)
target/ppc/helper.h +1 -0
@@ -709,6 +709,7 @@ DEF_HELPER_FLAGS_1(load_601_rtcu, TCG_CALL_NO_RWG, tl, env)#if !defined(CONFIG_USER_ONLY )#if defined(TARGET_PPC64 ) DEF_HELPER_FLAGS_1(load_purr, TCG_CALL_NO_RWG, tl, env) +DEF_HELPER_2(store_ptcr, void, env, tl)#endif DEF_HELPER_2(store_sdr1, void, env, tl)DEF_HELPER_2 (store_pidr, void, env, tl)
target/ppc/misc_helper.c +12 -0
@@ -88,6 +88,18 @@ void helper_store_sdr1(CPUPPCState *env, target_ulong val) } } +#if defined(TARGET_PPC64 ) +void helper_store_ptcr (CPUPPCState *env,target_ulong val) +{ +PowerPCCPU *cpu =ppc_env_get_cpu (env); + +if (env->spr[SPR_PTCR ] != val) { +ppc_store_ptcr (env, val); +tlb_flush (CPU (cpu)); + } +} +#endif /* defined(TARGET_PPC64) */ +void helper_store_pidr (CPUPPCState *env,target_ulong val) {PowerPCCPU *cpu =ppc_env_get_cpu (env);
target/ppc/mmu-book3s-v3.h +6 -0
@@ -22,6 +22,12 @@#ifndef CONFIG_USER_ONLY +/* +* Partition table definitions +*/ +#define PTCR_PATB 0x0FFFFFFFFFFFF000ULL/* Partition Table Base */ +#define PTCR_PATS 0x000000000000001FULL/* Partition Table Size */ +/* Partition Table Entry Fields */ #define PATBE1_GR 0x8000000000000000
target/ppc/mmu_helper.c +29 -0
@@ -2028,6 +2028,35 @@ void ppc_store_sdr1(CPUPPCState *env, target_ulong value) env->spr[SPR_SDR1 ] = value; } +#if defined(TARGET_PPC64 ) +void ppc_store_ptcr (CPUPPCState *env,target_ulong value) +{ +PowerPCCPU *cpu =ppc_env_get_cpu (env); +target_ulong ptcr_mask =PTCR_PATB |PTCR_PATS ; +target_ulong patbsize = value &PTCR_PATS ; + +qemu_log_mask (CPU_LOG_MMU ,"%s: " TARGET_FMT_lx"\n" , __func__, value); + +assert (!cpu->vhyp); +assert (env->mmu_model &POWERPC_MMU_3_00 ); + +if (value & ~ptcr_mask) { +error_report ("Invalid bits 0x" TARGET_FMT_lx" set in PTCR" , + value & ~ptcr_mask); + value &= ptcr_mask; + } + +if (patbsize >24 ) { +error_report ("Invalid Partition Table size 0x" TARGET_FMT_lx +" stored in PTCR" , patbsize); +return ; + } + + env->spr[SPR_PTCR ] = value; +} + +#endif /* defined(TARGET_PPC64) */ +/* Segment registers load and store */ target_ulong helper_load_sr (CPUPPCState *env,target_ulong sr_num) {
target/ppc/translate.c +3 -0
@@ -7136,6 +7136,9 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,if (env->spr_cb[SPR_SDR1 ].name) {/* SDR1 Exists */ cpu_fprintf (f," SDR1 " TARGET_FMT_lx" " , env->spr[SPR_SDR1 ]); } +if (env->spr_cb[SPR_PTCR ].name) {/* PTCR Exists */ +cpu_fprintf (f," PTCR " TARGET_FMT_lx" " , env->spr[SPR_PTCR ]); + }cpu_fprintf (f," DAR " TARGET_FMT_lx" DSISR " TARGET_FMT_lx"\n" , env->spr[SPR_DAR ], env->spr[SPR_DSISR ]);break ;
target/ppc/translate_init.c +18 -0
@@ -420,6 +420,11 @@ static void spr_write_hior(DisasContext *ctx, int sprn, int gprn)tcg_gen_st_tl (t0, cpu_env, offsetof(CPUPPCState , excp_prefix));tcg_temp_free (t0); } +static void spr_write_ptcr (DisasContext *ctx,int sprn,int gprn) +{ +gen_helper_store_ptcr (cpu_env, cpu_gpr[gprn]); +} +#endif #endif
@@ -8167,6 +8172,18 @@ static void gen_spr_power8_rpr(CPUPPCState *env)#endif } +static void gen_spr_power9_mmu (CPUPPCState *env) +{ +#if !defined(CONFIG_USER_ONLY ) +/* Partition Table Control */ +spr_register_hv (env,SPR_PTCR ,"PTCR" , +SPR_NOACCESS ,SPR_NOACCESS , +SPR_NOACCESS ,SPR_NOACCESS , + &spr_read_generic, &spr_write_ptcr, +0x00000000 ); +#endif +} +static void init_proc_book3s_common (CPUPPCState *env) {gen_spr_ne_601 (env);
@@ -8719,6 +8736,7 @@ static void init_proc_POWER9(CPUPPCState *env)gen_spr_power8_ic (env);gen_spr_power8_book4 (env);gen_spr_power8_rpr (env); +gen_spr_power9_mmu (env);/* POWER9 Specific registers */ spr_register_kvm(env, SPR_TIDR, "TIDR", NULL, NULL,
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 03/17] spapr: Remove support for explicitly allocated RMAs
In reply to David GibsonCurrent POWER cpus allow for a VRMA, a special mapping which describes a guest's view of memory when in real mode (MMU off, from the guest's point of view). Older cpus didn't have that which meant that to support a guest a special host-contiguous region of memory was needed to give the guest its Real Mode Area (RMA).
KVM used to provide special calls to allocate a contiguous RMA for those cases. This was useful in the early days of KVM on Power to allow it to be tested on PowerPC 970 chips as used in Macintosh G5 machines. Now, those machines are so old as to be almost irrelevant.
The normal qemu deprecation process would require this to be marked deprecated then removed in 2 releases. However, this can only be used with corresponding support in the host kernel - which was dropped years ago (in c17b98cf "KVM: PPC: Book3S HV: Remove code for PPC970 processors" of 2014-12-03 to be precise). Therefore it should be ok to drop this immediately.
Just to be clear this only affects *KVM HV* guests with PowerPC 970, and those already require an ancient host kernel. TCG and KVM PR guests with PowerPC 970 should still work.
--- hw/ppc/spapr.c | 61 ++++++++++++++------------------------------ target/ppc/kvm.c | 42 ------------------------------ target/ppc/kvm_ppc.h | 6 ----- 3 files changed, 19 insertions(+), 90 deletions(-)
hw/ppc/spapr.c +19 -42
@@ -2508,9 +2508,6 @@ static void spapr_machine_init(MachineState *machine)int i;MemoryRegion *sysmem =get_system_memory ();MemoryRegion *ram =g_new (MemoryRegion,1 ); -MemoryRegion *rma_region; -void *rma =NULL ; -hwaddr rma_alloc_size;hwaddr node0_size =spapr_node0_size (machine);long load_limit, fw_size;char *filename;
@@ -2549,40 +2546,28 @@ static void spapr_machine_init(MachineState *machine)exit (1 ); } -/* Allocate RMA if necessary */ - rma_alloc_size =kvmppc_alloc_rma (&rma); + spapr->rma_size = node0_size; -if (rma_alloc_size ==-1 ) { -error_report ("Unable to create RMA" ); -exit (1 ); +/* With KVM, we don't actually know whether KVM supports an +* unbounded RMA (PR KVM) or is limited by the hash table size +* (HV KVM using VRMA), so we always assume the latter +* +* In that case, we also limit the initial allocations for RTAS +* etc... to 256M since we have no way to know what the VRMA size +* is going to be as it depends on the size of the hash table +* which isn't determined yet. +*/ +if (kvm_enabled ()) { + spapr->vrma_adjust =1 ; + spapr->rma_size =MIN (spapr->rma_size,0x10000000 ); } -if (rma_alloc_size && (rma_alloc_size < node0_size)) { - spapr->rma_size = rma_alloc_size; - }else { - spapr->rma_size = node0_size; - -/* With KVM, we don't actually know whether KVM supports an -* unbounded RMA (PR KVM) or is limited by the hash table size -* (HV KVM using VRMA), so we always assume the latter -* -* In that case, we also limit the initial allocations for RTAS -* etc... to 256M since we have no way to know what the VRMA size -* is going to be as it depends on the size of the hash table -* isn't determined yet. -*/ -if (kvm_enabled ()) { - spapr->vrma_adjust =1 ; - spapr->rma_size =MIN (spapr->rma_size,0x10000000 ); - } - -/* Actually we don't support unbounded RMA anymore since we -* added proper emulation of HV mode. The max we can get is -* 16G which also happens to be what we configure for PAPR -* mode so make sure we don't do anything bigger than that -*/ - spapr->rma_size =MIN (spapr->rma_size,0x400000000ull ); - } +/* Actually we don't support unbounded RMA anymore since we added +* proper emulation of HV mode. The max we can get is 16G which +* also happens to be what we configure for PAPR mode so make sure +* we don't do anything bigger than that +*/ + spapr->rma_size =MIN (spapr->rma_size,0x400000000ull );if (spapr->rma_size > node0_size) { error_report("Numa node 0 has to span the RMA (%#08"HWADDR_PRIx")",
@@ -2643,14 +2628,6 @@ static void spapr_machine_init(MachineState *machine) machine->ram_size);memory_region_add_subregion (sysmem,0 , ram); -if (rma_alloc_size && rma) { - rma_region =g_new (MemoryRegion,1 ); -memory_region_init_ram_ptr (rma_region,NULL ,"ppc_spapr.rma" , - rma_alloc_size, rma); -vmstate_register_ram_global (rma_region); -memory_region_add_subregion (sysmem,0 , rma_region); - } -/* initialize hotplug memory address space */ if (machine->ram_size < machine->maxram_size) {ram_addr_t hotplug_mem_size = machine->maxram_size - machine->ram_size;
target/ppc/kvm.c +0 -42
66 lines not on this page · raw message
target/ppc/kvm_ppc.h +0 -6
@@ -37,7 +37,6 @@ target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, bool radix, bool gtse, uint64_t proc_tbl);#ifndef CONFIG_USER_ONLY -off_t kvmppc_alloc_rma (void **rma);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,
@@ -188,11 +187,6 @@ static inline target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, }#ifndef CONFIG_USER_ONLY -static inline off_t kvmppc_alloc_rma (void **rma) -{ -return 0 ; -} -static inline bool kvmppc_spapr_use_multitce (void ) {return false;
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 01/17] target/ppc: return a nil HPT base address on sPAPR machines
In reply to David GibsonFrom: Cédric Le Goater <[email protected]>
commit e57ca75ce3b2 ("target/ppc: Manage external HPT via virtual hypervisor") exported a set of methods to manipulate the HPT from the core hash MMU. But SPR_SDR1 is still used under some circumstances to get the base address of the HPT, which is incorrect for the sPAPR machines.
Only the logging should be impacted.
--- target/ppc/mmu-hash64.h | 3 +++ 1 file changed, 3 insertions(+)
target/ppc/mmu-hash64.h +3 -0
@@ -102,6 +102,9 @@ void ppc_hash64_finalize(PowerPCCPU *cpu);static inline hwaddr ppc_hash64_hpt_base (PowerPCCPU *cpu) { +if (cpu->vhyp) { +return 0 ; + }return cpu->env.spr[SPR_SDR1 ] &SDR_64_HTABORG ; }
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 08/17] spapr: Clean up LPCR updates from hypercalls
In reply to David GibsonThere are several places in spapr_hcall.c where we need to update the LPCR value on all CPUs. We do this with the set_spr() helper. That's not really correct because this directly sets the SPR value, without going through the ppc_store_lpcr() helper which may need to update state based on the LPCR change.
In fact, set_spr() is only ever used for the LPCR, so replace it with an explicit LPCR updated which uses the right low-level helper. While we're there, move the CPU_FOREACH() which was in every one of the callers into the new helper: set_all_lpcrs().
--- hw/ppc/spapr_hcall.c | 50 ++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 30 deletions(-)
hw/ppc/spapr_hcall.c +20 -30
@@ -15,32 +15,35 @@#include "hw/ppc/spapr_ovec.h" #include "mmu-book3s-v3.h" -struct SPRSyncState { -int spr; +struct LPCRSyncState {target_ulong value;target_ulong mask; }; -static void do_spr_sync (CPUState *cs,run_on_cpu_data arg) +static void do_lpcr_sync (CPUState *cs,run_on_cpu_data arg) { -struct SPRSyncState *s = arg.host_ptr; +struct LPCRSyncState *s = arg.host_ptr;PowerPCCPU *cpu =POWERPC_CPU (cs);CPUPPCState *env = &cpu->env; +target_ulong lpcr;cpu_synchronize_state (cs); - env->spr[s->spr] &= ~s->mask; - env->spr[s->spr] |= s->value; + lpcr = env->spr[SPR_LPCR ]; + lpcr &= ~s->mask; + lpcr |= s->value; +ppc_store_lpcr (cpu, lpcr); } -static void set_spr (CPUState *cs,int spr,target_ulong value, -target_ulong mask) +static void set_all_lpcrs (target_ulong value,target_ulong mask) { -struct SPRSyncState s = { - .spr = spr, +CPUState *cs; +struct LPCRSyncState s = { .value = value, .mask = mask }; -run_on_cpu (cs, do_spr_sync,RUN_ON_CPU_HOST_PTR (&s)); +CPU_FOREACH (cs) { +run_on_cpu (cs, do_lpcr_sync,RUN_ON_CPU_HOST_PTR (&s)); + } }static bool has_spr (PowerPCCPU *cpu,int spr)
@@ -1235,8 +1238,6 @@ static target_ulong h_set_mode_resource_le(PowerPCCPU *cpu, target_ulong value1, target_ulong value2) { -CPUState *cs; - if (value1) {return H_P3 ; }
@@ -1246,16 +1247,12 @@ static target_ulong h_set_mode_resource_le(PowerPCCPU *cpu,switch (mflags) {case H_SET_MODE_ENDIAN_BIG : - CPU_FOREACH(cs) { -set_spr (cs,SPR_LPCR ,0 ,LPCR_ILE ); - } +set_all_lpcrs (0 ,LPCR_ILE );spapr_pci_switch_vga (true);return H_SUCCESS ;case H_SET_MODE_ENDIAN_LITTLE : - CPU_FOREACH(cs) { -set_spr (cs,SPR_LPCR ,LPCR_ILE ,LPCR_ILE ); - } +set_all_lpcrs (LPCR_ILE ,LPCR_ILE );spapr_pci_switch_vga (false);return H_SUCCESS ; }
@@ -1268,7 +1265,6 @@ static target_ulong h_set_mode_resource_addr_trans_mode(PowerPCCPU *cpu, target_ulong value1, target_ulong value2) { -CPUState *cs;PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cpu);if (!(pcc->insns_flags2 &PPC2_ISA207S )) {
@@ -1285,9 +1281,7 @@ static target_ulong h_set_mode_resource_addr_trans_mode(PowerPCCPU *cpu,return H_UNSUPPORTED_FLAG ; } -CPU_FOREACH (cs) { -set_spr (cs,SPR_LPCR , mflags <<LPCR_AIL_SHIFT ,LPCR_AIL ); - } +set_all_lpcrs (mflags <<LPCR_AIL_SHIFT ,LPCR_AIL );return H_SUCCESS ; }
@@ -1364,7 +1358,6 @@ static target_ulong h_register_process_table(PowerPCCPU *cpu,target_ulong opcode, target_ulong *args) { - CPUState *cs; target_ulong flags = args[0];target_ulong proc_tbl = args[1 ];target_ulong page_size = args[2 ];
@@ -1422,12 +1415,9 @@ static target_ulong h_register_process_table(PowerPCCPU *cpu, spapr->patb_entry = cproc;/* Save new process table */ /* Update the UPRT and GTSE bits in the LPCR for all cpus */ -CPU_FOREACH (cs) { -set_spr (cs,SPR_LPCR , - ((flags & (FLAG_RADIX |FLAG_HASH_PROC_TBL )) ?LPCR_UPRT :0 ) | - ((flags &FLAG_GTSE ) ?LPCR_GTSE :0 ), -LPCR_UPRT |LPCR_GTSE ); - } +set_all_lpcrs (((flags & (FLAG_RADIX |FLAG_HASH_PROC_TBL )) ?LPCR_UPRT :0 ) | + ((flags &FLAG_GTSE ) ?LPCR_GTSE :0 ), +LPCR_UPRT |LPCR_GTSE );if (kvm_enabled ()) { return kvmppc_configure_v3_mmu(cpu, flags & FLAG_RADIX,
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 04/17] target/ppc: Add ppc_store_lpcr() helper
In reply to David GibsonThere are some fields in the cpu state which need to be updated when the LPCR register is changed, which is done by ppc_hash64_update_rmls() and ppc_hash64_update_vrma(). Code which alters env->spr[SPR_LPCR] needs to call them afterwards to make sure the state is up to date.
That's easy to get wrong. The normal way of dealing with sitautions like that is to use a helper which both updates the basic register value and the derived state.
So, do that.
--- target/ppc/mmu-hash64.c | 15 +++++++++++---- target/ppc/mmu-hash64.h | 3 +-- target/ppc/translate_init.c | 6 +----- 3 files changed, 13 insertions(+), 11 deletions(-)
target/ppc/mmu-hash64.c +11 -4
@@ -942,7 +942,7 @@ void ppc_hash64_tlb_flush_hpte(PowerPCCPU *cpu, target_ulong ptex, cpu->env.tlb_need_flush =TLB_NEED_GLOBAL_FLUSH |TLB_NEED_LOCAL_FLUSH ; } -void ppc_hash64_update_rmls (PowerPCCPU *cpu) +static void ppc_hash64_update_rmls (PowerPCCPU *cpu) {CPUPPCState *env = &cpu->env;uint64_t lpcr = env->spr[SPR_LPCR ];
@@ -977,7 +977,7 @@ void ppc_hash64_update_rmls(PowerPCCPU *cpu) } } -void ppc_hash64_update_vrma (PowerPCCPU *cpu) +static void ppc_hash64_update_vrma (PowerPCCPU *cpu) {CPUPPCState *env = &cpu->env;const PPCHash64SegmentPageSizes *sps =NULL ;
@@ -1028,9 +1028,9 @@ void ppc_hash64_update_vrma(PowerPCCPU *cpu) slb->sps = sps; } -void helper_store_lpcr (CPUPPCState *env,target_ulong val) +void ppc_store_lpcr (PowerPCCPU *cpu,target_ulong val) { -PowerPCCPU *cpu =ppc_env_get_cpu (env); +CPUPPCState *env = &cpu->env;uint64_t lpcr =0 ;/* Filter out bits */
@@ -1096,6 +1096,13 @@ void helper_store_lpcr(CPUPPCState *env, target_ulong val)ppc_hash64_update_vrma (cpu); } +void helper_store_lpcr (CPUPPCState *env,target_ulong val) +{ +PowerPCCPU *cpu =ppc_env_get_cpu (env); + +ppc_store_lpcr (cpu, val); +} +void ppc_hash64_init (PowerPCCPU *cpu) {CPUPPCState *env = &cpu->env;
target/ppc/mmu-hash64.h +1 -2
@@ -17,8 +17,7 @@ void ppc_hash64_tlb_flush_hpte(PowerPCCPU *cpu, target_ulong pte0, target_ulong pte1);unsigned ppc_hash64_hpte_page_shift_noslb (PowerPCCPU *cpu,uint64_t pte0,uint64_t pte1); -void ppc_hash64_update_vrma (PowerPCCPU *cpu); -void ppc_hash64_update_rmls (PowerPCCPU *cpu); +void ppc_store_lpcr (PowerPCCPU *cpu,target_ulong val);void ppc_hash64_init (PowerPCCPU *cpu);void ppc_hash64_finalize (PowerPCCPU *cpu);#endif
target/ppc/translate_init.c +1 -5
@@ -8940,15 +8940,11 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHypervisor *vhyp)/* We should be followed by a CPU reset but update the active value * just in case... */ - env->spr[SPR_LPCR ] = lpcr->default_value; +ppc_store_lpcr (cpu, lpcr->default_value);/* Set a full AMOR so guest can use the AMR as it sees fit */ env->spr[SPR_AMOR ] = amor->default_value =0xffffffffffffffffull ; -/* Update some env bits based on new LPCR value */ -ppc_hash64_update_rmls (cpu); -ppc_hash64_update_vrma (cpu); -/* Tell KVM that we're in PAPR mode */ if (kvm_enabled ()) {kvmppc_set_papr (cpu);
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 05/17] spapr: Clean up rtas_start_cpu() & rtas_stop_self()
In reply to David GibsonThis makes several minor cleanups to these functions:
* Follow usual convention of an early exit on error, rather than having most of the body in an if
* Clearer naming of cpu and cpu_. Now callcpu is the cpu from which the RTAS call is invoked, newcpu is the cpu which we're starting
* Use cpu_synchronize_state() instead of kvm_cpu_synchronize_state() directly
* Remove pointless comment describing what cpu_synchronize_state() does
* Use ppc_store_lpcr() instead of directly writing the register field
--- hw/ppc/spapr_rtas.c | 66 ++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 34 deletions(-)
hw/ppc/spapr_rtas.c +32 -34
@@ -32,7 +32,7 @@#include "hw/qdev.h" #include "sysemu/device_tree.h" #include "sysemu/cpus.h" -#include "sysemu/kvm.h" +#include "sysemu/hw_accel.h" #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h"
@@ -45,6 +45,7 @@#include "qemu/cutils.h" #include "trace.h" #include "hw/ppc/fdt.h" +#include "target/ppc/mmu-hash64.h" static void rtas_display_character(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t token, uint32_t nargs,
@@ -140,13 +141,15 @@ static void spapr_cpu_set_endianness(PowerPCCPU *cpu) } } -static void rtas_start_cpu (PowerPCCPU *cpu_,sPAPRMachineState *spapr, +static void rtas_start_cpu (PowerPCCPU *callcpu,sPAPRMachineState *spapr,uint32_t token,uint32_t nargs,target_ulong args,uint32_t nret,target_ulong rets) {target_ulong id, start, r3; -PowerPCCPU *cpu; +PowerPCCPU *newcpu; +CPUPPCState *env; +PowerPCCPUClass *pcc;if (nargs !=3 || nret !=1 ) {rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR );
@@ -157,41 +160,37 @@ static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMachineState *spapr, start =rtas_ld (args,1 ); r3 =rtas_ld (args,2 ); - cpu =spapr_find_cpu (id); -if (cpu !=NULL ) { -CPUState *cs =CPU (cpu); -CPUPPCState *env = &cpu->env; -PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cpu); + newcpu =spapr_find_cpu (id); +if (!newcpu) { +/* Didn't find a matching cpu */ +rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR ); +return ; + } -if (!cs->halted) { -rtas_st (rets,0 ,RTAS_OUT_HW_ERROR ); -return ; - } + env = &newcpu->env; + pcc =POWERPC_CPU_GET_CLASS (newcpu); -/* This will make sure qemu state is up to date with kvm, and -* mark it dirty so our changes get flushed back before the -* new cpu enters */ -kvm_cpu_synchronize_state (cs); +if (!CPU (newcpu)->halted) { +rtas_st (rets,0 ,RTAS_OUT_HW_ERROR ); +return ; + } - env->msr = (1ULL <<MSR_SF ) | (1ULL <<MSR_ME ); +cpu_synchronize_state (CPU (newcpu)); -/* Enable Power-saving mode Exit Cause exceptions for the new CPU */ - env->spr[SPR_LPCR ] |= pcc->lpcr_pm; + env->msr = (1ULL <<MSR_SF ) | (1ULL <<MSR_ME ); +spapr_cpu_set_endianness (newcpu); +spapr_cpu_update_tb_offset (newcpu); +/* Enable Power-saving mode Exit Cause exceptions for the new CPU */ +ppc_store_lpcr (newcpu, env->spr[SPR_LPCR ] | pcc->lpcr_pm); - env->nip = start; - env->gpr[3 ] = r3; - cs->halted =0 ; -spapr_cpu_set_endianness (cpu); -spapr_cpu_update_tb_offset (cpu); + env->nip = start; + env->gpr[3 ] = r3; -qemu_cpu_kick (cs); +CPU (newcpu)->halted =0 ; -rtas_st (rets,0 ,RTAS_OUT_SUCCESS ); -return ; - } +qemu_cpu_kick (CPU (newcpu)); -/* Didn't find a matching cpu */ -rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR ); +rtas_st (rets,0 ,RTAS_OUT_SUCCESS ); } static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachineState *spapr,
@@ -203,13 +202,12 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPRMachineState *spapr,CPUPPCState *env = &cpu->env;PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cpu); - cs->halted =1 ; -qemu_cpu_kick (cs); -/* Disable Power-saving mode Exit Cause exceptions for the CPU. * This could deliver an interrupt on a dying CPU and crash the * guest */ - env->spr[SPR_LPCR ] &= ~pcc->lpcr_pm; +ppc_store_lpcr (cpu, env->spr[SPR_LPCR ] & ~pcc->lpcr_pm); + cs->halted =1 ; +qemu_cpu_kick (cs); } static inline int sysparm_st(target_ulong addr, target_ulong len,
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 06/17] spapr: Remove unhelpful helpers from rtas_start_cpu()
In reply to David Gibsonrtas_start_cpu() calls spapr_cpu_update_tb_offset() and spapr_cpu_set_endianness() to initialize certain things in the new cpu's state. This is the only caller of those helpers, and they're each only a few lines long, so we might as well just fold them into the caller.
In addition, those helpers initialize state on the new cpu to match that of the first cpu. That will generally work, but might be at least logically incorrect if the first cpu has been set offline by the guest. So, instead base the state on that of the cpu invoking the RTAS call, which is obviously active already.
--- hw/ppc/spapr_rtas.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-)
hw/ppc/spapr_rtas.c +14 -24
@@ -120,27 +120,6 @@ static void rtas_query_cpu_stopped_state(PowerPCCPU *cpu_,rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR ); } -/* -* Set the timebase offset of the CPU to that of first CPU. -* This helps hotplugged CPU to have the correct timebase offset. -*/ -static void spapr_cpu_update_tb_offset (PowerPCCPU *cpu) -{ -PowerPCCPU *fcpu =POWERPC_CPU (first_cpu); - - cpu->env.tb_env->tb_offset = fcpu->env.tb_env->tb_offset; -} - -static void spapr_cpu_set_endianness (PowerPCCPU *cpu) -{ -PowerPCCPU *fcpu =POWERPC_CPU (first_cpu); -PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (fcpu); - -if (!pcc->interrupts_big_endian (fcpu)) { - cpu->env.spr[SPR_LPCR ] |=LPCR_ILE ; - } -} - static void rtas_start_cpu(PowerPCCPU *callcpu, sPAPRMachineState *spapr, uint32_t token, uint32_t nargs, target_ulong args,
@@ -150,6 +129,7 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, sPAPRMachineState *spapr,PowerPCCPU *newcpu;CPUPPCState *env;PowerPCCPUClass *pcc; +target_ulong lpcr;if (nargs !=3 || nret !=1 ) {rtas_st (rets,0 ,RTAS_OUT_PARAM_ERROR );
@@ -178,10 +158,20 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, sPAPRMachineState *spapr,cpu_synchronize_state (CPU (newcpu)); env->msr = (1ULL <<MSR_SF ) | (1ULL <<MSR_ME ); -spapr_cpu_set_endianness (newcpu); -spapr_cpu_update_tb_offset (newcpu); +/* Enable Power-saving mode Exit Cause exceptions for the new CPU */ -ppc_store_lpcr (newcpu, env->spr[SPR_LPCR ] | pcc->lpcr_pm); + lpcr = env->spr[SPR_LPCR ] | pcc->lpcr_pm; +if (!pcc->interrupts_big_endian (callcpu)) { + lpcr |=LPCR_ILE ; + } +ppc_store_lpcr (newcpu, lpcr); + +/* +* Set the timebase offset of the new CPU to that of the invoking +* CPU. This helps hotplugged CPU to have the correct timebase +* offset. +*/ + newcpu->env.tb_env->tb_offset = callcpu->env.tb_env->tb_offset; env->nip = start; env->gpr[3 ] = r3;
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 07/17] spapr: Make a helper to set up cpu entry point state
In reply to David GibsonUnder PAPR, only the boot CPU is active when the system starts. Other cpus must be explicitly activated using an RTAS call. The entry state for the boot and secondary cpus isn't identical, but it has some things in common. We're going to add a bit more common setup later, too, so to simplify make a helper which sets up the common entry state for both boot and secondary cpu threads.
--- hw/ppc/spapr.c | 4 +--- hw/ppc/spapr_cpu_core.c | 9 +++++++++ hw/ppc/spapr_rtas.c | 6 ++---- include/hw/ppc/spapr_cpu_core.h | 3 +++ 4 files changed, 15 insertions(+), 7 deletions(-)
hw/ppc/spapr.c +1 -3
@@ -1668,10 +1668,8 @@ static void spapr_machine_reset(void)g_free (fdt);/* Set up the entry state */ - first_ppc_cpu->env.gpr[3 ] = fdt_addr; +spapr_cpu_set_entry_state (first_ppc_cpu,SPAPR_ENTRY_POINT , fdt_addr); first_ppc_cpu->env.gpr[5 ] =0 ; - first_cpu->halted =0 ; - first_ppc_cpu->env.nip =SPAPR_ENTRY_POINT ; spapr->cas_reboot = false; }
hw/ppc/spapr_cpu_core.c +9 -0
@@ -52,6 +52,15 @@ static void spapr_cpu_reset(void *opaque) } +void spapr_cpu_set_entry_state (PowerPCCPU *cpu,target_ulong nip,target_ulong r3) +{ +CPUPPCState *env = &cpu->env; + + env->nip = nip; + env->gpr[3 ] = r3; +CPU (cpu)->halted =0 ; +} +static void spapr_cpu_destroy (PowerPCCPU *cpu) {qemu_unregister_reset (spapr_cpu_reset, cpu);
hw/ppc/spapr_rtas.c +2 -4
@@ -37,6 +37,7 @@#include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" #include "hw/ppc/spapr_rtas.h" +#include "hw/ppc/spapr_cpu_core.h" #include "hw/ppc/ppc.h" #include "hw/boards.h"
@@ -173,10 +174,7 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, sPAPRMachineState *spapr,*/ newcpu->env.tb_env->tb_offset = callcpu->env.tb_env->tb_offset; - env->nip = start; - env->gpr[3 ] = r3; - -CPU (newcpu)->halted =0 ; +spapr_cpu_set_entry_state (newcpu, start, r3);qemu_cpu_kick (CPU (newcpu));
include/hw/ppc/spapr_cpu_core.h +3 -0
@@ -12,6 +12,7 @@#include "hw/qdev.h" #include "hw/cpu/core.h" #include "target/ppc/cpu-qom.h" +#include "target/ppc/cpu.h" #define TYPE_SPAPR_CPU_CORE "spapr-cpu-core"#define SPAPR_CPU_CORE (obj) \
@@ -38,4 +39,6 @@ typedef struct sPAPRCPUCoreClass { } sPAPRCPUCoreClass;const char *spapr_get_cpu_core_type (const char *cpu_type); +void spapr_cpu_set_entry_state (PowerPCCPU *cpu,target_ulong nip,target_ulong r3); +#endif
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 09/17] target/ppc: Delay initialization of LPCR_UPRT for secondary cpus
In reply to David GibsonIn cpu_ppc_set_papr() the UPRT and GTSE bits of the LPCR default value are initialized based on on ppc64_radix_guest(). Which seems reasonable, except that ppc64_radix_guest() is based on spapr->patb_entry which is only set up in spapr_machine_reset, called _after_ cpu_ppc_set_papr() for boot cpus. Well, and the fact that modifying the SPR default value for an instance rather than a class is kind of yucky.
The initialization here is really only necessary or valid for hotplugged cpus; the base cpu initialization already sets a value that's good enough for the boot cpus until the guest uses an hcall to configure it's preferred MMU mode.
So, move this initialization to the rtas_start_cpu() path, at which point ppc64_radix_guest() will have a sensible value, to make sure secondary cpus come up in an MMU mode matching the existing cpus.
--- hw/ppc/spapr_rtas.c | 12 ++++++++++++ target/ppc/translate_init.c | 16 ---------------- 2 files changed, 12 insertions(+), 16 deletions(-)
hw/ppc/spapr_rtas.c +12 -0
@@ -47,6 +47,7 @@#include "trace.h" #include "hw/ppc/fdt.h" #include "target/ppc/mmu-hash64.h" +#include "target/ppc/mmu-book3s-v3.h" static void rtas_display_character(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t token, uint32_t nargs,
@@ -165,6 +166,17 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, sPAPRMachineState *spapr,if (!pcc->interrupts_big_endian (callcpu)) { lpcr |=LPCR_ILE ; } +if (env->mmu_model ==POWERPC_MMU_3_00 ) { +/* +* New cpus are expected to start in the same radix/hash mode +* as the existing CPUs +*/ +if (ppc64_radix_guest (callcpu)) { + lpcr |=LPCR_UPRT |LPCR_GTSE ; + }else { + lpcr &= ~(LPCR_UPRT |LPCR_GTSE ); + } + }ppc_store_lpcr (newcpu, lpcr);/*
target/ppc/translate_init.c +0 -16
@@ -8914,22 +8914,6 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHypervisor *vhyp) lpcr->default_value &= ~LPCR_RMLS ; lpcr->default_value |=1ull <<LPCR_RMLS_SHIFT ; -if (env->mmu_model ==POWERPC_MMU_3_00 ) { -/* By default we choose legacy mode and switch to new hash or radix -* when a register process table hcall is made. So disable process -* tables and guest translation shootdown by default -* -* Hot-plugged CPUs inherit from the guest radix setting under -* KVM but not under TCG. Update the default LPCR to keep new -* CPUs in sync when radix is enabled. -*/ -if (ppc64_radix_guest (cpu)) { - lpcr->default_value |=LPCR_UPRT |LPCR_GTSE ; - }else { - lpcr->default_value &= ~(LPCR_UPRT |LPCR_GTSE ); - } - } -/* Only enable Power-saving mode Exit Cause exceptions on the boot * CPU. The RTAS command start-cpu will enable them on secondaries. */
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 11/17] spapr: Clean up handling of LPCR power-saving exit bits
In reply to David GibsonTo prevent spurious wakeups on cpus that are supposed to be disabled, we need to clear the LPCR bits which control certain wakeup events. spapr_cpu_reset() has separate cases here for boot and non-boot (initially inactive) cpus. rtas_start_cpu() then turns the LPCR bits on when the non-boot cpus are activated.
But explicit checks against first_cpu are not how we usually do things:
instead spapr_cpu_reset() generally sets things up for non-boot (inactive) cpus, then spapr_machine_reset() and/or rtas_start_cpu() override as necessary.
So, do that instead. Because the LPCR activation is identical for boot cpus and non-boot cpus just activated with rtas_start_cpu() we can put the code common in spapr_cpu_set_entry_state().
--- hw/ppc/spapr_cpu_core.c | 22 +++++++--------------- hw/ppc/spapr_rtas.c | 2 +- 2 files changed, 8 insertions(+), 16 deletions(-)
hw/ppc/spapr_cpu_core.c +7 -15
@@ -54,28 +54,17 @@ static void spapr_cpu_reset(void *opaque)* Clearing VPM0 will also cause us to use RMOR in mmu-hash64.c for * real mode accesses, which thankfully defaults to 0 and isn't * accessible in guest mode. +* +* Disable Power-saving mode Exit Cause exceptions for the CPU, so +* we don't get spurious wakups before an RTAS start-cpu call. */ - lpcr &= ~(LPCR_VPM0 |LPCR_VPM1 |LPCR_ISL |LPCR_KBV ); + lpcr &= ~(LPCR_VPM0 |LPCR_VPM1 |LPCR_ISL |LPCR_KBV | pcc->lpcr_pm); lpcr |=LPCR_LPES0 |LPCR_LPES1 ;/* Set RMLS to the max (ie, 16G) */ lpcr &= ~LPCR_RMLS ; lpcr |=1ull <<LPCR_RMLS_SHIFT ; -/* Only enable Power-saving mode Exit Cause exceptions on the boot -* CPU. The RTAS command start-cpu will enable them on secondaries. -*/ -if (cs == first_cpu) { - lpcr |= pcc->lpcr_pm; - } - -/* Disable Power-saving mode Exit Cause exceptions for the CPU. -* This can cause issues when rebooting the guest if a secondary -* is awaken */ -if (cs != first_cpu) { - lpcr &= ~pcc->lpcr_pm; - } -ppc_store_lpcr (cpu, lpcr);/* Set a full AMOR so guest can use the AMR as it sees fit */
@@ -84,11 +73,14 @@ static void spapr_cpu_reset(void *opaque)void spapr_cpu_set_entry_state (PowerPCCPU *cpu,target_ulong nip,target_ulong r3) { +PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cpu);CPUPPCState *env = &cpu->env; env->nip = nip; env->gpr[3 ] = r3;CPU (cpu)->halted =0 ; +/* Enable Power-saving mode Exit Cause exceptions */ +ppc_store_lpcr (cpu, env->spr[SPR_LPCR ] | pcc->lpcr_pm); }static void spapr_cpu_destroy (PowerPCCPU *cpu)
hw/ppc/spapr_rtas.c +1 -1
@@ -162,7 +162,7 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, sPAPRMachineState *spapr, env->msr = (1ULL <<MSR_SF ) | (1ULL <<MSR_ME );/* Enable Power-saving mode Exit Cause exceptions for the new CPU */ - lpcr = env->spr[SPR_LPCR ] | pcc->lpcr_pm; + lpcr = env->spr[SPR_LPCR ];if (!pcc->interrupts_big_endian (callcpu)) { lpcr |=LPCR_ILE ; }
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 10/17] spapr: Move PAPR mode cpu setup fully to spapr code
In reply to David Gibsoncpu_ppc_set_papr() does several things:
1) it sets up the virtual hypervisor interface
2) it prevents the cpu from ever entering hypervisor mode
3) it tells KVM that we're emulating a cpu in PAPR mode
and 4) it configures the LPCR and AMOR (hypervisor privileged registers)
so that TCG will behave correctly for PAPR guests, without attempting to emulate the cpu in hypervisor mode
(1) & (2) make sense for any virtual hypervisor (if another one ever exists).
(3) belongs more properly in the machine type specific to a PAPR guest, so move it to spapr_cpu_init(). While we're at it, remove an ugly test on kvm_enabled() by making kvmppc_set_papr() a safe no-op on non-KVM.
(4) also belongs more properly in the machine type specific code. (4) is done by mangling the default values of the SPRs, so that they will be set correctly at reset time. Manipulating usually-static parameters of the cpu model like this is kind of ugly, especially since the values used really have more to do with the platform than the cpu.
The spapr code already has places for PAPR specific initializations of register state in spapr_cpu_reset(), so move this handling there.
--- hw/ppc/spapr_cpu_core.c | 36 ++++++++++++++++++++++++++++--- target/ppc/cpu.h | 2 +- target/ppc/kvm.c | 4 ++++ target/ppc/translate_init.c | 42 +------------------------------------ 4 files changed, 39 insertions(+), 45 deletions(-)
hw/ppc/spapr_cpu_core.c +33 -3
@@ -28,6 +28,7 @@ static void spapr_cpu_reset(void *opaque)CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env;PowerPCCPUClass *pcc =POWERPC_CPU_GET_CLASS (cpu); +target_ulong lpcr;cpu_reset (cs);
@@ -43,13 +44,42 @@ static void spapr_cpu_reset(void *opaque) env->spr[SPR_HIOR ] =0 ; + lpcr = env->spr[SPR_LPCR ]; + +/* Set emulated LPCR to not send interrupts to hypervisor. Note that +* under KVM, the actual HW LPCR will be set differently by KVM itself, +* the settings below ensure proper operations with TCG in absence of +* a real hypervisor. +* +* Clearing VPM0 will also cause us to use RMOR in mmu-hash64.c for +* real mode accesses, which thankfully defaults to 0 and isn't +* accessible in guest mode. +*/ + lpcr &= ~(LPCR_VPM0 |LPCR_VPM1 |LPCR_ISL |LPCR_KBV ); + lpcr |=LPCR_LPES0 |LPCR_LPES1 ; + +/* Set RMLS to the max (ie, 16G) */ + lpcr &= ~LPCR_RMLS ; + lpcr |=1ull <<LPCR_RMLS_SHIFT ; + +/* Only enable Power-saving mode Exit Cause exceptions on the boot +* CPU. The RTAS command start-cpu will enable them on secondaries. +*/ +if (cs == first_cpu) { + lpcr |= pcc->lpcr_pm; + } +/* Disable Power-saving mode Exit Cause exceptions for the CPU. * This can cause issues when rebooting the guest if a secondary * is awaken */ if (cs != first_cpu) { - env->spr[SPR_LPCR ] &= ~pcc->lpcr_pm; + lpcr &= ~pcc->lpcr_pm; } +ppc_store_lpcr (cpu, lpcr); + +/* Set a full AMOR so guest can use the AMR as it sees fit */ + env->spr[SPR_AMOR ] =0xffffffffffffffffull ; }void spapr_cpu_set_entry_state (PowerPCCPU *cpu,target_ulong nip,target_ulong r3)
@@ -74,8 +104,8 @@ static void spapr_cpu_init(sPAPRMachineState *spapr, PowerPCCPU *cpu,/* Set time-base frequency to 512 MHz */ cpu_ppc_tb_init (env,SPAPR_TIMEBASE_FREQ ); -/* Enable PAPR mode in TCG or KVM */ -cpu_ppc_set_papr (cpu,PPC_VIRTUAL_HYPERVISOR (spapr)); +cpu_ppc_set_vhyp (cpu,PPC_VIRTUAL_HYPERVISOR (spapr)); +kvmppc_set_papr (cpu);qemu_register_reset (spapr_cpu_reset, cpu);spapr_cpu_reset (cpu);
target/ppc/cpu.h +1 -1
@@ -1332,7 +1332,7 @@ void store_booke_tcr (CPUPPCState *env, target_ulong val);void store_booke_tsr (CPUPPCState *env,target_ulong val);void ppc_tlb_invalidate_all (CPUPPCState *env);void ppc_tlb_invalidate_one (CPUPPCState *env,target_ulong addr); -void cpu_ppc_set_papr (PowerPCCPU *cpu,PPCVirtualHypervisor *vhyp); +void cpu_ppc_set_vhyp (PowerPCCPU *cpu,PPCVirtualHypervisor *vhyp);#endif #endif
target/ppc/kvm.c +4 -0
@@ -2088,6 +2088,10 @@ void kvmppc_set_papr(PowerPCCPU *cpu)CPUState *cs =CPU (cpu);int ret; +if (!kvm_enabled ()) { +return ; + } + ret =kvm_vcpu_enable_cap (cs,KVM_CAP_PPC_PAPR ,0 );if (ret) {error_report ("This vCPU type or KVM version does not support PAPR" );
target/ppc/translate_init.c +1 -41
56 lines not on this page · raw message
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 12/17] uninorth: create new uninorth device
In reply to David GibsonFrom: Mark Cave-Ayland <[email protected]>
Commit 4e46dcdbd3 "PPC: Newworld: Add uninorth token register" added a TODO which was to convert the uninorth registers hack to a proper device. Move these registers to a new uninorth device, removing the old hacks from mac_newworld.c.
--- hw/pci-host/trace-events | 2 ++ hw/pci-host/uninorth.c | 58 ++++++++++++++++++++++++++++++++++ hw/ppc/mac_newworld.c | 41 ++++-------------------- hw/ppc/trace-events | 4 --- include/hw/pci-host/uninorth.h | 11 +++++++ 5 files changed, 77 insertions(+), 39 deletions(-)
hw/pci-host/trace-events +2 -0
@@ -18,3 +18,5 @@ unin_set_irq(int irq_num, int level) "setting INT %d = %d" unin_get_config_reg(uint32_t reg, uint32_t addr, uint32_t retval) "converted config space accessor 0x%"PRIx32 "/0x%"PRIx32 " -> 0x%"PRIx32 unin_data_write(uint64_t addr, unsigned len, uint64_t val) "write addr 0x%"PRIx64 " len %d val 0x%"PRIx64 unin_data_read(uint64_t addr, unsigned len, uint64_t val) "read addr 0x%"PRIx64 " len %d val 0x%"PRIx64 +unin_write(uint64_t addr, uint64_t value) "addr=0x%" PRIx64 " val=0x%"PRIx64 +unin_read(uint64_t addr, uint64_t value) "addr=0x%" PRIx64 " val=0x%"PRIx64
hw/pci-host/uninorth.c +58 -0
70 lines not on this page · raw message
hw/ppc/mac_newworld.c +6 -35
65 lines not on this page · raw message
hw/ppc/trace-events +0 -4
@@ -92,10 +92,6 @@ rs6000mc_size_read(uint32_t addr, uint32_t val) "read addr=0x%x val=0x%x" rs6000mc_size_write(uint32_t addr, uint32_t val) "write addr=0x%x val=0x%x" rs6000mc_parity_read(uint32_t addr, uint32_t val) "read addr=0x%x val=0x%x" -# hw/ppc/mac_newworld.c -mac99_uninorth_write(uint64_t addr, uint64_t value) "addr=0x%" PRIx64 " val=0x%"PRIx64 -mac99_uninorth_read(uint64_t addr, uint64_t value) "addr=0x%" PRIx64 " val=0x%"PRIx64 - # hw/ppc/ppc4xx_pci.c ppc4xx_pci_map_irq(int32_t devfn, int irq_num, int slot) "devfn 0x%x irq %d -> %d" ppc4xx_pci_set_irq(int irq_num) "PCI irq %d"
include/hw/pci-host/uninorth.h +11 -0
@@ -53,4 +53,15 @@ typedef struct UNINHostState { MemoryRegion pci_io; } UNINHostState; +typedef struct UNINState { +SysBusDevice parent_obj; + +MemoryRegion mem; +int token[1 ]; +}UNINState ; + +#define TYPE_UNI_NORTH "uni-north" +#define UNI_NORTH (obj) \ + OBJECT_CHECK(UNINState, (obj), TYPE_UNI_NORTH) +#endif /* UNINORTH_H */
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 15/17] target/ppc: always set PPC_MEM_TLBIE in pre 2.8 migration hack
In reply to David GibsonFrom: Greg Kurz <[email protected]>
The pseries-2.7 and older machine types require CPUPPCState::insns_flags to be strictly equal between source and destination. This checking is abusive and breaks migration of KVM guests when the host CPU models are different, even if they are compatible enough to allow the guest to run transparently. This buggy behaviour was fixed for pseries-2.8 and we added some hacks to allow backward migration of older machine types. These hacks assume that the CPU belongs to the POWER8 family, which was true for most KVM based setup we cared about at the time. But now POWER9 systems are coming, and backward migration of pre 2.8 guests running in POWER8 architected mode from a POWER9 host to a POWER8 host is broken:
qemu-system-ppc64: error while loading state for instance 0x0 of device
'cpu'
qemu-system-ppc64: load of migration failed: Invalid argument
This happens because POWER9 doesn't set PPC_MEM_TLBIE in insns_flags, while POWER8 does. Let's force PPC_MEM_TLBIE in the migration hack to fix the issue. This is an acceptable hack because these old machine types only support CPU models that do set PPC_MEM_TLBIE.
--- target/ppc/machine.c | 5 +++++ 1 file changed, 5 insertions(+)
target/ppc/machine.c +5 -0
@@ -212,6 +212,11 @@ static int cpu_pre_save(void *opaque) ; cpu->mig_msr_mask = env->msr_mask & ~metamask; cpu->mig_insns_flags = env->insns_flags & insns_compat_mask; +/* CPU models supported by old machines all have PPC_MEM_TLBIE, +* so we set it unconditionally to allow backward migration from +* a POWER9 host to a POWER8 host. +*/ + cpu->mig_insns_flags |=PPC_MEM_TLBIE ; cpu->mig_insns_flags2 = env->insns_flags2 & insns_compat_mask2; cpu->mig_nb_BATs = env->nb_BATs; }
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 13/17] mac_newworld: remove pics IRQ array and wire up macio to OpenPIC directly
In reply to David GibsonFrom: Mark Cave-Ayland <[email protected]>
Introduce constants for the pre-defined New World IRQs to help keep things readable.
--- hw/ppc/mac.h | 9 +++++++++ hw/ppc/mac_newworld.c | 29 +++++++++++++++-------------- 2 files changed, 24 insertions(+), 14 deletions(-)
hw/ppc/mac.h +9 -0
@@ -56,6 +56,15 @@#define OLDWORLD_IDE1_IRQ 0xe#define OLDWORLD_IDE1_DMA_IRQ 0x3 +/* New World IRQs */ +#define NEWWORLD_CUDA_IRQ 0x19 +#define NEWWORLD_ESCCB_IRQ 0x24 +#define NEWWORLD_ESCCA_IRQ 0x25 +#define NEWWORLD_IDE0_IRQ 0xd +#define NEWWORLD_IDE0_DMA_IRQ 0x2 +#define NEWWORLD_IDE1_IRQ 0xe +#define NEWWORLD_IDE1_DMA_IRQ 0x3 +/* MacIO */ #define TYPE_MACIO_IDE "macio-ide"#define MACIO_IDE (obj) OBJECT_CHECK(MACIOIDEState, (obj), TYPE_MACIO_IDE)
hw/ppc/mac_newworld.c +15 -14
@@ -114,7 +114,7 @@ static void ppc_core99_init(MachineState *machine)PowerPCCPU *cpu =NULL ;CPUPPCState *env =NULL ;char *filename; -qemu_irq *pic, **openpic_irqs; +qemu_irq **openpic_irqs;int linux_boot, i, j, k;MemoryRegion *ram =g_new (MemoryRegion,1 ), *bios =g_new (MemoryRegion,1 );hwaddr kernel_base, initrd_base, cmdline_base =0 ;
@@ -291,8 +291,6 @@ static void ppc_core99_init(MachineState *machine) } } - pic =g_new0 (qemu_irq,64 ); - pic_dev =qdev_create (NULL ,TYPE_OPENPIC );qdev_prop_set_uint32 (pic_dev,"model" ,OPENPIC_MODEL_KEYLARGO );qdev_init_nofail (pic_dev);
@@ -304,10 +302,6 @@ static void ppc_core99_init(MachineState *machine) } } -for (i =0 ; i <64 ; i++) { - pic[i] =qdev_get_gpio_in (pic_dev, i); - } -if (PPC_INPUT (env) ==PPC_FLAGS_INPUT_970 ) {/* 970 gets a U3 bus */ /* Uninorth AGP bus */
@@ -381,13 +375,20 @@ static void ppc_core99_init(MachineState *machine)/* MacIO */ macio =NEWWORLD_MACIO (pci_create (pci_bus,-1 ,TYPE_NEWWORLD_MACIO )); dev =DEVICE (macio); -qdev_connect_gpio_out (dev,0 , pic[0x19 ]);/* CUDA */ -qdev_connect_gpio_out (dev,1 , pic[0x24 ]);/* ESCC-B */ -qdev_connect_gpio_out (dev,2 , pic[0x25 ]);/* ESCC-A */ -qdev_connect_gpio_out (dev,3 , pic[0x0d ]);/* IDE */ -qdev_connect_gpio_out (dev,4 , pic[0x02 ]);/* IDE DMA */ -qdev_connect_gpio_out (dev,5 , pic[0x0e ]);/* IDE */ -qdev_connect_gpio_out (dev,6 , pic[0x03 ]);/* IDE DMA */ +qdev_connect_gpio_out (dev,0 , +qdev_get_gpio_in (pic_dev,NEWWORLD_CUDA_IRQ )); +qdev_connect_gpio_out (dev,1 , +qdev_get_gpio_in (pic_dev,NEWWORLD_ESCCB_IRQ )); +qdev_connect_gpio_out (dev,2 , +qdev_get_gpio_in (pic_dev,NEWWORLD_ESCCA_IRQ )); +qdev_connect_gpio_out (dev,3 , +qdev_get_gpio_in (pic_dev,NEWWORLD_IDE0_IRQ )); +qdev_connect_gpio_out (dev,4 , +qdev_get_gpio_in (pic_dev,NEWWORLD_IDE0_DMA_IRQ )); +qdev_connect_gpio_out (dev,5 , +qdev_get_gpio_in (pic_dev,NEWWORLD_IDE1_IRQ )); +qdev_connect_gpio_out (dev,6 , +qdev_get_gpio_in (pic_dev,NEWWORLD_IDE1_DMA_IRQ ));qdev_prop_set_uint64 (dev,"frequency" , tbfreq);object_property_set_link (OBJECT (macio),OBJECT (pic_dev),"pic" , &error_abort);
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 16/17] spapr: don't migrate "spapr_option_vector_ov5_cas" to pre 2.8 machines
In reply to David GibsonFrom: Greg Kurz <[email protected]>
a324d6f16697 "spapr: Support ibm,dynamic-memory-v2 property" added a new feature in the set of CAS-negotiatable options. This causes the CAS-negotiated options subsection to be migrated, even for old machine types that don't know about it, and breaks backward migration to QEMU 2.7 and older versions:
qemu-system-ppc64: error while loading state for instance 0x0 of device
'spapr'
qemu-system-ppc64: load of migration failed: No such file or directory
Since this feature only affects boot time behaviour, it should be filtered out when we decide to migrate CAS-negotiated options, like we already do with OV5_FORM1_AFFINITY and OV5_DRCONF_MEMORY.
--- hw/ppc/spapr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +3 -1
@@ -1849,10 +1849,12 @@ static bool spapr_ov5_cas_needed(void *opaque)* * Thus, for any cases where the set of available CAS-negotiatable * options extends beyond OV5_FORM1_AFFINITY and OV5_DRCONF_MEMORY, we -* include the CAS-negotiated options in the migration stream. +* include the CAS-negotiated options in the migration stream, unless +* if they affect boot time behaviour only. */ spapr_ovec_set (ov5_mask,OV5_FORM1_AFFINITY );spapr_ovec_set (ov5_mask,OV5_DRCONF_MEMORY ); +spapr_ovec_set (ov5_mask,OV5_DRMEM_V2 );/* spapr_ovec_diff returns true if bits were removed. we avoid using * the mask itself since in the future it's possible "legacy" bits may be
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 17/17] spapr: don't advertise radix GTSE if max-compat-cpu < power9
In reply to David GibsonFrom: Greg Kurz <[email protected]>
On a POWER9 host, if a guest runs in pre POWER9 compat mode, it necessarily uses the hash MMU mode. In this case, we shouldn't advertise radix GTSE in the ibm,arch-vec-5-platform-support DT property as the current code does. The first reason is that it doesn't make sense, and the second one is that causes the CAS-negotiated options subsection to be migrated. This breaks backward migration to QEMU 2.7 and older versions on POWER8 hosts:
qemu-system-ppc64: error while loading state for instance 0x0 of device
'spapr'
qemu-system-ppc64: load of migration failed: No such file or directory
This patch hence initialize CPUs a bit earlier so that we can check the requested compat mode, and don't set OV5_MMU_RADIX_GTSE for power8 and older.
--- hw/ppc/spapr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
hw/ppc/spapr.c +10 -5
@@ -2512,6 +2512,7 @@ static void spapr_machine_init(MachineState *machine)long load_limit, fw_size;char *filename;Error *resize_hpt_err =NULL ; +PowerPCCPU *first_ppc_cpu; msi_nonbroken = true;
@@ -2592,11 +2593,6 @@ static void spapr_machine_init(MachineState *machine) }spapr_ovec_set (spapr->ov5,OV5_FORM1_AFFINITY ); -if (!kvm_enabled () ||kvmppc_has_cap_mmu_radix ()) { -/* KVM and TCG always allow GTSE with radix... */ -spapr_ovec_set (spapr->ov5,OV5_MMU_RADIX_GTSE ); - } -/* ... but not with hash (currently). */ /* advertise support for dedicated HP event source to guests */ if (spapr->use_hotplug_event_source) {
@@ -2614,6 +2610,15 @@ static void spapr_machine_init(MachineState *machine)/* init CPUs */ spapr_init_cpus (spapr); + first_ppc_cpu =POWERPC_CPU (first_cpu); +if ((!kvm_enabled () ||kvmppc_has_cap_mmu_radix ()) && +ppc_check_compat (first_ppc_cpu,CPU_POWERPC_LOGICAL_3_00 ,0 , + spapr->max_compat_pvr)) { +/* KVM and TCG always allow GTSE with radix... */ +spapr_ovec_set (spapr->ov5,OV5_MMU_RADIX_GTSE ); + } +/* ... but not with hash (currently). */ +if (kvm_enabled ()) {/* Enable H_LOGICAL_CI_* so SLOF can talk to in-kernel devices */ kvmppc_enable_logical_ci_hcalls ();
Signature · 1 line
2.17.0
[Qemu-devel] [PULL 14/17] mac_newworld: move wiring of macio IRQs to macio_newworld_realize()
In reply to David GibsonFrom: Mark Cave-Ayland <[email protected]>
Since the macio device has a link to the PIC device, we can now wire up the IRQs directly via qdev GPIOs rather than having to use an intermediate array.
--- hw/misc/macio/macio.c | 39 +++++++++++++++++++++-------------- hw/ppc/mac_newworld.c | 14 ------------- include/hw/misc/macio/macio.h | 1 - 3 files changed, 23 insertions(+), 31 deletions(-)
hw/misc/macio/macio.c +23 -16
@@ -279,11 +279,10 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp) {MacIOState *s =MACIO (d);NewWorldMacIOState *ns =NEWWORLD_MACIO (d); +DeviceState *pic_dev =DEVICE (ns->pic);Error *err =NULL ;SysBusDevice *sysbus_dev;MemoryRegion *timer_memory =NULL ; -int i; -int cur_irq =0 ;macio_common_realize (d, &err);if (err) {
@@ -292,11 +291,14 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp) } sysbus_dev =SYS_BUS_DEVICE (&s->cuda); -sysbus_connect_irq (sysbus_dev,0 , ns->irqs[cur_irq++]); +sysbus_connect_irq (sysbus_dev,0 ,qdev_get_gpio_in (pic_dev, +NEWWORLD_CUDA_IRQ )); sysbus_dev =SYS_BUS_DEVICE (&s->escc); -sysbus_connect_irq (sysbus_dev,0 , ns->irqs[cur_irq++]); -sysbus_connect_irq (sysbus_dev,1 , ns->irqs[cur_irq++]); +sysbus_connect_irq (sysbus_dev,0 ,qdev_get_gpio_in (pic_dev, +NEWWORLD_ESCCB_IRQ )); +sysbus_connect_irq (sysbus_dev,1 ,qdev_get_gpio_in (pic_dev, +NEWWORLD_ESCCA_IRQ ));/* OpenPIC */ sysbus_dev =SYS_BUS_DEVICE (ns->pic);
@@ -304,15 +306,22 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp) sysbus_mmio_get_region(sysbus_dev, 0));/* IDE buses */ -for (i =0 ; i <ARRAY_SIZE (ns->ide); i++) { -qemu_irq irq0 = ns->irqs[cur_irq++]; -qemu_irq irq1 = ns->irqs[cur_irq++]; - -macio_realize_ide (s, &ns->ide[i], irq0, irq1,0x16 + (i *4 ), &err); -if (err) { -error_propagate (errp, err); -return ; - } +macio_realize_ide (s, &ns->ide[0 ], +qdev_get_gpio_in (pic_dev,NEWWORLD_IDE0_IRQ ), +qdev_get_gpio_in (pic_dev,NEWWORLD_IDE0_DMA_IRQ ), +0x16 , &err); +if (err) { +error_propagate (errp, err); +return ; + } + +macio_realize_ide (s, &ns->ide[1 ], +qdev_get_gpio_in (pic_dev,NEWWORLD_IDE1_IRQ ), +qdev_get_gpio_in (pic_dev,NEWWORLD_IDE1_DMA_IRQ ), +0x1a , &err); +if (err) { +error_propagate (errp, err); +return ; }/* Timer */
@@ -328,8 +337,6 @@ static void macio_newworld_init(Object *obj)NewWorldMacIOState *ns =NEWWORLD_MACIO (obj);int i; -qdev_init_gpio_out (DEVICE (obj), ns->irqs,ARRAY_SIZE (ns->irqs)); - object_property_add_link(obj, "pic", TYPE_OPENPIC, (Object **) &ns->pic, qdev_prop_allow_set_link_before_realize,
hw/ppc/mac_newworld.c +0 -14
@@ -375,20 +375,6 @@ static void ppc_core99_init(MachineState *machine)/* MacIO */ macio =NEWWORLD_MACIO (pci_create (pci_bus,-1 ,TYPE_NEWWORLD_MACIO )); dev =DEVICE (macio); -qdev_connect_gpio_out (dev,0 , -qdev_get_gpio_in (pic_dev,NEWWORLD_CUDA_IRQ )); -qdev_connect_gpio_out (dev,1 , -qdev_get_gpio_in (pic_dev,NEWWORLD_ESCCB_IRQ )); -qdev_connect_gpio_out (dev,2 , -qdev_get_gpio_in (pic_dev,NEWWORLD_ESCCA_IRQ )); -qdev_connect_gpio_out (dev,3 , -qdev_get_gpio_in (pic_dev,NEWWORLD_IDE0_IRQ )); -qdev_connect_gpio_out (dev,4 , -qdev_get_gpio_in (pic_dev,NEWWORLD_IDE0_DMA_IRQ )); -qdev_connect_gpio_out (dev,5 , -qdev_get_gpio_in (pic_dev,NEWWORLD_IDE1_IRQ )); -qdev_connect_gpio_out (dev,6 , -qdev_get_gpio_in (pic_dev,NEWWORLD_IDE1_DMA_IRQ ));qdev_prop_set_uint64 (dev,"frequency" , tbfreq);object_property_set_link (OBJECT (macio),OBJECT (pic_dev),"pic" , &error_abort);
include/hw/misc/macio/macio.h +0 -1
@@ -71,7 +71,6 @@ typedef struct NewWorldMacIOState {/*< public >*/ OpenPICState *pic; -qemu_irq irqs[7 ];MACIOIDEState ide[2 ]; } NewWorldMacIOState;
Signature · 1 line
2.17.0
Peter Maydell
AppliedQuoted 15 lines · David Gibson
The following changes since commit
59255887e6cafeff747250d2613003a41d1d9dff:Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180502' into staging (2018-05-03 11:25:14 +0100)
are available in the Git repository at:
git://github.com/dgibson/qemu.gittags/ppc-for-2.13-20180504for you to fetch changes up to
0550b1206a91d66051a21441a02c4ff126b531fe:spapr: don't advertise radix GTSE if max-compat-cpu < power9 (2018-05-04 15:00:37 +1000)
----------------------------------------------------------------
ppc patch queue 2018-05-04
Quoted 8 lines
Second patch of patches for qemu-2.13 (or whatever the version ends up being called). Highlights are:
* Preliminary patches for POWER9 hash MMU support for powernv
* A number of cleanups fo pseries startup and LPCR handling
* Remove support for explicitly allocated RMAs (which require kernel support that's been gone for 3+ years)
* Somemac_newworldcleanups
* A few bugfixes
Applied, thanks.
-- PMM