All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] PPC: Fix race in mtmsr paravirt implementation
@ 2011-10-13  9:59 Bharat Bhushan
  2011-10-13 10:11   ` Alexander Graf
  0 siblings, 1 reply; 3+ messages in thread
From: Bharat Bhushan @ 2011-10-13  9:59 UTC (permalink / raw)
  To: kvm-ppc

The current implementation of mtmsr and mtmsrd are racy in that it does:

  * check (int_pending = 0)
  ---> host sets int_pending = 1 <---
  * write shared page
  * done

while instead we should check for int_pending after the shared page is written.

Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
---
v2:
 - msr.ee and int_pending are checked as earlier.

 arch/powerpc/kernel/kvm_emul.S |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/kvm_emul.S b/arch/powerpc/kernel/kvm_emul.S
index f2b1b25..3d64c57 100644
--- a/arch/powerpc/kernel/kvm_emul.S
+++ b/arch/powerpc/kernel/kvm_emul.S
@@ -167,6 +167,9 @@ maybe_stay_in_guest:
 kvm_emulate_mtmsr_reg2:
 	ori	r30, r0, 0
 
+	/* Put MSR into magic page because we don't call mtmsr */
+	STL64(r30, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
+
 	/* Check if we have to fetch an interrupt */
 	lwz	r31, (KVM_MAGIC_PAGE + KVM_MAGIC_INT)(0)
 	cmpwi	r31, 0
@@ -174,15 +177,10 @@ kvm_emulate_mtmsr_reg2:
 
 	/* Check if we may trigger an interrupt */
 	andi.	r31, r30, MSR_EE
-	beq	no_mtmsr
-
-	b	do_mtmsr
+	bne	do_mtmsr
 
 no_mtmsr:
 
-	/* Put MSR into magic page because we don't call mtmsr */
-	STL64(r30, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
-
 	SCRATCH_RESTORE
 
 	/* Go back to caller */
-- 
1.7.0.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-13 10:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-13  9:59 [PATCH V2] PPC: Fix race in mtmsr paravirt implementation Bharat Bhushan
2011-10-13 10:11 ` Alexander Graf
2011-10-13 10:11   ` Alexander Graf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.