diff options
author | Hollis Blanchard <hollisb@us.ibm.com> | 2008-11-05 10:36:12 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2008-12-31 09:51:50 -0500 |
commit | 0f55dc481ea5c4f87fc0161cb1b8c6e2cafae8fc (patch) | |
tree | 18b5bb0ad449607690329c6c23083886cb39a9bc /arch/powerpc | |
parent | a0d7b9f246074fab1f42678d203ef4ba281505f2 (diff) |
KVM: ppc: Rename "struct tlbe" to "struct kvmppc_44x_tlbe"
This will ease ports to other cores.
Also remove unused "struct kvm_tlb" while we're at it.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/include/asm/kvm_host.h | 6 | ||||
-rw-r--r-- | arch/powerpc/include/asm/kvm_ppc.h | 5 | ||||
-rw-r--r-- | arch/powerpc/kernel/asm-offsets.c | 2 | ||||
-rw-r--r-- | arch/powerpc/kvm/44x_tlb.c | 22 | ||||
-rw-r--r-- | arch/powerpc/kvm/44x_tlb.h | 24 | ||||
-rw-r--r-- | arch/powerpc/kvm/booke_guest.c | 8 |
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 | ||
67 | struct tlbe { | 67 | struct 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 | ||
77 | struct kvm_vcpu_arch { | 77 | struct 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 | ||
32 | struct kvm_tlb { | ||
33 | struct tlbe guest_tlb[PPC44x_TLB_SIZE]; | ||
34 | struct tlbe shadow_tlb[PPC44x_TLB_SIZE]; | ||
35 | }; | ||
36 | |||
37 | enum emulation_result { | 32 | enum 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 | ||
114 | struct tlbe *kvmppc_44x_itlb_search(struct kvm_vcpu *vcpu, gva_t eaddr) | 114 | struct 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 | ||
125 | struct tlbe *kvmppc_44x_dtlb_search(struct kvm_vcpu *vcpu, gva_t eaddr) | 126 | struct 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 | ||
136 | static int kvmppc_44x_tlbe_is_writable(struct tlbe *tlbe) | 138 | static 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) | |||
141 | static void kvmppc_44x_shadow_release(struct kvm_vcpu *vcpu, | 143 | static 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 | ||
281 | static int tlbe_is_host_safe(const struct kvm_vcpu *vcpu, | 283 | static 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 | ||
26 | extern int kvmppc_44x_tlb_index(struct kvm_vcpu *vcpu, gva_t eaddr, | 26 | extern 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); |
28 | extern struct tlbe *kvmppc_44x_dtlb_search(struct kvm_vcpu *vcpu, gva_t eaddr); | 28 | extern struct kvmppc_44x_tlbe *kvmppc_44x_dtlb_search(struct kvm_vcpu *vcpu, |
29 | extern struct tlbe *kvmppc_44x_itlb_search(struct kvm_vcpu *vcpu, gva_t eaddr); | 29 | gva_t eaddr); |
30 | extern 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 */ |
32 | static inline unsigned int get_tlb_size(const struct tlbe *tlbe) | 34 | static 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 | ||
37 | static inline gva_t get_tlb_eaddr(const struct tlbe *tlbe) | 39 | static 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 | ||
42 | static inline gva_t get_tlb_bytes(const struct tlbe *tlbe) | 44 | static 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 | ||
48 | static inline gva_t get_tlb_end(const struct tlbe *tlbe) | 50 | static 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 | ||
53 | static inline u64 get_tlb_raddr(const struct tlbe *tlbe) | 55 | static 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 | ||
59 | static inline unsigned int get_tlb_tid(const struct tlbe *tlbe) | 61 | static 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 | ||
64 | static inline unsigned int get_tlb_ts(const struct tlbe *tlbe) | 66 | static 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 | ||
69 | static inline unsigned int get_tlb_v(const struct tlbe *tlbe) | 71 | static 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 | ||
84 | static inline gpa_t tlb_xlate(struct tlbe *tlbe, gva_t eaddr) | 86 | static 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 */ |
443 | int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) | 443 | int 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) | |||
553 | int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, | 553 | int 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; |