KVM: PPC: Book3S HV: Fix guest r11 corruption with POWER9 TM workarounds
PATCH 1/1 KVM: PPC: Book3S HV: Fix guest r11 corruption with POWER9 TM workarounds
When we come into the softpatch handler (0x1500), we use r11 to store the HSRR0 for later use by the denorm handler.
We also use the softpatch handler for the TM workarounds for POWER9. Unfortunately, in kvmppc_interrupt_hv we later store r11 out to the vcpu assuming it's still what we got from userspace.
This causes r11 to be corrupted in the VCPU and hence when we restore the guest, we get a corrupted r11. We've seen this when running TM tests inside guests on P9.
This fixes the problem by only touching r11 in the denorm case.
--- arch/powerpc/kernel/exceptions-64s.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/exceptions-64s.S +2 -2
@@ -1314,9 +1314,7 @@ EXC_REAL_BEGIN(denorm_exception_hv, 0x1500, 0x100) #ifdef CONFIG_PPC_DENORMALISATION mfspr r10,SPRN_HSRR1 - mfspr r11,SPRN_HSRR0 /* save HSRR0 */ andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */ - addi r11,r11,-4 /* HSRR0 is next instruction */ bne+ denorm_assist #endif
@@ -1382,6 +1380,8 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) */ XVCPSGNDP32(32) denorm_done: + mfspr r11,SPRN_HSRR0 + subi r11,r11,4 mtspr SPRN_HSRR0,r11 mtcrf 0x80,r9 ld r9,PACA_EXGEN+EX_R9(r13)
Signature · 1 line
2.17.1
Michael Ellerman
AppliedQuoted 11 lines · Michael Neuling
When we come into the softpatch handler (
0x1500), we use r11 to store the HSRR0 for later use by the denorm handler.We also use the softpatch handler for the TM workarounds for POWER9. Unfortunately, in
kvmppc_interrupt_hvwe later store r11 out to the vcpu assuming it's still what we got from userspace.This causes r11 to be corrupted in the VCPU and hence when we restore the guest, we get a corrupted r11. We've seen this when running TM tests inside guests on P9.
Quoted 7 lines
This fixes the problem by only touching r11 in the denorm case.
Fixes 4bb3c7a020 ("KVM: PPC: Book3S HV: Work around transactional memory bugs in POWER9")Cc <[email protected]> # 4.17+Reviewed-by Paul Mackerras <[email protected]>Signed-off-by Michael Neuling <[email protected]>
Applied to powerpc fixes, thanks.
https://git.kernel.org/powerpc/c/f14040bca89258b8a1c71e2112e430
cheers
A message that is not in the archive (sent off-list or not yet received): 20180914165657.GB6306@MiWiFi-R3L-srv
sathnaga
Tested-byQuoted 22 lines · On 2018-09-14 22:26, [email protected] wrote:
Date: Thu, 13 Sep 2018 15:33:47 +1000
From: Michael Neuling <[email protected]>
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: KVM: PPC: Book3S HV: Fix guest r11 corruption with POWER9 TM workaroundsWhen we come into the softpatch handler (
0x1500), we use r11 to store the HSRR0 for later use by the denorm handler.We also use the softpatch handler for the TM workarounds for POWER9. Unfortunately, in
kvmppc_interrupt_hvwe later store r11 out to the vcpu assuming it's still what we got from userspace.This causes r11 to be corrupted in the VCPU and hence when we restore the guest, we get a corrupted r11. We've seen this when running TM tests inside guests on P9.
This fixes the problem by only touching r11 in the denorm case.
Fixes 4bb3c7a020 ("KVM: PPC: Book3S HV: Work around transactional
Quoted 9 lines
memory bugs in POWER9")
Cc <[email protected]> # 4.17+Reviewed-by Paul Mackerras <[email protected]>Signed-off-by Michael Neuling <[email protected]>--- arch/powerpc/kernel/exceptions-64s.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Test details: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1792501
Regards,
-Satheesh.
Quoted 26 lines
arch/powerpc/kernel/exceptions-64s.S +2
-2@@ -1314,9 +1314,7 @@ EXC_REAL_BEGIN(denorm_exception_hv, 0x1500, 0x100) #ifdef CONFIG_PPC_DENORMALISATION mfspr r10,SPRN_HSRR1 - mfspr r11,SPRN_HSRR0 /* save HSRR0 */ andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */ - addi r11,r11,-4 /* HSRR0 is next instruction */ bne+ denorm_assist #endif@@ -1382,6 +1380,8 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) */ XVCPSGNDP32(32) denorm_done: + mfspr r11,SPRN_HSRR0 + subi r11,r11,4 mtspr SPRN_HSRR0,r11 mtcrf 0x80,r9 ld r9,PACA_EXGEN+EX_R9(r13)