aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2013-09-05 23:24:35 -0400
committerAlexander Graf <agraf@suse.de>2013-10-17 08:45:01 -0400
commit8c2dbb79c62e9da4857b873435925d3654d9fccd (patch)
treef2ddb353aa55859891e2e4d9a031d27d8974c354
parentc934243ca0aa464610a8b8ff85c7a777bf066ce4 (diff)
KVM: PPC: Book3S HV: Avoid unbalanced increments of VPA yield count
The yield count in the VPA is supposed to be incremented every time we enter the guest, and every time we exit the guest, so that its value is even when the vcpu is running in the guest and odd when it isn't. However, it's currently possible that we increment the yield count on the way into the guest but then find that other CPU threads are already exiting the guest, so we go back to nap mode via the secondary_too_late label. In this situation we don't increment the yield count again, breaking the relationship between the LSB of the count and whether the vcpu is in the guest. To fix this, we move the increment of the yield count to a point after we have checked whether other CPU threads are exiting. Signed-off-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Alexander Graf <agraf@suse.de>
-rw-r--r--arch/powerpc/kvm/book3s_hv_rmhandlers.S20
1 files changed, 10 insertions, 10 deletions
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index c91ae2b67845..0effcd144241 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -405,16 +405,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
405 /* Save R1 in the PACA */ 405 /* Save R1 in the PACA */
406 std r1, HSTATE_HOST_R1(r13) 406 std r1, HSTATE_HOST_R1(r13)
407 407
408 /* Increment yield count if they have a VPA */
409 ld r3, VCPU_VPA(r4)
410 cmpdi r3, 0
411 beq 25f
412 lwz r5, LPPACA_YIELDCOUNT(r3)
413 addi r5, r5, 1
414 stw r5, LPPACA_YIELDCOUNT(r3)
415 li r6, 1
416 stb r6, VCPU_VPA_DIRTY(r4)
41725:
418 /* Load up DAR and DSISR */ 408 /* Load up DAR and DSISR */
419 ld r5, VCPU_DAR(r4) 409 ld r5, VCPU_DAR(r4)
420 lwz r6, VCPU_DSISR(r4) 410 lwz r6, VCPU_DSISR(r4)
@@ -525,6 +515,16 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
525 mtspr SPRN_RMOR,r8 515 mtspr SPRN_RMOR,r8
526 isync 516 isync
527 517
518 /* Increment yield count if they have a VPA */
519 ld r3, VCPU_VPA(r4)
520 cmpdi r3, 0
521 beq 25f
522 lwz r5, LPPACA_YIELDCOUNT(r3)
523 addi r5, r5, 1
524 stw r5, LPPACA_YIELDCOUNT(r3)
525 li r6, 1
526 stb r6, VCPU_VPA_DIRTY(r4)
52725:
528 /* Check if HDEC expires soon */ 528 /* Check if HDEC expires soon */
529 mfspr r3,SPRN_HDEC 529 mfspr r3,SPRN_HDEC
530 cmpwi r3,10 530 cmpwi r3,10