blob: 08fe69edcd103f7882a3e172b7c5a55764009550 [file] [log] [blame]
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -05001/*
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 IBM Corp. 2007
16 *
17 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
18 */
19
Christian Borntraegerdd135eb2008-04-02 13:04:40 -070020#ifndef __LINUX_KVM_POWERPC_H
21#define __LINUX_KVM_POWERPC_H
22
Jaswinder Singh Rajput9f2cd962009-01-31 11:44:45 +053023#include <linux/types.h>
Christian Borntraegerdd135eb2008-04-02 13:04:40 -070024
David Gibson54738c02011-06-29 00:22:41 +000025/* Select powerpc specific features in <linux/kvm.h> */
26#define __KVM_HAVE_SPAPR_TCE
Paul Mackerras371fefd2011-06-29 00:23:08 +000027#define __KVM_HAVE_PPC_SMT
David Gibson54738c02011-06-29 00:22:41 +000028
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -050029struct kvm_regs {
30 __u64 pc;
31 __u64 cr;
32 __u64 ctr;
33 __u64 lr;
34 __u64 xer;
35 __u64 msr;
36 __u64 srr0;
37 __u64 srr1;
38 __u64 pid;
39
40 __u64 sprg0;
41 __u64 sprg1;
42 __u64 sprg2;
43 __u64 sprg3;
44 __u64 sprg4;
45 __u64 sprg5;
46 __u64 sprg6;
47 __u64 sprg7;
48
49 __u64 gpr[32];
50};
51
Scott Wood5ce941e2011-04-27 17:24:21 -050052#define KVM_SREGS_E_IMPL_NONE 0
53#define KVM_SREGS_E_IMPL_FSL 1
54
55#define KVM_SREGS_E_FSL_PIDn (1 << 0) /* PID1/PID2 */
56
57/*
58 * Feature bits indicate which sections of the sregs struct are valid,
59 * both in KVM_GET_SREGS and KVM_SET_SREGS. On KVM_SET_SREGS, registers
60 * corresponding to unset feature bits will not be modified. This allows
61 * restoring a checkpoint made without that feature, while keeping the
62 * default values of the new registers.
63 *
64 * KVM_SREGS_E_BASE contains:
65 * CSRR0/1 (refers to SRR2/3 on 40x)
66 * ESR
67 * DEAR
68 * MCSR
69 * TSR
70 * TCR
71 * DEC
72 * TB
73 * VRSAVE (USPRG0)
74 */
75#define KVM_SREGS_E_BASE (1 << 0)
76
77/*
78 * KVM_SREGS_E_ARCH206 contains:
79 *
80 * PIR
81 * MCSRR0/1
82 * DECAR
83 * IVPR
84 */
85#define KVM_SREGS_E_ARCH206 (1 << 1)
86
87/*
88 * Contains EPCR, plus the upper half of 64-bit registers
89 * that are 32-bit on 32-bit implementations.
90 */
91#define KVM_SREGS_E_64 (1 << 2)
92
93#define KVM_SREGS_E_SPRG8 (1 << 3)
94#define KVM_SREGS_E_MCIVPR (1 << 4)
95
96/*
97 * IVORs are used -- contains IVOR0-15, plus additional IVORs
98 * in combination with an appropriate feature bit.
99 */
100#define KVM_SREGS_E_IVOR (1 << 5)
101
102/*
103 * Contains MAS0-4, MAS6-7, TLBnCFG, MMUCFG.
104 * Also TLBnPS if MMUCFG[MAVN] = 1.
105 */
106#define KVM_SREGS_E_ARCH206_MMU (1 << 6)
107
108/* DBSR, DBCR, IAC, DAC, DVC */
109#define KVM_SREGS_E_DEBUG (1 << 7)
110
111/* Enhanced debug -- DSRR0/1, SPRG9 */
112#define KVM_SREGS_E_ED (1 << 8)
113
114/* Embedded Floating Point (SPE) -- IVOR32-34 if KVM_SREGS_E_IVOR */
115#define KVM_SREGS_E_SPE (1 << 9)
116
117/* External Proxy (EXP) -- EPR */
118#define KVM_SREGS_EXP (1 << 10)
119
120/* External PID (E.PD) -- EPSC/EPLC */
121#define KVM_SREGS_E_PD (1 << 11)
122
123/* Processor Control (E.PC) -- IVOR36-37 if KVM_SREGS_E_IVOR */
124#define KVM_SREGS_E_PC (1 << 12)
125
126/* Page table (E.PT) -- EPTCFG */
127#define KVM_SREGS_E_PT (1 << 13)
128
129/* Embedded Performance Monitor (E.PM) -- IVOR35 if KVM_SREGS_E_IVOR */
130#define KVM_SREGS_E_PM (1 << 14)
131
132/*
133 * Special updates:
134 *
135 * Some registers may change even while a vcpu is not running.
136 * To avoid losing these changes, by default these registers are
137 * not updated by KVM_SET_SREGS. To force an update, set the bit
138 * in u.e.update_special corresponding to the register to be updated.
139 *
140 * The update_special field is zero on return from KVM_GET_SREGS.
141 *
142 * When restoring a checkpoint, the caller can set update_special
143 * to 0xffffffff to ensure that everything is restored, even new features
144 * that the caller doesn't know about.
145 */
146#define KVM_SREGS_E_UPDATE_MCSR (1 << 0)
147#define KVM_SREGS_E_UPDATE_TSR (1 << 1)
148#define KVM_SREGS_E_UPDATE_DEC (1 << 2)
149#define KVM_SREGS_E_UPDATE_DBSR (1 << 3)
150
151/*
Alexander Grafa15bd352011-08-08 17:17:09 +0200152 * Book3S special bits to indicate contents in the struct by maintaining
153 * backwards compatibility with older structs. If adding a new field,
154 * please make sure to add a flag for that new field */
155#define KVM_SREGS_S_HIOR (1 << 0)
156
157/*
Scott Wood5ce941e2011-04-27 17:24:21 -0500158 * In KVM_SET_SREGS, reserved/pad fields must be left untouched from a
159 * previous KVM_GET_REGS.
160 *
161 * Unless otherwise indicated, setting any register with KVM_SET_SREGS
162 * directly sets its value. It does not trigger any special semantics such
163 * as write-one-to-clear. Calling KVM_SET_SREGS on an unmodified struct
164 * just received from KVM_GET_SREGS is always a no-op.
165 */
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500166struct kvm_sregs {
Alexander Grafec3c11a2009-10-30 05:47:02 +0000167 __u32 pvr;
Alexander Grafe15a1132009-11-30 03:02:02 +0000168 union {
169 struct {
170 __u64 sdr1;
171 struct {
172 struct {
173 __u64 slbe;
174 __u64 slbv;
175 } slb[64];
176 } ppc64;
177 struct {
178 __u32 sr[16];
179 __u64 ibat[8];
180 __u64 dbat[8];
181 } ppc32;
Alexander Grafa15bd352011-08-08 17:17:09 +0200182 __u64 flags; /* KVM_SREGS_S_ */
183 __u64 hior;
Alexander Grafe15a1132009-11-30 03:02:02 +0000184 } s;
Scott Wood5ce941e2011-04-27 17:24:21 -0500185 struct {
186 union {
187 struct { /* KVM_SREGS_E_IMPL_FSL */
188 __u32 features; /* KVM_SREGS_E_FSL_ */
189 __u32 svr;
190 __u64 mcar;
191 __u32 hid0;
192
193 /* KVM_SREGS_E_FSL_PIDn */
194 __u32 pid1, pid2;
195 } fsl;
196 __u8 pad[256];
197 } impl;
198
199 __u32 features; /* KVM_SREGS_E_ */
200 __u32 impl_id; /* KVM_SREGS_E_IMPL_ */
201 __u32 update_special; /* KVM_SREGS_E_UPDATE_ */
202 __u32 pir; /* read-only */
203 __u64 sprg8;
204 __u64 sprg9; /* E.ED */
205 __u64 csrr0;
206 __u64 dsrr0; /* E.ED */
207 __u64 mcsrr0;
208 __u32 csrr1;
209 __u32 dsrr1; /* E.ED */
210 __u32 mcsrr1;
211 __u32 esr;
212 __u64 dear;
213 __u64 ivpr;
214 __u64 mcivpr;
215 __u64 mcsr; /* KVM_SREGS_E_UPDATE_MCSR */
216
217 __u32 tsr; /* KVM_SREGS_E_UPDATE_TSR */
218 __u32 tcr;
219 __u32 decar;
220 __u32 dec; /* KVM_SREGS_E_UPDATE_DEC */
221
222 /*
223 * Userspace can read TB directly, but the
224 * value reported here is consistent with "dec".
225 *
226 * Read-only.
227 */
228 __u64 tb;
229
230 __u32 dbsr; /* KVM_SREGS_E_UPDATE_DBSR */
231 __u32 dbcr[3];
232 __u32 iac[4];
233 __u32 dac[2];
234 __u32 dvc[2];
235 __u8 num_iac; /* read-only */
236 __u8 num_dac; /* read-only */
237 __u8 num_dvc; /* read-only */
238 __u8 pad;
239
240 __u32 epr; /* EXP */
241 __u32 vrsave; /* a.k.a. USPRG0 */
242 __u32 epcr; /* KVM_SREGS_E_64 */
243
244 __u32 mas0;
245 __u32 mas1;
246 __u64 mas2;
247 __u64 mas7_3;
248 __u32 mas4;
249 __u32 mas6;
250
251 __u32 ivor_low[16]; /* IVOR0-15 */
252 __u32 ivor_high[18]; /* IVOR32+, plus room to expand */
253
254 __u32 mmucfg; /* read-only */
255 __u32 eptcfg; /* E.PT, read-only */
256 __u32 tlbcfg[4];/* read-only */
257 __u32 tlbps[4]; /* read-only */
258
259 __u32 eplc, epsc; /* E.PD */
260 } e;
Alexander Grafe15a1132009-11-30 03:02:02 +0000261 __u8 pad[1020];
262 } u;
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500263};
264
265struct kvm_fpu {
266 __u64 fpr[32];
267};
268
Jan Kiszkad0bfb942008-12-15 13:52:10 +0100269struct kvm_debug_exit_arch {
270};
271
272/* for KVM_SET_GUEST_DEBUG */
273struct kvm_guest_debug_arch {
274};
275
Alexander Grafb104d062010-02-19 11:00:29 +0100276#define KVM_REG_MASK 0x001f
277#define KVM_REG_EXT_MASK 0xffe0
278#define KVM_REG_GPR 0x0000
279#define KVM_REG_FPR 0x0020
280#define KVM_REG_QPR 0x0040
281#define KVM_REG_FQPR 0x0060
282
Alexander Graf18978762010-03-24 21:48:18 +0100283#define KVM_INTERRUPT_SET -1U
284#define KVM_INTERRUPT_UNSET -2U
Alexander Graf17bd1582010-08-30 10:44:15 +0200285#define KVM_INTERRUPT_SET_LEVEL -3U
Alexander Graf18978762010-03-24 21:48:18 +0100286
Alexander Grafaf8f38b2011-08-10 13:57:08 +0200287#define KVM_CPU_440 1
288#define KVM_CPU_E500V2 2
289#define KVM_CPU_3S_32 3
290#define KVM_CPU_3S_64 4
291
David Gibson54738c02011-06-29 00:22:41 +0000292/* for KVM_CAP_SPAPR_TCE */
293struct kvm_create_spapr_tce {
294 __u64 liobn;
295 __u32 window_size;
296};
297
Paul Mackerrasaa04b4c2011-06-29 00:25:44 +0000298/* for KVM_ALLOCATE_RMA */
299struct kvm_allocate_rma {
300 __u64 rma_size;
301};
302
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500303#endif /* __LINUX_KVM_POWERPC_H */