aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2010-08-02 20:29:27 -0400
committerAvi Kivity <avi@redhat.com>2010-10-24 04:52:11 -0400
commitdf1bfa25d81f9451715ccbbb67551e0f792ceec8 (patch)
treec0a214d5acd8f152e53b11f5972d9c19fe413641 /arch/powerpc
parent8e8651783ff2458f31098be7c2abacf2fcab054a (diff)
KVM: PPC: Put segment registers in shared page
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>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/include/asm/kvm_book3s.h1
-rw-r--r--arch/powerpc/include/asm/kvm_para.h1
-rw-r--r--arch/powerpc/kvm/book3s.c7
-rw-r--r--arch/powerpc/kvm/book3s_32_mmu.c12
-rw-r--r--arch/powerpc/kvm/powerpc.c2
5 files changed, 11 insertions, 12 deletions
diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
index 08846520220c..be8aac24ba83 100644
--- a/arch/powerpc/include/asm/kvm_book3s.h
+++ b/arch/powerpc/include/asm/kvm_book3s.h
@@ -70,7 +70,6 @@ struct kvmppc_vcpu_book3s {
70 u64 vsid; 70 u64 vsid;
71 } slb_shadow[64]; 71 } slb_shadow[64];
72 u8 slb_shadow_max; 72 u8 slb_shadow_max;
73 u32 sr[16];
74 struct kvmppc_bat ibat[8]; 73 struct kvmppc_bat ibat[8];
75 struct kvmppc_bat dbat[8]; 74 struct kvmppc_bat dbat[8];
76 u64 hid[6]; 75 u64 hid[6];
diff --git a/arch/powerpc/include/asm/kvm_para.h b/arch/powerpc/include/asm/kvm_para.h
index 43c1b2260af8..d79fd0910964 100644
--- a/arch/powerpc/include/asm/kvm_para.h
+++ b/arch/powerpc/include/asm/kvm_para.h
@@ -38,6 +38,7 @@ struct kvm_vcpu_arch_shared {
38 __u64 msr; 38 __u64 msr;
39 __u32 dsisr; 39 __u32 dsisr;
40 __u32 int_pending; /* Tells the guest if we have an interrupt */ 40 __u32 int_pending; /* Tells the guest if we have an interrupt */
41 __u32 sr[16];
41}; 42};
42 43
43#define KVM_SC_MAGIC_R0 0x4b564d21 /* "KVM!" */ 44#define KVM_SC_MAGIC_R0 0x4b564d21 /* "KVM!" */
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index 34472afbb3ec..02a9cb165d53 100644
--- a/arch/powerpc/kvm/book3s.c
+++ b/arch/powerpc/kvm/book3s.c
@@ -1161,10 +1161,9 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
1161 sregs->u.s.ppc64.slb[i].slbv = vcpu3s->slb[i].origv; 1161 sregs->u.s.ppc64.slb[i].slbv = vcpu3s->slb[i].origv;
1162 } 1162 }
1163 } else { 1163 } else {
1164 for (i = 0; i < 16; i++) { 1164 for (i = 0; i < 16; i++)
1165 sregs->u.s.ppc32.sr[i] = vcpu3s->sr[i]; 1165 sregs->u.s.ppc32.sr[i] = vcpu->arch.shared->sr[i];
1166 sregs->u.s.ppc32.sr[i] = vcpu3s->sr[i]; 1166
1167 }
1168 for (i = 0; i < 8; i++) { 1167 for (i = 0; i < 8; i++) {
1169 sregs->u.s.ppc32.ibat[i] = vcpu3s->ibat[i].raw; 1168 sregs->u.s.ppc32.ibat[i] = vcpu3s->ibat[i].raw;
1170 sregs->u.s.ppc32.dbat[i] = vcpu3s->dbat[i].raw; 1169 sregs->u.s.ppc32.dbat[i] = vcpu3s->dbat[i].raw;
diff --git a/arch/powerpc/kvm/book3s_32_mmu.c b/arch/powerpc/kvm/book3s_32_mmu.c
index d4ff76fd1ff9..c8cefdd15fd8 100644
--- a/arch/powerpc/kvm/book3s_32_mmu.c
+++ b/arch/powerpc/kvm/book3s_32_mmu.c
@@ -88,9 +88,9 @@ static int kvmppc_mmu_book3s_32_xlate_bat(struct kvm_vcpu *vcpu, gva_t eaddr,
88static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid, 88static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
89 u64 *vsid); 89 u64 *vsid);
90 90
91static u32 find_sr(struct kvmppc_vcpu_book3s *vcpu_book3s, gva_t eaddr) 91static u32 find_sr(struct kvm_vcpu *vcpu, gva_t eaddr)
92{ 92{
93 return vcpu_book3s->sr[(eaddr >> 28) & 0xf]; 93 return vcpu->arch.shared->sr[(eaddr >> 28) & 0xf];
94} 94}
95 95
96static u64 kvmppc_mmu_book3s_32_ea_to_vp(struct kvm_vcpu *vcpu, gva_t eaddr, 96static 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,
211 int i; 211 int i;
212 int found = 0; 212 int found = 0;
213 213
214 sre = find_sr(vcpu_book3s, eaddr); 214 sre = find_sr(vcpu, eaddr);
215 215
216 dprintk_pte("SR 0x%lx: vsid=0x%x, raw=0x%x\n", eaddr >> 28, 216 dprintk_pte("SR 0x%lx: vsid=0x%x, raw=0x%x\n", eaddr >> 28,
217 sr_vsid(sre), sre); 217 sr_vsid(sre), sre);
@@ -335,13 +335,13 @@ static int kvmppc_mmu_book3s_32_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
335 335
336static u32 kvmppc_mmu_book3s_32_mfsrin(struct kvm_vcpu *vcpu, u32 srnum) 336static u32 kvmppc_mmu_book3s_32_mfsrin(struct kvm_vcpu *vcpu, u32 srnum)
337{ 337{
338 return to_book3s(vcpu)->sr[srnum]; 338 return vcpu->arch.shared->sr[srnum];
339} 339}
340 340
341static void kvmppc_mmu_book3s_32_mtsrin(struct kvm_vcpu *vcpu, u32 srnum, 341static void kvmppc_mmu_book3s_32_mtsrin(struct kvm_vcpu *vcpu, u32 srnum,
342 ulong value) 342 ulong value)
343{ 343{
344 to_book3s(vcpu)->sr[srnum] = value; 344 vcpu->arch.shared->sr[srnum] = value;
345 kvmppc_mmu_map_segment(vcpu, srnum << SID_SHIFT); 345 kvmppc_mmu_map_segment(vcpu, srnum << SID_SHIFT);
346} 346}
347 347
@@ -358,7 +358,7 @@ static int kvmppc_mmu_book3s_32_esid_to_vsid(struct kvm_vcpu *vcpu, ulong esid,
358 u64 gvsid = esid; 358 u64 gvsid = esid;
359 359
360 if (vcpu->arch.shared->msr & (MSR_DR|MSR_IR)) { 360 if (vcpu->arch.shared->msr & (MSR_DR|MSR_IR)) {
361 sr = find_sr(to_book3s(vcpu), ea); 361 sr = find_sr(vcpu, ea);
362 if (sr_valid(sr)) 362 if (sr_valid(sr))
363 gvsid = sr_vsid(sr); 363 gvsid = sr_vsid(sr);
364 } 364 }
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 496d7a5200dc..028891c0baff 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -66,7 +66,7 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
66 vcpu->arch.magic_page_pa = param1; 66 vcpu->arch.magic_page_pa = param1;
67 vcpu->arch.magic_page_ea = param2; 67 vcpu->arch.magic_page_ea = param2;
68 68
69 r2 = 0; 69 r2 = KVM_MAGIC_FEAT_SR;
70 70
71 r = HC_EV_SUCCESS; 71 r = HC_EV_SUCCESS;
72 break; 72 break;