ppc: complete the new HV mode
cover ppc: complete the new HV mode
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fix hreg_store_msr() so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV mode
Cédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilege
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/3 ppc: Fix hreg_store_msr() so that non-HV mode cannot alter MSR:HV
From: Benjamin Herrenschmidt <[email protected]>
This helper is only used by the various instructions that can alter MSR and not interrupts. Add a comment to that effect to the interrupt code as well in case somebody wants to change this
--- target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-)
target-ppc/excp_helper.c +6 -2
@@ -709,8 +709,12 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp) } }#endif -/* XXX: we don't use hreg_store_msr here as already have treated -* any special case that could occur. Just store MSR and update hflags +/* We don't use hreg_store_msr here as already have treated +* any special case that could occur. Just store MSR and update hflags +* +* Note: We *MUST* not use hreg_store_msr() as-is anyway because it +* will prevent setting of the HV bit which some exceptions might need +* to do. */ env->msr = new_msr & env->msr_mask;hreg_compute_hflags (env);
target-ppc/helper_regs.h +2 -2
@@ -114,8 +114,8 @@ static inline int hreg_store_msr(CPUPPCState *env, target_ulong value, excp =0 ; value &= env->msr_mask;#if !defined(CONFIG_USER_ONLY ) -if (!alter_hv) { -/* mtmsr cannot alter the hypervisor state */ +/* Neither mtmsr nor guest state can alter HV */ +if (!alter_hv || !(env->msr &MSR_HVB )) { value &= ~MSR_HVB ; value |= env->msr &MSR_HVB ; }
Signature · 1 line
2.1.4
PATCH 2/3 ppc: Better figure out if processor has HV mode
In reply to Cédric Le GoaterFrom: Benjamin Herrenschmidt <[email protected]>
We use an env. flag which is set to the initial value of MSR_HVB in the msr_mask. We also adjust the POWER8 mask to set SHV.
Also use this to adjust ctx.hv so that it is *set* when the processor doesn't have an HV mode (970 with Apple mode for example), thus enabling hypervisor instructions/SPRs.
[clg: ctx.hv used to be defined only for the hypervisor kernel
(HV=1|PR=0). It is now defined also when PR=1 and conditions are fixed accordingly.
stripped unwanted tabs.]
--- target-ppc/cpu.h | 4 ++++ target-ppc/translate.c | 4 +++- target-ppc/translate_init.c | 19 +++++++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-)
target-ppc/cpu.h +4 -0
@@ -1050,6 +1050,10 @@ struct CPUPPCState {hwaddr mpic_iack;/* true when the external proxy facility mode is enabled */ bool mpic_proxy; +/* set when the processor has an HV mode, thus HV priv +* instructions and SPRs are diallowed if MSR:HV is 0 +*/ +bool has_hv_mode;#endif /* Those resources are used only during code translation */
target-ppc/translate.c +3 -1
@@ -11478,8 +11478,10 @@ void gen_intermediate_code(CPUPPCState *env, struct TranslationBlock *tb) ctx.exception =POWERPC_EXCP_NONE ; ctx.spr_cb = env->spr_cb; ctx.pr = msr_pr; - ctx.hv = !msr_pr && msr_hv; ctx.mem_idx = env->dmmu_idx; +#if !defined(CONFIG_USER_ONLY ) + ctx.hv = msr_hv || !env->has_hv_mode; +#endif ctx.insns_flags = env->insns_flags; ctx.insns_flags2 = env->insns_flags2; ctx.access_type =-1 ;
target-ppc/translate_init.c +15 -4
@@ -8450,6 +8450,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)PPC2_ISA205 |PPC2_ISA207S |PPC2_FP_CVT_S64 |PPC2_TM ; pcc->msr_mask = (1ull <<MSR_SF ) | + (1ull <<MSR_SHV ) | (1ull <<MSR_TM ) | (1ull <<MSR_VR ) | (1ull << MSR_VSX) |
@@ -9854,10 +9855,7 @@ static void ppc_cpu_reset(CPUState *s) pcc->parent_reset (s); msr = (target_ulong )0 ; -if (0 ) { -/* XXX: find a suitable condition to enable the hypervisor mode */ - msr |= (target_ulong )MSR_HVB ; - } + msr |= (target_ulong )MSR_HVB ; msr |= (target_ulong )0 <<MSR_AP ;/* TO BE CHECKED */ msr |= (target_ulong )0 <<MSR_SA ;/* TO BE CHECKED */ msr |= (target_ulong )1 <<MSR_EP ;
@@ -9958,6 +9956,19 @@ static void ppc_cpu_initfn(Object *obj) env->bfd_mach = pcc->bfd_mach; env->check_pow = pcc->check_pow; +/* Mark HV mode as supported if the CPU has an MSR_HV bit +* in the msr_mask. The mask can later be cleared by PAPR +* mode but the hv mode support will remain, thus enforcing +* that we cannot use priv. instructions in guest in PAPR +* mode. For 970 we currently simply don't set HV in msr_mask +* thus simulating an "Apple mode" 970. If we ever want to +* support 970 HV mode, we'll have to add a processor attribute +* of some sort. +*/ +#if !defined(CONFIG_USER_ONLY ) + env->has_hv_mode = !!(env->msr_mask &MSR_HVB ); +#endif +#if defined(TARGET_PPC64 )if (pcc->sps) { env->sps = *pcc->sps;
Signature · 1 line
2.1.4
PATCH 3/3 ppc: fix hrfid, tlbia and slbia privilege
In reply to Cédric Le Goatercommit 74693da98894 ('ppc: tlbie, tlbia and tlbisync are HV only') introduced some extra checks on the instruction privilege. slbia was changed wrongly and hrfid, tlbia were forgotten.
--- target-ppc/translate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target-ppc/translate.c +3 -3
@@ -4108,7 +4108,7 @@ static void gen_hrfid(DisasContext *ctx)gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );#else /* Restore CPU state */ -if (unlikely (!ctx->hv)) { +if (unlikely (ctx->pr || !ctx->hv)) {gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );return ; }
@@ -4845,7 +4845,7 @@ static void gen_tlbia(DisasContext *ctx)#if defined(CONFIG_USER_ONLY )gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );#else -if (unlikely (ctx->pr)) { +if (unlikely (ctx->pr || !ctx->hv)) {gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );return ; }
@@ -4913,7 +4913,7 @@ static void gen_slbia(DisasContext *ctx)#if defined(CONFIG_USER_ONLY )gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );#else -if (unlikely (ctx->pr || !ctx->hv)) { +if (unlikely (ctx->pr)) {gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );return ; }
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH 3/3] ppc: fix hrfid, tlbia and slbia privilege
Quoted 32 lines · Cédric Le Goater
commit
74693da98894('ppc: tlbie, tlbia and tlbisync are HV only') introduced some extra checks on the instruction privilege. slbia was changed wrongly and hrfid, tlbia were forgotten.Signed-off-by Cédric Le Goater <[email protected]>--- target-ppc/translate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)target-ppc/translate.c +2
-2@@ -4108,7 +4108,7 @@ static void gen_hrfid(DisasContext *ctx)gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );#else /* Restore CPU state */ -if (unlikely (!ctx->hv)) { +if (unlikely (ctx->pr || !ctx->hv)) {gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );return ; }@@ -4845,7 +4845,7 @@ static void gen_tlbia(DisasContext *ctx)#if defined(CONFIG_USER_ONLY )gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );#else -if (unlikely (ctx->pr)) { +if (unlikely (ctx->pr || !ctx->hv)) {gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );return ; }
target-ppc/translate.c static void gen_slbia(DisasContext *ctx) · line 4919
Quoted 8 lines
target-ppc/translate.c +1
-1@@ -4913,7 +4913,7 @@ static void gen_slbia(DisasContext *ctx)#if defined(CONFIG_USER_ONLY )gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );#else -if (unlikely (ctx->pr || !ctx->hv)) { +if (unlikely (ctx->pr)) {gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );return ; }
I just double-checked the PowerISA 2.07, and you're right, hrfid and tlbia are hypervisor-privileged, slbia is only "normal" privileged.
Re: [Qemu-devel] [PATCH 3/3] ppc: fix hrfid, tlbia and slbia privilege
Quoted 45 lines · Thomas Huth
Quoted 32 lines · Cédric Le Goater
commit
74693da98894('ppc: tlbie, tlbia and tlbisync are HV only') introduced some extra checks on the instruction privilege. slbia was changed wrongly and hrfid, tlbia were forgotten.Signed-off-by Cédric Le Goater <[email protected]>--- target-ppc/translate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)target-ppc/translate.c +2
-2@@ -4108,7 +4108,7 @@ static void gen_hrfid(DisasContext *ctx)gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );#else /* Restore CPU state */ -if (unlikely (!ctx->hv)) { +if (unlikely (ctx->pr || !ctx->hv)) {gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );return ; }@@ -4845,7 +4845,7 @@ static void gen_tlbia(DisasContext *ctx)#if defined(CONFIG_USER_ONLY )gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );#else -if (unlikely (ctx->pr)) { +if (unlikely (ctx->pr || !ctx->hv)) {gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );return ; }target-ppc/translate.c static void gen_slbia(DisasContext *ctx) · line 4919
Quoted 8 lines
target-ppc/translate.c +1
-1@@ -4913,7 +4913,7 @@ static void gen_slbia(DisasContext *ctx)#if defined(CONFIG_USER_ONLY )gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );#else -if (unlikely (ctx->pr || !ctx->hv)) { +if (unlikely (ctx->pr)) {gen_inval_exception (ctx,POWERPC_EXCP_PRIV_OPC );return ; }I just double-checked the PowerISA 2.07, and you're right, hrfid and tlbia are hypervisor-privileged, slbia is only "normal" privileged.
Quoted 1 line
Reviewed-by Thomas Huth <[email protected]>
Yes, the SLB is owned by the guest - otherwise it would need hypercalls on every context switch. Should have caught this the first time around, sorry.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 12 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilege
Quoted 6 lines
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)
Hi Cédric,
I can confirm that this patchset fixes starting up OpenBIOS for both g3beige/mac99 in my tests here. With the escc fix also applied, the only outstanding issue is the removal of the tlb_flush() statements which causes Darwin, MacOS X and HelenOS 0.60 to panic on boot
My only request is if it would be possible to move patch 2 "ppc: Better figure out if processor has HV mode" to the front of this patchset which will make the remaining patches bisectable for the Mac machines. With that:
Does anyone know if Ben has any ideas as to why the MMU tlb_flush changes patch is causing such problems?
ATB,
Mark.
Hello Mark,
Quoted 21 lines · Mark Cave-Ayland
Quoted 12 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilegeQuoted 6 lines
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)
Quoted 6 lines
Hi Cédric,
I can confirm that this patchset fixes starting up OpenBIOS for both g3beige/mac99 in my tests here. With the escc fix also applied, the only outstanding issue is the removal of the
tlb_flush()statements which causes Darwin, MacOS X and HelenOS 0.60 to panic on boot
Is that just booting the CDROM or the complete OS ? because I tried that a couple of time with ppc-for-2.7-20160531 + the three patches above and did not see the issue again. I reached the device selection prompt.
I must be doing something wrong.
Quoted 5 lines
My only request is if it would be possible to move patch 2 "ppc: Better figure out if processor has HV mode" to the front of this patchset which will make the remaining patches bisectable for the Mac machines. With that:
Tested-by Mark Cave-Ayland <[email protected]>
Thanks,
C.
Quoted 8 lines
Does anyone know if Ben has any ideas as to why the MMU
tlb_flushchanges patch is causing such problems?ATB,
Mark.
Quoted 31 lines · Cédric Le Goater
Hello Mark,
Quoted 21 lines · Mark Cave-Ayland
Quoted 12 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilegeQuoted 6 lines
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)Quoted 6 lines
Hi Cédric,
I can confirm that this patchset fixes starting up OpenBIOS for both g3beige/mac99 in my tests here. With the escc fix also applied, the only outstanding issue is the removal of the
tlb_flush()statements which causes Darwin, MacOS X and HelenOS 0.60 to panic on boot
Quoted 5 lines
Is that just booting the CDROM or the complete OS ? because I tried that a couple of time with ppc-for-2.7-20160531 + the three patches above and did not see the issue again. I reached the device selection prompt.
I must be doing something wrong.
I was using '-cpu 750' for some reason and this is why it succeeded. It fails without. We are getting close.
C.
Quoted 19 lines
Quoted 5 lines
My only request is if it would be possible to move patch 2 "ppc: Better figure out if processor has HV mode" to the front of this patchset which will make the remaining patches bisectable for the Mac machines. With that:
Tested-by Mark Cave-Ayland <[email protected]>Thanks,
C.
Quoted 8 lines
Does anyone know if Ben has any ideas as to why the MMU
tlb_flushchanges patch is causing such problems?ATB,
Mark.
Quoted 32 lines · Cedric Le Goater
Quoted 31 lines · Cédric Le Goater
Hello Mark,
Quoted 27 lines · Mark Cave-Ayland
Quoted 12 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilegeQuoted 6 lines
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)Hi Cédric,
I can confirm that this patchset fixes starting up OpenBIOS for both g3beige/mac99 in my tests here. With the escc fix also applied, the only outstanding issue is the removal of the
tlb_flush()statements which causes Darwin, MacOS X and HelenOS 0.60 to panic on boot
Quoted 8 lines
Quoted 5 lines
Is that just booting the CDROM or the complete OS ? because I tried that a couple of time with ppc-for-2.7-20160531 + the three patches above and did not see the issue again. I reached the device selection prompt.
I must be doing something wrong.
I was using '-cpu 750' for some reason and this is why it succeeded. It fails without. We are getting close.
Hmmm that works for -M g3beige Darwin, but not HelenOS here. Although interestingly -M g3beige -m 256 seems to "fix" Darwin here too (presumably because the memory allocation routines can just allocate new RAM rather than reusing existing RAM which may be cached in the TLB).
What a strange coincidence that I've just posted a patch that fixes up the debugging in target-ppc/mmu_helper.c ;)
ATB,
Mark.
Quoted 43 lines · Mark Cave-Ayland
Quoted 32 lines · Cedric Le Goater
Quoted 31 lines · Cédric Le Goater
Hello Mark,
Quoted 27 lines · Mark Cave-Ayland
Quoted 12 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilegeQuoted 6 lines
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)Hi Cédric,
I can confirm that this patchset fixes starting up OpenBIOS for both g3beige/mac99 in my tests here. With the escc fix also applied, the only outstanding issue is the removal of the
tlb_flush()statements which causes Darwin, MacOS X and HelenOS 0.60 to panic on bootQuoted 8 lines
Quoted 5 lines
Is that just booting the CDROM or the complete OS ? because I tried that a couple of time with ppc-for-2.7-20160531 + the three patches above and did not see the issue again. I reached the device selection prompt.
I must be doing something wrong.
I was using '-cpu 750' for some reason and this is why it succeeded. It fails without. We are getting close.
Quoted 7 lines
Hmmm that works for -M g3beige Darwin, but not HelenOS here. Although interestingly -M g3beige -m 256 seems to "fix" Darwin here too (presumably because the memory allocation routines can just allocate new RAM rather than reusing existing RAM which may be cached in the TLB).
What a strange coincidence that I've just posted a patch that fixes up the debugging in
target-ppc/mmu_helper.c;)
It also looks like you need my beta patch to convert the macio controller over to using the DMA helpers here:
https://lists.nongnu.org/archive/html/qemu-devel/2016-05/msg04907.html.
At least that seems to progress things a little further on one of my MacOS tests.
Looking at the DBDMA code I still see a few calls to cpu_physical_memory_read() / cpu_physical_memory_write() scattered around. Do these need to be switched over to dma_memory_read() / dma_memory_write() in order to correctly invalidate the TLB upon write?
ATB,
Mark.
Quoted 59 lines · Mark Cave-Ayland
Quoted 43 lines · Mark Cave-Ayland
Quoted 32 lines · Cedric Le Goater
Quoted 31 lines · Cédric Le Goater
Hello Mark,
Quoted 27 lines · Mark Cave-Ayland
Quoted 12 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilegeQuoted 6 lines
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)Hi Cédric,
I can confirm that this patchset fixes starting up OpenBIOS for both g3beige/mac99 in my tests here. With the escc fix also applied, the only outstanding issue is the removal of the
tlb_flush()statements which causes Darwin, MacOS X and HelenOS 0.60 to panic on bootQuoted 8 lines
Quoted 5 lines
Is that just booting the CDROM or the complete OS ? because I tried that a couple of time with ppc-for-2.7-20160531 + the three patches above and did not see the issue again. I reached the device selection prompt.
I must be doing something wrong.
I was using '-cpu 750' for some reason and this is why it succeeded. It fails without. We are getting close.
Quoted 7 lines
Hmmm that works for -M g3beige Darwin, but not HelenOS here. Although interestingly -M g3beige -m 256 seems to "fix" Darwin here too (presumably because the memory allocation routines can just allocate new RAM rather than reusing existing RAM which may be cached in the TLB).
What a strange coincidence that I've just posted a patch that fixes up the debugging in
target-ppc/mmu_helper.c;)It also looks like you need my beta patch to convert the macio controller over to using the DMA helpers here:
https://lists.nongnu.org/archive/html/qemu-devel/2016-05/msg04907.html.
At least that seems to progress things a little further on one of my MacOS tests.
Quoted 4 lines
Looking at the DBDMA code I still see a few calls to
cpu_physical_memory_read()/cpu_physical_memory_write()scattered around. Do these need to be switched over todma_memory_read()/dma_memory_write()in order to correctly invalidate the TLB upon write?
I haven't had time to check your patches yet. I will give them a try in a couple of days.
Thanks,
C.
Quoted 31 lines · Cédric Le Goater
Hello Mark,
Quoted 21 lines · Mark Cave-Ayland
Quoted 12 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilegeQuoted 6 lines
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)Quoted 6 lines
Hi Cédric,
I can confirm that this patchset fixes starting up OpenBIOS for both g3beige/mac99 in my tests here. With the escc fix also applied, the only outstanding issue is the removal of the
tlb_flush()statements which causes Darwin, MacOS X and HelenOS 0.60 to panic on boot
Quoted 5 lines
Is that just booting the CDROM or the complete OS ? because I tried that a couple of time with ppc-for-2.7-20160531 + the three patches above and did not see the issue again. I reached the device selection prompt.
I must be doing something wrong.
Hmmm not necessarily. It seems that the Darwin crash only manifests itself on -M g3beige (the default) rather than -M mac99, although I can confirm that HelenOS crashes on both -M g3beige and -M mac99:
./qemu-system-ppc -cdrom HelenOS-0.6.0-ppc32.iso -boot d -bios -m 256 -M mac99
Quoted 9 lines
Quoted 5 lines
My only request is if it would be possible to move patch 2 "ppc: Better figure out if processor has HV mode" to the front of this patchset which will make the remaining patches bisectable for the Mac machines. With that:
Tested-by Mark Cave-Ayland <[email protected]>Thanks,
C.
ATB,
Mark.
Hello Mark,
Quoted 28 lines · Mark Cave-Ayland
Quoted 12 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilegeQuoted 6 lines
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)Hi Cédric,
I can confirm that this patchset fixes starting up OpenBIOS for both g3beige/mac99 in my tests here. With the escc fix also applied, the only outstanding issue is the removal of the
tlb_flush()statements which causes Darwin, MacOS X and HelenOS 0.60 to panic on boot
Quoted 8 lines
My only request is if it would be possible to move patch 2 "ppc: Better figure out if processor has HV mode" to the front of this patchset which will make the remaining patches bisectable for the Mac machines. With that:
Tested-by Mark Cave-Ayland <[email protected]>Does anyone know if Ben has any ideas as to why the MMU
tlb_flushchanges patch is causing such problems?
Here is a fix I think. Could you give it a try ?
Cheers,
C.
From: Cédric Le Goater <[email protected]>
Subject: [PATCH] ppc: fix tlb flushes for 32bit environment
Date: Sun, 05 Jun 2016 18:46:19 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
commit cd0c6f473532 ('ppc: Do some batching of TCG tlb flushes') introduced an optimisation to flush TLBs only when a context synchronizing event is reached (interrupt, rfi). This was done for ppc64 but 32bit was forgotten on the way.
Tested on mac99 and g3beige with
qemu-system-ppc -cdrom darwinppc-602.cdr -boot d
---
I think the hunk in powerpc_excp() is needed if we don't generate a context synchronizing event. what is best to do ?
target-ppc/cpu.h | 2 +- target-ppc/excp_helper.c | 10 ++++++++++ target-ppc/helper_regs.h | 9 ++++++++- target-ppc/translate.c | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-)
target-ppc/translate.c +1 -1
@@ -3290,7 +3290,7 @@ static void gen_eieio(DisasContext *ctx) { } -#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void gen_check_tlb_flush (DisasContext *ctx) {TCGv_i32 t =tcg_temp_new_i32 ();
target-ppc/cpu.h +1 -1
@@ -958,9 +958,9 @@ struct CPUPPCState {/* PowerPC 64 SLB area */ ppc_slb_t slb[MAX_SLB_ENTRIES ];int32_t slb_nr; +#endif /* tcg TLB needs flush (deferred slb inval instruction typically) */ uint32_t tlb_need_flush; -#endif /* segment registers */ hwaddr htab_base;/* mask used to normalize hash value to PTEG index */
target-ppc/helper_regs.h +8 -1
@@ -121,6 +121,13 @@ static inline int hreg_store_msr(CPUPPCS }if (((value >>MSR_IR ) &1 ) != msr_ir || ((value >>MSR_DR ) &1 ) != msr_dr) { +/* A change of the instruction relocation bit in the MSR can +* cause an implicit branch in the address space. This +* requires a tlb flush. +*/ +if (env->mmu_model &POWERPC_MMU_32B ) { + env->tlb_need_flush =1 ; + } cs->interrupt_request |=CPU_INTERRUPT_EXITTB ; } if ((env->mmu_model & POWERPC_MMU_BOOKE) &&
@@ -151,7 +158,7 @@ static inline int hreg_store_msr(CPUPPCSreturn excp; } -#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void check_tlb_flush (CPUPPCState *env) {CPUState *cs =CPU (ppc_env_get_cpu (env));
target-ppc/excp_helper.c +10 -0
@@ -709,6 +709,16 @@ static inline void powerpc_excp(PowerPCC } }#endif +if (((new_msr >>MSR_IR ) &1 ) != msr_ir || + ((new_msr >>MSR_DR ) &1 ) != msr_dr) { +/* A change of the instruction relocation bit in the MSR can +* cause an implicit branch in the address space. This +* requires a tlb flush. +*/ +if (env->mmu_model &POWERPC_MMU_32B ) { + env->tlb_need_flush =1 ; + } + }/* We don't use hreg_store_msr here as already have treated * any special case that could occur. Just store MSR and update hflags *
Mark Cave-Ayland
Tested-byQuoted 143 lines · Cédric Le Goater
Hello Mark,
Quoted 28 lines · Mark Cave-Ayland
Quoted 12 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilegeQuoted 6 lines
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)Hi Cédric,
I can confirm that this patchset fixes starting up OpenBIOS for both g3beige/mac99 in my tests here. With the escc fix also applied, the only outstanding issue is the removal of the
tlb_flush()statements which causes Darwin, MacOS X and HelenOS 0.60 to panic on bootQuoted 8 lines
My only request is if it would be possible to move patch 2 "ppc: Better figure out if processor has HV mode" to the front of this patchset which will make the remaining patches bisectable for the Mac machines. With that:
Tested-by Mark Cave-Ayland <[email protected]>Does anyone know if Ben has any ideas as to why the MMU
tlb_flushchanges patch is causing such problems?Here is a fix I think. Could you give it a try ?
Cheers,
C.
From: Cédric Le Goater <[email protected]>
Subject: [PATCH] ppc: fix tlb flushes for 32bit environment
Date: Sun, 05 Jun 2016 18:46:19 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitcommit
cd0c6f473532('ppc: Do some batching of TCG tlb flushes') introduced an optimisation to flush TLBs only when a context synchronizing event is reached (interrupt, rfi). This was done for ppc64 but 32bit was forgotten on the way.Tested on mac99 and g3beige with
qemu-system-ppc -cdrom darwinppc-602.cdr -boot d
Signed-off-by Cédric Le Goater <[email protected]>---
I think the hunk in
powerpc_excp()is needed if we don't generate a context synchronizing event. what is best to do ?target-ppc/cpu.h | 2 +- target-ppc/excp_helper.c | 10 ++++++++++ target-ppc/helper_regs.h | 9 ++++++++- target-ppc/translate.c | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-)Index:
qemu-dgibson-for-2.7.git/target-ppc/translate.c
===================================================================target-ppc/translate.c +1
-1@@ -3290,7 +3290,7 @@ static void gen_eieio(DisasContext *ctx) { } -#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void gen_check_tlb_flush (DisasContext *ctx) {TCGv_i32 t =tcg_temp_new_i32 ();Index:
qemu-dgibson-for-2.7.git/target-ppc/cpu.h
===================================================================target-ppc/cpu.h +1
-1@@ -958,9 +958,9 @@ struct CPUPPCState {/* PowerPC 64 SLB area */ ppc_slb_t slb[MAX_SLB_ENTRIES ];int32_t slb_nr; +#endif /* tcg TLB needs flush (deferred slb inval instruction typically) */ uint32_t tlb_need_flush; -#endif /* segment registers */ hwaddr htab_base;/* mask used to normalize hash value to PTEG index */ Index:
qemu-dgibson-for-2.7.git/target-ppc/helper_regs.h
===================================================================target-ppc/helper_regs.h +8
-1@@ -121,6 +121,13 @@ static inline int hreg_store_msr(CPUPPCS }if (((value >>MSR_IR ) &1 ) != msr_ir || ((value >>MSR_DR ) &1 ) != msr_dr) { +/* A change of the instruction relocation bit in the MSR can +* cause an implicit branch in the address space. This +* requires a tlb flush. +*/ +if (env->mmu_model &POWERPC_MMU_32B ) { + env->tlb_need_flush =1 ; + } cs->interrupt_request |=CPU_INTERRUPT_EXITTB ; } if ((env->mmu_model & POWERPC_MMU_BOOKE) &&@@ -151,7 +158,7 @@ static inline int hreg_store_msr(CPUPPCSreturn excp; } -#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void check_tlb_flush (CPUPPCState *env) {CPUState *cs =CPU (ppc_env_get_cpu (env));Index:
qemu-dgibson-for-2.7.git/target-ppc/excp_helper.c
===================================================================target-ppc/excp_helper.c +3
-0@@ -709,6 +709,16 @@ static inline void powerpc_excp(PowerPCC } }#endif +if (((new_msr >>MSR_IR ) &1 ) != msr_ir || + ((new_msr >>MSR_DR ) &1 ) != msr_dr) { +/* A change of the instruction relocation bit in the MSR can
target-ppc/excp_helper.c static inline void powerpc_excp(PowerPCC · line 724
Quoted 10 lines
target-ppc/excp_helper.c +7
-0+* cause an implicit branch in the address space. This +* requires a tlb flush. +*/ +if (env->mmu_model &POWERPC_MMU_32B ) { + env->tlb_need_flush =1 ; + } + }/* We don't use hreg_store_msr here as already have treated * any special case that could occur. Just store MSR and update hflags *
Hi Cédric,
I've just tried this patch on a selection of images here with both g3beige and mac99 and as far as I can tell the crash has now gone away:
Thanks for getting this sorted so quickly.
ATB,
Mark.
Quoted 158 lines · Mark Cave-Ayland
Quoted 143 lines · Cédric Le Goater
Hello Mark,
Quoted 28 lines · Mark Cave-Ayland
Quoted 12 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilegeQuoted 6 lines
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)Hi Cédric,
I can confirm that this patchset fixes starting up OpenBIOS for both g3beige/mac99 in my tests here. With the escc fix also applied, the only outstanding issue is the removal of the
tlb_flush()statements which causes Darwin, MacOS X and HelenOS 0.60 to panic on bootQuoted 8 lines
My only request is if it would be possible to move patch 2 "ppc: Better figure out if processor has HV mode" to the front of this patchset which will make the remaining patches bisectable for the Mac machines. With that:
Tested-by Mark Cave-Ayland <[email protected]>Does anyone know if Ben has any ideas as to why the MMU
tlb_flushchanges patch is causing such problems?Here is a fix I think. Could you give it a try ?
Cheers,
C.
From: Cédric Le Goater <[email protected]>
Subject: [PATCH] ppc: fix tlb flushes for 32bit environment
Date: Sun, 05 Jun 2016 18:46:19 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitcommit
cd0c6f473532('ppc: Do some batching of TCG tlb flushes') introduced an optimisation to flush TLBs only when a context synchronizing event is reached (interrupt, rfi). This was done for ppc64 but 32bit was forgotten on the way.Tested on mac99 and g3beige with
qemu-system-ppc -cdrom darwinppc-602.cdr -boot d
Signed-off-by Cédric Le Goater <[email protected]>---
I think the hunk in
powerpc_excp()is needed if we don't generate a context synchronizing event. what is best to do ?target-ppc/cpu.h | 2 +- target-ppc/excp_helper.c | 10 ++++++++++ target-ppc/helper_regs.h | 9 ++++++++- target-ppc/translate.c | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-)Index:
qemu-dgibson-for-2.7.git/target-ppc/translate.c
===================================================================target-ppc/translate.c +1
-1@@ -3290,7 +3290,7 @@ static void gen_eieio(DisasContext *ctx) { } -#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void gen_check_tlb_flush (DisasContext *ctx) {TCGv_i32 t =tcg_temp_new_i32 ();Index:
qemu-dgibson-for-2.7.git/target-ppc/cpu.h
===================================================================target-ppc/cpu.h +1
-1@@ -958,9 +958,9 @@ struct CPUPPCState {/* PowerPC 64 SLB area */ ppc_slb_t slb[MAX_SLB_ENTRIES ];int32_t slb_nr; +#endif /* tcg TLB needs flush (deferred slb inval instruction typically) */ uint32_t tlb_need_flush; -#endif /* segment registers */ hwaddr htab_base;/* mask used to normalize hash value to PTEG index */ Index:
qemu-dgibson-for-2.7.git/target-ppc/helper_regs.h
===================================================================target-ppc/helper_regs.h +8
-1@@ -121,6 +121,13 @@ static inline int hreg_store_msr(CPUPPCS }if (((value >>MSR_IR ) &1 ) != msr_ir || ((value >>MSR_DR ) &1 ) != msr_dr) { +/* A change of the instruction relocation bit in the MSR can +* cause an implicit branch in the address space. This +* requires a tlb flush. +*/ +if (env->mmu_model &POWERPC_MMU_32B ) { + env->tlb_need_flush =1 ; + } cs->interrupt_request |=CPU_INTERRUPT_EXITTB ; } if ((env->mmu_model & POWERPC_MMU_BOOKE) &&@@ -151,7 +158,7 @@ static inline int hreg_store_msr(CPUPPCSreturn excp; } -#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void check_tlb_flush (CPUPPCState *env) {CPUState *cs =CPU (ppc_env_get_cpu (env));Index:
qemu-dgibson-for-2.7.git/target-ppc/excp_helper.c
===================================================================target-ppc/excp_helper.c +3
-0@@ -709,6 +709,16 @@ static inline void powerpc_excp(PowerPCC } }#endif +if (((new_msr >>MSR_IR ) &1 ) != msr_ir || + ((new_msr >>MSR_DR ) &1 ) != msr_dr) { +/* A change of the instruction relocation bit in the MSR can target-ppc/excp_helper.c static inline void powerpc_excp(PowerPCC · line 724
Quoted 10 lines
target-ppc/excp_helper.c +7
-0+* cause an implicit branch in the address space. This +* requires a tlb flush. +*/ +if (env->mmu_model &POWERPC_MMU_32B ) { + env->tlb_need_flush =1 ; + } + }/* We don't use hreg_store_msr here as already have treated * any special case that could occur. Just store MSR and update hflags * Hi Cédric,
Quoted 4 lines
I've just tried this patch on a selection of images here with both g3beige and mac99 and as far as I can tell the crash has now gone away:
Tested-by Mark Cave-Ayland <[email protected]>
Super. I still need to sort out the exit path of hreg_store_msr().
If we have a change in IR/DR, this is a case to transform mtmsr in a context-synchronize instruction, for a tlb flush. This is problably the reason behind the POWERPC_EXCP_NONE I believe, which is then handled in powerpc_excp(). I need to look at that path closer.
And, now that I have a darwin guest, I have a few questions :
1. How do I get X running ?
2. I have an old ibook G4 from which I dd'ed the disk. openbios complains for some invalid state. is that supported ?
Thanks,
C.
Quoted 7 lines
Thanks for getting this sorted so quickly.
ATB,
Mark.
Quoted 162 lines · Cédric Le Goater
Quoted 161 lines · Mark Cave-Ayland
Quoted 143 lines · Cédric Le Goater
Hello Mark,
Quoted 28 lines · Mark Cave-Ayland
Quoted 12 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilegeQuoted 6 lines
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)Hi Cédric,
I can confirm that this patchset fixes starting up OpenBIOS for both g3beige/mac99 in my tests here. With the escc fix also applied, the only outstanding issue is the removal of the
tlb_flush()statements which causes Darwin, MacOS X and HelenOS 0.60 to panic on bootQuoted 8 lines
My only request is if it would be possible to move patch 2 "ppc: Better figure out if processor has HV mode" to the front of this patchset which will make the remaining patches bisectable for the Mac machines. With that:
Tested-by Mark Cave-Ayland <[email protected]>Does anyone know if Ben has any ideas as to why the MMU
tlb_flushchanges patch is causing such problems?Here is a fix I think. Could you give it a try ?
Cheers,
C.
From: Cédric Le Goater <[email protected]>
Subject: [PATCH] ppc: fix tlb flushes for 32bit environment
Date: Sun, 05 Jun 2016 18:46:19 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitcommit
cd0c6f473532('ppc: Do some batching of TCG tlb flushes') introduced an optimisation to flush TLBs only when a context synchronizing event is reached (interrupt, rfi). This was done for ppc64 but 32bit was forgotten on the way.Tested on mac99 and g3beige with
qemu-system-ppc -cdrom darwinppc-602.cdr -boot d
Signed-off-by Cédric Le Goater <[email protected]>---
I think the hunk in
powerpc_excp()is needed if we don't generate a context synchronizing event. what is best to do ?target-ppc/cpu.h | 2 +- target-ppc/excp_helper.c | 10 ++++++++++ target-ppc/helper_regs.h | 9 ++++++++- target-ppc/translate.c | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-)Index:
qemu-dgibson-for-2.7.git/target-ppc/translate.c
===================================================================target-ppc/translate.c +1
-1@@ -3290,7 +3290,7 @@ static void gen_eieio(DisasContext *ctx) { } -#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void gen_check_tlb_flush (DisasContext *ctx) {TCGv_i32 t =tcg_temp_new_i32 ();Index:
qemu-dgibson-for-2.7.git/target-ppc/cpu.h
===================================================================target-ppc/cpu.h +1
-1@@ -958,9 +958,9 @@ struct CPUPPCState {/* PowerPC 64 SLB area */ ppc_slb_t slb[MAX_SLB_ENTRIES ];int32_t slb_nr; +#endif /* tcg TLB needs flush (deferred slb inval instruction typically) */ uint32_t tlb_need_flush; -#endif /* segment registers */ hwaddr htab_base;/* mask used to normalize hash value to PTEG index */ Index:
qemu-dgibson-for-2.7.git/target-ppc/helper_regs.h
===================================================================target-ppc/helper_regs.h +8
-1@@ -121,6 +121,13 @@ static inline int hreg_store_msr(CPUPPCS }if (((value >>MSR_IR ) &1 ) != msr_ir || ((value >>MSR_DR ) &1 ) != msr_dr) { +/* A change of the instruction relocation bit in the MSR can +* cause an implicit branch in the address space. This +* requires a tlb flush. +*/ +if (env->mmu_model &POWERPC_MMU_32B ) { + env->tlb_need_flush =1 ; + } cs->interrupt_request |=CPU_INTERRUPT_EXITTB ; } if ((env->mmu_model & POWERPC_MMU_BOOKE) &&@@ -151,7 +158,7 @@ static inline int hreg_store_msr(CPUPPCSreturn excp; } -#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void check_tlb_flush (CPUPPCState *env) {CPUState *cs =CPU (ppc_env_get_cpu (env));Index:
qemu-dgibson-for-2.7.git/target-ppc/excp_helper.c
===================================================================target-ppc/excp_helper.c +3
-0@@ -709,6 +709,16 @@ static inline void powerpc_excp(PowerPCC } }#endif +if (((new_msr >>MSR_IR ) &1 ) != msr_ir || + ((new_msr >>MSR_DR ) &1 ) != msr_dr) { +/* A change of the instruction relocation bit in the MSR can target-ppc/excp_helper.c static inline void powerpc_excp(PowerPCC · line 724
Quoted 10 lines
target-ppc/excp_helper.c +7
-0+* cause an implicit branch in the address space. This +* requires a tlb flush. +*/ +if (env->mmu_model &POWERPC_MMU_32B ) { + env->tlb_need_flush =1 ; + } + }/* We don't use hreg_store_msr here as already have treated * any special case that could occur. Just store MSR and update hflags * Hi Cédric,
I've just tried this patch on a selection of images here with both g3beige and mac99 and as far as I can tell the crash has now gone away:
Quoted 8 lines
Quoted 1 line
Tested-by Mark Cave-Ayland <[email protected]>Super. I still need to sort out the exit path of
hreg_store_msr().If we have a change in IR/DR, this is a case to transform mtmsr in a context-synchronize instruction, for a tlb flush. This is problably the reason behind the
POWERPC_EXCP_NONEI believe, which is then handled inpowerpc_excp(). I need to look at that path closer.
Forget the above as Ben just passed by :)
I still interested by what is below :
Quoted 20 lines
And, now that I have a darwin guest, I have a few questions :
1. How do I get X running ?
2. I have an old ibook G4 from which I dd'ed the disk. openbios complains for some invalid state. is that supported ?Thanks,
C.
Quoted 7 lines
Thanks for getting this sorted so quickly.
ATB,
Mark.
Quoted 167 lines · Cedric Le Goater
Quoted 166 lines · Cédric Le Goater
Quoted 158 lines · Mark Cave-Ayland
Quoted 143 lines · Cédric Le Goater
Hello Mark,
Quoted 28 lines · Mark Cave-Ayland
Quoted 12 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilegeQuoted 6 lines
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)Hi Cédric,
I can confirm that this patchset fixes starting up OpenBIOS for both g3beige/mac99 in my tests here. With the escc fix also applied, the only outstanding issue is the removal of the
tlb_flush()statements which causes Darwin, MacOS X and HelenOS 0.60 to panic on bootQuoted 8 lines
My only request is if it would be possible to move patch 2 "ppc: Better figure out if processor has HV mode" to the front of this patchset which will make the remaining patches bisectable for the Mac machines. With that:
Tested-by Mark Cave-Ayland <[email protected]>Does anyone know if Ben has any ideas as to why the MMU
tlb_flushchanges patch is causing such problems?Here is a fix I think. Could you give it a try ?
Cheers,
C.
From: Cédric Le Goater <[email protected]>
Subject: [PATCH] ppc: fix tlb flushes for 32bit environment
Date: Sun, 05 Jun 2016 18:46:19 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitcommit
cd0c6f473532('ppc: Do some batching of TCG tlb flushes') introduced an optimisation to flush TLBs only when a context synchronizing event is reached (interrupt, rfi). This was done for ppc64 but 32bit was forgotten on the way.Tested on mac99 and g3beige with
qemu-system-ppc -cdrom darwinppc-602.cdr -boot d
Signed-off-by Cédric Le Goater <[email protected]>---
I think the hunk in
powerpc_excp()is needed if we don't generate a context synchronizing event. what is best to do ?target-ppc/cpu.h | 2 +- target-ppc/excp_helper.c | 10 ++++++++++ target-ppc/helper_regs.h | 9 ++++++++- target-ppc/translate.c | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-)Index:
qemu-dgibson-for-2.7.git/target-ppc/translate.c
===================================================================target-ppc/translate.c +1
-1@@ -3290,7 +3290,7 @@ static void gen_eieio(DisasContext *ctx) { } -#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void gen_check_tlb_flush (DisasContext *ctx) {TCGv_i32 t =tcg_temp_new_i32 ();Index:
qemu-dgibson-for-2.7.git/target-ppc/cpu.h
===================================================================target-ppc/cpu.h +1
-1@@ -958,9 +958,9 @@ struct CPUPPCState {/* PowerPC 64 SLB area */ ppc_slb_t slb[MAX_SLB_ENTRIES ];int32_t slb_nr; +#endif /* tcg TLB needs flush (deferred slb inval instruction typically) */ uint32_t tlb_need_flush; -#endif /* segment registers */ hwaddr htab_base;/* mask used to normalize hash value to PTEG index */ Index:
qemu-dgibson-for-2.7.git/target-ppc/helper_regs.h
===================================================================target-ppc/helper_regs.h +8
-1@@ -121,6 +121,13 @@ static inline int hreg_store_msr(CPUPPCS }if (((value >>MSR_IR ) &1 ) != msr_ir || ((value >>MSR_DR ) &1 ) != msr_dr) { +/* A change of the instruction relocation bit in the MSR can +* cause an implicit branch in the address space. This +* requires a tlb flush. +*/ +if (env->mmu_model &POWERPC_MMU_32B ) { + env->tlb_need_flush =1 ; + } cs->interrupt_request |=CPU_INTERRUPT_EXITTB ; } if ((env->mmu_model & POWERPC_MMU_BOOKE) &&@@ -151,7 +158,7 @@ static inline int hreg_store_msr(CPUPPCSreturn excp; } -#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void check_tlb_flush (CPUPPCState *env) {CPUState *cs =CPU (ppc_env_get_cpu (env));Index:
qemu-dgibson-for-2.7.git/target-ppc/excp_helper.c
===================================================================target-ppc/excp_helper.c +3
-0@@ -709,6 +709,16 @@ static inline void powerpc_excp(PowerPCC } }#endif +if (((new_msr >>MSR_IR ) &1 ) != msr_ir || + ((new_msr >>MSR_DR ) &1 ) != msr_dr) { +/* A change of the instruction relocation bit in the MSR can target-ppc/excp_helper.c static inline void powerpc_excp(PowerPCC · line 724
Quoted 10 lines
target-ppc/excp_helper.c +7
-0+* cause an implicit branch in the address space. This +* requires a tlb flush. +*/ +if (env->mmu_model &POWERPC_MMU_32B ) { + env->tlb_need_flush =1 ; + } + }/* We don't use hreg_store_msr here as already have treated * any special case that could occur. Just store MSR and update hflags * Hi Cédric,
Quoted 4 lines
I've just tried this patch on a selection of images here with both g3beige and mac99 and as far as I can tell the crash has now gone away:
Tested-by Mark Cave-Ayland <[email protected]>Super. I still need to sort out the exit path of
hreg_store_msr().
Quoted 12 lines
Quoted 4 lines
If we have a change in IR/DR, this is a case to transform mtmsr in a context-synchronize instruction, for a tlb flush. This is problably the reason behind the
POWERPC_EXCP_NONEI believe, which is then handled inpowerpc_excp(). I need to look at that path closer.Forget the above as Ben just passed by :)
I still interested by what is below :
Quoted 3 lines
And, now that I have a darwin guest, I have a few questions :
1. How do I get X running ?
It's not something I really test here, but shouldn't startx work? You may need to do some configuration work if X is configured to directly use the ATI driver.
Quoted 2 lines
Quoted 2 lines
2. I have an old ibook G4 from which I dd'ed the disk. openbios complains for some invalid state. is that supported ?
Yes, OpenBIOS should boot most things these days (MorphOS is the only execption I know of where the bootloader won't execute correctly as it assumes real mode). The above message means that OpenBIOS couldn't find a bootloader, or it could but was unable to execute it, e.g. due to incompatible architecture - which OS is your image running? Have you tried both mac99 and g3beige machines?
ATB,
Mark.
Quoted 186 lines · Mark Cave-Ayland
Quoted 167 lines · Cedric Le Goater
Quoted 166 lines · Cédric Le Goater
Quoted 158 lines · Mark Cave-Ayland
Quoted 143 lines · Cédric Le Goater
Hello Mark,
Quoted 28 lines · Mark Cave-Ayland
Quoted 12 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilegeQuoted 6 lines
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)Hi Cédric,
I can confirm that this patchset fixes starting up OpenBIOS for both g3beige/mac99 in my tests here. With the escc fix also applied, the only outstanding issue is the removal of the
tlb_flush()statements which causes Darwin, MacOS X and HelenOS 0.60 to panic on bootQuoted 8 lines
My only request is if it would be possible to move patch 2 "ppc: Better figure out if processor has HV mode" to the front of this patchset which will make the remaining patches bisectable for the Mac machines. With that:
Tested-by Mark Cave-Ayland <[email protected]>Does anyone know if Ben has any ideas as to why the MMU
tlb_flushchanges patch is causing such problems?Here is a fix I think. Could you give it a try ?
Cheers,
C.
From: Cédric Le Goater <[email protected]>
Subject: [PATCH] ppc: fix tlb flushes for 32bit environment
Date: Sun, 05 Jun 2016 18:46:19 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitcommit
cd0c6f473532('ppc: Do some batching of TCG tlb flushes') introduced an optimisation to flush TLBs only when a context synchronizing event is reached (interrupt, rfi). This was done for ppc64 but 32bit was forgotten on the way.Tested on mac99 and g3beige with
qemu-system-ppc -cdrom darwinppc-602.cdr -boot d
Signed-off-by Cédric Le Goater <[email protected]>---
I think the hunk in
powerpc_excp()is needed if we don't generate a context synchronizing event. what is best to do ?target-ppc/cpu.h | 2 +- target-ppc/excp_helper.c | 10 ++++++++++ target-ppc/helper_regs.h | 9 ++++++++- target-ppc/translate.c | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-)Index:
qemu-dgibson-for-2.7.git/target-ppc/translate.c
===================================================================target-ppc/translate.c +1
-1@@ -3290,7 +3290,7 @@ static void gen_eieio(DisasContext *ctx) { } -#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void gen_check_tlb_flush (DisasContext *ctx) {TCGv_i32 t =tcg_temp_new_i32 ();Index:
qemu-dgibson-for-2.7.git/target-ppc/cpu.h
===================================================================target-ppc/cpu.h +1
-1@@ -958,9 +958,9 @@ struct CPUPPCState {/* PowerPC 64 SLB area */ ppc_slb_t slb[MAX_SLB_ENTRIES ];int32_t slb_nr; +#endif /* tcg TLB needs flush (deferred slb inval instruction typically) */ uint32_t tlb_need_flush; -#endif /* segment registers */ hwaddr htab_base;/* mask used to normalize hash value to PTEG index */ Index:
qemu-dgibson-for-2.7.git/target-ppc/helper_regs.h
===================================================================target-ppc/helper_regs.h +8
-1@@ -121,6 +121,13 @@ static inline int hreg_store_msr(CPUPPCS }if (((value >>MSR_IR ) &1 ) != msr_ir || ((value >>MSR_DR ) &1 ) != msr_dr) { +/* A change of the instruction relocation bit in the MSR can +* cause an implicit branch in the address space. This +* requires a tlb flush. +*/ +if (env->mmu_model &POWERPC_MMU_32B ) { + env->tlb_need_flush =1 ; + } cs->interrupt_request |=CPU_INTERRUPT_EXITTB ; } if ((env->mmu_model & POWERPC_MMU_BOOKE) &&@@ -151,7 +158,7 @@ static inline int hreg_store_msr(CPUPPCSreturn excp; } -#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void check_tlb_flush (CPUPPCState *env) {CPUState *cs =CPU (ppc_env_get_cpu (env));Index:
qemu-dgibson-for-2.7.git/target-ppc/excp_helper.c
===================================================================target-ppc/excp_helper.c +3
-0@@ -709,6 +709,16 @@ static inline void powerpc_excp(PowerPCC } }#endif +if (((new_msr >>MSR_IR ) &1 ) != msr_ir || + ((new_msr >>MSR_DR ) &1 ) != msr_dr) { +/* A change of the instruction relocation bit in the MSR can target-ppc/excp_helper.c static inline void powerpc_excp(PowerPCC · line 724
Quoted 10 lines
target-ppc/excp_helper.c +7
-0+* cause an implicit branch in the address space. This +* requires a tlb flush. +*/ +if (env->mmu_model &POWERPC_MMU_32B ) { + env->tlb_need_flush =1 ; + } + }/* We don't use hreg_store_msr here as already have treated * any special case that could occur. Just store MSR and update hflags * Hi Cédric,
Quoted 4 lines
I've just tried this patch on a selection of images here with both g3beige and mac99 and as far as I can tell the crash has now gone away:
Tested-by Mark Cave-Ayland <[email protected]>Super. I still need to sort out the exit path of
hreg_store_msr().Quoted 12 lines
Quoted 4 lines
If we have a change in IR/DR, this is a case to transform mtmsr in a context-synchronize instruction, for a tlb flush. This is problably the reason behind the
POWERPC_EXCP_NONEI believe, which is then handled inpowerpc_excp(). I need to look at that path closer.Forget the above as Ben just passed by :)
I still interested by what is below :
Quoted 3 lines
And, now that I have a darwin guest, I have a few questions :
1. How do I get X running ?
It's not something I really test here, but shouldn't startx work? You may need to do some configuration work if X is configured to directly use the ATI driver.
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
2. I have an old ibook G4 from which I dd'ed the disk. openbios complains for some invalid state. is that supported ?
Yes, OpenBIOS should boot most things these days (MorphOS is the only execption I know of where the bootloader won't execute correctly as it assumes real mode). The above message means that OpenBIOS couldn't find a bootloader, or it could but was unable to execute it, e.g. due to incompatible architecture - which OS is your image running?
I am pretty sure it is a Mac OS X v10.5. I still have the hardware but it is running Linux now :
# cat /proc/cpuinfo processor : 0 cpu : 7447A, altivec supported clock : 1333.333000MHz revision : 1.5 (pvr 8003 0105) bogomips : 36.86
total bogomips : 36.86
timebase : 18432000
platform : PowerMac
model : PowerBook6,7
machine : PowerBook6,7
motherboard : PowerBook6,7 MacRISC3 Power Macintosh
detected as : 287 (iBook G4)
pmac flags : 0000001a
L2 cache : 512K unified
pmac-generation : NewWorld
Memory : 1024 MB
# lsprop /proc/device-tree/rom@ff800000/boot-rom@fff00000/ reg fff00000 00100000 info fff00000 00003f00 000493f0 20050705 815fda85 fff08000 00078001 000493f0 20050705 23765c6c fff80000 00080002 000493f0 20050705 b3364dca fff03f00 00000083 000493f0 20050705 c2b72d61 fff03f80 00000084 e24a68ca 15a82001 ffffffff fff04000 00004005 6e767261 6d000000 00000000 00000000 00000000 [140 bytes total] name "boot-rom" security-modes 6e6f6e65 2c206675 6c6c2c20 636f6d6d 616e642c 206e6f2d 70617373 776f7264 image 00080000 (524288) model "Apple PowerBook6,7 4.9.3f0 BootROM built on 07/05/05 at 11:14:11" write-characteristic "flash" hwi-flags 402a1220 (1076498976) BootROM-version "$0004.93f0" BootROM-build-date "07/05/05 at 11:14:11" linux,phandle ff89cb08 has-config-block
Quoted 1 line
Have you tried both mac99 and g3beige machines?
yes.
C.
Quoted 57 lines · Cédric Le Goater
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
2. I have an old ibook G4 from which I dd'ed the disk. openbios complains for some invalid state. is that supported ?
Yes, OpenBIOS should boot most things these days (MorphOS is the only execption I know of where the bootloader won't execute correctly as it assumes real mode). The above message means that OpenBIOS couldn't find a bootloader, or it could but was unable to execute it, e.g. due to incompatible architecture - which OS is your image running?
I am pretty sure it is a Mac OS X v10.5. I still have the hardware but it is running Linux now :
# cat /proc/cpuinfo processor : 0 cpu : 7447A, altivec supported clock : 1333.333000MHz revision : 1.5 (pvr 8003 0105) bogomips : 36.86total bogomips : 36.86
timebase : 18432000
platform : PowerMac
model : PowerBook6,7
machine : PowerBook6,7
motherboard : PowerBook6,7 MacRISC3 Power Macintosh
detected as : 287 (iBook G4)
pmac flags :0000001a
L2 cache : 512K unified
pmac-generation : NewWorld
Memory : 1024 MB# lsprop /proc/device-tree/rom@ff800000/boot-rom@fff00000/ reg fff00000 00100000 info fff00000 00003f00 000493f0 20050705 815fda85 fff08000 00078001 000493f0 20050705 23765c6c fff80000 00080002 000493f0 20050705 b3364dca fff03f00 00000083 000493f0 20050705 c2b72d61 fff03f80 00000084 e24a68ca 15a82001 ffffffff fff04000 00004005 6e767261 6d000000 00000000 00000000 00000000 [140 bytes total] name "boot-rom" security-modes 6e6f6e65 2c206675 6c6c2c20 636f6d6d 616e642c 206e6f2d 70617373 776f7264 image 00080000 (524288) model "Apple PowerBook6,7 4.9.3f0 BootROM built on 07/05/05 at 11:14:11" write-characteristic "flash" hwi-flags 402a1220 (1076498976) BootROM-version "$0004.93f0" BootROM-build-date "07/05/05 at 11:14:11" linux,phandle ff89cb08 has-config-block
Quoted 3 lines
Quoted 1 line
Have you tried both mac99 and g3beige machines?
yes.
(I'm wondering if we should start a new thread here either just on qemu-ppc or over on the OpenBIOS list)
OpenBIOS will read hfs/hfsplus filesystems fine - I wonder if maybe it can't locate a suitable partition in the Apple Partition Map?
If you boot to the Forth prompt with -prom-env 'auto-boot?=false' can you try the following to see if you can list the disk contents:
dir hd:,\
If that doesn't work it means that the partition auto-detection is failing, so try manually forcing the partition number until you find one that works e.g.
dir hd:0,\
dir hd:1,\
etc.
up until around partition 10? Once you find one that works it should be possible to boot that partition directly e.g.
boot hd:1
ATB,
Mark.
Quoted 35 lines · Cédric Le Goater
Hello Mark,
Quoted 32 lines · Mark Cave-Ayland
Quoted 12 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilegeQuoted 6 lines
target-ppc/cpu.h | 4 ++++ target-ppc/excp_helper.c | 8 ++++++-- target-ppc/helper_regs.h | 4 ++-- target-ppc/translate.c | 10 ++++++---- target-ppc/translate_init.c | 19 +++++++++++++++---- 5 files changed, 33 insertions(+), 12 deletions(-)Hi Cédric,
I can confirm that this patchset fixes starting up OpenBIOS for both g3beige/mac99 in my tests here. With the escc fix also applied, the only outstanding issue is the removal of the
tlb_flush()statements which causes Darwin, MacOS X and HelenOS 0.60 to panic on bootMy only request is if it would be possible to move patch 2 "ppc: Better figure out if processor has HV mode" to the front of this patchset which will make the remaining patches bisectable for the Mac machines. With that:
Quoted 7 lines
Quoted 4 lines
Tested-by Mark Cave-Ayland <[email protected]>Does anyone know if Ben has any ideas as to why the MMU
tlb_flushchanges patch is causing such problems?Here is a fix I think. Could you give it a try ?
So, I had applied this to ppc-for-2.7, but I've now removed it again. BenH correctly pointed out that it basically just removes any benefit of his original tlb_flush() patch, in a slightly more subtle way that the last "fix". You just set the need_flush flag whenever IR or DR are changed, whereas the whole point of BenH's patch is that the translation on and off modes are now different MM contexts, which should be flagged in qemu's TLB and so not require a full flush. We need to work out what the real problem is here.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 2 lines · Cédric Le Goater
Here is a fix I think. Could you give it a try ?
This is somewhat wrong...
Quoted 4 lines
commit
cd0c6f473532('ppc: Do some batching of TCG tlb flushes') introduced an optimisation to flush TLBs only when a context synchronizing event is reached (interrupt, rfi). This was done for ppc64 but 32bit was forgotten on the way.
No it didn't. That commit only delays flushes on ppc64. ppc32 is unaffected, unless I missed something. IE. It will delay flushes caused by slb instructions (which don't exist on 32-bit)
and ppc_tlb_invalidate_one() only in the 64-bit cases.
Also what your patch does in practice is not really change that, though you seem to try to somewhat extend the batching to 32-bit (but incompletely), you also introduce something which effectively reverts part of 9fb044911444fdd09f5f072ad0ca269d7f8b841d (split I/D mode).
I think that's more what's "fixing" your problem, ie, the flush in IR/DR changes. However it shouldn't be needed.
I suspect all of that is papering over another bug somewhere else which got exposed by the split I/D mode, since we no longer over-flush on transitions to/from real-mode. So we must be missing flushes elsewhere, possibly some G3 specific stuff, or there always was some kind of bug in the TLB flushing on 32-bit that got somewhat masked by the over- flushing we used to do.
I need a repro-case.
Cheers,
Ben.
Quoted 95 lines
Tested on mac99 and g3beige with
qemu-system-ppc -cdrom darwinppc-602.cdr -boot d
Signed-off-by Cédric Le Goater <[email protected]>---
I think the hunk in
powerpc_excp()is needed if we don't generate a context synchronizing event. what is best to do ?target-ppc/cpu.h | 2 +-
target-ppc/excp_helper.c | 10 ++++++++++
target-ppc/helper_regs.h | 9 ++++++++-
target-ppc/translate.c | 2 +-4 files changed, 20 insertions(+), 3 deletions(-)Index:
qemu-dgibson-for-2.7.git/target-ppc/translate.c
===================================================================target-ppc/translate.c +0
-0@@ -3290,7 +3290,7 @@ static void gen_eieio(DisasContext *ctx) { }target-ppc/translate.c +1
-1-#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void
gen_check_tlb_flush(DisasContext *ctx){
TCGv_i32 t =tcg_temp_new_i32();
Index:qemu-dgibson-for-2.7.git/target-ppc/cpu.h
===================================================================target-ppc/cpu.h +1
-0@@ -958,9 +958,9 @@ struct CPUPPCState { /* PowerPC 64 SLB area */ ppc_slb_t slb[MAX_SLB_ENTRIES]; int32_t slb_nr; +#endif /* tcg TLB needs flush (deferred slb inval instructiontypically) */
uint32_ttlb_need_flush;
-#endif
/* segment registers */
hwaddrhtab_base;
/* mask used to normalize hash value to PTEG index */
Index:qemu-dgibson-for-2.7.git/target-ppc/helper_regs.h
===================================================================target-ppc/helper_regs.h +0
-0@@ -121,6 +121,13 @@ static inline int hreg_store_msr(CPUPPCS }if (((value >>
MSR_IR) & 1) !=msr_ir||
((value >>MSR_DR) & 1) !=msr_dr) {
+ /* A change of the instruction relocation bit in the MSR can + * cause an implicit branch in the address space. This + * requires a tlb flush.
+ */
+ if (env->mmu_model&POWERPC_MMU_32B) {
+ env->tlb_need_flush = 1;
+ }
cs->interrupt_request |=CPU_INTERRUPT_EXITTB;
}
if ((env->mmu_model&POWERPC_MMU_BOOKE) &&target-ppc/helper_regs.h +0
-0@@ -151,7 +158,7 @@ static inline int hreg_store_msr(CPUPPCS return excp; }target-ppc/helper_regs.h +1
-1-#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void
check_tlb_flush(CPUPPCState *env){
CPUState *cs = CPU(ppc_env_get_cpu(env));
Index:qemu-dgibson-for-2.7.git/target-ppc/excp_helper.c
===================================================================target-ppc/excp_helper.c +10
-0@@ -709,6 +709,16 @@ static inline void powerpc_excp(PowerPCC } } #endif + if (((new_msr >> MSR_IR) & 1) != msr_ir || + ((new_msr >> MSR_DR) & 1) != msr_dr) { + /* A change of the instruction relocation bit in the MSR can + * cause an implicit branch in the address space. This + * requires a tlb flush. + */ + if (env->mmu_model & POWERPC_MMU_32B) { + env->tlb_need_flush = 1; + } + } /* We don't use hreg_store_msr here as already have treated* any special case that could occur. Just store MSR and update hflags
*
Quoted 16 lines · Benjamin Herrenschmidt
Quoted 2 lines · Cédric Le Goater
Here is a fix I think. Could you give it a try ?
This is somewhat wrong...
Quoted 4 lines
commit
cd0c6f473532('ppc: Do some batching of TCG tlb flushes') introduced an optimisation to flush TLBs only when a context synchronizing event is reached (interrupt, rfi). This was done for ppc64 but 32bit was forgotten on the way.No it didn't. That commit only delays flushes on ppc64. ppc32 is unaffected, unless I missed something. IE. It will delay flushes caused by slb instructions (which don't exist on 32-bit)
andppc_tlb_invalidate_one()only in the 64-bit cases.
Quoted 7 lines
Also what your patch does in practice is not really change that, though you seem to try to somewhat extend the batching to 32-bit (but incompletely), you also introduce something which effectively reverts part of
9fb044911444fdd09f5f072ad0ca269d7f8b841d(split I/D mode).I think that's more what's "fixing" your problem, ie, the flush in IR/DR changes. However it shouldn't be needed.
OK. I thought that was needed because of what the 32b specs say in "Synchronization Requirements for Special Registers and for Lookaside Buffers", a "Context-synchronizing instruction" is required after a mtmsr({I,D}R) and also because changing IR can break implicit branching.
But I might just misunderstand all of it as I am discovering.
Quoted 8 lines
I suspect all of that is papering over another bug somewhere else which got exposed by the split I/D mode, since we no longer over-flush on transitions to/from real-mode. So we must be missing flushes elsewhere, possibly some G3 specific stuff, or there always was some kind of bug in the TLB flushing on 32-bit that got somewhat masked by the over- flushing we used to do.
From what I see, darwin loops on tlbie :
0x000952fc: mtctr r0 0x00095300: tlbie r6 0x00095304: addi r6,r6,4096 0x00095308: bdnz+ 0x95300 0x0009530c: mtcrf 128,r11 0x00095310: sync 0x00095314: eieio 0x00095318: bns- 0x95328
and this is done on the G4, but not necessarily on the G3, it depends on r11 which contains some bits of SPRG2 :
0x0009531c: tlbsync 0x00095320: sync 0x00095324: isync
HID0 is also read and written to but to control cache bits.
Quoted 1 line
I need a repro-case.
Booting the darwin CD is enough.
Cheers,
C.
Quoted 98 lines
Cheers,
Ben.Quoted 95 lines
Tested on mac99 and g3beige with
qemu-system-ppc -cdrom darwinppc-602.cdr -boot d
Signed-off-by Cédric Le Goater <[email protected]>---
I think the hunk in
powerpc_excp()is needed if we don't generate a context synchronizing event. what is best to do ?target-ppc/cpu.h | 2 +- target-ppc/excp_helper.c | 10 ++++++++++ target-ppc/helper_regs.h | 9 ++++++++- target-ppc/translate.c | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-)Index:
qemu-dgibson-for-2.7.git/target-ppc/translate.c
===================================================================target-ppc/translate.c +1
-1@@ -3290,7 +3290,7 @@ static void gen_eieio(DisasContext *ctx) { } -#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void gen_check_tlb_flush (DisasContext *ctx) {TCGv_i32 t =tcg_temp_new_i32 ();Index:
qemu-dgibson-for-2.7.git/target-ppc/cpu.h
===================================================================target-ppc/cpu.h +1
-0@@ -958,9 +958,9 @@ struct CPUPPCState {/* PowerPC 64 SLB area */ ppc_slb_t slb[MAX_SLB_ENTRIES ];int32_t slb_nr; +#endif /* tcg TLB needs flush (deferred slb inval instruction typically) */
uint32_t tlb_need_flush; -#endif /* segment registers */ hwaddr htab_base; /* mask used to normalize hash value to PTEG index */Index:
qemu-dgibson-for-2.7.git/target-ppc/helper_regs.h
===================================================================target-ppc/helper_regs.h +8
-1@@ -121,6 +121,13 @@ static inline int hreg_store_msr(CPUPPCS }if (((value >>MSR_IR ) &1 ) != msr_ir || ((value >>MSR_DR ) &1 ) != msr_dr) { +/* A change of the instruction relocation bit in the MSR can +* cause an implicit branch in the address space. This +* requires a tlb flush. +*/ +if (env->mmu_model &POWERPC_MMU_32B ) { + env->tlb_need_flush =1 ; + } cs->interrupt_request |=CPU_INTERRUPT_EXITTB ; } if ((env->mmu_model & POWERPC_MMU_BOOKE) &&@@ -151,7 +158,7 @@ static inline int hreg_store_msr(CPUPPCSreturn excp; } -#if !defined(CONFIG_USER_ONLY ) && defined(TARGET_PPC64 ) +#if !defined(CONFIG_USER_ONLY )static inline void check_tlb_flush (CPUPPCState *env) {CPUState *cs =CPU (ppc_env_get_cpu (env));Index:
qemu-dgibson-for-2.7.git/target-ppc/excp_helper.c
===================================================================target-ppc/excp_helper.c +10
-0@@ -709,6 +709,16 @@ static inline void powerpc_excp(PowerPCC } }#endif +if (((new_msr >>MSR_IR ) &1 ) != msr_ir || + ((new_msr >>MSR_DR ) &1 ) != msr_dr) { +/* A change of the instruction relocation bit in the MSR can +* cause an implicit branch in the address space. This +* requires a tlb flush. +*/ +if (env->mmu_model &POWERPC_MMU_32B ) { + env->tlb_need_flush =1 ; + } + }/* We don't use hreg_store_msr here as already have treated * any special case that could occur. Just store MSR and update hflags
*
Quoted 11 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV modeCédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilege
I've applied this series to ppc-for-2.7, swapping the order of patches 1 & 2 as Marc requested. I've also applied the extra patch to fix tlb flushing on 32-bit cpus. I aim to send a pull request once I've done my usual tests.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 11 lines · David Gibson
Quoted 10 lines · Cédric Le Goater
This is follow up to complete the serie "ppc: preparing pnv landing (round 2)" plus a little fix on instruction privileges.
Tested on a POWER8 pserie guest and on mac99.
Benjamin Herrenschmidt (2):
ppc: Fixhreg_store_msr()so that non-HV mode cannot alter MSR:HV
ppc: Better figure out if processor has HV mode
Quoted 7 lines
Quoted 2 lines
Cédric Le Goater (1):
ppc: fix hrfid, tlbia and slbia privilegeI've applied this series to ppc-for-2.7, swapping the order of patches 1 & 2 as Marc requested. I've also applied the extra patch to fix tlb flushing on 32-bit cpus. I aim to send a pull request once I've done my usual tests.
I'm not sure that 32-bit patch is correct. We shouldn't have to flush on IR/DR transitions at all, that's the whole point of the split I/D code.
I think something else is wrong.
Cheers,
Ben.
Quoted 6 lines · Benjamin Herrenschmidt
I'm not sure that 32-bit patch is correct. We shouldn't have to flush on IR/DR transitions at all, that's the whole point of the split I/D code.
I think something else is wrong.
Note: With whatever's in this branch, OpenBIOS won't start at all
Cheers,
Ben.
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 6 lines · Benjamin Herrenschmidt
I'm not sure that 32-bit patch is correct. We shouldn't have to flush on IR/DR transitions at all, that's the whole point of the split I/D code.
I think something else is wrong.
Note: With whatever's in this branch, OpenBIOS won't start at all
Yeah, there's a patch currently pending upstream to fix the serial port which hangs OpenBIOS upon startup:
https://lists.nongnu.org/archive/html/qemu-devel/2016-06/msg00035.html.
The best reproducer is to run from David's ppc-for-2.7 branch with the above patch applied manually and then try booting the following ISOs which now panic on boot with the split I/D MMU mode enabled:
Darwin/ppc: https://opensource.apple.com/static/iso/darwinppc-602.cdr.gz HelenOS: http://www.helenos.org/releases/HelenOS-0.6.0-ppc32.iso
I've seen some DMA coherence issues related to macio in some of my local tests and so I'm also testing with my beta patch to switch macio over to use the DMA helpers here:
https://lists.nongnu.org/archive/html/qemu-devel/2016-05/msg04907.html.
ATB,
Mark.
Quoted 4 lines · Mark Cave-Ayland
The best reproducer is to run from David's ppc-for-2.7 branch with the above patch applied manually and then try booting the following ISOs which now panic on boot with the split I/D MMU mode enabled:
So at least HelenOS is fixed by this:
target-ppc/mmu_helper.c +0 -0
@@ -1969,6 +1969,11 @@ void ppc_tlb_invalidate_one(CPUPPCState *env, target_ulong addr)
/* XXX: this case should be optimized,
* giving a mask to tlb_flush_page
*/
+ /* This is broken, some CPUs invalidate a whole congruence + * class on an even smaller subset of bits and some OSes take + * advantage of this. Just blow the whole thing away. + */
+#if 0
tlb_flush_page(cs, addr | (0x0 << 28)); tlb_flush_page(cs, addr | (0x1 << 28)); tlb_flush_page(cs, addr | (0x2 << 28)); @@ -1985,6 +1990,9 @@ void ppc_tlb_invalidate_one(CPUPPCState *env, target_ulong addr) tlb_flush_page(cs, addr | (0xD << 28)); tlb_flush_page(cs, addr | (0xE << 28)); tlb_flush_page(cs, addr | (0xF << 28));
+#else
+ tlb_flush(cs, 1);
+#endif
break;
#if defined(TARGET_PPC64)
case POWERPC_MMU_64B:
I'll check Darwin...
Cheers,
Ben.
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 5 lines · Mark Cave-Ayland
The best reproducer is to run from David's ppc-for-2.7 branch with the above patch applied manually and then try booting the following ISOs which now panic on boot with the split I/D MMU mode enabled:
So at least HelenOS is fixed by this:
Note that Cedric is right, the TLB flush batching isn't done for 32- bit, and we could do it, it would probably improve performances, but it needs to be done properly :-) I'll look into it next.
Quoted 32 lines
target-ppc/mmu_helper.c +2
-0@@ -1969,6 +1969,11 @@ void ppc_tlb_invalidate_one(CPUPPCState *env, target_ulong addr) /* XXX: this case should be optimized, * giving a mask to tlb_flush_page */ + /* This is broken, some CPUs invalidate a whole congruence +* class on an even smaller subset of bits and some OSes take
+ * advantage of this. Just blow the whole thing away. + */
+#if 0tlb_flush_page(cs, addr | (0x0 << 28)); tlb_flush_page(cs, addr | (0x1 << 28)); tlb_flush_page(cs, addr | (0x2 << 28));target-ppc/mmu_helper.c +3
-0@@ -1985,6 +1990,9 @@ void ppc_tlb_invalidate_one(CPUPPCState *env, target_ulong addr) tlb_flush_page(cs, addr | (0xD << 28)); tlb_flush_page(cs, addr | (0xE << 28)); tlb_flush_page(cs, addr | (0xF << 28)); +#else + tlb_flush(cs, 1); +#endif break; #if defined(TARGET_PPC64)case
POWERPC_MMU_64B:I'll check Darwin...
Cheers,
Ben.