Merge tag 'for-4.21/libata-20190102' of git://git.kernel.dk/linux-block
[linux-2.6-block.git] / arch / powerpc / include / asm / kvm_booke.h
CommitLineData
c7f38f46
AG
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 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
188e267c
MC
26/*
27 * Number of available lpids. Only the low-order 6 bits of LPID rgister are
28 * implemented on e500mc+ cores.
29 */
043cc4d7
SW
30#define KVMPPC_NR_LPIDS 64
31
b12c7841
BB
32#define KVMPPC_INST_EHPRIV 0x7c00021c
33#define EHPRIV_OC_SHIFT 11
34/* "ehpriv 1" : ehpriv with OC = 1 is used for debug emulation */
35#define EHPRIV_OC_DEBUG 1
8c32a2ea 36
c7f38f46
AG
37static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
38{
1143a706 39 vcpu->arch.regs.gpr[num] = val;
c7f38f46
AG
40}
41
42static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
43{
1143a706 44 return vcpu->arch.regs.gpr[num];
c7f38f46
AG
45}
46
47static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
48{
fd0944ba 49 vcpu->arch.regs.ccr = val;
c7f38f46
AG
50}
51
52static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
53{
fd0944ba 54 return vcpu->arch.regs.ccr;
c7f38f46
AG
55}
56
c63517c2 57static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val)
c7f38f46 58{
173c520a 59 vcpu->arch.regs.xer = val;
c7f38f46
AG
60}
61
c63517c2 62static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu)
c7f38f46 63{
173c520a 64 return vcpu->arch.regs.xer;
c7f38f46
AG
65}
66
73601775
CLG
67static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu)
68{
69 /* XXX Would need to check TLB entry */
70 return false;
71}
72
c7f38f46
AG
73static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
74{
173c520a 75 vcpu->arch.regs.ctr = val;
c7f38f46
AG
76}
77
78static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
79{
173c520a 80 return vcpu->arch.regs.ctr;
c7f38f46
AG
81}
82
83static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
84{
173c520a 85 vcpu->arch.regs.link = val;
c7f38f46
AG
86}
87
88static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
89{
173c520a 90 return vcpu->arch.regs.link;
c7f38f46
AG
91}
92
93static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
94{
173c520a 95 vcpu->arch.regs.nip = val;
c7f38f46
AG
96}
97
98static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
99{
173c520a 100 return vcpu->arch.regs.nip;
c7f38f46
AG
101}
102
103static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)
104{
105 return vcpu->arch.fault_dear;
106}
c12fb43c
AG
107
108static inline bool kvmppc_supports_magic_page(struct kvm_vcpu *vcpu)
109{
110 /* Magic page is only supported on e500v2 */
111#ifdef CONFIG_KVM_E500V2
112 return true;
113#else
114 return false;
115#endif
116}
c7f38f46 117#endif /* __ASM_KVM_BOOKE_H__ */