diff options
Diffstat (limited to 'arch/powerpc/include/asm/kvm_ppc.h')
-rw-r--r-- | arch/powerpc/include/asm/kvm_ppc.h | 97 |
1 files changed, 31 insertions, 66 deletions
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index e2642829e435..18d139ec2d22 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h | |||
@@ -30,6 +30,8 @@ | |||
30 | #include <linux/kvm_host.h> | 30 | #include <linux/kvm_host.h> |
31 | #ifdef CONFIG_PPC_BOOK3S | 31 | #ifdef CONFIG_PPC_BOOK3S |
32 | #include <asm/kvm_book3s.h> | 32 | #include <asm/kvm_book3s.h> |
33 | #else | ||
34 | #include <asm/kvm_booke.h> | ||
33 | #endif | 35 | #endif |
34 | 36 | ||
35 | enum emulation_result { | 37 | enum emulation_result { |
@@ -37,6 +39,7 @@ enum emulation_result { | |||
37 | EMULATE_DO_MMIO, /* kvm_run filled with MMIO request */ | 39 | EMULATE_DO_MMIO, /* kvm_run filled with MMIO request */ |
38 | EMULATE_DO_DCR, /* kvm_run filled with DCR request */ | 40 | EMULATE_DO_DCR, /* kvm_run filled with DCR request */ |
39 | EMULATE_FAIL, /* can't emulate this instruction */ | 41 | EMULATE_FAIL, /* can't emulate this instruction */ |
42 | EMULATE_AGAIN, /* something went wrong. go again */ | ||
40 | }; | 43 | }; |
41 | 44 | ||
42 | extern int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu); | 45 | extern int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu); |
@@ -48,8 +51,11 @@ extern void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu); | |||
48 | extern int kvmppc_handle_load(struct kvm_run *run, struct kvm_vcpu *vcpu, | 51 | extern int kvmppc_handle_load(struct kvm_run *run, struct kvm_vcpu *vcpu, |
49 | unsigned int rt, unsigned int bytes, | 52 | unsigned int rt, unsigned int bytes, |
50 | int is_bigendian); | 53 | int is_bigendian); |
54 | extern int kvmppc_handle_loads(struct kvm_run *run, struct kvm_vcpu *vcpu, | ||
55 | unsigned int rt, unsigned int bytes, | ||
56 | int is_bigendian); | ||
51 | extern int kvmppc_handle_store(struct kvm_run *run, struct kvm_vcpu *vcpu, | 57 | extern int kvmppc_handle_store(struct kvm_run *run, struct kvm_vcpu *vcpu, |
52 | u32 val, unsigned int bytes, int is_bigendian); | 58 | u64 val, unsigned int bytes, int is_bigendian); |
53 | 59 | ||
54 | extern int kvmppc_emulate_instruction(struct kvm_run *run, | 60 | extern int kvmppc_emulate_instruction(struct kvm_run *run, |
55 | struct kvm_vcpu *vcpu); | 61 | struct kvm_vcpu *vcpu); |
@@ -63,6 +69,7 @@ extern void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gpa_t gpaddr, | |||
63 | extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode); | 69 | extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode); |
64 | extern void kvmppc_mmu_switch_pid(struct kvm_vcpu *vcpu, u32 pid); | 70 | extern void kvmppc_mmu_switch_pid(struct kvm_vcpu *vcpu, u32 pid); |
65 | extern void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu); | 71 | extern void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu); |
72 | extern int kvmppc_mmu_init(struct kvm_vcpu *vcpu); | ||
66 | extern int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr); | 73 | extern int kvmppc_mmu_dtlb_index(struct kvm_vcpu *vcpu, gva_t eaddr); |
67 | extern int kvmppc_mmu_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr); | 74 | extern int kvmppc_mmu_itlb_index(struct kvm_vcpu *vcpu, gva_t eaddr); |
68 | extern gpa_t kvmppc_mmu_xlate(struct kvm_vcpu *vcpu, unsigned int gtlb_index, | 75 | extern gpa_t kvmppc_mmu_xlate(struct kvm_vcpu *vcpu, unsigned int gtlb_index, |
@@ -88,6 +95,8 @@ extern void kvmppc_core_queue_dec(struct kvm_vcpu *vcpu); | |||
88 | extern void kvmppc_core_dequeue_dec(struct kvm_vcpu *vcpu); | 95 | extern void kvmppc_core_dequeue_dec(struct kvm_vcpu *vcpu); |
89 | extern void kvmppc_core_queue_external(struct kvm_vcpu *vcpu, | 96 | extern void kvmppc_core_queue_external(struct kvm_vcpu *vcpu, |
90 | struct kvm_interrupt *irq); | 97 | struct kvm_interrupt *irq); |
98 | extern void kvmppc_core_dequeue_external(struct kvm_vcpu *vcpu, | ||
99 | struct kvm_interrupt *irq); | ||
91 | 100 | ||
92 | extern int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, | 101 | extern int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, |
93 | unsigned int op, int *advance); | 102 | unsigned int op, int *advance); |
@@ -99,81 +108,37 @@ extern void kvmppc_booke_exit(void); | |||
99 | 108 | ||
100 | extern void kvmppc_core_destroy_mmu(struct kvm_vcpu *vcpu); | 109 | extern void kvmppc_core_destroy_mmu(struct kvm_vcpu *vcpu); |
101 | 110 | ||
102 | #ifdef CONFIG_PPC_BOOK3S | 111 | /* |
103 | 112 | * Cuts out inst bits with ordering according to spec. | |
104 | /* We assume we're always acting on the current vcpu */ | 113 | * That means the leftmost bit is zero. All given bits are included. |
105 | 114 | */ | |
106 | static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val) | 115 | static inline u32 kvmppc_get_field(u64 inst, int msb, int lsb) |
107 | { | ||
108 | if ( num < 14 ) { | ||
109 | get_paca()->shadow_vcpu.gpr[num] = val; | ||
110 | to_book3s(vcpu)->shadow_vcpu.gpr[num] = val; | ||
111 | } else | ||
112 | vcpu->arch.gpr[num] = val; | ||
113 | } | ||
114 | |||
115 | static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num) | ||
116 | { | ||
117 | if ( num < 14 ) | ||
118 | return get_paca()->shadow_vcpu.gpr[num]; | ||
119 | else | ||
120 | return vcpu->arch.gpr[num]; | ||
121 | } | ||
122 | |||
123 | static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val) | ||
124 | { | ||
125 | get_paca()->shadow_vcpu.cr = val; | ||
126 | to_book3s(vcpu)->shadow_vcpu.cr = val; | ||
127 | } | ||
128 | |||
129 | static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu) | ||
130 | { | ||
131 | return get_paca()->shadow_vcpu.cr; | ||
132 | } | ||
133 | |||
134 | static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val) | ||
135 | { | ||
136 | get_paca()->shadow_vcpu.xer = val; | ||
137 | to_book3s(vcpu)->shadow_vcpu.xer = val; | ||
138 | } | ||
139 | |||
140 | static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu) | ||
141 | { | 116 | { |
142 | return get_paca()->shadow_vcpu.xer; | 117 | u32 r; |
143 | } | 118 | u32 mask; |
144 | 119 | ||
145 | #else | 120 | BUG_ON(msb > lsb); |
146 | 121 | ||
147 | static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val) | 122 | mask = (1 << (lsb - msb + 1)) - 1; |
148 | { | 123 | r = (inst >> (63 - lsb)) & mask; |
149 | vcpu->arch.gpr[num] = val; | ||
150 | } | ||
151 | 124 | ||
152 | static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num) | 125 | return r; |
153 | { | ||
154 | return vcpu->arch.gpr[num]; | ||
155 | } | 126 | } |
156 | 127 | ||
157 | static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val) | 128 | /* |
129 | * Replaces inst bits with ordering according to spec. | ||
130 | */ | ||
131 | static inline u32 kvmppc_set_field(u64 inst, int msb, int lsb, int value) | ||
158 | { | 132 | { |
159 | vcpu->arch.cr = val; | 133 | u32 r; |
160 | } | 134 | u32 mask; |
161 | 135 | ||
162 | static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu) | 136 | BUG_ON(msb > lsb); |
163 | { | ||
164 | return vcpu->arch.cr; | ||
165 | } | ||
166 | 137 | ||
167 | static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val) | 138 | mask = ((1 << (lsb - msb + 1)) - 1) << (63 - lsb); |
168 | { | 139 | r = (inst & ~mask) | ((value << (63 - lsb)) & mask); |
169 | vcpu->arch.xer = val; | ||
170 | } | ||
171 | 140 | ||
172 | static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu) | 141 | return r; |
173 | { | ||
174 | return vcpu->arch.xer; | ||
175 | } | 142 | } |
176 | 143 | ||
177 | #endif | ||
178 | |||
179 | #endif /* __POWERPC_KVM_PPC_H__ */ | 144 | #endif /* __POWERPC_KVM_PPC_H__ */ |