Skip to content

Commit 87a11bb

Browse files
sjitindarsinghmpe
authored andcommitted
KVM: PPC: Book3S HV: Work around XER[SO] bug in fake suspend mode
This works around a hardware bug in "Nimbus" POWER9 DD2.2 processors, where a treclaim performed in fake suspend mode can cause subsequent reads from the XER register to return inconsistent values for the SO (summary overflow) bit. The inconsistent SO bit state can potentially be observed on any thread in the core. We have to do the treclaim because that is the only way to get the thread out of suspend state (fake or real) and into non-transactional state. The workaround for the bug is to force the core into SMT4 mode before doing the treclaim. This patch adds the code to do that, conditional on the CPU_FTR_P9_TM_XER_SO_BUG feature bit. Signed-off-by: Suraj Jitindar Singh <[email protected]> Signed-off-by: Paul Mackerras <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 4bb3c7a commit 87a11bb

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

arch/powerpc/kvm/book3s_hv_rmhandlers.S

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3101,6 +3101,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
31013101
kvmppc_save_tm:
31023102
mflr r0
31033103
std r0, PPC_LR_STKOFF(r1)
3104+
stdu r1, -PPC_MIN_STKFRM(r1)
31043105

31053106
/* Turn on TM. */
31063107
mfmsr r8
@@ -3120,8 +3121,16 @@ BEGIN_FTR_SECTION
31203121
mfspr r6, SPRN_TEXASR
31213122
std r6, VCPU_ORIG_TEXASR(r9)
31223123

3123-
rldicl. r8, r8, 64 - MSR_TS_S_LG, 62
3124+
lbz r0, HSTATE_FAKE_SUSPEND(r13) /* Were we fake suspended? */
3125+
cmpwi r0, 0
31243126
beq 3f
3127+
rldicl. r8, r8, 64 - MSR_TS_S_LG, 62 /* Did we actually hrfid? */
3128+
beq 4f
3129+
BEGIN_FTR_SECTION_NESTED(96)
3130+
bl pnv_power9_force_smt4_catch
3131+
END_FTR_SECTION_NESTED(CPU_FTR_P9_TM_XER_SO_BUG, CPU_FTR_P9_TM_XER_SO_BUG, 96)
3132+
nop
3133+
3:
31253134
END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_HV_ASSIST)
31263135

31273136
/* Clear the MSR RI since r1, r13 are all going to be foobar. */
@@ -3138,7 +3147,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_HV_ASSIST)
31383147

31393148
/* If doing TM emulation on POWER9 DD2.2, check for fake suspend mode */
31403149
BEGIN_FTR_SECTION
3141-
3:
31423150
lbz r9, HSTATE_FAKE_SUSPEND(r13)
31433151
cmpwi r9, 0
31443152
beq 2f
@@ -3150,13 +3158,18 @@ BEGIN_FTR_SECTION
31503158
/* Reload stack pointer and TOC. */
31513159
ld r1, HSTATE_HOST_R1(r13)
31523160
ld r2, PACATOC(r13)
3161+
/* Set MSR RI now we have r1 and r13 back. */
31533162
li r5, MSR_RI
31543163
mtmsrd r5, 1
31553164
HMT_MEDIUM
31563165
ld r6, HSTATE_DSCR(r13)
31573166
mtspr SPRN_DSCR, r6
3158-
li r0, 0
3159-
stb r0, HSTATE_FAKE_SUSPEND(r13)
3167+
BEGIN_FTR_SECTION_NESTED(96)
3168+
bl pnv_power9_force_smt4_release
3169+
END_FTR_SECTION_NESTED(CPU_FTR_P9_TM_XER_SO_BUG, CPU_FTR_P9_TM_XER_SO_BUG, 96)
3170+
nop
3171+
3172+
4:
31603173
mfspr r3, SPRN_PSSCR
31613174
/* PSSCR_FAKE_SUSPEND is a write-only bit, but clear it anyway */
31623175
li r0, PSSCR_FAKE_SUSPEND
@@ -3244,6 +3257,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_HV_ASSIST)
32443257
std r6, VCPU_TFIAR(r9)
32453258
std r7, VCPU_TEXASR(r9)
32463259

3260+
addi r1, r1, PPC_MIN_STKFRM
32473261
ld r0, PPC_LR_STKOFF(r1)
32483262
mtlr r0
32493263
blr
@@ -3278,6 +3292,8 @@ kvmppc_restore_tm:
32783292
mtspr SPRN_TFIAR, r6
32793293
mtspr SPRN_TEXASR, r7
32803294

3295+
li r0, 0
3296+
stb r0, HSTATE_FAKE_SUSPEND(r13)
32813297
ld r5, VCPU_MSR(r4)
32823298
rldicl. r5, r5, 64 - MSR_TS_S_LG, 62
32833299
beqlr /* TM not active in guest */

0 commit comments

Comments
 (0)