Skip to content

Commit

Permalink
PPC: Fix race in mtmsr paravirt implementation
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
  • Loading branch information
Bharat Bhushan authored and Avi Kivity committed Mar 5, 2012
1 parent 95325e6 commit f920842
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions arch/powerpc/kernel/kvm_emul.S
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,20 @@ 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
beq+ no_mtmsr

/* 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 */
Expand Down

0 comments on commit f920842

Please sign in to comment.