aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/include/asm/kvm_host.h6
-rw-r--r--arch/powerpc/include/asm/kvm_ppc.h5
-rw-r--r--arch/powerpc/kernel/asm-offsets.c2
-rw-r--r--arch/powerpc/kvm/44x_tlb.c22
-rw-r--r--arch/powerpc/kvm/44x_tlb.h24
-rw-r--r--arch/powerpc/kvm/booke_guest.c8
6 files changed, 33 insertions, 34 deletions
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index 34b52b7180cd..df733511d671 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -64,7 +64,7 @@ struct kvm_vcpu_stat {
64 u32 halt_wakeup; 64 u32 halt_wakeup;
65}; 65};
66 66
67struct tlbe { 67struct kvmppc_44x_tlbe {
68 u32 tid; /* Only the low 8 bits are used. */ 68 u32 tid; /* Only the low 8 bits are used. */
69 u32 word0; 69 u32 word0;
70 u32 word1; 70 u32 word1;
@@ -76,9 +76,9 @@ struct kvm_arch {
76 76
77struct kvm_vcpu_arch { 77struct kvm_vcpu_arch {
78 /* Unmodified copy of the guest's TLB. */ 78 /* Unmodified copy of the guest's TLB. */
79 struct tlbe guest_tlb[PPC44x_TLB_SIZE]; 79 struct kvmppc_44x_tlbe guest_tlb[PPC44x_TLB_SIZE];
80 /* TLB that's actually used when the guest is running. */ 80 /* TLB that's actually used when the guest is running. */
81 struct tlbe shadow_tlb[PPC44x_TLB_SIZE]; 81 struct kvmppc_44x_tlbe shadow_tlb[PPC44x_TLB_SIZE];
82 /* Pages which are referenced in the shadow TLB. */ 82 /* Pages which are referenced in the shadow TLB. */
83 struct page *shadow_pages[PPC44x_TLB_SIZE]; 83 struct page *shadow_pages[PPC44x_TLB_SIZE];
84 84
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index 4adb4a397508..39daeaa82b53 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -29,11 +29,6 @@
29#include <linux/kvm_types.h> 29#include <linux/kvm_types.h>
30#include <linux/kvm_host.h> 30#include <linux/kvm_host.h>
31 31
32struct kvm_tlb {
33 struct tlbe guest_tlb[PPC44x_TLB_SIZE];
34 struct tlbe shadow_tlb[PPC44x_TLB_SIZE];
35};
36
37enum emulation_result { 32enum emulation_result {
38 EMULATE_DONE, /* no further processing */ 33 EMULATE_DONE, /* no further processing */
39 EMULATE_DO_MMIO, /* kvm_run filled with MMIO request */ 34 EMULATE_DO_MMIO, /* kvm_run filled with MMIO request */
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 661d07d2146b..0264c97e02b5 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -357,7 +357,7 @@ int main(void)
357 DEFINE(PTE_SIZE, sizeof(pte_t)); 357 DEFINE(PTE_SIZE, sizeof(pte_t));
358 358
359#ifdef CONFIG_KVM 359#ifdef CONFIG_KVM
360 DEFINE(TLBE_BYTES, sizeof(struct tlbe)); 360 DEFINE(TLBE_BYTES, sizeof(struct kvmppc_44x_tlbe));
361 361
362 DEFINE(VCPU_HOST_STACK, offsetof(struct kvm_vcpu, arch.host_stack)); 362 DEFINE(VCPU_HOST_STACK, offsetof(struct kvm_vcpu, arch.host_stack));
363 DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid)); 363 DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid));
diff --git a/arch/powerpc/kvm/44x_tlb.c b/arch/powerpc/kvm/44x_tlb.c
index dd75ab84e04e..5152fe5b2a9b 100644
--- a/arch/powerpc/kvm/44x_tlb.c
+++ b/arch/powerpc/kvm/44x_tlb.c
@@ -86,7 +86,7 @@ int kvmppc_44x_tlb_index(struct kvm_vcpu *vcpu, gva_t eaddr, unsigned int pid,
86 86
87 /* XXX Replace loop with fancy data structures. */ 87 /* XXX Replace loop with fancy data structures. */
88 for (i = 0; i < PPC44x_TLB_SIZE; i++) { 88 for (i = 0; i < PPC44x_TLB_SIZE; i++) {
89 struct tlbe *tlbe = &vcpu->arch.guest_tlb[i]; 89 struct kvmppc_44x_tlbe *tlbe = &vcpu->arch.guest_tlb[i];
90 unsigned int tid; 90 unsigned int tid;
91 91
92 if (eaddr < get_tlb_eaddr(tlbe)) 92 if (eaddr < get_tlb_eaddr(tlbe))
@@ -111,7 +111,8 @@ int kvmppc_44x_tlb_index(struct kvm_vcpu *vcpu, gva_t eaddr, unsigned int pid,
111 return -1; 111 return -1;
112} 112}
113 113
114struct tlbe *kvmppc_44x_itlb_search(struct kvm_vcpu *vcpu, gva_t eaddr) 114struct kvmppc_44x_tlbe *kvmppc_44x_itlb_search(struct kvm_vcpu *vcpu,
115 gva_t eaddr)
115{ 116{
116 unsigned int as = !!(vcpu->arch.msr & MSR_IS); 117 unsigned int as = !!(vcpu->arch.msr & MSR_IS);
117 unsigned int index; 118 unsigned int index;
@@ -122,7 +123,8 @@ struct tlbe *kvmppc_44x_itlb_search(struct kvm_vcpu *vcpu, gva_t eaddr)
122 return &vcpu->arch.guest_tlb[index]; 123 return &vcpu->arch.guest_tlb[index];
123} 124}
124 125
125struct tlbe *kvmppc_44x_dtlb_search(struct kvm_vcpu *vcpu, gva_t eaddr) 126struct kvmppc_44x_tlbe *kvmppc_44x_dtlb_search(struct kvm_vcpu *vcpu,
127 gva_t eaddr)
126{ 128{
127 unsigned int as = !!(vcpu->arch.msr & MSR_DS); 129 unsigned int as = !!(vcpu->arch.msr & MSR_DS);
128 unsigned int index; 130 unsigned int index;
@@ -133,7 +135,7 @@ struct tlbe *kvmppc_44x_dtlb_search(struct kvm_vcpu *vcpu, gva_t eaddr)
133 return &vcpu->arch.guest_tlb[index]; 135 return &vcpu->arch.guest_tlb[index];
134} 136}
135 137
136static int kvmppc_44x_tlbe_is_writable(struct tlbe *tlbe) 138static int kvmppc_44x_tlbe_is_writable(struct kvmppc_44x_tlbe *tlbe)
137{ 139{
138 return tlbe->word2 & (PPC44x_TLB_SW|PPC44x_TLB_UW); 140 return tlbe->word2 & (PPC44x_TLB_SW|PPC44x_TLB_UW);
139} 141}
@@ -141,7 +143,7 @@ static int kvmppc_44x_tlbe_is_writable(struct tlbe *tlbe)
141static void kvmppc_44x_shadow_release(struct kvm_vcpu *vcpu, 143static void kvmppc_44x_shadow_release(struct kvm_vcpu *vcpu,
142 unsigned int index) 144 unsigned int index)
143{ 145{
144 struct tlbe *stlbe = &vcpu->arch.shadow_tlb[index]; 146 struct kvmppc_44x_tlbe *stlbe = &vcpu->arch.shadow_tlb[index];
145 struct page *page = vcpu->arch.shadow_pages[index]; 147 struct page *page = vcpu->arch.shadow_pages[index];
146 148
147 if (get_tlb_v(stlbe)) { 149 if (get_tlb_v(stlbe)) {
@@ -171,7 +173,7 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gfn_t gfn, u64 asid,
171 u32 flags) 173 u32 flags)
172{ 174{
173 struct page *new_page; 175 struct page *new_page;
174 struct tlbe *stlbe; 176 struct kvmppc_44x_tlbe *stlbe;
175 hpa_t hpaddr; 177 hpa_t hpaddr;
176 unsigned int victim; 178 unsigned int victim;
177 179
@@ -227,7 +229,7 @@ static void kvmppc_mmu_invalidate(struct kvm_vcpu *vcpu, gva_t eaddr,
227 229
228 /* XXX Replace loop with fancy data structures. */ 230 /* XXX Replace loop with fancy data structures. */
229 for (i = 0; i <= tlb_44x_hwater; i++) { 231 for (i = 0; i <= tlb_44x_hwater; i++) {
230 struct tlbe *stlbe = &vcpu->arch.shadow_tlb[i]; 232 struct kvmppc_44x_tlbe *stlbe = &vcpu->arch.shadow_tlb[i];
231 unsigned int tid; 233 unsigned int tid;
232 234
233 if (!get_tlb_v(stlbe)) 235 if (!get_tlb_v(stlbe))
@@ -262,7 +264,7 @@ void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode)
262 if (vcpu->arch.swap_pid) { 264 if (vcpu->arch.swap_pid) {
263 /* XXX Replace loop with fancy data structures. */ 265 /* XXX Replace loop with fancy data structures. */
264 for (i = 0; i <= tlb_44x_hwater; i++) { 266 for (i = 0; i <= tlb_44x_hwater; i++) {
265 struct tlbe *stlbe = &vcpu->arch.shadow_tlb[i]; 267 struct kvmppc_44x_tlbe *stlbe = &vcpu->arch.shadow_tlb[i];
266 268
267 /* Future optimization: clear only userspace mappings. */ 269 /* Future optimization: clear only userspace mappings. */
268 kvmppc_44x_shadow_release(vcpu, i); 270 kvmppc_44x_shadow_release(vcpu, i);
@@ -279,7 +281,7 @@ void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode)
279} 281}
280 282
281static int tlbe_is_host_safe(const struct kvm_vcpu *vcpu, 283static int tlbe_is_host_safe(const struct kvm_vcpu *vcpu,
282 const struct tlbe *tlbe) 284 const struct kvmppc_44x_tlbe *tlbe)
283{ 285{
284 gpa_t gpa; 286 gpa_t gpa;
285 287
@@ -305,7 +307,7 @@ int kvmppc_emul_tlbwe(struct kvm_vcpu *vcpu, u8 ra, u8 rs, u8 ws)
305 u64 raddr; 307 u64 raddr;
306 u64 asid; 308 u64 asid;
307 u32 flags; 309 u32 flags;
308 struct tlbe *tlbe; 310 struct kvmppc_44x_tlbe *tlbe;
309 unsigned int index; 311 unsigned int index;
310 312
311 index = vcpu->arch.gpr[ra]; 313 index = vcpu->arch.gpr[ra];
diff --git a/arch/powerpc/kvm/44x_tlb.h b/arch/powerpc/kvm/44x_tlb.h
index 2ccd46b6f6b7..e5b0a76798bd 100644
--- a/arch/powerpc/kvm/44x_tlb.h
+++ b/arch/powerpc/kvm/44x_tlb.h
@@ -25,48 +25,50 @@
25 25
26extern int kvmppc_44x_tlb_index(struct kvm_vcpu *vcpu, gva_t eaddr, 26extern int kvmppc_44x_tlb_index(struct kvm_vcpu *vcpu, gva_t eaddr,
27 unsigned int pid, unsigned int as); 27 unsigned int pid, unsigned int as);
28extern struct tlbe *kvmppc_44x_dtlb_search(struct kvm_vcpu *vcpu, gva_t eaddr); 28extern struct kvmppc_44x_tlbe *kvmppc_44x_dtlb_search(struct kvm_vcpu *vcpu,
29extern struct tlbe *kvmppc_44x_itlb_search(struct kvm_vcpu *vcpu, gva_t eaddr); 29 gva_t eaddr);
30extern struct kvmppc_44x_tlbe *kvmppc_44x_itlb_search(struct kvm_vcpu *vcpu,
31 gva_t eaddr);
30 32
31/* TLB helper functions */ 33/* TLB helper functions */
32static inline unsigned int get_tlb_size(const struct tlbe *tlbe) 34static inline unsigned int get_tlb_size(const struct kvmppc_44x_tlbe *tlbe)
33{ 35{
34 return (tlbe->word0 >> 4) & 0xf; 36 return (tlbe->word0 >> 4) & 0xf;
35} 37}
36 38
37static inline gva_t get_tlb_eaddr(const struct tlbe *tlbe) 39static inline gva_t get_tlb_eaddr(const struct kvmppc_44x_tlbe *tlbe)
38{ 40{
39 return tlbe->word0 & 0xfffffc00; 41 return tlbe->word0 & 0xfffffc00;
40} 42}
41 43
42static inline gva_t get_tlb_bytes(const struct tlbe *tlbe) 44static inline gva_t get_tlb_bytes(const struct kvmppc_44x_tlbe *tlbe)
43{ 45{
44 unsigned int pgsize = get_tlb_size(tlbe); 46 unsigned int pgsize = get_tlb_size(tlbe);
45 return 1 << 10 << (pgsize << 1); 47 return 1 << 10 << (pgsize << 1);
46} 48}
47 49
48static inline gva_t get_tlb_end(const struct tlbe *tlbe) 50static inline gva_t get_tlb_end(const struct kvmppc_44x_tlbe *tlbe)
49{ 51{
50 return get_tlb_eaddr(tlbe) + get_tlb_bytes(tlbe) - 1; 52 return get_tlb_eaddr(tlbe) + get_tlb_bytes(tlbe) - 1;
51} 53}
52 54
53static inline u64 get_tlb_raddr(const struct tlbe *tlbe) 55static inline u64 get_tlb_raddr(const struct kvmppc_44x_tlbe *tlbe)
54{ 56{
55 u64 word1 = tlbe->word1; 57 u64 word1 = tlbe->word1;
56 return ((word1 & 0xf) << 32) | (word1 & 0xfffffc00); 58 return ((word1 & 0xf) << 32) | (word1 & 0xfffffc00);
57} 59}
58 60
59static inline unsigned int get_tlb_tid(const struct tlbe *tlbe) 61static inline unsigned int get_tlb_tid(const struct kvmppc_44x_tlbe *tlbe)
60{ 62{
61 return tlbe->tid & 0xff; 63 return tlbe->tid & 0xff;
62} 64}
63 65
64static inline unsigned int get_tlb_ts(const struct tlbe *tlbe) 66static inline unsigned int get_tlb_ts(const struct kvmppc_44x_tlbe *tlbe)
65{ 67{
66 return (tlbe->word0 >> 8) & 0x1; 68 return (tlbe->word0 >> 8) & 0x1;
67} 69}
68 70
69static inline unsigned int get_tlb_v(const struct tlbe *tlbe) 71static inline unsigned int get_tlb_v(const struct kvmppc_44x_tlbe *tlbe)
70{ 72{
71 return (tlbe->word0 >> 9) & 0x1; 73 return (tlbe->word0 >> 9) & 0x1;
72} 74}
@@ -81,7 +83,7 @@ static inline unsigned int get_mmucr_sts(const struct kvm_vcpu *vcpu)
81 return (vcpu->arch.mmucr >> 16) & 0x1; 83 return (vcpu->arch.mmucr >> 16) & 0x1;
82} 84}
83 85
84static inline gpa_t tlb_xlate(struct tlbe *tlbe, gva_t eaddr) 86static inline gpa_t tlb_xlate(struct kvmppc_44x_tlbe *tlbe, gva_t eaddr)
85{ 87{
86 unsigned int pgmask = get_tlb_bytes(tlbe) - 1; 88 unsigned int pgmask = get_tlb_bytes(tlbe) - 1;
87 89
diff --git a/arch/powerpc/kvm/booke_guest.c b/arch/powerpc/kvm/booke_guest.c
index c0f8532630ec..41bbf4c78f88 100644
--- a/arch/powerpc/kvm/booke_guest.c
+++ b/arch/powerpc/kvm/booke_guest.c
@@ -307,7 +307,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
307 break; 307 break;
308 308
309 case BOOKE_INTERRUPT_DTLB_MISS: { 309 case BOOKE_INTERRUPT_DTLB_MISS: {
310 struct tlbe *gtlbe; 310 struct kvmppc_44x_tlbe *gtlbe;
311 unsigned long eaddr = vcpu->arch.fault_dear; 311 unsigned long eaddr = vcpu->arch.fault_dear;
312 gfn_t gfn; 312 gfn_t gfn;
313 313
@@ -347,7 +347,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
347 } 347 }
348 348
349 case BOOKE_INTERRUPT_ITLB_MISS: { 349 case BOOKE_INTERRUPT_ITLB_MISS: {
350 struct tlbe *gtlbe; 350 struct kvmppc_44x_tlbe *gtlbe;
351 unsigned long eaddr = vcpu->arch.pc; 351 unsigned long eaddr = vcpu->arch.pc;
352 gfn_t gfn; 352 gfn_t gfn;
353 353
@@ -442,7 +442,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
442/* Initial guest state: 16MB mapping 0 -> 0, PC = 0, MSR = 0, R1 = 16MB */ 442/* Initial guest state: 16MB mapping 0 -> 0, PC = 0, MSR = 0, R1 = 16MB */
443int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) 443int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
444{ 444{
445 struct tlbe *tlbe = &vcpu->arch.guest_tlb[0]; 445 struct kvmppc_44x_tlbe *tlbe = &vcpu->arch.guest_tlb[0];
446 446
447 tlbe->tid = 0; 447 tlbe->tid = 0;
448 tlbe->word0 = PPC44x_TLB_16M | PPC44x_TLB_VALID; 448 tlbe->word0 = PPC44x_TLB_16M | PPC44x_TLB_VALID;
@@ -553,7 +553,7 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
553int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, 553int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
554 struct kvm_translation *tr) 554 struct kvm_translation *tr)
555{ 555{
556 struct tlbe *gtlbe; 556 struct kvmppc_44x_tlbe *gtlbe;
557 int index; 557 int index;
558 gva_t eaddr; 558 gva_t eaddr;
559 u8 pid; 559 u8 pid;