]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
KVM: PPC: BookE: Add support for vcpu->mode
authorAlexander Graf <agraf@suse.de>
Wed, 8 Aug 2012 18:44:20 +0000 (20:44 +0200)
committerAlexander Graf <agraf@suse.de>
Fri, 14 Sep 2012 14:25:03 +0000 (16:25 +0200)
Generic KVM code might want to know whether we are inside guest context
or outside. It also wants to be able to push us out of guest context.

Add support to the BookE code for the generic vcpu->mode field that describes
the above states.

Signed-off-by: Alexander Graf <agraf@suse.de>
arch/powerpc/kvm/booke.c

index bcf87fe891797de569db22fc333be6c8ed1a1f41..70a86c0a9d854f166c212bd6eb6022b9c804ce6d 100644 (file)
@@ -501,6 +501,15 @@ static int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu)
                        continue;
                }
 
+               if (vcpu->mode == EXITING_GUEST_MODE) {
+                       r = 1;
+                       break;
+               }
+
+               /* Going into guest context! Yay! */
+               vcpu->mode = IN_GUEST_MODE;
+               smp_wmb();
+
                break;
        }
 
@@ -572,6 +581,8 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
        kvm_guest_exit();
 
 out:
+       vcpu->mode = OUTSIDE_GUEST_MODE;
+       smp_wmb();
        local_irq_enable();
        return ret;
 }