diff options
author | Alexander Graf <agraf@suse.de> | 2011-07-08 07:40:10 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-09-25 12:52:18 -0400 |
commit | db507c300ed6ce6e9fc71d4e19975d5abe01a7de (patch) | |
tree | bd7e5fbc2ab5d326a5a9f1679c205763e027c90f /arch/powerpc | |
parent | 364426871ca33752a6e8fcfccec4d89e2eaf06f7 (diff) |
KVM: PPC: move compute_tlbie_rb to book3s common header
We need the compute_tlbie_rb in _pr and _hv implementations for papr
soon, so let's move it over to a common header file that both
implementations can leverage.
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/include/asm/kvm_book3s.h | 33 | ||||
-rw-r--r-- | arch/powerpc/kvm/book3s_hv_rm_mmu.c | 33 |
2 files changed, 33 insertions, 33 deletions
diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h index 98da010252a3..37dd7486627b 100644 --- a/arch/powerpc/include/asm/kvm_book3s.h +++ b/arch/powerpc/include/asm/kvm_book3s.h | |||
@@ -382,6 +382,39 @@ static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu) | |||
382 | } | 382 | } |
383 | #endif | 383 | #endif |
384 | 384 | ||
385 | static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r, | ||
386 | unsigned long pte_index) | ||
387 | { | ||
388 | unsigned long rb, va_low; | ||
389 | |||
390 | rb = (v & ~0x7fUL) << 16; /* AVA field */ | ||
391 | va_low = pte_index >> 3; | ||
392 | if (v & HPTE_V_SECONDARY) | ||
393 | va_low = ~va_low; | ||
394 | /* xor vsid from AVA */ | ||
395 | if (!(v & HPTE_V_1TB_SEG)) | ||
396 | va_low ^= v >> 12; | ||
397 | else | ||
398 | va_low ^= v >> 24; | ||
399 | va_low &= 0x7ff; | ||
400 | if (v & HPTE_V_LARGE) { | ||
401 | rb |= 1; /* L field */ | ||
402 | if (cpu_has_feature(CPU_FTR_ARCH_206) && | ||
403 | (r & 0xff000)) { | ||
404 | /* non-16MB large page, must be 64k */ | ||
405 | /* (masks depend on page size) */ | ||
406 | rb |= 0x1000; /* page encoding in LP field */ | ||
407 | rb |= (va_low & 0x7f) << 16; /* 7b of VA in AVA/LP field */ | ||
408 | rb |= (va_low & 0xfe); /* AVAL field (P7 doesn't seem to care) */ | ||
409 | } | ||
410 | } else { | ||
411 | /* 4kB page */ | ||
412 | rb |= (va_low & 0x7ff) << 12; /* remaining 11b of VA */ | ||
413 | } | ||
414 | rb |= (v >> 54) & 0x300; /* B field */ | ||
415 | return rb; | ||
416 | } | ||
417 | |||
385 | /* Magic register values loaded into r3 and r4 before the 'sc' assembly | 418 | /* Magic register values loaded into r3 and r4 before the 'sc' assembly |
386 | * instruction for the OSI hypercalls */ | 419 | * instruction for the OSI hypercalls */ |
387 | #define OSI_SC_MAGIC_R3 0x113724FA | 420 | #define OSI_SC_MAGIC_R3 0x113724FA |
diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c index fcfe6b055558..bacb0cfa3602 100644 --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c | |||
@@ -110,39 +110,6 @@ long kvmppc_h_enter(struct kvm_vcpu *vcpu, unsigned long flags, | |||
110 | return H_SUCCESS; | 110 | return H_SUCCESS; |
111 | } | 111 | } |
112 | 112 | ||
113 | static unsigned long compute_tlbie_rb(unsigned long v, unsigned long r, | ||
114 | unsigned long pte_index) | ||
115 | { | ||
116 | unsigned long rb, va_low; | ||
117 | |||
118 | rb = (v & ~0x7fUL) << 16; /* AVA field */ | ||
119 | va_low = pte_index >> 3; | ||
120 | if (v & HPTE_V_SECONDARY) | ||
121 | va_low = ~va_low; | ||
122 | /* xor vsid from AVA */ | ||
123 | if (!(v & HPTE_V_1TB_SEG)) | ||
124 | va_low ^= v >> 12; | ||
125 | else | ||
126 | va_low ^= v >> 24; | ||
127 | va_low &= 0x7ff; | ||
128 | if (v & HPTE_V_LARGE) { | ||
129 | rb |= 1; /* L field */ | ||
130 | if (cpu_has_feature(CPU_FTR_ARCH_206) && | ||
131 | (r & 0xff000)) { | ||
132 | /* non-16MB large page, must be 64k */ | ||
133 | /* (masks depend on page size) */ | ||
134 | rb |= 0x1000; /* page encoding in LP field */ | ||
135 | rb |= (va_low & 0x7f) << 16; /* 7b of VA in AVA/LP field */ | ||
136 | rb |= (va_low & 0xfe); /* AVAL field (P7 doesn't seem to care) */ | ||
137 | } | ||
138 | } else { | ||
139 | /* 4kB page */ | ||
140 | rb |= (va_low & 0x7ff) << 12; /* remaining 11b of VA */ | ||
141 | } | ||
142 | rb |= (v >> 54) & 0x300; /* B field */ | ||
143 | return rb; | ||
144 | } | ||
145 | |||
146 | #define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token)) | 113 | #define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token)) |
147 | 114 | ||
148 | static inline int try_lock_tlbie(unsigned int *lock) | 115 | static inline int try_lock_tlbie(unsigned int *lock) |