diff mbox

KVM: PPC: Book3S HV: Fix case where HDEC is treated as 32-bit on POWER9

Message ID 20170825095212.GB14035@fergus.ozlabs.ibm.com
State Accepted
Headers show

Commit Message

Paul Mackerras Aug. 25, 2017, 9:52 a.m. UTC
Commit 2f2724630f7a ("KVM: PPC: Book3S HV: Cope with host using large
decrementer mode", 2017-05-22) added code to treat the hypervisor
decrementer (HDEC) as a 64-bit value on POWER9 rather than 32-bit.
Unfortunately, that commit missed one place where HDEC is treated
as a 32-bit value.  This fixes it.

This bug should not have any user-visible consequences that I can
think of, beyond an occasional unnecessary exit to the host kernel.
If the hypervisor decrementer has gone negative, then the bottom
32 bits will be negative for about 4 seconds after that, so as
long as we get out of the guest within those 4 seconds we won't
conclude that the HDEC interrupt is spurious.

Reported-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Fixes: 2f2724630f7a ("KVM: PPC: Book3S HV: Cope with host using large decrementer mode")
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
---
 arch/powerpc/kvm/book3s_hv_rmhandlers.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Paul Mackerras Aug. 31, 2017, 3:42 a.m. UTC | #1
On Fri, Aug 25, 2017 at 07:52:12PM +1000, Paul Mackerras wrote:
> Commit 2f2724630f7a ("KVM: PPC: Book3S HV: Cope with host using large
> decrementer mode", 2017-05-22) added code to treat the hypervisor
> decrementer (HDEC) as a 64-bit value on POWER9 rather than 32-bit.
> Unfortunately, that commit missed one place where HDEC is treated
> as a 32-bit value.  This fixes it.
> 
> This bug should not have any user-visible consequences that I can
> think of, beyond an occasional unnecessary exit to the host kernel.
> If the hypervisor decrementer has gone negative, then the bottom
> 32 bits will be negative for about 4 seconds after that, so as
> long as we get out of the guest within those 4 seconds we won't
> conclude that the HDEC interrupt is spurious.
> 
> Reported-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
> Fixes: 2f2724630f7a ("KVM: PPC: Book3S HV: Cope with host using large decrementer mode")
> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>

Patch applied to my kvm-ppc-next branch.

Paul.
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index c52184a..9f1521e 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -1280,7 +1280,8 @@  END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
 	cmpwi	r12,BOOK3S_INTERRUPT_HV_DECREMENTER
 	bne	2f
 	mfspr	r3,SPRN_HDEC
-	cmpwi	r3,0
+	EXTEND_HDEC(r3)
+	cmpdi	r3,0
 	mr	r4,r9
 	bge	fast_guest_return
 2: