aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kvm/book3s_32_mmu_host.c
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2010-04-19 20:49:53 -0400
committerAvi Kivity <avi@redhat.com>2010-05-17 05:19:07 -0400
commit251585b5d02152973dbc24c803ca322bb977d4a2 (patch)
treecce6b6beda97aaad86e5e31debc6f2fb2a4d8ebe /arch/powerpc/kvm/book3s_32_mmu_host.c
parent5156f274bb1ee1cfc22240445ef94f7dcfc9929d (diff)
KVM: PPC: Find HTAB ourselves
For KVM we need to find the location of the HTAB. We can either rely on internal data structures of the kernel or ask the hardware. Ben issued complaints about the internal data structure method, so let's switch it to our own inquiry of the HTAB. Now we're fully independend :-). CC: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc/kvm/book3s_32_mmu_host.c')
-rw-r--r--arch/powerpc/kvm/book3s_32_mmu_host.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/arch/powerpc/kvm/book3s_32_mmu_host.c b/arch/powerpc/kvm/book3s_32_mmu_host.c
index 2bb67e633de2..0bb66005338f 100644
--- a/arch/powerpc/kvm/book3s_32_mmu_host.c
+++ b/arch/powerpc/kvm/book3s_32_mmu_host.c
@@ -54,6 +54,9 @@
54#error Only 32 bit pages are supported for now 54#error Only 32 bit pages are supported for now
55#endif 55#endif
56 56
57static ulong htab;
58static u32 htabmask;
59
57static void invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte) 60static void invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte)
58{ 61{
59 volatile u32 *pteg; 62 volatile u32 *pteg;
@@ -217,14 +220,11 @@ static struct kvmppc_sid_map *find_sid_vsid(struct kvm_vcpu *vcpu, u64 gvsid)
217 return NULL; 220 return NULL;
218} 221}
219 222
220extern struct hash_pte *Hash;
221extern unsigned long _SDR1;
222
223static u32 *kvmppc_mmu_get_pteg(struct kvm_vcpu *vcpu, u32 vsid, u32 eaddr, 223static u32 *kvmppc_mmu_get_pteg(struct kvm_vcpu *vcpu, u32 vsid, u32 eaddr,
224 bool primary) 224 bool primary)
225{ 225{
226 u32 page, hash, htabmask; 226 u32 page, hash;
227 ulong pteg = (ulong)Hash; 227 ulong pteg = htab;
228 228
229 page = (eaddr & ~ESID_MASK) >> 12; 229 page = (eaddr & ~ESID_MASK) >> 12;
230 230
@@ -232,13 +232,12 @@ static u32 *kvmppc_mmu_get_pteg(struct kvm_vcpu *vcpu, u32 vsid, u32 eaddr,
232 if (!primary) 232 if (!primary)
233 hash = ~hash; 233 hash = ~hash;
234 234
235 htabmask = ((_SDR1 & 0x1FF) << 16) | 0xFFC0;
236 hash &= htabmask; 235 hash &= htabmask;
237 236
238 pteg |= hash; 237 pteg |= hash;
239 238
240 dprintk_mmu("htab: %p | hash: %x | htabmask: %x | pteg: %lx\n", 239 dprintk_mmu("htab: %lx | hash: %x | htabmask: %x | pteg: %lx\n",
241 Hash, hash, htabmask, pteg); 240 htab, hash, htabmask, pteg);
242 241
243 return (u32*)pteg; 242 return (u32*)pteg;
244} 243}
@@ -453,6 +452,7 @@ int kvmppc_mmu_init(struct kvm_vcpu *vcpu)
453{ 452{
454 struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); 453 struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu);
455 int err; 454 int err;
455 ulong sdr1;
456 456
457 err = __init_new_context(); 457 err = __init_new_context();
458 if (err < 0) 458 if (err < 0)
@@ -474,5 +474,10 @@ int kvmppc_mmu_init(struct kvm_vcpu *vcpu)
474 474
475 vcpu3s->vsid_next = vcpu3s->vsid_first; 475 vcpu3s->vsid_next = vcpu3s->vsid_first;
476 476
477 /* Remember where the HTAB is */
478 asm ( "mfsdr1 %0" : "=r"(sdr1) );
479 htabmask = ((sdr1 & 0x1FF) << 16) | 0xFFC0;
480 htab = (ulong)__va(sdr1 & 0xffff0000);
481
477 return 0; 482 return 0;
478} 483}