blob: 80d46b5a7efb49cc6de436e45da6b0b5e690d9cf [file] [log] [blame]
Alexander Grafc7f38f42010-04-16 00:11:40 +02001/*
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 2010
16 *
17 * Authors: Alexander Graf <agraf@suse.de>
18 */
19
20#ifndef __ASM_KVM_BOOKE_H__
21#define __ASM_KVM_BOOKE_H__
22
23#include <linux/types.h>
24#include <linux/kvm_host.h>
25
Scott Wood043cc4d2011-12-20 15:34:20 +000026/* LPIDs we support with this build -- runtime limit may be lower */
27#define KVMPPC_NR_LPIDS 64
28
Bharat Bhushanb12c7842013-07-04 12:27:45 +053029#define KVMPPC_INST_EHPRIV 0x7c00021c
30#define EHPRIV_OC_SHIFT 11
31/* "ehpriv 1" : ehpriv with OC = 1 is used for debug emulation */
32#define EHPRIV_OC_DEBUG 1
33#define KVMPPC_INST_EHPRIV_DEBUG (KVMPPC_INST_EHPRIV | \
34 (EHPRIV_OC_DEBUG << EHPRIV_OC_SHIFT))
Bharat Bhushan8c32a2e2013-03-20 20:24:58 +000035
Alexander Grafc7f38f42010-04-16 00:11:40 +020036static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
37{
38 vcpu->arch.gpr[num] = val;
39}
40
41static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
42{
43 return vcpu->arch.gpr[num];
44}
45
46static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
47{
48 vcpu->arch.cr = val;
49}
50
51static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
52{
53 return vcpu->arch.cr;
54}
55
56static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val)
57{
58 vcpu->arch.xer = val;
59}
60
61static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu)
62{
63 return vcpu->arch.xer;
64}
65
Cédric Le Goater73601772014-01-09 11:51:16 +010066static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu)
67{
68 /* XXX Would need to check TLB entry */
69 return false;
70}
71
Alexander Grafc7f38f42010-04-16 00:11:40 +020072static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu)
73{
74 return vcpu->arch.last_inst;
75}
76
77static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
78{
79 vcpu->arch.ctr = val;
80}
81
82static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
83{
84 return vcpu->arch.ctr;
85}
86
87static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
88{
89 vcpu->arch.lr = val;
90}
91
92static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
93{
94 return vcpu->arch.lr;
95}
96
97static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
98{
99 vcpu->arch.pc = val;
100}
101
102static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
103{
104 return vcpu->arch.pc;
105}
106
107static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)
108{
109 return vcpu->arch.fault_dear;
110}
111
Paul Mackerrasde56a942011-06-29 00:21:34 +0000112static inline ulong kvmppc_get_msr(struct kvm_vcpu *vcpu)
113{
114 return vcpu->arch.shared->msr;
115}
Alexander Grafc7f38f42010-04-16 00:11:40 +0200116#endif /* __ASM_KVM_BOOKE_H__ */