KVM: PPC: Put segment registers in shared page
authorAlexander Graf <agraf@suse.de>
Tue, 3 Aug 2010 00:29:27 +0000 (02:29 +0200)
committerAvi Kivity <avi@redhat.com>
Sun, 24 Oct 2010 08:52:11 +0000 (10:52 +0200)
Now that the actual mtsr doesn't do anything anymore, we can move the sr
contents over to the shared page, so a guest can directly read and write
its sr contents from guest context.

Signed-off-by: Alexander Graf <agraf@suse.de>
arch/powerpc/include/asm/kvm_book3s.h
arch/powerpc/include/asm/kvm_para.h
arch/powerpc/kvm/book3s.c
arch/powerpc/kvm/book3s_32_mmu.c
arch/powerpc/kvm/powerpc.c

index 08846520220c2fd852b50be2d49ad759f75307cb..be8aac24ba83f0383b4899acb748929a37ab0bbd 100644 (file)
@@ -70,7 +70,6 @@ struct kvmppc_vcpu_book3s {
                u64 vsid;
        } slb_shadow[64];
        u8 slb_shadow_max;
-       u32 sr[16];
        struct kvmppc_bat ibat[8];
        struct kvmppc_bat dbat[8];
        u64 hid[6];
index 43c1b2260af85bef8e4d165051f6fcea1f912831..d79fd09109649acfd16e539e6587bda594b9128c 100644 (file)
@@ -38,6 +38,7 @@ struct kvm_vcpu_arch_shared {
        __u64 msr;
        __u32 dsisr;
        __u32 int_pending;      /* Tells the guest if we have an interrupt */
+       __u32 sr[16];
 };
 
 #define KVM_SC_MAGIC_R0                0x4b564d21 /* "KVM!" */
index 34472afbb3ec8fa596ef69b2422128e0141595a0..02a9cb165d53cff3e8c373fdd3dc6d5c42bbfae2 100644 (file)
@@ -1161,10 +1161,9 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
                        sregs->u.s.ppc64.slb[i].slbv = vcpu3s->slb[i].origv;
                }
        } else {
-               for (i = 0; i < 16; i++) {
-                       sregs->u.s.ppc32.sr[i] = vcpu3s->sr[i];
-                       sregs->u.s.ppc32.sr[i] = vcpu3s->sr[i];
-               }
+               for (i = 0; i < 16; i++)
+                       sregs->u.s.ppc32.sr[i] = vcpu->arch.shared->sr[i];
+
                for (i = 0; i < 8; i++) {
                        sregs->u.s.ppc32.ibat[i] = vcpu3s->ibat[i].raw;
                        sregs->u.s.ppc32.dbat[i] = vcpu3s->dbat[i].raw;
index d4ff76fd1ff9ca4d66cb2a6a439a4cf30f132786..c8cefdd15fd8a2fa03661511e3ca6d2d7c730877 100644 (file)
@@ -88,9 +88,9 @@ static int kvmppc_mmu_book3s_32_xlate_bat(struct kvm_vcpu *vcpu, gva_t eaddr,
 static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
                                             u64 *vsid);
 
-static u32 find_sr(struct kvmppc_vcpu_book3s *vcpu_book3s, gva_t eaddr)
+static u32 find_sr(struct kvm_vcpu *vcpu, gva_t eaddr)
 {
-       return vcpu_book3s->sr[(eaddr >> 28) & 0xf];
+       return vcpu->arch.shared->sr[(eaddr >> 28) & 0xf];
 }
 
 static u64 kvmppc_mmu_book3s_32_ea_to_vp(struct kvm_vcpu *vcpu, gva_t eaddr,
@@ -211,7 +211,7 @@ static int kvmppc_mmu_book3s_32_xlate_pte(struct kvm_vcpu *vcpu, gva_t eaddr,
        int i;
        int found = 0;
 
-       sre = find_sr(vcpu_book3s, eaddr);
+       sre = find_sr(vcpu, eaddr);
 
        dprintk_pte("SR 0x%lx: vsid=0x%x, raw=0x%x\n", eaddr >> 28,
                    sr_vsid(sre), sre);
@@ -335,13 +335,13 @@ static int kvmppc_mmu_book3s_32_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
 
 static u32 kvmppc_mmu_book3s_32_mfsrin(struct kvm_vcpu *vcpu, u32 srnum)
 {
-       return to_book3s(vcpu)->sr[srnum];
+       return vcpu->arch.shared->sr[srnum];
 }
 
 static void kvmppc_mmu_book3s_32_mtsrin(struct kvm_vcpu *vcpu, u32 srnum,
                                        ulong value)
 {
-       to_book3s(vcpu)->sr[srnum] = value;
+       vcpu->arch.shared->sr[srnum] = value;
        kvmppc_mmu_map_segment(vcpu, srnum << SID_SHIFT);
 }
 
@@ -358,7 +358,7 @@ static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
        u64 gvsid = esid;
 
        if (vcpu->arch.shared->msr & (MSR_DR|MSR_IR)) {
-               sr = find_sr(to_book3s(vcpu), ea);
+               sr = find_sr(vcpu, ea);
                if (sr_valid(sr))
                        gvsid = sr_vsid(sr);
        }
index 496d7a5200dc4ff94fd4c25b38c84b4f530b7116..028891c0baff97a7ec24d3d772b23b6b55701e1d 100644 (file)
@@ -66,7 +66,7 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
                vcpu->arch.magic_page_pa = param1;
                vcpu->arch.magic_page_ea = param2;
 
-               r2 = 0;
+               r2 = KVM_MAGIC_FEAT_SR;
 
                r = HC_EV_SUCCESS;
                break;