blob: 75d6d8557e57a8345dba31b3f797629423622e78 [file] [log] [blame]
Sanjay Lal740765c2012-11-21 18:34:00 -08001/*
David Daney1f3dc6d2013-05-23 09:49:05 -07002 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
7 * Copyright (C) 2013 Cavium, Inc.
8 * Authors: Sanjay Lal <sanjayl@kymasys.com>
9 */
Sanjay Lal740765c2012-11-21 18:34:00 -080010
11#ifndef __LINUX_KVM_MIPS_H
12#define __LINUX_KVM_MIPS_H
13
14#include <linux/types.h>
15
David Daney4c73fb22013-05-23 09:49:09 -070016/*
17 * KVM MIPS specific structures and definitions.
18 *
19 * Some parts derived from the x86 version of this file.
20 */
Sanjay Lal740765c2012-11-21 18:34:00 -080021
David Daney688cded2013-05-23 09:49:06 -070022/*
23 * for KVM_GET_REGS and KVM_SET_REGS
24 *
25 * If Config[AT] is zero (32-bit CPU), the register contents are
26 * stored in the lower 32-bits of the struct kvm_regs fields and sign
27 * extended to 64-bits.
28 */
Sanjay Lal740765c2012-11-21 18:34:00 -080029struct kvm_regs {
David Daneybf32ebf2013-05-23 09:49:07 -070030 /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
31 __u64 gpr[32];
David Daney688cded2013-05-23 09:49:06 -070032 __u64 hi;
33 __u64 lo;
34 __u64 pc;
Sanjay Lal740765c2012-11-21 18:34:00 -080035};
36
David Daney1f3dc6d2013-05-23 09:49:05 -070037/*
38 * for KVM_GET_FPU and KVM_SET_FPU
39 *
40 * If Status[FR] is zero (32-bit FPU), the upper 32-bits of the FPRs
41 * are zero filled.
42 */
Sanjay Lal740765c2012-11-21 18:34:00 -080043struct kvm_fpu {
David Daney1f3dc6d2013-05-23 09:49:05 -070044 __u64 fpr[32];
45 __u32 fir;
46 __u32 fccr;
47 __u32 fexr;
48 __u32 fenr;
49 __u32 fcsr;
50 __u32 pad;
Sanjay Lal740765c2012-11-21 18:34:00 -080051};
52
David Daney4c73fb22013-05-23 09:49:09 -070053
54/*
James Hogan7bd4ace2014-12-02 15:47:04 +000055 * For MIPS, we use KVM_SET_ONE_REG and KVM_GET_ONE_REG to access various
David Daney4c73fb22013-05-23 09:49:09 -070056 * registers. The id field is broken down as follows:
57 *
David Daney681865d2013-06-10 12:33:48 -070058 * bits[63..52] - As per linux/kvm.h
James Hogan7bd4ace2014-12-02 15:47:04 +000059 * bits[51..32] - Must be zero.
60 * bits[31..16] - Register set.
61 *
62 * Register set = 0: GP registers from kvm_regs (see definitions below).
63 *
64 * Register set = 1: CP0 registers.
65 * bits[15..8] - Must be zero.
66 * bits[7..3] - Register 'rd' index.
67 * bits[2..0] - Register 'sel' index.
68 *
69 * Register set = 2: KVM specific registers (see definitions below).
David Daney4c73fb22013-05-23 09:49:09 -070070 *
71 * Other sets registers may be added in the future. Each set would
David Daney681865d2013-06-10 12:33:48 -070072 * have its own identifier in bits[31..16].
David Daney4c73fb22013-05-23 09:49:09 -070073 */
74
James Hogan7bd4ace2014-12-02 15:47:04 +000075#define KVM_REG_MIPS_GP (KVM_REG_MIPS | 0x0000000000000000ULL)
76#define KVM_REG_MIPS_CP0 (KVM_REG_MIPS | 0x0000000000010000ULL)
77#define KVM_REG_MIPS_KVM (KVM_REG_MIPS | 0x0000000000020000ULL)
David Daney4c73fb22013-05-23 09:49:09 -070078
David Daney4c73fb22013-05-23 09:49:09 -070079
James Hogan7bd4ace2014-12-02 15:47:04 +000080/*
81 * KVM_REG_MIPS_GP - General purpose registers from kvm_regs.
82 */
83
84#define KVM_REG_MIPS_R0 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 0)
85#define KVM_REG_MIPS_R1 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 1)
86#define KVM_REG_MIPS_R2 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 2)
87#define KVM_REG_MIPS_R3 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 3)
88#define KVM_REG_MIPS_R4 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 4)
89#define KVM_REG_MIPS_R5 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 5)
90#define KVM_REG_MIPS_R6 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 6)
91#define KVM_REG_MIPS_R7 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 7)
92#define KVM_REG_MIPS_R8 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 8)
93#define KVM_REG_MIPS_R9 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 9)
94#define KVM_REG_MIPS_R10 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 10)
95#define KVM_REG_MIPS_R11 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 11)
96#define KVM_REG_MIPS_R12 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 12)
97#define KVM_REG_MIPS_R13 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 13)
98#define KVM_REG_MIPS_R14 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 14)
99#define KVM_REG_MIPS_R15 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 15)
100#define KVM_REG_MIPS_R16 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 16)
101#define KVM_REG_MIPS_R17 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 17)
102#define KVM_REG_MIPS_R18 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 18)
103#define KVM_REG_MIPS_R19 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 19)
104#define KVM_REG_MIPS_R20 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 20)
105#define KVM_REG_MIPS_R21 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 21)
106#define KVM_REG_MIPS_R22 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 22)
107#define KVM_REG_MIPS_R23 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 23)
108#define KVM_REG_MIPS_R24 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 24)
109#define KVM_REG_MIPS_R25 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 25)
110#define KVM_REG_MIPS_R26 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 26)
111#define KVM_REG_MIPS_R27 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 27)
112#define KVM_REG_MIPS_R28 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 28)
113#define KVM_REG_MIPS_R29 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 29)
114#define KVM_REG_MIPS_R30 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 30)
115#define KVM_REG_MIPS_R31 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 31)
116
117#define KVM_REG_MIPS_HI (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 32)
118#define KVM_REG_MIPS_LO (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 33)
119#define KVM_REG_MIPS_PC (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 34)
120
121
122/*
123 * KVM_REG_MIPS_KVM - KVM specific control registers.
124 */
James Hoganf8239342014-05-29 10:16:37 +0100125
126/*
127 * CP0_Count control
128 * DC: Set 0: Master disable CP0_Count and set COUNT_RESUME to now
129 * Set 1: Master re-enable CP0_Count with unchanged bias, handling timer
130 * interrupts since COUNT_RESUME
131 * This can be used to freeze the timer to get a consistent snapshot of
132 * the CP0_Count and timer interrupt pending state, while also resuming
133 * safely without losing time or guest timer interrupts.
134 * Other: Reserved, do not change.
135 */
James Hogan7bd4ace2014-12-02 15:47:04 +0000136#define KVM_REG_MIPS_COUNT_CTL (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 0)
James Hoganf8239342014-05-29 10:16:37 +0100137#define KVM_REG_MIPS_COUNT_CTL_DC 0x00000001
138
139/*
140 * CP0_Count resume monotonic nanoseconds
141 * The monotonic nanosecond time of the last set of COUNT_CTL.DC (master
142 * disable). Any reads and writes of Count related registers while
143 * COUNT_CTL.DC=1 will appear to occur at this time. When COUNT_CTL.DC is
144 * cleared again (master enable) any timer interrupts since this time will be
145 * emulated.
146 * Modifications to times in the future are rejected.
147 */
James Hogan7bd4ace2014-12-02 15:47:04 +0000148#define KVM_REG_MIPS_COUNT_RESUME (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 1)
James Hoganf74a8e22014-05-29 10:16:38 +0100149/*
150 * CP0_Count rate in Hz
151 * Specifies the rate of the CP0_Count timer in Hz. Modifications occur without
152 * discontinuities in CP0_Count.
153 */
James Hogan7bd4ace2014-12-02 15:47:04 +0000154#define KVM_REG_MIPS_COUNT_HZ (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 2)
155
James Hoganf8239342014-05-29 10:16:37 +0100156
David Daney4c73fb22013-05-23 09:49:09 -0700157/*
158 * KVM MIPS specific structures and definitions
159 *
160 */
Sanjay Lal740765c2012-11-21 18:34:00 -0800161struct kvm_debug_exit_arch {
David Daney4c73fb22013-05-23 09:49:09 -0700162 __u64 epc;
Sanjay Lal740765c2012-11-21 18:34:00 -0800163};
164
165/* for KVM_SET_GUEST_DEBUG */
166struct kvm_guest_debug_arch {
167};
168
David Daney4c73fb22013-05-23 09:49:09 -0700169/* definition of registers in kvm_run */
170struct kvm_sync_regs {
171};
172
173/* dummy definition */
174struct kvm_sregs {
175};
176
Sanjay Lal740765c2012-11-21 18:34:00 -0800177struct kvm_mips_interrupt {
178 /* in */
179 __u32 cpu;
180 __u32 irq;
181};
182
Sanjay Lal740765c2012-11-21 18:34:00 -0800183#endif /* __LINUX_KVM_MIPS_H */