xref: /kvmtool/mips/include/asm/kvm.h (revision 764dfba19d3b5a3a565b303464b6e336198eb6f9)
160021220SAndre Przywara /*
260021220SAndre Przywara  * This file is subject to the terms and conditions of the GNU General Public
360021220SAndre Przywara  * License.  See the file "COPYING" in the main directory of this archive
460021220SAndre Przywara  * for more details.
560021220SAndre Przywara  *
660021220SAndre Przywara  * Copyright (C) 2012  MIPS Technologies, Inc.  All rights reserved.
760021220SAndre Przywara  * Copyright (C) 2013 Cavium, Inc.
860021220SAndre Przywara  * Authors: Sanjay Lal <sanjayl@kymasys.com>
960021220SAndre Przywara  */
1060021220SAndre Przywara 
1160021220SAndre Przywara #ifndef __LINUX_KVM_MIPS_H
1260021220SAndre Przywara #define __LINUX_KVM_MIPS_H
1360021220SAndre Przywara 
1460021220SAndre Przywara #include <linux/types.h>
1560021220SAndre Przywara 
1660021220SAndre Przywara /*
1760021220SAndre Przywara  * KVM MIPS specific structures and definitions.
1860021220SAndre Przywara  *
1960021220SAndre Przywara  * Some parts derived from the x86 version of this file.
2060021220SAndre Przywara  */
2160021220SAndre Przywara 
22*764dfba1SAndre Przywara #define __KVM_HAVE_READONLY_MEM
23*764dfba1SAndre Przywara 
2460021220SAndre Przywara /*
2560021220SAndre Przywara  * for KVM_GET_REGS and KVM_SET_REGS
2660021220SAndre Przywara  *
2760021220SAndre Przywara  * If Config[AT] is zero (32-bit CPU), the register contents are
2860021220SAndre Przywara  * stored in the lower 32-bits of the struct kvm_regs fields and sign
2960021220SAndre Przywara  * extended to 64-bits.
3060021220SAndre Przywara  */
3160021220SAndre Przywara struct kvm_regs {
3260021220SAndre Przywara 	/* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
3360021220SAndre Przywara 	__u64 gpr[32];
3460021220SAndre Przywara 	__u64 hi;
3560021220SAndre Przywara 	__u64 lo;
3660021220SAndre Przywara 	__u64 pc;
3760021220SAndre Przywara };
3860021220SAndre Przywara 
3960021220SAndre Przywara /*
4060021220SAndre Przywara  * for KVM_GET_FPU and KVM_SET_FPU
4160021220SAndre Przywara  */
4260021220SAndre Przywara struct kvm_fpu {
4360021220SAndre Przywara };
4460021220SAndre Przywara 
4560021220SAndre Przywara 
4660021220SAndre Przywara /*
4760021220SAndre Przywara  * For MIPS, we use KVM_SET_ONE_REG and KVM_GET_ONE_REG to access various
4860021220SAndre Przywara  * registers.  The id field is broken down as follows:
4960021220SAndre Przywara  *
5060021220SAndre Przywara  *  bits[63..52] - As per linux/kvm.h
5160021220SAndre Przywara  *  bits[51..32] - Must be zero.
5260021220SAndre Przywara  *  bits[31..16] - Register set.
5360021220SAndre Przywara  *
5460021220SAndre Przywara  * Register set = 0: GP registers from kvm_regs (see definitions below).
5560021220SAndre Przywara  *
5660021220SAndre Przywara  * Register set = 1: CP0 registers.
5760021220SAndre Przywara  *  bits[15..8]  - Must be zero.
5860021220SAndre Przywara  *  bits[7..3]   - Register 'rd'  index.
5960021220SAndre Przywara  *  bits[2..0]   - Register 'sel' index.
6060021220SAndre Przywara  *
6160021220SAndre Przywara  * Register set = 2: KVM specific registers (see definitions below).
6260021220SAndre Przywara  *
6360021220SAndre Przywara  * Register set = 3: FPU / MSA registers (see definitions below).
6460021220SAndre Przywara  *
6560021220SAndre Przywara  * Other sets registers may be added in the future.  Each set would
6660021220SAndre Przywara  * have its own identifier in bits[31..16].
6760021220SAndre Przywara  */
6860021220SAndre Przywara 
6960021220SAndre Przywara #define KVM_REG_MIPS_GP		(KVM_REG_MIPS | 0x0000000000000000ULL)
7060021220SAndre Przywara #define KVM_REG_MIPS_CP0	(KVM_REG_MIPS | 0x0000000000010000ULL)
7160021220SAndre Przywara #define KVM_REG_MIPS_KVM	(KVM_REG_MIPS | 0x0000000000020000ULL)
7260021220SAndre Przywara #define KVM_REG_MIPS_FPU	(KVM_REG_MIPS | 0x0000000000030000ULL)
7360021220SAndre Przywara 
7460021220SAndre Przywara 
7560021220SAndre Przywara /*
7660021220SAndre Przywara  * KVM_REG_MIPS_GP - General purpose registers from kvm_regs.
7760021220SAndre Przywara  */
7860021220SAndre Przywara 
7960021220SAndre Przywara #define KVM_REG_MIPS_R0		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  0)
8060021220SAndre Przywara #define KVM_REG_MIPS_R1		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  1)
8160021220SAndre Przywara #define KVM_REG_MIPS_R2		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  2)
8260021220SAndre Przywara #define KVM_REG_MIPS_R3		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  3)
8360021220SAndre Przywara #define KVM_REG_MIPS_R4		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  4)
8460021220SAndre Przywara #define KVM_REG_MIPS_R5		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  5)
8560021220SAndre Przywara #define KVM_REG_MIPS_R6		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  6)
8660021220SAndre Przywara #define KVM_REG_MIPS_R7		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  7)
8760021220SAndre Przywara #define KVM_REG_MIPS_R8		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  8)
8860021220SAndre Przywara #define KVM_REG_MIPS_R9		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  9)
8960021220SAndre Przywara #define KVM_REG_MIPS_R10	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 10)
9060021220SAndre Przywara #define KVM_REG_MIPS_R11	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 11)
9160021220SAndre Przywara #define KVM_REG_MIPS_R12	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 12)
9260021220SAndre Przywara #define KVM_REG_MIPS_R13	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 13)
9360021220SAndre Przywara #define KVM_REG_MIPS_R14	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 14)
9460021220SAndre Przywara #define KVM_REG_MIPS_R15	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 15)
9560021220SAndre Przywara #define KVM_REG_MIPS_R16	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 16)
9660021220SAndre Przywara #define KVM_REG_MIPS_R17	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 17)
9760021220SAndre Przywara #define KVM_REG_MIPS_R18	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 18)
9860021220SAndre Przywara #define KVM_REG_MIPS_R19	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 19)
9960021220SAndre Przywara #define KVM_REG_MIPS_R20	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 20)
10060021220SAndre Przywara #define KVM_REG_MIPS_R21	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 21)
10160021220SAndre Przywara #define KVM_REG_MIPS_R22	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 22)
10260021220SAndre Przywara #define KVM_REG_MIPS_R23	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 23)
10360021220SAndre Przywara #define KVM_REG_MIPS_R24	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 24)
10460021220SAndre Przywara #define KVM_REG_MIPS_R25	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 25)
10560021220SAndre Przywara #define KVM_REG_MIPS_R26	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 26)
10660021220SAndre Przywara #define KVM_REG_MIPS_R27	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 27)
10760021220SAndre Przywara #define KVM_REG_MIPS_R28	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 28)
10860021220SAndre Przywara #define KVM_REG_MIPS_R29	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 29)
10960021220SAndre Przywara #define KVM_REG_MIPS_R30	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 30)
11060021220SAndre Przywara #define KVM_REG_MIPS_R31	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 31)
11160021220SAndre Przywara 
11260021220SAndre Przywara #define KVM_REG_MIPS_HI		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 32)
11360021220SAndre Przywara #define KVM_REG_MIPS_LO		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 33)
11460021220SAndre Przywara #define KVM_REG_MIPS_PC		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 34)
11560021220SAndre Przywara 
11660021220SAndre Przywara 
11760021220SAndre Przywara /*
11860021220SAndre Przywara  * KVM_REG_MIPS_KVM - KVM specific control registers.
11960021220SAndre Przywara  */
12060021220SAndre Przywara 
12160021220SAndre Przywara /*
12260021220SAndre Przywara  * CP0_Count control
12360021220SAndre Przywara  * DC:    Set 0: Master disable CP0_Count and set COUNT_RESUME to now
12460021220SAndre Przywara  *        Set 1: Master re-enable CP0_Count with unchanged bias, handling timer
12560021220SAndre Przywara  *               interrupts since COUNT_RESUME
12660021220SAndre Przywara  *        This can be used to freeze the timer to get a consistent snapshot of
12760021220SAndre Przywara  *        the CP0_Count and timer interrupt pending state, while also resuming
12860021220SAndre Przywara  *        safely without losing time or guest timer interrupts.
12960021220SAndre Przywara  * Other: Reserved, do not change.
13060021220SAndre Przywara  */
13160021220SAndre Przywara #define KVM_REG_MIPS_COUNT_CTL	    (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 0)
13260021220SAndre Przywara #define KVM_REG_MIPS_COUNT_CTL_DC	0x00000001
13360021220SAndre Przywara 
13460021220SAndre Przywara /*
13560021220SAndre Przywara  * CP0_Count resume monotonic nanoseconds
13660021220SAndre Przywara  * The monotonic nanosecond time of the last set of COUNT_CTL.DC (master
13760021220SAndre Przywara  * disable). Any reads and writes of Count related registers while
13860021220SAndre Przywara  * COUNT_CTL.DC=1 will appear to occur at this time. When COUNT_CTL.DC is
13960021220SAndre Przywara  * cleared again (master enable) any timer interrupts since this time will be
14060021220SAndre Przywara  * emulated.
14160021220SAndre Przywara  * Modifications to times in the future are rejected.
14260021220SAndre Przywara  */
14360021220SAndre Przywara #define KVM_REG_MIPS_COUNT_RESUME   (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 1)
14460021220SAndre Przywara /*
14560021220SAndre Przywara  * CP0_Count rate in Hz
14660021220SAndre Przywara  * Specifies the rate of the CP0_Count timer in Hz. Modifications occur without
14760021220SAndre Przywara  * discontinuities in CP0_Count.
14860021220SAndre Przywara  */
14960021220SAndre Przywara #define KVM_REG_MIPS_COUNT_HZ	    (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 2)
15060021220SAndre Przywara 
15160021220SAndre Przywara 
15260021220SAndre Przywara /*
15360021220SAndre Przywara  * KVM_REG_MIPS_FPU - Floating Point and MIPS SIMD Architecture (MSA) registers.
15460021220SAndre Przywara  *
15560021220SAndre Przywara  *  bits[15..8]  - Register subset (see definitions below).
15660021220SAndre Przywara  *  bits[7..5]   - Must be zero.
15760021220SAndre Przywara  *  bits[4..0]   - Register number within register subset.
15860021220SAndre Przywara  */
15960021220SAndre Przywara 
16060021220SAndre Przywara #define KVM_REG_MIPS_FPR	(KVM_REG_MIPS_FPU | 0x0000000000000000ULL)
16160021220SAndre Przywara #define KVM_REG_MIPS_FCR	(KVM_REG_MIPS_FPU | 0x0000000000000100ULL)
16260021220SAndre Przywara #define KVM_REG_MIPS_MSACR	(KVM_REG_MIPS_FPU | 0x0000000000000200ULL)
16360021220SAndre Przywara 
16460021220SAndre Przywara /*
16560021220SAndre Przywara  * KVM_REG_MIPS_FPR - Floating point / Vector registers.
16660021220SAndre Przywara  */
16760021220SAndre Przywara #define KVM_REG_MIPS_FPR_32(n)	(KVM_REG_MIPS_FPR | KVM_REG_SIZE_U32  | (n))
16860021220SAndre Przywara #define KVM_REG_MIPS_FPR_64(n)	(KVM_REG_MIPS_FPR | KVM_REG_SIZE_U64  | (n))
16960021220SAndre Przywara #define KVM_REG_MIPS_VEC_128(n)	(KVM_REG_MIPS_FPR | KVM_REG_SIZE_U128 | (n))
17060021220SAndre Przywara 
17160021220SAndre Przywara /*
17260021220SAndre Przywara  * KVM_REG_MIPS_FCR - Floating point control registers.
17360021220SAndre Przywara  */
17460021220SAndre Przywara #define KVM_REG_MIPS_FCR_IR	(KVM_REG_MIPS_FCR | KVM_REG_SIZE_U32 |  0)
17560021220SAndre Przywara #define KVM_REG_MIPS_FCR_CSR	(KVM_REG_MIPS_FCR | KVM_REG_SIZE_U32 | 31)
17660021220SAndre Przywara 
17760021220SAndre Przywara /*
17860021220SAndre Przywara  * KVM_REG_MIPS_MSACR - MIPS SIMD Architecture (MSA) control registers.
17960021220SAndre Przywara  */
18060021220SAndre Przywara #define KVM_REG_MIPS_MSA_IR	 (KVM_REG_MIPS_MSACR | KVM_REG_SIZE_U32 |  0)
18160021220SAndre Przywara #define KVM_REG_MIPS_MSA_CSR	 (KVM_REG_MIPS_MSACR | KVM_REG_SIZE_U32 |  1)
18260021220SAndre Przywara 
18360021220SAndre Przywara 
18460021220SAndre Przywara /*
18560021220SAndre Przywara  * KVM MIPS specific structures and definitions
18660021220SAndre Przywara  *
18760021220SAndre Przywara  */
18860021220SAndre Przywara struct kvm_debug_exit_arch {
18960021220SAndre Przywara 	__u64 epc;
19060021220SAndre Przywara };
19160021220SAndre Przywara 
19260021220SAndre Przywara /* for KVM_SET_GUEST_DEBUG */
19360021220SAndre Przywara struct kvm_guest_debug_arch {
19460021220SAndre Przywara };
19560021220SAndre Przywara 
19660021220SAndre Przywara /* definition of registers in kvm_run */
19760021220SAndre Przywara struct kvm_sync_regs {
19860021220SAndre Przywara };
19960021220SAndre Przywara 
20060021220SAndre Przywara /* dummy definition */
20160021220SAndre Przywara struct kvm_sregs {
20260021220SAndre Przywara };
20360021220SAndre Przywara 
20460021220SAndre Przywara struct kvm_mips_interrupt {
20560021220SAndre Przywara 	/* in */
20660021220SAndre Przywara 	__u32 cpu;
20760021220SAndre Przywara 	__u32 irq;
20860021220SAndre Przywara };
20960021220SAndre Przywara 
21060021220SAndre Przywara #endif /* __LINUX_KVM_MIPS_H */
211