xref: /kvmtool/mips/include/asm/kvm.h (revision 6002122071ef0fe9b42e9ecaa4de769b2645f89b)
1*60021220SAndre Przywara /*
2*60021220SAndre Przywara  * This file is subject to the terms and conditions of the GNU General Public
3*60021220SAndre Przywara  * License.  See the file "COPYING" in the main directory of this archive
4*60021220SAndre Przywara  * for more details.
5*60021220SAndre Przywara  *
6*60021220SAndre Przywara  * Copyright (C) 2012  MIPS Technologies, Inc.  All rights reserved.
7*60021220SAndre Przywara  * Copyright (C) 2013 Cavium, Inc.
8*60021220SAndre Przywara  * Authors: Sanjay Lal <sanjayl@kymasys.com>
9*60021220SAndre Przywara  */
10*60021220SAndre Przywara 
11*60021220SAndre Przywara #ifndef __LINUX_KVM_MIPS_H
12*60021220SAndre Przywara #define __LINUX_KVM_MIPS_H
13*60021220SAndre Przywara 
14*60021220SAndre Przywara #include <linux/types.h>
15*60021220SAndre Przywara 
16*60021220SAndre Przywara /*
17*60021220SAndre Przywara  * KVM MIPS specific structures and definitions.
18*60021220SAndre Przywara  *
19*60021220SAndre Przywara  * Some parts derived from the x86 version of this file.
20*60021220SAndre Przywara  */
21*60021220SAndre Przywara 
22*60021220SAndre Przywara /*
23*60021220SAndre Przywara  * for KVM_GET_REGS and KVM_SET_REGS
24*60021220SAndre Przywara  *
25*60021220SAndre Przywara  * If Config[AT] is zero (32-bit CPU), the register contents are
26*60021220SAndre Przywara  * stored in the lower 32-bits of the struct kvm_regs fields and sign
27*60021220SAndre Przywara  * extended to 64-bits.
28*60021220SAndre Przywara  */
29*60021220SAndre Przywara struct kvm_regs {
30*60021220SAndre Przywara 	/* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
31*60021220SAndre Przywara 	__u64 gpr[32];
32*60021220SAndre Przywara 	__u64 hi;
33*60021220SAndre Przywara 	__u64 lo;
34*60021220SAndre Przywara 	__u64 pc;
35*60021220SAndre Przywara };
36*60021220SAndre Przywara 
37*60021220SAndre Przywara /*
38*60021220SAndre Przywara  * for KVM_GET_FPU and KVM_SET_FPU
39*60021220SAndre Przywara  */
40*60021220SAndre Przywara struct kvm_fpu {
41*60021220SAndre Przywara };
42*60021220SAndre Przywara 
43*60021220SAndre Przywara 
44*60021220SAndre Przywara /*
45*60021220SAndre Przywara  * For MIPS, we use KVM_SET_ONE_REG and KVM_GET_ONE_REG to access various
46*60021220SAndre Przywara  * registers.  The id field is broken down as follows:
47*60021220SAndre Przywara  *
48*60021220SAndre Przywara  *  bits[63..52] - As per linux/kvm.h
49*60021220SAndre Przywara  *  bits[51..32] - Must be zero.
50*60021220SAndre Przywara  *  bits[31..16] - Register set.
51*60021220SAndre Przywara  *
52*60021220SAndre Przywara  * Register set = 0: GP registers from kvm_regs (see definitions below).
53*60021220SAndre Przywara  *
54*60021220SAndre Przywara  * Register set = 1: CP0 registers.
55*60021220SAndre Przywara  *  bits[15..8]  - Must be zero.
56*60021220SAndre Przywara  *  bits[7..3]   - Register 'rd'  index.
57*60021220SAndre Przywara  *  bits[2..0]   - Register 'sel' index.
58*60021220SAndre Przywara  *
59*60021220SAndre Przywara  * Register set = 2: KVM specific registers (see definitions below).
60*60021220SAndre Przywara  *
61*60021220SAndre Przywara  * Register set = 3: FPU / MSA registers (see definitions below).
62*60021220SAndre Przywara  *
63*60021220SAndre Przywara  * Other sets registers may be added in the future.  Each set would
64*60021220SAndre Przywara  * have its own identifier in bits[31..16].
65*60021220SAndre Przywara  */
66*60021220SAndre Przywara 
67*60021220SAndre Przywara #define KVM_REG_MIPS_GP		(KVM_REG_MIPS | 0x0000000000000000ULL)
68*60021220SAndre Przywara #define KVM_REG_MIPS_CP0	(KVM_REG_MIPS | 0x0000000000010000ULL)
69*60021220SAndre Przywara #define KVM_REG_MIPS_KVM	(KVM_REG_MIPS | 0x0000000000020000ULL)
70*60021220SAndre Przywara #define KVM_REG_MIPS_FPU	(KVM_REG_MIPS | 0x0000000000030000ULL)
71*60021220SAndre Przywara 
72*60021220SAndre Przywara 
73*60021220SAndre Przywara /*
74*60021220SAndre Przywara  * KVM_REG_MIPS_GP - General purpose registers from kvm_regs.
75*60021220SAndre Przywara  */
76*60021220SAndre Przywara 
77*60021220SAndre Przywara #define KVM_REG_MIPS_R0		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  0)
78*60021220SAndre Przywara #define KVM_REG_MIPS_R1		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  1)
79*60021220SAndre Przywara #define KVM_REG_MIPS_R2		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  2)
80*60021220SAndre Przywara #define KVM_REG_MIPS_R3		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  3)
81*60021220SAndre Przywara #define KVM_REG_MIPS_R4		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  4)
82*60021220SAndre Przywara #define KVM_REG_MIPS_R5		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  5)
83*60021220SAndre Przywara #define KVM_REG_MIPS_R6		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  6)
84*60021220SAndre Przywara #define KVM_REG_MIPS_R7		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  7)
85*60021220SAndre Przywara #define KVM_REG_MIPS_R8		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  8)
86*60021220SAndre Przywara #define KVM_REG_MIPS_R9		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  9)
87*60021220SAndre Przywara #define KVM_REG_MIPS_R10	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 10)
88*60021220SAndre Przywara #define KVM_REG_MIPS_R11	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 11)
89*60021220SAndre Przywara #define KVM_REG_MIPS_R12	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 12)
90*60021220SAndre Przywara #define KVM_REG_MIPS_R13	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 13)
91*60021220SAndre Przywara #define KVM_REG_MIPS_R14	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 14)
92*60021220SAndre Przywara #define KVM_REG_MIPS_R15	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 15)
93*60021220SAndre Przywara #define KVM_REG_MIPS_R16	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 16)
94*60021220SAndre Przywara #define KVM_REG_MIPS_R17	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 17)
95*60021220SAndre Przywara #define KVM_REG_MIPS_R18	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 18)
96*60021220SAndre Przywara #define KVM_REG_MIPS_R19	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 19)
97*60021220SAndre Przywara #define KVM_REG_MIPS_R20	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 20)
98*60021220SAndre Przywara #define KVM_REG_MIPS_R21	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 21)
99*60021220SAndre Przywara #define KVM_REG_MIPS_R22	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 22)
100*60021220SAndre Przywara #define KVM_REG_MIPS_R23	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 23)
101*60021220SAndre Przywara #define KVM_REG_MIPS_R24	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 24)
102*60021220SAndre Przywara #define KVM_REG_MIPS_R25	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 25)
103*60021220SAndre Przywara #define KVM_REG_MIPS_R26	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 26)
104*60021220SAndre Przywara #define KVM_REG_MIPS_R27	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 27)
105*60021220SAndre Przywara #define KVM_REG_MIPS_R28	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 28)
106*60021220SAndre Przywara #define KVM_REG_MIPS_R29	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 29)
107*60021220SAndre Przywara #define KVM_REG_MIPS_R30	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 30)
108*60021220SAndre Przywara #define KVM_REG_MIPS_R31	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 31)
109*60021220SAndre Przywara 
110*60021220SAndre Przywara #define KVM_REG_MIPS_HI		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 32)
111*60021220SAndre Przywara #define KVM_REG_MIPS_LO		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 33)
112*60021220SAndre Przywara #define KVM_REG_MIPS_PC		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 34)
113*60021220SAndre Przywara 
114*60021220SAndre Przywara 
115*60021220SAndre Przywara /*
116*60021220SAndre Przywara  * KVM_REG_MIPS_KVM - KVM specific control registers.
117*60021220SAndre Przywara  */
118*60021220SAndre Przywara 
119*60021220SAndre Przywara /*
120*60021220SAndre Przywara  * CP0_Count control
121*60021220SAndre Przywara  * DC:    Set 0: Master disable CP0_Count and set COUNT_RESUME to now
122*60021220SAndre Przywara  *        Set 1: Master re-enable CP0_Count with unchanged bias, handling timer
123*60021220SAndre Przywara  *               interrupts since COUNT_RESUME
124*60021220SAndre Przywara  *        This can be used to freeze the timer to get a consistent snapshot of
125*60021220SAndre Przywara  *        the CP0_Count and timer interrupt pending state, while also resuming
126*60021220SAndre Przywara  *        safely without losing time or guest timer interrupts.
127*60021220SAndre Przywara  * Other: Reserved, do not change.
128*60021220SAndre Przywara  */
129*60021220SAndre Przywara #define KVM_REG_MIPS_COUNT_CTL	    (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 0)
130*60021220SAndre Przywara #define KVM_REG_MIPS_COUNT_CTL_DC	0x00000001
131*60021220SAndre Przywara 
132*60021220SAndre Przywara /*
133*60021220SAndre Przywara  * CP0_Count resume monotonic nanoseconds
134*60021220SAndre Przywara  * The monotonic nanosecond time of the last set of COUNT_CTL.DC (master
135*60021220SAndre Przywara  * disable). Any reads and writes of Count related registers while
136*60021220SAndre Przywara  * COUNT_CTL.DC=1 will appear to occur at this time. When COUNT_CTL.DC is
137*60021220SAndre Przywara  * cleared again (master enable) any timer interrupts since this time will be
138*60021220SAndre Przywara  * emulated.
139*60021220SAndre Przywara  * Modifications to times in the future are rejected.
140*60021220SAndre Przywara  */
141*60021220SAndre Przywara #define KVM_REG_MIPS_COUNT_RESUME   (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 1)
142*60021220SAndre Przywara /*
143*60021220SAndre Przywara  * CP0_Count rate in Hz
144*60021220SAndre Przywara  * Specifies the rate of the CP0_Count timer in Hz. Modifications occur without
145*60021220SAndre Przywara  * discontinuities in CP0_Count.
146*60021220SAndre Przywara  */
147*60021220SAndre Przywara #define KVM_REG_MIPS_COUNT_HZ	    (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 2)
148*60021220SAndre Przywara 
149*60021220SAndre Przywara 
150*60021220SAndre Przywara /*
151*60021220SAndre Przywara  * KVM_REG_MIPS_FPU - Floating Point and MIPS SIMD Architecture (MSA) registers.
152*60021220SAndre Przywara  *
153*60021220SAndre Przywara  *  bits[15..8]  - Register subset (see definitions below).
154*60021220SAndre Przywara  *  bits[7..5]   - Must be zero.
155*60021220SAndre Przywara  *  bits[4..0]   - Register number within register subset.
156*60021220SAndre Przywara  */
157*60021220SAndre Przywara 
158*60021220SAndre Przywara #define KVM_REG_MIPS_FPR	(KVM_REG_MIPS_FPU | 0x0000000000000000ULL)
159*60021220SAndre Przywara #define KVM_REG_MIPS_FCR	(KVM_REG_MIPS_FPU | 0x0000000000000100ULL)
160*60021220SAndre Przywara #define KVM_REG_MIPS_MSACR	(KVM_REG_MIPS_FPU | 0x0000000000000200ULL)
161*60021220SAndre Przywara 
162*60021220SAndre Przywara /*
163*60021220SAndre Przywara  * KVM_REG_MIPS_FPR - Floating point / Vector registers.
164*60021220SAndre Przywara  */
165*60021220SAndre Przywara #define KVM_REG_MIPS_FPR_32(n)	(KVM_REG_MIPS_FPR | KVM_REG_SIZE_U32  | (n))
166*60021220SAndre Przywara #define KVM_REG_MIPS_FPR_64(n)	(KVM_REG_MIPS_FPR | KVM_REG_SIZE_U64  | (n))
167*60021220SAndre Przywara #define KVM_REG_MIPS_VEC_128(n)	(KVM_REG_MIPS_FPR | KVM_REG_SIZE_U128 | (n))
168*60021220SAndre Przywara 
169*60021220SAndre Przywara /*
170*60021220SAndre Przywara  * KVM_REG_MIPS_FCR - Floating point control registers.
171*60021220SAndre Przywara  */
172*60021220SAndre Przywara #define KVM_REG_MIPS_FCR_IR	(KVM_REG_MIPS_FCR | KVM_REG_SIZE_U32 |  0)
173*60021220SAndre Przywara #define KVM_REG_MIPS_FCR_CSR	(KVM_REG_MIPS_FCR | KVM_REG_SIZE_U32 | 31)
174*60021220SAndre Przywara 
175*60021220SAndre Przywara /*
176*60021220SAndre Przywara  * KVM_REG_MIPS_MSACR - MIPS SIMD Architecture (MSA) control registers.
177*60021220SAndre Przywara  */
178*60021220SAndre Przywara #define KVM_REG_MIPS_MSA_IR	 (KVM_REG_MIPS_MSACR | KVM_REG_SIZE_U32 |  0)
179*60021220SAndre Przywara #define KVM_REG_MIPS_MSA_CSR	 (KVM_REG_MIPS_MSACR | KVM_REG_SIZE_U32 |  1)
180*60021220SAndre Przywara 
181*60021220SAndre Przywara 
182*60021220SAndre Przywara /*
183*60021220SAndre Przywara  * KVM MIPS specific structures and definitions
184*60021220SAndre Przywara  *
185*60021220SAndre Przywara  */
186*60021220SAndre Przywara struct kvm_debug_exit_arch {
187*60021220SAndre Przywara 	__u64 epc;
188*60021220SAndre Przywara };
189*60021220SAndre Przywara 
190*60021220SAndre Przywara /* for KVM_SET_GUEST_DEBUG */
191*60021220SAndre Przywara struct kvm_guest_debug_arch {
192*60021220SAndre Przywara };
193*60021220SAndre Przywara 
194*60021220SAndre Przywara /* definition of registers in kvm_run */
195*60021220SAndre Przywara struct kvm_sync_regs {
196*60021220SAndre Przywara };
197*60021220SAndre Przywara 
198*60021220SAndre Przywara /* dummy definition */
199*60021220SAndre Przywara struct kvm_sregs {
200*60021220SAndre Przywara };
201*60021220SAndre Przywara 
202*60021220SAndre Przywara struct kvm_mips_interrupt {
203*60021220SAndre Przywara 	/* in */
204*60021220SAndre Przywara 	__u32 cpu;
205*60021220SAndre Przywara 	__u32 irq;
206*60021220SAndre Przywara };
207*60021220SAndre Przywara 
208*60021220SAndre Przywara #endif /* __LINUX_KVM_MIPS_H */
209