20 #ifndef __ASM_KVM_BOOK3S_H__
21 #define __ASM_KVM_BOOK3S_H__
23 #include <linux/types.h>
45 #define SID_MAP_BITS 9
46 #define SID_MAP_NUM (1 << SID_MAP_BITS)
47 #define SID_MAP_MASK (SID_MAP_NUM - 1)
49 #ifdef CONFIG_PPC_BOOK3S_64
50 #define SID_CONTEXTS 1
52 #define SID_CONTEXTS 128
53 #define VSID_POOL_SIZE (SID_CONTEXTS * 16)
84 #ifdef CONFIG_PPC_BOOK3S_32
104 #define CONTEXT_HOST 0
105 #define CONTEXT_GUEST 1
106 #define CONTEXT_GUEST_END 2
108 #define VSID_REAL 0x1fffffffffc00000ULL
109 #define VSID_BAT 0x1fffffffffb00000ULL
110 #define VSID_REAL_DR 0x2000000000000000ULL
111 #define VSID_REAL_IR 0x4000000000000000ULL
112 #define VSID_PR 0x8000000000000000ULL
129 unsigned long slb_v,
unsigned long valid);
150 unsigned long *rmap,
long pte_index,
int realmode);
156 unsigned long *nb_ret);
159 long pte_index,
unsigned long pteh,
unsigned long ptel);
161 long pte_index,
unsigned long pteh,
unsigned long ptel);
183 #ifdef CONFIG_KVM_BOOK3S_32_HANDLER
186 #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
190 #ifdef CONFIG_KVM_BOOK3S_PR
192 static inline unsigned long kvmppc_interrupt_offset(
struct kvm_vcpu *
vcpu)
194 return to_book3s(vcpu)->hior;
197 static inline void kvmppc_update_int_pending(
struct kvm_vcpu *
vcpu,
198 unsigned long pending_now,
unsigned long old_pending)
201 vcpu->
arch.shared->int_pending = 1;
202 else if (old_pending)
203 vcpu->
arch.shared->int_pending = 0;
206 static inline void kvmppc_set_gpr(
struct kvm_vcpu *vcpu,
int num,
ulong val)
212 to_book3s(vcpu)->shadow_vcpu->gpr[num] =
val;
217 static inline ulong kvmppc_get_gpr(
struct kvm_vcpu *vcpu,
int num)
225 return vcpu->
arch.gpr[num];
228 static inline void kvmppc_set_cr(
struct kvm_vcpu *vcpu,
u32 val)
233 to_book3s(vcpu)->shadow_vcpu->cr =
val;
236 static inline u32 kvmppc_get_cr(
struct kvm_vcpu *vcpu)
245 static inline void kvmppc_set_xer(
struct kvm_vcpu *vcpu,
u32 val)
249 to_book3s(vcpu)->shadow_vcpu->xer =
val;
253 static inline u32 kvmppc_get_xer(
struct kvm_vcpu *vcpu)
262 static inline void kvmppc_set_ctr(
struct kvm_vcpu *vcpu,
ulong val)
278 static inline void kvmppc_set_lr(
struct kvm_vcpu *vcpu,
ulong val)
294 static inline void kvmppc_set_pc(
struct kvm_vcpu *vcpu,
ulong val)
310 static inline u32 kvmppc_get_last_inst(
struct kvm_vcpu *vcpu)
312 ulong pc = kvmppc_get_pc(vcpu);
326 static inline ulong kvmppc_get_fault_dar(
struct kvm_vcpu *vcpu)
335 static inline bool kvmppc_critical_section(
struct kvm_vcpu *vcpu)
337 ulong crit_raw = vcpu->
arch.shared->critical;
338 ulong crit_r1 = kvmppc_get_gpr(vcpu, 1);
342 if (!(vcpu->
arch.shared->msr & MSR_SF)) {
343 crit_raw &= 0xffffffff;
344 crit_r1 &= 0xffffffff;
348 crit = (crit_raw == crit_r1);
350 crit = crit && !(vcpu->
arch.shared->msr & MSR_PR);
356 static inline unsigned long kvmppc_interrupt_offset(
struct kvm_vcpu *vcpu)
361 static inline void kvmppc_update_int_pending(
struct kvm_vcpu *vcpu,
362 unsigned long pending_now,
unsigned long old_pending)
366 static inline void kvmppc_set_gpr(
struct kvm_vcpu *vcpu,
int num,
ulong val)
371 static inline ulong kvmppc_get_gpr(
struct kvm_vcpu *vcpu,
int num)
373 return vcpu->
arch.gpr[num];
376 static inline void kvmppc_set_cr(
struct kvm_vcpu *vcpu,
u32 val)
381 static inline u32 kvmppc_get_cr(
struct kvm_vcpu *vcpu)
383 return vcpu->
arch.cr;
386 static inline void kvmppc_set_xer(
struct kvm_vcpu *vcpu,
u32 val)
391 static inline u32 kvmppc_get_xer(
struct kvm_vcpu *vcpu)
393 return vcpu->
arch.xer;
396 static inline void kvmppc_set_ctr(
struct kvm_vcpu *vcpu,
ulong val)
403 return vcpu->
arch.ctr;
406 static inline void kvmppc_set_lr(
struct kvm_vcpu *vcpu,
ulong val)
413 return vcpu->
arch.lr;
416 static inline void kvmppc_set_pc(
struct kvm_vcpu *vcpu,
ulong val)
423 return vcpu->
arch.pc;
426 static inline u32 kvmppc_get_last_inst(
struct kvm_vcpu *vcpu)
428 ulong pc = kvmppc_get_pc(vcpu);
435 return vcpu->
arch.last_inst;
438 static inline ulong kvmppc_get_fault_dar(
struct kvm_vcpu *vcpu)
440 return vcpu->
arch.fault_dar;
443 static inline bool kvmppc_critical_section(
struct kvm_vcpu *vcpu)
451 #define OSI_SC_MAGIC_R3 0x113724FA
452 #define OSI_SC_MAGIC_R4 0x77810F9B
454 #define INS_DCBZ 0x7c0007ec
457 #define KVMPPC_NR_LPIDS (LPID_RSVD + 1)