Loading...
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 *
4 * Copyright SUSE Linux Products GmbH 2010
5 *
6 * Authors: Alexander Graf <agraf@suse.de>
7 */
8
9#ifndef __ASM_KVM_BOOKE_H__
10#define __ASM_KVM_BOOKE_H__
11
12#include <linux/types.h>
13#include <linux/kvm_host.h>
14
15/*
16 * Number of available lpids. Only the low-order 6 bits of LPID rgister are
17 * implemented on e500mc+ cores.
18 */
19#define KVMPPC_NR_LPIDS 64
20
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
25
26static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
27{
28 vcpu->arch.regs.gpr[num] = val;
29}
30
31static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
32{
33 return vcpu->arch.regs.gpr[num];
34}
35
36static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
37{
38 vcpu->arch.regs.ccr = val;
39}
40
41static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
42{
43 return vcpu->arch.regs.ccr;
44}
45
46static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val)
47{
48 vcpu->arch.regs.xer = val;
49}
50
51static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu)
52{
53 return vcpu->arch.regs.xer;
54}
55
56static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu)
57{
58 /* XXX Would need to check TLB entry */
59 return false;
60}
61
62static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
63{
64 vcpu->arch.regs.ctr = val;
65}
66
67static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
68{
69 return vcpu->arch.regs.ctr;
70}
71
72static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
73{
74 vcpu->arch.regs.link = val;
75}
76
77static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
78{
79 return vcpu->arch.regs.link;
80}
81
82static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
83{
84 vcpu->arch.regs.nip = val;
85}
86
87static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
88{
89 return vcpu->arch.regs.nip;
90}
91
92static inline void kvmppc_set_fpr(struct kvm_vcpu *vcpu, int i, u64 val)
93{
94 vcpu->arch.fp.fpr[i][TS_FPROFFSET] = val;
95}
96
97static inline u64 kvmppc_get_fpr(struct kvm_vcpu *vcpu, int i)
98{
99 return vcpu->arch.fp.fpr[i][TS_FPROFFSET];
100}
101
102#ifdef CONFIG_BOOKE
103static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)
104{
105 return vcpu->arch.fault_dear;
106}
107#endif
108
109static inline bool kvmppc_supports_magic_page(struct kvm_vcpu *vcpu)
110{
111 /* Magic page is only supported on e500v2 */
112#ifdef CONFIG_KVM_E500V2
113 return true;
114#else
115 return false;
116#endif
117}
118#endif /* __ASM_KVM_BOOKE_H__ */
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
26/*
27 * Number of available lpids. Only the low-order 6 bits of LPID rgister are
28 * implemented on e500mc+ cores.
29 */
30#define KVMPPC_NR_LPIDS 64
31
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
36
37static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
38{
39 vcpu->arch.gpr[num] = val;
40}
41
42static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
43{
44 return vcpu->arch.gpr[num];
45}
46
47static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
48{
49 vcpu->arch.cr = val;
50}
51
52static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
53{
54 return vcpu->arch.cr;
55}
56
57static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val)
58{
59 vcpu->arch.xer = val;
60}
61
62static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu)
63{
64 return vcpu->arch.xer;
65}
66
67static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu)
68{
69 /* XXX Would need to check TLB entry */
70 return false;
71}
72
73static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
74{
75 vcpu->arch.ctr = val;
76}
77
78static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
79{
80 return vcpu->arch.ctr;
81}
82
83static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
84{
85 vcpu->arch.lr = val;
86}
87
88static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
89{
90 return vcpu->arch.lr;
91}
92
93static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
94{
95 vcpu->arch.pc = val;
96}
97
98static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
99{
100 return vcpu->arch.pc;
101}
102
103static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)
104{
105 return vcpu->arch.fault_dear;
106}
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}
117#endif /* __ASM_KVM_BOOKE_H__ */