diff options
author | Scott Wood <scottwood@freescale.com> | 2012-08-22 17:03:50 +0200 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2012-10-05 23:38:54 +0200 |
commit | 5bd1cf118533aba41b3fbd4834e6362a9237db71 (patch) | |
tree | 33cf8766cec82d210d95755a8291855c7f199705 /arch/powerpc/kvm/powerpc.c | |
parent | KVM: PPC: e500: MMU API: fix leak of shared_tlb_pages (diff) | |
download | linux-5bd1cf118533aba41b3fbd4834e6362a9237db71.tar.xz linux-5bd1cf118533aba41b3fbd4834e6362a9237db71.zip |
KVM: PPC: set IN_GUEST_MODE before checking requests
Avoid a race as described in the code comment.
Also remove a related smp_wmb() from booke's kvmppc_prepare_to_enter().
I can't see any reason for it, and the book3s_pr version doesn't have it.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to '')
-rw-r--r-- | arch/powerpc/kvm/powerpc.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 6002ea938a48..deb0d596d815 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -78,7 +78,16 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu) break; } + vcpu->mode = IN_GUEST_MODE; + + /* + * Reading vcpu->requests must happen after setting vcpu->mode, + * so we don't miss a request because the requester sees + * OUTSIDE_GUEST_MODE and assumes we'll be checking requests + * before next entering the guest (and thus doesn't IPI). + */ smp_mb(); + if (vcpu->requests) { /* Make sure we process requests preemptable */ local_irq_enable(); @@ -111,11 +120,6 @@ int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu) #endif kvm_guest_enter(); - - /* Going into guest context! Yay! */ - vcpu->mode = IN_GUEST_MODE; - smp_wmb(); - break; } |