aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-ia64/kvm_host.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-ia64/kvm_host.h')
-rw-r--r--include/asm-ia64/kvm_host.h527
1 files changed, 0 insertions, 527 deletions
diff --git a/include/asm-ia64/kvm_host.h b/include/asm-ia64/kvm_host.h
deleted file mode 100644
index 1efe513a9941..000000000000
--- a/include/asm-ia64/kvm_host.h
+++ /dev/null
@@ -1,527 +0,0 @@
1/*
2 * kvm_host.h: used for kvm module, and hold ia64-specific sections.
3 *
4 * Copyright (C) 2007, Intel Corporation.
5 *
6 * Xiantao Zhang <xiantao.zhang@intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 * Place - Suite 330, Boston, MA 02111-1307 USA.
20 *
21 */
22
23#ifndef __ASM_KVM_HOST_H
24#define __ASM_KVM_HOST_H
25
26
27#include <linux/types.h>
28#include <linux/mm.h>
29#include <linux/kvm.h>
30#include <linux/kvm_para.h>
31#include <linux/kvm_types.h>
32
33#include <asm/pal.h>
34#include <asm/sal.h>
35
36#define KVM_MAX_VCPUS 4
37#define KVM_MEMORY_SLOTS 32
38/* memory slots that does not exposed to userspace */
39#define KVM_PRIVATE_MEM_SLOTS 4
40
41#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
42
43/* define exit reasons from vmm to kvm*/
44#define EXIT_REASON_VM_PANIC 0
45#define EXIT_REASON_MMIO_INSTRUCTION 1
46#define EXIT_REASON_PAL_CALL 2
47#define EXIT_REASON_SAL_CALL 3
48#define EXIT_REASON_SWITCH_RR6 4
49#define EXIT_REASON_VM_DESTROY 5
50#define EXIT_REASON_EXTERNAL_INTERRUPT 6
51#define EXIT_REASON_IPI 7
52#define EXIT_REASON_PTC_G 8
53
54/*Define vmm address space and vm data space.*/
55#define KVM_VMM_SIZE (16UL<<20)
56#define KVM_VMM_SHIFT 24
57#define KVM_VMM_BASE 0xD000000000000000UL
58#define VMM_SIZE (8UL<<20)
59
60/*
61 * Define vm_buffer, used by PAL Services, base address.
62 * Note: vmbuffer is in the VMM-BLOCK, the size must be < 8M
63 */
64#define KVM_VM_BUFFER_BASE (KVM_VMM_BASE + VMM_SIZE)
65#define KVM_VM_BUFFER_SIZE (8UL<<20)
66
67/*Define Virtual machine data layout.*/
68#define KVM_VM_DATA_SHIFT 24
69#define KVM_VM_DATA_SIZE (1UL << KVM_VM_DATA_SHIFT)
70#define KVM_VM_DATA_BASE (KVM_VMM_BASE + KVM_VMM_SIZE)
71
72
73#define KVM_P2M_BASE KVM_VM_DATA_BASE
74#define KVM_P2M_OFS 0
75#define KVM_P2M_SIZE (8UL << 20)
76
77#define KVM_VHPT_BASE (KVM_P2M_BASE + KVM_P2M_SIZE)
78#define KVM_VHPT_OFS KVM_P2M_SIZE
79#define KVM_VHPT_BLOCK_SIZE (2UL << 20)
80#define VHPT_SHIFT 18
81#define VHPT_SIZE (1UL << VHPT_SHIFT)
82#define VHPT_NUM_ENTRIES (1<<(VHPT_SHIFT-5))
83
84#define KVM_VTLB_BASE (KVM_VHPT_BASE+KVM_VHPT_BLOCK_SIZE)
85#define KVM_VTLB_OFS (KVM_VHPT_OFS+KVM_VHPT_BLOCK_SIZE)
86#define KVM_VTLB_BLOCK_SIZE (1UL<<20)
87#define VTLB_SHIFT 17
88#define VTLB_SIZE (1UL<<VTLB_SHIFT)
89#define VTLB_NUM_ENTRIES (1<<(VTLB_SHIFT-5))
90
91#define KVM_VPD_BASE (KVM_VTLB_BASE+KVM_VTLB_BLOCK_SIZE)
92#define KVM_VPD_OFS (KVM_VTLB_OFS+KVM_VTLB_BLOCK_SIZE)
93#define KVM_VPD_BLOCK_SIZE (2UL<<20)
94#define VPD_SHIFT 16
95#define VPD_SIZE (1UL<<VPD_SHIFT)
96
97#define KVM_VCPU_BASE (KVM_VPD_BASE+KVM_VPD_BLOCK_SIZE)
98#define KVM_VCPU_OFS (KVM_VPD_OFS+KVM_VPD_BLOCK_SIZE)
99#define KVM_VCPU_BLOCK_SIZE (2UL<<20)
100#define VCPU_SHIFT 18
101#define VCPU_SIZE (1UL<<VCPU_SHIFT)
102#define MAX_VCPU_NUM KVM_VCPU_BLOCK_SIZE/VCPU_SIZE
103
104#define KVM_VM_BASE (KVM_VCPU_BASE+KVM_VCPU_BLOCK_SIZE)
105#define KVM_VM_OFS (KVM_VCPU_OFS+KVM_VCPU_BLOCK_SIZE)
106#define KVM_VM_BLOCK_SIZE (1UL<<19)
107
108#define KVM_MEM_DIRTY_LOG_BASE (KVM_VM_BASE+KVM_VM_BLOCK_SIZE)
109#define KVM_MEM_DIRTY_LOG_OFS (KVM_VM_OFS+KVM_VM_BLOCK_SIZE)
110#define KVM_MEM_DIRTY_LOG_SIZE (1UL<<19)
111
112/* Get vpd, vhpt, tlb, vcpu, base*/
113#define VPD_ADDR(n) (KVM_VPD_BASE+n*VPD_SIZE)
114#define VHPT_ADDR(n) (KVM_VHPT_BASE+n*VHPT_SIZE)
115#define VTLB_ADDR(n) (KVM_VTLB_BASE+n*VTLB_SIZE)
116#define VCPU_ADDR(n) (KVM_VCPU_BASE+n*VCPU_SIZE)
117
118/*IO section definitions*/
119#define IOREQ_READ 1
120#define IOREQ_WRITE 0
121
122#define STATE_IOREQ_NONE 0
123#define STATE_IOREQ_READY 1
124#define STATE_IOREQ_INPROCESS 2
125#define STATE_IORESP_READY 3
126
127/*Guest Physical address layout.*/
128#define GPFN_MEM (0UL << 60) /* Guest pfn is normal mem */
129#define GPFN_FRAME_BUFFER (1UL << 60) /* VGA framebuffer */
130#define GPFN_LOW_MMIO (2UL << 60) /* Low MMIO range */
131#define GPFN_PIB (3UL << 60) /* PIB base */
132#define GPFN_IOSAPIC (4UL << 60) /* IOSAPIC base */
133#define GPFN_LEGACY_IO (5UL << 60) /* Legacy I/O base */
134#define GPFN_GFW (6UL << 60) /* Guest Firmware */
135#define GPFN_HIGH_MMIO (7UL << 60) /* High MMIO range */
136
137#define GPFN_IO_MASK (7UL << 60) /* Guest pfn is I/O type */
138#define GPFN_INV_MASK (1UL << 63) /* Guest pfn is invalid */
139#define INVALID_MFN (~0UL)
140#define MEM_G (1UL << 30)
141#define MEM_M (1UL << 20)
142#define MMIO_START (3 * MEM_G)
143#define MMIO_SIZE (512 * MEM_M)
144#define VGA_IO_START 0xA0000UL
145#define VGA_IO_SIZE 0x20000
146#define LEGACY_IO_START (MMIO_START + MMIO_SIZE)
147#define LEGACY_IO_SIZE (64 * MEM_M)
148#define IO_SAPIC_START 0xfec00000UL
149#define IO_SAPIC_SIZE 0x100000
150#define PIB_START 0xfee00000UL
151#define PIB_SIZE 0x200000
152#define GFW_START (4 * MEM_G - 16 * MEM_M)
153#define GFW_SIZE (16 * MEM_M)
154
155/*Deliver mode, defined for ioapic.c*/
156#define dest_Fixed IOSAPIC_FIXED
157#define dest_LowestPrio IOSAPIC_LOWEST_PRIORITY
158
159#define NMI_VECTOR 2
160#define ExtINT_VECTOR 0
161#define NULL_VECTOR (-1)
162#define IA64_SPURIOUS_INT_VECTOR 0x0f
163
164#define VCPU_LID(v) (((u64)(v)->vcpu_id) << 24)
165
166/*
167 *Delivery mode
168 */
169#define SAPIC_DELIV_SHIFT 8
170#define SAPIC_FIXED 0x0
171#define SAPIC_LOWEST_PRIORITY 0x1
172#define SAPIC_PMI 0x2
173#define SAPIC_NMI 0x4
174#define SAPIC_INIT 0x5
175#define SAPIC_EXTINT 0x7
176
177/*
178 * vcpu->requests bit members for arch
179 */
180#define KVM_REQ_PTC_G 32
181#define KVM_REQ_RESUME 33
182
183#define KVM_PAGES_PER_HPAGE 1
184
185struct kvm;
186struct kvm_vcpu;
187struct kvm_guest_debug{
188};
189
190struct kvm_mmio_req {
191 uint64_t addr; /* physical address */
192 uint64_t size; /* size in bytes */
193 uint64_t data; /* data (or paddr of data) */
194 uint8_t state:4;
195 uint8_t dir:1; /* 1=read, 0=write */
196};
197
198/*Pal data struct */
199struct kvm_pal_call{
200 /*In area*/
201 uint64_t gr28;
202 uint64_t gr29;
203 uint64_t gr30;
204 uint64_t gr31;
205 /*Out area*/
206 struct ia64_pal_retval ret;
207};
208
209/* Sal data structure */
210struct kvm_sal_call{
211 /*In area*/
212 uint64_t in0;
213 uint64_t in1;
214 uint64_t in2;
215 uint64_t in3;
216 uint64_t in4;
217 uint64_t in5;
218 uint64_t in6;
219 uint64_t in7;
220 struct sal_ret_values ret;
221};
222
223/*Guest change rr6*/
224struct kvm_switch_rr6 {
225 uint64_t old_rr;
226 uint64_t new_rr;
227};
228
229union ia64_ipi_a{
230 unsigned long val;
231 struct {
232 unsigned long rv : 3;
233 unsigned long ir : 1;
234 unsigned long eid : 8;
235 unsigned long id : 8;
236 unsigned long ib_base : 44;
237 };
238};
239
240union ia64_ipi_d {
241 unsigned long val;
242 struct {
243 unsigned long vector : 8;
244 unsigned long dm : 3;
245 unsigned long ig : 53;
246 };
247};
248
249/*ipi check exit data*/
250struct kvm_ipi_data{
251 union ia64_ipi_a addr;
252 union ia64_ipi_d data;
253};
254
255/*global purge data*/
256struct kvm_ptc_g {
257 unsigned long vaddr;
258 unsigned long rr;
259 unsigned long ps;
260 struct kvm_vcpu *vcpu;
261};
262
263/*Exit control data */
264struct exit_ctl_data{
265 uint32_t exit_reason;
266 uint32_t vm_status;
267 union {
268 struct kvm_mmio_req ioreq;
269 struct kvm_pal_call pal_data;
270 struct kvm_sal_call sal_data;
271 struct kvm_switch_rr6 rr_data;
272 struct kvm_ipi_data ipi_data;
273 struct kvm_ptc_g ptc_g_data;
274 } u;
275};
276
277union pte_flags {
278 unsigned long val;
279 struct {
280 unsigned long p : 1; /*0 */
281 unsigned long : 1; /* 1 */
282 unsigned long ma : 3; /* 2-4 */
283 unsigned long a : 1; /* 5 */
284 unsigned long d : 1; /* 6 */
285 unsigned long pl : 2; /* 7-8 */
286 unsigned long ar : 3; /* 9-11 */
287 unsigned long ppn : 38; /* 12-49 */
288 unsigned long : 2; /* 50-51 */
289 unsigned long ed : 1; /* 52 */
290 };
291};
292
293union ia64_pta {
294 unsigned long val;
295 struct {
296 unsigned long ve : 1;
297 unsigned long reserved0 : 1;
298 unsigned long size : 6;
299 unsigned long vf : 1;
300 unsigned long reserved1 : 6;
301 unsigned long base : 49;
302 };
303};
304
305struct thash_cb {
306 /* THASH base information */
307 struct thash_data *hash; /* hash table pointer */
308 union ia64_pta pta;
309 int num;
310};
311
312struct kvm_vcpu_stat {
313};
314
315struct kvm_vcpu_arch {
316 int launched;
317 int last_exit;
318 int last_run_cpu;
319 int vmm_tr_slot;
320 int vm_tr_slot;
321
322#define KVM_MP_STATE_RUNNABLE 0
323#define KVM_MP_STATE_UNINITIALIZED 1
324#define KVM_MP_STATE_INIT_RECEIVED 2
325#define KVM_MP_STATE_HALTED 3
326 int mp_state;
327
328#define MAX_PTC_G_NUM 3
329 int ptc_g_count;
330 struct kvm_ptc_g ptc_g_data[MAX_PTC_G_NUM];
331
332 /*halt timer to wake up sleepy vcpus*/
333 struct hrtimer hlt_timer;
334 long ht_active;
335
336 struct kvm_lapic *apic; /* kernel irqchip context */
337 struct vpd *vpd;
338
339 /* Exit data for vmm_transition*/
340 struct exit_ctl_data exit_data;
341
342 cpumask_t cache_coherent_map;
343
344 unsigned long vmm_rr;
345 unsigned long host_rr6;
346 unsigned long psbits[8];
347 unsigned long cr_iipa;
348 unsigned long cr_isr;
349 unsigned long vsa_base;
350 unsigned long dirty_log_lock_pa;
351 unsigned long __gp;
352 /* TR and TC. */
353 struct thash_data itrs[NITRS];
354 struct thash_data dtrs[NDTRS];
355 /* Bit is set if there is a tr/tc for the region. */
356 unsigned char itr_regions;
357 unsigned char dtr_regions;
358 unsigned char tc_regions;
359 /* purge all */
360 unsigned long ptce_base;
361 unsigned long ptce_count[2];
362 unsigned long ptce_stride[2];
363 /* itc/itm */
364 unsigned long last_itc;
365 long itc_offset;
366 unsigned long itc_check;
367 unsigned long timer_check;
368 unsigned long timer_pending;
369
370 unsigned long vrr[8];
371 unsigned long ibr[8];
372 unsigned long dbr[8];
373 unsigned long insvc[4]; /* Interrupt in service. */
374 unsigned long xtp;
375
376 unsigned long metaphysical_rr0; /* from kvm_arch (so is pinned) */
377 unsigned long metaphysical_rr4; /* from kvm_arch (so is pinned) */
378 unsigned long metaphysical_saved_rr0; /* from kvm_arch */
379 unsigned long metaphysical_saved_rr4; /* from kvm_arch */
380 unsigned long fp_psr; /*used for lazy float register */
381 unsigned long saved_gp;
382 /*for phycial emulation */
383 int mode_flags;
384 struct thash_cb vtlb;
385 struct thash_cb vhpt;
386 char irq_check;
387 char irq_new_pending;
388
389 unsigned long opcode;
390 unsigned long cause;
391 union context host;
392 union context guest;
393};
394
395struct kvm_vm_stat {
396 u64 remote_tlb_flush;
397};
398
399struct kvm_sal_data {
400 unsigned long boot_ip;
401 unsigned long boot_gp;
402};
403
404struct kvm_arch {
405 unsigned long vm_base;
406 unsigned long metaphysical_rr0;
407 unsigned long metaphysical_rr4;
408 unsigned long vmm_init_rr;
409 unsigned long vhpt_base;
410 unsigned long vtlb_base;
411 unsigned long vpd_base;
412 spinlock_t dirty_log_lock;
413 struct kvm_ioapic *vioapic;
414 struct kvm_vm_stat stat;
415 struct kvm_sal_data rdv_sal_data;
416};
417
418union cpuid3_t {
419 u64 value;
420 struct {
421 u64 number : 8;
422 u64 revision : 8;
423 u64 model : 8;
424 u64 family : 8;
425 u64 archrev : 8;
426 u64 rv : 24;
427 };
428};
429
430struct kvm_pt_regs {
431 /* The following registers are saved by SAVE_MIN: */
432 unsigned long b6; /* scratch */
433 unsigned long b7; /* scratch */
434
435 unsigned long ar_csd; /* used by cmp8xchg16 (scratch) */
436 unsigned long ar_ssd; /* reserved for future use (scratch) */
437
438 unsigned long r8; /* scratch (return value register 0) */
439 unsigned long r9; /* scratch (return value register 1) */
440 unsigned long r10; /* scratch (return value register 2) */
441 unsigned long r11; /* scratch (return value register 3) */
442
443 unsigned long cr_ipsr; /* interrupted task's psr */
444 unsigned long cr_iip; /* interrupted task's instruction pointer */
445 unsigned long cr_ifs; /* interrupted task's function state */
446
447 unsigned long ar_unat; /* interrupted task's NaT register (preserved) */
448 unsigned long ar_pfs; /* prev function state */
449 unsigned long ar_rsc; /* RSE configuration */
450 /* The following two are valid only if cr_ipsr.cpl > 0: */
451 unsigned long ar_rnat; /* RSE NaT */
452 unsigned long ar_bspstore; /* RSE bspstore */
453
454 unsigned long pr; /* 64 predicate registers (1 bit each) */
455 unsigned long b0; /* return pointer (bp) */
456 unsigned long loadrs; /* size of dirty partition << 16 */
457
458 unsigned long r1; /* the gp pointer */
459 unsigned long r12; /* interrupted task's memory stack pointer */
460 unsigned long r13; /* thread pointer */
461
462 unsigned long ar_fpsr; /* floating point status (preserved) */
463 unsigned long r15; /* scratch */
464
465 /* The remaining registers are NOT saved for system calls. */
466 unsigned long r14; /* scratch */
467 unsigned long r2; /* scratch */
468 unsigned long r3; /* scratch */
469 unsigned long r16; /* scratch */
470 unsigned long r17; /* scratch */
471 unsigned long r18; /* scratch */
472 unsigned long r19; /* scratch */
473 unsigned long r20; /* scratch */
474 unsigned long r21; /* scratch */
475 unsigned long r22; /* scratch */
476 unsigned long r23; /* scratch */
477 unsigned long r24; /* scratch */
478 unsigned long r25; /* scratch */
479 unsigned long r26; /* scratch */
480 unsigned long r27; /* scratch */
481 unsigned long r28; /* scratch */
482 unsigned long r29; /* scratch */
483 unsigned long r30; /* scratch */
484 unsigned long r31; /* scratch */
485 unsigned long ar_ccv; /* compare/exchange value (scratch) */
486
487 /*
488 * Floating point registers that the kernel considers scratch:
489 */
490 struct ia64_fpreg f6; /* scratch */
491 struct ia64_fpreg f7; /* scratch */
492 struct ia64_fpreg f8; /* scratch */
493 struct ia64_fpreg f9; /* scratch */
494 struct ia64_fpreg f10; /* scratch */
495 struct ia64_fpreg f11; /* scratch */
496
497 unsigned long r4; /* preserved */
498 unsigned long r5; /* preserved */
499 unsigned long r6; /* preserved */
500 unsigned long r7; /* preserved */
501 unsigned long eml_unat; /* used for emulating instruction */
502 unsigned long pad0; /* alignment pad */
503};
504
505static inline struct kvm_pt_regs *vcpu_regs(struct kvm_vcpu *v)
506{
507 return (struct kvm_pt_regs *) ((unsigned long) v + IA64_STK_OFFSET) - 1;
508}
509
510typedef int kvm_vmm_entry(void);
511typedef void kvm_tramp_entry(union context *host, union context *guest);
512
513struct kvm_vmm_info{
514 struct module *module;
515 kvm_vmm_entry *vmm_entry;
516 kvm_tramp_entry *tramp_entry;
517 unsigned long vmm_ivt;
518};
519
520int kvm_highest_pending_irq(struct kvm_vcpu *vcpu);
521int kvm_emulate_halt(struct kvm_vcpu *vcpu);
522int kvm_pal_emul(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
523void kvm_sal_emul(struct kvm_vcpu *vcpu);
524
525static inline void kvm_inject_nmi(struct kvm_vcpu *vcpu) {}
526
527#endif