1 /* SPDX-License-Identifier: GPL-2.0-only */
4 * Copyright SUSE Linux Products GmbH 2010
6 * Authors: Alexander Graf <agraf@suse.de>
9 #ifndef __ASM_KVM_BOOKE_H__
10 #define __ASM_KVM_BOOKE_H__
12 #include <linux/types.h>
13 #include <linux/kvm_host.h>
16 * Number of available lpids. Only the low-order 6 bits of LPID rgister are
17 * implemented on e500mc+ cores.
19 #define KVMPPC_NR_LPIDS 64
21 #define KVMPPC_INST_EHPRIV 0x7c00021c
22 #define EHPRIV_OC_SHIFT 11
23 /* "ehpriv 1" : ehpriv with OC = 1 is used for debug emulation */
24 #define EHPRIV_OC_DEBUG 1
26 static inline void kvmppc_set_gpr(struct kvm_vcpu
*vcpu
, int num
, ulong val
)
28 vcpu
->arch
.regs
.gpr
[num
] = val
;
31 static inline ulong
kvmppc_get_gpr(struct kvm_vcpu
*vcpu
, int num
)
33 return vcpu
->arch
.regs
.gpr
[num
];
36 static inline void kvmppc_set_cr(struct kvm_vcpu
*vcpu
, u32 val
)
38 vcpu
->arch
.regs
.ccr
= val
;
41 static inline u32
kvmppc_get_cr(struct kvm_vcpu
*vcpu
)
43 return vcpu
->arch
.regs
.ccr
;
46 static inline void kvmppc_set_xer(struct kvm_vcpu
*vcpu
, ulong val
)
48 vcpu
->arch
.regs
.xer
= val
;
51 static inline ulong
kvmppc_get_xer(struct kvm_vcpu
*vcpu
)
53 return vcpu
->arch
.regs
.xer
;
56 static inline bool kvmppc_need_byteswap(struct kvm_vcpu
*vcpu
)
58 /* XXX Would need to check TLB entry */
62 static inline void kvmppc_set_ctr(struct kvm_vcpu
*vcpu
, ulong val
)
64 vcpu
->arch
.regs
.ctr
= val
;
67 static inline ulong
kvmppc_get_ctr(struct kvm_vcpu
*vcpu
)
69 return vcpu
->arch
.regs
.ctr
;
72 static inline void kvmppc_set_lr(struct kvm_vcpu
*vcpu
, ulong val
)
74 vcpu
->arch
.regs
.link
= val
;
77 static inline ulong
kvmppc_get_lr(struct kvm_vcpu
*vcpu
)
79 return vcpu
->arch
.regs
.link
;
82 static inline void kvmppc_set_pc(struct kvm_vcpu
*vcpu
, ulong val
)
84 vcpu
->arch
.regs
.nip
= val
;
87 static inline ulong
kvmppc_get_pc(struct kvm_vcpu
*vcpu
)
89 return vcpu
->arch
.regs
.nip
;
92 static inline ulong
kvmppc_get_fault_dar(struct kvm_vcpu
*vcpu
)
94 return vcpu
->arch
.fault_dear
;
97 static inline bool kvmppc_supports_magic_page(struct kvm_vcpu
*vcpu
)
99 /* Magic page is only supported on e500v2 */
100 #ifdef CONFIG_KVM_E500V2
106 #endif /* __ASM_KVM_BOOKE_H__ */