Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This program is free software; you can redistribute it and/or modify |
| 3 | * it under the terms of the GNU General Public License, version 2, as |
| 4 | * published by the Free Software Foundation. |
| 5 | * |
| 6 | * This program is distributed in the hope that it will be useful, |
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 9 | * GNU General Public License for more details. |
| 10 | * |
| 11 | * You should have received a copy of the GNU General Public License |
| 12 | * along with this program; if not, write to the Free Software |
| 13 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 14 | * |
| 15 | * Copyright SUSE Linux Products GmbH 2009 |
| 16 | * |
| 17 | * Authors: Alexander Graf <agraf@suse.de> |
| 18 | */ |
| 19 | |
| 20 | #ifndef __ASM_KVM_BOOK3S_H__ |
| 21 | #define __ASM_KVM_BOOK3S_H__ |
| 22 | |
| 23 | #include <linux/types.h> |
| 24 | #include <linux/kvm_host.h> |
Alexander Graf | 2191d65 | 2010-04-16 00:11:32 +0200 | [diff] [blame] | 25 | #include <asm/kvm_book3s_asm.h> |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 26 | |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 27 | struct kvmppc_bat { |
Alexander Graf | e15a113 | 2009-11-30 03:02:02 +0000 | [diff] [blame] | 28 | u64 raw; |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 29 | u32 bepi; |
| 30 | u32 bepi_mask; |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 31 | u32 brpn; |
| 32 | u8 wimg; |
| 33 | u8 pp; |
Alexander Graf | 3ed9c6d | 2010-03-24 21:48:36 +0100 | [diff] [blame] | 34 | bool vs : 1; |
| 35 | bool vp : 1; |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | struct kvmppc_sid_map { |
| 39 | u64 guest_vsid; |
| 40 | u64 guest_esid; |
| 41 | u64 host_vsid; |
Alexander Graf | 3ed9c6d | 2010-03-24 21:48:36 +0100 | [diff] [blame] | 42 | bool valid : 1; |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | #define SID_MAP_BITS 9 |
| 46 | #define SID_MAP_NUM (1 << SID_MAP_BITS) |
| 47 | #define SID_MAP_MASK (SID_MAP_NUM - 1) |
| 48 | |
Alexander Graf | 8b6db3b | 2010-08-15 08:04:24 +0200 | [diff] [blame] | 49 | #ifdef CONFIG_PPC_BOOK3S_64 |
| 50 | #define SID_CONTEXTS 1 |
| 51 | #else |
| 52 | #define SID_CONTEXTS 128 |
| 53 | #define VSID_POOL_SIZE (SID_CONTEXTS * 16) |
| 54 | #endif |
| 55 | |
Paul Mackerras | c4befc5 | 2011-06-29 00:17:33 +0000 | [diff] [blame] | 56 | struct hpte_cache { |
| 57 | struct hlist_node list_pte; |
| 58 | struct hlist_node list_pte_long; |
| 59 | struct hlist_node list_vpte; |
| 60 | struct hlist_node list_vpte_long; |
| 61 | struct rcu_head rcu_head; |
| 62 | u64 host_va; |
| 63 | u64 pfn; |
| 64 | ulong slot; |
| 65 | struct kvmppc_pte pte; |
| 66 | }; |
| 67 | |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 68 | struct kvmppc_vcpu_book3s { |
| 69 | struct kvm_vcpu vcpu; |
Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +0200 | [diff] [blame] | 70 | struct kvmppc_book3s_shadow_vcpu *shadow_vcpu; |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 71 | struct kvmppc_sid_map sid_map[SID_MAP_NUM]; |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 72 | struct { |
| 73 | u64 esid; |
| 74 | u64 vsid; |
| 75 | } slb_shadow[64]; |
| 76 | u8 slb_shadow_max; |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 77 | struct kvmppc_bat ibat[8]; |
| 78 | struct kvmppc_bat dbat[8]; |
| 79 | u64 hid[6]; |
Alexander Graf | d6d549b | 2010-02-19 11:00:33 +0100 | [diff] [blame] | 80 | u64 gqr[8]; |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 81 | u64 sdr1; |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 82 | u64 hior; |
| 83 | u64 msr_mask; |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 84 | u64 vsid_next; |
Alexander Graf | 8b6db3b | 2010-08-15 08:04:24 +0200 | [diff] [blame] | 85 | #ifdef CONFIG_PPC_BOOK3S_32 |
| 86 | u32 vsid_pool[VSID_POOL_SIZE]; |
| 87 | #else |
| 88 | u64 vsid_first; |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 89 | u64 vsid_max; |
Alexander Graf | 8b6db3b | 2010-08-15 08:04:24 +0200 | [diff] [blame] | 90 | #endif |
| 91 | int context_id[SID_CONTEXTS]; |
Alexander Graf | 25a8a02 | 2010-01-08 02:58:07 +0100 | [diff] [blame] | 92 | ulong prog_flags; /* flags to inject when giving a 700 trap */ |
Paul Mackerras | c4befc5 | 2011-06-29 00:17:33 +0000 | [diff] [blame] | 93 | |
| 94 | struct hlist_head hpte_hash_pte[HPTEG_HASH_NUM_PTE]; |
| 95 | struct hlist_head hpte_hash_pte_long[HPTEG_HASH_NUM_PTE_LONG]; |
| 96 | struct hlist_head hpte_hash_vpte[HPTEG_HASH_NUM_VPTE]; |
| 97 | struct hlist_head hpte_hash_vpte_long[HPTEG_HASH_NUM_VPTE_LONG]; |
| 98 | int hpte_cache_count; |
| 99 | spinlock_t mmu_lock; |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | #define CONTEXT_HOST 0 |
| 103 | #define CONTEXT_GUEST 1 |
| 104 | #define CONTEXT_GUEST_END 2 |
| 105 | |
Alexander Graf | f7bc74e | 2010-04-20 02:49:48 +0200 | [diff] [blame] | 106 | #define VSID_REAL 0x1fffffffffc00000ULL |
| 107 | #define VSID_BAT 0x1fffffffffb00000ULL |
| 108 | #define VSID_REAL_DR 0x2000000000000000ULL |
| 109 | #define VSID_REAL_IR 0x4000000000000000ULL |
Alexander Graf | 5a1b419 | 2010-03-24 21:48:35 +0100 | [diff] [blame] | 110 | #define VSID_PR 0x8000000000000000ULL |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 111 | |
Alexander Graf | af7b4d1 | 2010-04-20 02:49:46 +0200 | [diff] [blame] | 112 | extern void kvmppc_mmu_pte_flush(struct kvm_vcpu *vcpu, ulong ea, ulong ea_mask); |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 113 | extern void kvmppc_mmu_pte_vflush(struct kvm_vcpu *vcpu, u64 vp, u64 vp_mask); |
Alexander Graf | af7b4d1 | 2010-04-20 02:49:46 +0200 | [diff] [blame] | 114 | extern void kvmppc_mmu_pte_pflush(struct kvm_vcpu *vcpu, ulong pa_start, ulong pa_end); |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 115 | extern void kvmppc_set_msr(struct kvm_vcpu *vcpu, u64 new_msr); |
Paul Mackerras | f05ed4d | 2011-06-29 00:17:58 +0000 | [diff] [blame] | 116 | extern void kvmppc_set_pvr(struct kvm_vcpu *vcpu, u32 pvr); |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 117 | extern void kvmppc_mmu_book3s_64_init(struct kvm_vcpu *vcpu); |
| 118 | extern void kvmppc_mmu_book3s_32_init(struct kvm_vcpu *vcpu); |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame^] | 119 | extern void kvmppc_mmu_book3s_hv_init(struct kvm_vcpu *vcpu); |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 120 | extern int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte); |
| 121 | extern int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr); |
| 122 | extern void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu); |
Alexander Graf | fef093be | 2010-06-30 15:18:46 +0200 | [diff] [blame] | 123 | |
| 124 | extern void kvmppc_mmu_hpte_cache_map(struct kvm_vcpu *vcpu, struct hpte_cache *pte); |
| 125 | extern struct hpte_cache *kvmppc_mmu_hpte_cache_next(struct kvm_vcpu *vcpu); |
| 126 | extern void kvmppc_mmu_hpte_destroy(struct kvm_vcpu *vcpu); |
| 127 | extern int kvmppc_mmu_hpte_init(struct kvm_vcpu *vcpu); |
| 128 | extern void kvmppc_mmu_invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte); |
| 129 | extern int kvmppc_mmu_hpte_sysinit(void); |
| 130 | extern void kvmppc_mmu_hpte_sysexit(void); |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame^] | 131 | extern int kvmppc_mmu_hv_init(void); |
Alexander Graf | fef093be | 2010-06-30 15:18:46 +0200 | [diff] [blame] | 132 | |
Alexander Graf | 5467a97 | 2010-02-19 11:00:38 +0100 | [diff] [blame] | 133 | extern int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, bool data); |
| 134 | extern int kvmppc_st(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, bool data); |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 135 | extern void kvmppc_book3s_queue_irqprio(struct kvm_vcpu *vcpu, unsigned int vec); |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame^] | 136 | extern void kvmppc_inject_interrupt(struct kvm_vcpu *vcpu, int vec, u64 flags); |
Alexander Graf | e15a113 | 2009-11-30 03:02:02 +0000 | [diff] [blame] | 137 | extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat, |
| 138 | bool upper, u32 val); |
Alexander Graf | aba3bd7 | 2010-02-19 11:00:39 +0100 | [diff] [blame] | 139 | extern void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr); |
Alexander Graf | 831317b | 2010-02-19 11:00:44 +0100 | [diff] [blame] | 140 | extern int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu); |
Alexander Graf | e850894 | 2010-07-29 14:47:54 +0200 | [diff] [blame] | 141 | extern pfn_t kvmppc_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn); |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 142 | |
Alexander Graf | a22a2da | 2011-06-07 20:45:34 +0200 | [diff] [blame] | 143 | extern void kvmppc_handler_lowmem_trampoline(void); |
| 144 | extern void kvmppc_handler_trampoline_enter(void); |
Alexander Graf | 021ec9c | 2010-01-08 02:58:06 +0100 | [diff] [blame] | 145 | extern void kvmppc_rmcall(ulong srr0, ulong srr1); |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame^] | 146 | extern void kvmppc_hv_entry_trampoline(void); |
Alexander Graf | d5e5281 | 2010-01-15 14:49:10 +0100 | [diff] [blame] | 147 | extern void kvmppc_load_up_fpu(void); |
| 148 | extern void kvmppc_load_up_altivec(void); |
| 149 | extern void kvmppc_load_up_vsx(void); |
Alexander Graf | ca7f420 | 2010-03-24 21:48:28 +0100 | [diff] [blame] | 150 | extern u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst); |
| 151 | extern ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst); |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 152 | |
| 153 | static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu) |
| 154 | { |
| 155 | return container_of(vcpu, struct kvmppc_vcpu_book3s, vcpu); |
| 156 | } |
| 157 | |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame^] | 158 | extern void kvm_return_point(void); |
| 159 | |
| 160 | /* Also add subarch specific defines */ |
| 161 | |
| 162 | #ifdef CONFIG_KVM_BOOK3S_32_HANDLER |
| 163 | #include <asm/kvm_book3s_32.h> |
| 164 | #endif |
| 165 | #ifdef CONFIG_KVM_BOOK3S_64_HANDLER |
| 166 | #include <asm/kvm_book3s_64.h> |
| 167 | #endif |
| 168 | |
| 169 | #ifdef CONFIG_KVM_BOOK3S_PR |
| 170 | |
Paul Mackerras | f05ed4d | 2011-06-29 00:17:58 +0000 | [diff] [blame] | 171 | static inline unsigned long kvmppc_interrupt_offset(struct kvm_vcpu *vcpu) |
| 172 | { |
| 173 | return to_book3s(vcpu)->hior; |
| 174 | } |
| 175 | |
| 176 | static inline void kvmppc_update_int_pending(struct kvm_vcpu *vcpu, |
| 177 | unsigned long pending_now, unsigned long old_pending) |
| 178 | { |
| 179 | if (pending_now) |
| 180 | vcpu->arch.shared->int_pending = 1; |
| 181 | else if (old_pending) |
| 182 | vcpu->arch.shared->int_pending = 0; |
| 183 | } |
| 184 | |
Alexander Graf | c7f38f4 | 2010-04-16 00:11:40 +0200 | [diff] [blame] | 185 | static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val) |
| 186 | { |
| 187 | if ( num < 14 ) { |
| 188 | to_svcpu(vcpu)->gpr[num] = val; |
| 189 | to_book3s(vcpu)->shadow_vcpu->gpr[num] = val; |
| 190 | } else |
| 191 | vcpu->arch.gpr[num] = val; |
| 192 | } |
| 193 | |
| 194 | static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num) |
| 195 | { |
| 196 | if ( num < 14 ) |
| 197 | return to_svcpu(vcpu)->gpr[num]; |
| 198 | else |
| 199 | return vcpu->arch.gpr[num]; |
| 200 | } |
| 201 | |
| 202 | static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val) |
| 203 | { |
| 204 | to_svcpu(vcpu)->cr = val; |
| 205 | to_book3s(vcpu)->shadow_vcpu->cr = val; |
| 206 | } |
| 207 | |
| 208 | static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu) |
| 209 | { |
| 210 | return to_svcpu(vcpu)->cr; |
| 211 | } |
| 212 | |
| 213 | static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val) |
| 214 | { |
| 215 | to_svcpu(vcpu)->xer = val; |
| 216 | to_book3s(vcpu)->shadow_vcpu->xer = val; |
| 217 | } |
| 218 | |
| 219 | static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu) |
| 220 | { |
| 221 | return to_svcpu(vcpu)->xer; |
| 222 | } |
| 223 | |
| 224 | static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val) |
| 225 | { |
| 226 | to_svcpu(vcpu)->ctr = val; |
| 227 | } |
| 228 | |
| 229 | static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu) |
| 230 | { |
| 231 | return to_svcpu(vcpu)->ctr; |
| 232 | } |
| 233 | |
| 234 | static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val) |
| 235 | { |
| 236 | to_svcpu(vcpu)->lr = val; |
| 237 | } |
| 238 | |
| 239 | static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu) |
| 240 | { |
| 241 | return to_svcpu(vcpu)->lr; |
| 242 | } |
| 243 | |
| 244 | static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val) |
| 245 | { |
| 246 | to_svcpu(vcpu)->pc = val; |
| 247 | } |
| 248 | |
| 249 | static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu) |
| 250 | { |
| 251 | return to_svcpu(vcpu)->pc; |
| 252 | } |
| 253 | |
| 254 | static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu) |
| 255 | { |
| 256 | ulong pc = kvmppc_get_pc(vcpu); |
| 257 | struct kvmppc_book3s_shadow_vcpu *svcpu = to_svcpu(vcpu); |
| 258 | |
| 259 | /* Load the instruction manually if it failed to do so in the |
| 260 | * exit path */ |
| 261 | if (svcpu->last_inst == KVM_INST_FETCH_FAILED) |
| 262 | kvmppc_ld(vcpu, &pc, sizeof(u32), &svcpu->last_inst, false); |
| 263 | |
| 264 | return svcpu->last_inst; |
| 265 | } |
| 266 | |
| 267 | static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu) |
| 268 | { |
| 269 | return to_svcpu(vcpu)->fault_dar; |
| 270 | } |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 271 | |
Paul Mackerras | f05ed4d | 2011-06-29 00:17:58 +0000 | [diff] [blame] | 272 | static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu) |
| 273 | { |
| 274 | ulong crit_raw = vcpu->arch.shared->critical; |
| 275 | ulong crit_r1 = kvmppc_get_gpr(vcpu, 1); |
| 276 | bool crit; |
| 277 | |
| 278 | /* Truncate crit indicators in 32 bit mode */ |
| 279 | if (!(vcpu->arch.shared->msr & MSR_SF)) { |
| 280 | crit_raw &= 0xffffffff; |
| 281 | crit_r1 &= 0xffffffff; |
| 282 | } |
| 283 | |
| 284 | /* Critical section when crit == r1 */ |
| 285 | crit = (crit_raw == crit_r1); |
| 286 | /* ... and we're in supervisor mode */ |
| 287 | crit = crit && !(vcpu->arch.shared->msr & MSR_PR); |
| 288 | |
| 289 | return crit; |
| 290 | } |
Paul Mackerras | de56a94 | 2011-06-29 00:21:34 +0000 | [diff] [blame^] | 291 | #else /* CONFIG_KVM_BOOK3S_PR */ |
| 292 | |
| 293 | static inline unsigned long kvmppc_interrupt_offset(struct kvm_vcpu *vcpu) |
| 294 | { |
| 295 | return 0; |
| 296 | } |
| 297 | |
| 298 | static inline void kvmppc_update_int_pending(struct kvm_vcpu *vcpu, |
| 299 | unsigned long pending_now, unsigned long old_pending) |
| 300 | { |
| 301 | /* Recalculate LPCR:MER based on the presence of |
| 302 | * a pending external interrupt |
| 303 | */ |
| 304 | if (test_bit(BOOK3S_IRQPRIO_EXTERNAL, &pending_now) || |
| 305 | test_bit(BOOK3S_IRQPRIO_EXTERNAL_LEVEL, &pending_now)) |
| 306 | vcpu->arch.lpcr |= LPCR_MER; |
| 307 | else |
| 308 | vcpu->arch.lpcr &= ~((u64)LPCR_MER); |
| 309 | } |
| 310 | |
| 311 | static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val) |
| 312 | { |
| 313 | vcpu->arch.gpr[num] = val; |
| 314 | } |
| 315 | |
| 316 | static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num) |
| 317 | { |
| 318 | return vcpu->arch.gpr[num]; |
| 319 | } |
| 320 | |
| 321 | static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val) |
| 322 | { |
| 323 | vcpu->arch.cr = val; |
| 324 | } |
| 325 | |
| 326 | static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu) |
| 327 | { |
| 328 | return vcpu->arch.cr; |
| 329 | } |
| 330 | |
| 331 | static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val) |
| 332 | { |
| 333 | vcpu->arch.xer = val; |
| 334 | } |
| 335 | |
| 336 | static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu) |
| 337 | { |
| 338 | return vcpu->arch.xer; |
| 339 | } |
| 340 | |
| 341 | static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val) |
| 342 | { |
| 343 | vcpu->arch.ctr = val; |
| 344 | } |
| 345 | |
| 346 | static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu) |
| 347 | { |
| 348 | return vcpu->arch.ctr; |
| 349 | } |
| 350 | |
| 351 | static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val) |
| 352 | { |
| 353 | vcpu->arch.lr = val; |
| 354 | } |
| 355 | |
| 356 | static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu) |
| 357 | { |
| 358 | return vcpu->arch.lr; |
| 359 | } |
| 360 | |
| 361 | static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val) |
| 362 | { |
| 363 | vcpu->arch.pc = val; |
| 364 | } |
| 365 | |
| 366 | static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu) |
| 367 | { |
| 368 | return vcpu->arch.pc; |
| 369 | } |
| 370 | |
| 371 | static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu) |
| 372 | { |
| 373 | ulong pc = kvmppc_get_pc(vcpu); |
| 374 | |
| 375 | /* Load the instruction manually if it failed to do so in the |
| 376 | * exit path */ |
| 377 | if (vcpu->arch.last_inst == KVM_INST_FETCH_FAILED) |
| 378 | kvmppc_ld(vcpu, &pc, sizeof(u32), &vcpu->arch.last_inst, false); |
| 379 | |
| 380 | return vcpu->arch.last_inst; |
| 381 | } |
| 382 | |
| 383 | static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu) |
| 384 | { |
| 385 | return vcpu->arch.fault_dar; |
| 386 | } |
| 387 | |
| 388 | static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu) |
| 389 | { |
| 390 | return false; |
| 391 | } |
| 392 | #endif |
Paul Mackerras | f05ed4d | 2011-06-29 00:17:58 +0000 | [diff] [blame] | 393 | |
Alexander Graf | ad0a048 | 2010-03-24 21:48:30 +0100 | [diff] [blame] | 394 | /* Magic register values loaded into r3 and r4 before the 'sc' assembly |
| 395 | * instruction for the OSI hypercalls */ |
| 396 | #define OSI_SC_MAGIC_R3 0x113724FA |
| 397 | #define OSI_SC_MAGIC_R4 0x77810F9B |
| 398 | |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 399 | #define INS_DCBZ 0x7c0007ec |
| 400 | |
Alexander Graf | 4e342025 | 2009-10-30 05:47:05 +0000 | [diff] [blame] | 401 | #endif /* __ASM_KVM_BOOK3S_H__ */ |