diff options
author | Alexander Graf <agraf@suse.de> | 2010-04-19 20:49:53 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-05-17 05:19:07 -0400 |
commit | 251585b5d02152973dbc24c803ca322bb977d4a2 (patch) | |
tree | cce6b6beda97aaad86e5e31debc6f2fb2a4d8ebe /arch/powerpc | |
parent | 5156f274bb1ee1cfc22240445ef94f7dcfc9929d (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')
-rw-r--r-- | arch/powerpc/kernel/ppc_ksyms.c | 5 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s_32_mmu_host.c | 21 |
2 files changed, 13 insertions, 13 deletions
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c index 2b7c43f95bb2..bc9f39d2598b 100644 --- a/arch/powerpc/kernel/ppc_ksyms.c +++ b/arch/powerpc/kernel/ppc_ksyms.c | |||
@@ -178,11 +178,6 @@ EXPORT_SYMBOL(switch_mmu_context); | |||
178 | extern long mol_trampoline; | 178 | extern long mol_trampoline; |
179 | EXPORT_SYMBOL(mol_trampoline); /* For MOL */ | 179 | EXPORT_SYMBOL(mol_trampoline); /* For MOL */ |
180 | EXPORT_SYMBOL(flush_hash_pages); /* For MOL */ | 180 | EXPORT_SYMBOL(flush_hash_pages); /* For MOL */ |
181 | |||
182 | extern struct hash_pte *Hash; | ||
183 | extern unsigned long _SDR1; | ||
184 | EXPORT_SYMBOL_GPL(Hash); /* For KVM */ | ||
185 | EXPORT_SYMBOL_GPL(_SDR1); /* For KVM */ | ||
186 | #ifdef CONFIG_SMP | 181 | #ifdef CONFIG_SMP |
187 | extern int mmu_hash_lock; | 182 | extern int mmu_hash_lock; |
188 | EXPORT_SYMBOL(mmu_hash_lock); /* For MOL */ | 183 | EXPORT_SYMBOL(mmu_hash_lock); /* For MOL */ |
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 | ||
57 | static ulong htab; | ||
58 | static u32 htabmask; | ||
59 | |||
57 | static void invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte) | 60 | static 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 | ||
220 | extern struct hash_pte *Hash; | ||
221 | extern unsigned long _SDR1; | ||
222 | |||
223 | static u32 *kvmppc_mmu_get_pteg(struct kvm_vcpu *vcpu, u32 vsid, u32 eaddr, | 223 | static 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 | } |