2 * vti.h: prototype for generial vt related interface
3 * Copyright (c) 2004, Intel Corporation.
5 * Xuefei Xu (Anthony Xu) (anthony.xu@intel.com)
6 * Fred Yang (fred.yang@intel.com)
7 * Kun Tian (Kevin Tian) (kevin.tian@intel.com)
9 * Copyright (c) 2007, Intel Corporation.
10 * Zhang xiantao <xiantao.zhang@intel.com>
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms and conditions of the GNU General Public License,
14 * version 2, as published by the Free Software Foundation.
16 * This program is distributed in the hope it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 * You should have received a copy of the GNU General Public License along with
22 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23 * Place - Suite 330, Boston, MA 02111-1307 USA.
31 #include <linux/kvm_host.h>
33 /* define itr.i and itr.d in ia64_itr function */
38 #define IA64_TR_VMM 6 /*itr6, dtr6 : maps vmm code, vmbuffer*/
39 #define IA64_TR_VM_DATA 7 /*dtr7 : maps current vm data*/
45 /* config_options in pal_vp_init_env */
46 #define VP_INITIALIZE 1UL
47 #define VP_FR_PMC 1UL<<1
48 #define VP_OPCODE 1UL<<8
49 #define VP_CAUSE 1UL<<9
50 #define VP_FW_ACC 1UL<<63
52 /* init vp env with initializing vm_buffer */
53 #define VP_INIT_ENV_INITALIZE (VP_INITIALIZE | VP_FR_PMC |\
54 VP_OPCODE | VP_CAUSE | VP_FW_ACC)
55 /* init vp env without initializing vm_buffer */
56 #define VP_INIT_ENV VP_FR_PMC | VP_OPCODE | VP_CAUSE | VP_FW_ACC
58 #define PAL_VP_CREATE 265
59 /* Stacked Virt. Initializes a new VPD for the operation of
60 * a new virtual processor in the virtual environment.
62 #define PAL_VP_ENV_INFO 266
63 /*Stacked Virt. Returns the parameters needed to enter a virtual environment.*/
64 #define PAL_VP_EXIT_ENV 267
65 /*Stacked Virt. Allows a logical processor to exit a virtual environment.*/
66 #define PAL_VP_INIT_ENV 268
67 /*Stacked Virt. Allows a logical processor to enter a virtual environment.*/
68 #define PAL_VP_REGISTER 269
69 /*Stacked Virt. Register a different host IVT for the virtual processor.*/
70 #define PAL_VP_RESUME 270
71 /* Renamed from PAL_VP_RESUME */
72 #define PAL_VP_RESTORE 270
73 /*Stacked Virt. Resumes virtual processor operation on the logical processor.*/
74 #define PAL_VP_SUSPEND 271
75 /* Renamed from PAL_VP_SUSPEND */
76 #define PAL_VP_SAVE 271
77 /* Stacked Virt. Suspends operation for the specified virtual processor on
78 * the logical processor.
80 #define PAL_VP_TERMINATE 272
81 /* Stacked Virt. Terminates operation for the specified virtual processor.*/
87 unsigned int a_from_int_cr
:1;
88 unsigned int a_to_int_cr
:1;
89 unsigned int a_from_psr
:1;
90 unsigned int a_from_cpuid
:1;
91 unsigned int a_cover
:1;
100 unsigned int d_vmsw
:1;
101 unsigned int d_extint
:1;
102 unsigned int d_ibr_dbr
:1;
103 unsigned int d_pmc
:1;
104 unsigned int d_to_pmd
:1;
105 unsigned int d_itm
:1;
113 unsigned long virt_env_vaddr
;
114 unsigned long reserved1
[29];
116 unsigned long reserved2
[95];
117 unsigned long vgr
[16];
118 unsigned long vbgr
[16];
121 unsigned long vcpuid
[5];
122 unsigned long reserved3
[11];
125 unsigned long reserved4
[76];
127 unsigned long vcr
[128];
132 unsigned long rsv1
[5];
134 unsigned long rsv2
[7];
145 unsigned long rsv4
[38];
150 unsigned long irr
[4];
154 unsigned long rsv5
[5];
157 unsigned long rsv6
[46];
160 unsigned long reserved5
[128];
161 unsigned long reserved6
[3456];
162 unsigned long vmm_avail
[128];
163 unsigned long reserved7
[4096];
166 #define PAL_PROC_VM_BIT (1UL << 40)
167 #define PAL_PROC_VMSW_BIT (1UL << 54)
169 static inline s64
ia64_pal_vp_env_info(u64
*buffer_size
,
172 struct ia64_pal_retval iprv
;
173 PAL_CALL_STK(iprv
, PAL_VP_ENV_INFO
, 0, 0, 0);
174 *buffer_size
= iprv
.v0
;
175 *vp_env_info
= iprv
.v1
;
179 static inline s64
ia64_pal_vp_exit_env(u64 iva
)
181 struct ia64_pal_retval iprv
;
183 PAL_CALL_STK(iprv
, PAL_VP_EXIT_ENV
, (u64
)iva
, 0, 0);
187 static inline s64
ia64_pal_vp_init_env(u64 config_options
, u64 pbase_addr
,
188 u64 vbase_addr
, u64
*vsa_base
)
190 struct ia64_pal_retval iprv
;
192 PAL_CALL_STK(iprv
, PAL_VP_INIT_ENV
, config_options
, pbase_addr
,
199 static inline s64
ia64_pal_vp_restore(u64
*vpd
, u64 pal_proc_vector
)
201 struct ia64_pal_retval iprv
;
203 PAL_CALL_STK(iprv
, PAL_VP_RESTORE
, (u64
)vpd
, pal_proc_vector
, 0);
208 static inline s64
ia64_pal_vp_save(u64
*vpd
, u64 pal_proc_vector
)
210 struct ia64_pal_retval iprv
;
212 PAL_CALL_STK(iprv
, PAL_VP_SAVE
, (u64
)vpd
, pal_proc_vector
, 0);
220 #define VPD_VAC_START_OFFSET 0
221 #define VPD_VDC_START_OFFSET 8
222 #define VPD_VHPI_START_OFFSET 256
223 #define VPD_VGR_START_OFFSET 1024
224 #define VPD_VBGR_START_OFFSET 1152
225 #define VPD_VNAT_START_OFFSET 1280
226 #define VPD_VBNAT_START_OFFSET 1288
227 #define VPD_VCPUID_START_OFFSET 1296
228 #define VPD_VPSR_START_OFFSET 1424
229 #define VPD_VPR_START_OFFSET 1432
230 #define VPD_VRSE_CFLE_START_OFFSET 1440
231 #define VPD_VCR_START_OFFSET 2048
232 #define VPD_VTPR_START_OFFSET 2576
233 #define VPD_VRR_START_OFFSET 3072
234 #define VPD_VMM_VAIL_START_OFFSET 31744
236 /*Virtualization faults*/
238 #define EVENT_MOV_TO_AR 1
239 #define EVENT_MOV_TO_AR_IMM 2
240 #define EVENT_MOV_FROM_AR 3
241 #define EVENT_MOV_TO_CR 4
242 #define EVENT_MOV_FROM_CR 5
243 #define EVENT_MOV_TO_PSR 6
244 #define EVENT_MOV_FROM_PSR 7
245 #define EVENT_ITC_D 8
246 #define EVENT_ITC_I 9
247 #define EVENT_MOV_TO_RR 10
248 #define EVENT_MOV_TO_DBR 11
249 #define EVENT_MOV_TO_IBR 12
250 #define EVENT_MOV_TO_PKR 13
251 #define EVENT_MOV_TO_PMC 14
252 #define EVENT_MOV_TO_PMD 15
253 #define EVENT_ITR_D 16
254 #define EVENT_ITR_I 17
255 #define EVENT_MOV_FROM_RR 18
256 #define EVENT_MOV_FROM_DBR 19
257 #define EVENT_MOV_FROM_IBR 20
258 #define EVENT_MOV_FROM_PKR 21
259 #define EVENT_MOV_FROM_PMC 22
260 #define EVENT_MOV_FROM_CPUID 23
263 #define EVENT_PTC_L 26
264 #define EVENT_PTC_G 27
265 #define EVENT_PTC_GA 28
266 #define EVENT_PTR_D 29
267 #define EVENT_PTR_I 30
268 #define EVENT_THASH 31
269 #define EVENT_TTAG 32
272 #define EVENT_PTC_E 35
273 #define EVENT_COVER 36
275 #define EVENT_BSW_0 38
276 #define EVENT_BSW_1 39
277 #define EVENT_VMSW 40
279 /**PAL virtual services offsets */
280 #define PAL_VPS_RESUME_NORMAL 0x0000
281 #define PAL_VPS_RESUME_HANDLER 0x0400
282 #define PAL_VPS_SYNC_READ 0x0800
283 #define PAL_VPS_SYNC_WRITE 0x0c00
284 #define PAL_VPS_SET_PENDING_INTERRUPT 0x1000
285 #define PAL_VPS_THASH 0x1400
286 #define PAL_VPS_TTAG 0x1800
287 #define PAL_VPS_RESTORE 0x1c00
288 #define PAL_VPS_SAVE 0x2000