diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-27 13:13:52 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-27 13:13:52 -0400 |
| commit | 42cadc86008aae0fd9ff31642dc01ed50723cf32 (patch) | |
| tree | b05d4c8f0561bad5a0183a89fb23ce4c8ee1653c /include | |
| parent | fba5c1af5c4fd6645fe62ea84ccde0981282cf66 (diff) | |
| parent | 66c0b394f08fd89236515c1c84485ea712a157be (diff) | |
Merge branch 'kvm-updates-2.6.26' of git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm
* 'kvm-updates-2.6.26' of git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm: (147 commits)
KVM: kill file->f_count abuse in kvm
KVM: MMU: kvm_pv_mmu_op should not take mmap_sem
KVM: SVM: remove selective CR0 comment
KVM: SVM: remove now obsolete FIXME comment
KVM: SVM: disable CR8 intercept when tpr is not masking interrupts
KVM: SVM: sync V_TPR with LAPIC.TPR if CR8 write intercept is disabled
KVM: export kvm_lapic_set_tpr() to modules
KVM: SVM: sync TPR value to V_TPR field in the VMCB
KVM: ppc: PowerPC 440 KVM implementation
KVM: Add MAINTAINERS entry for PowerPC KVM
KVM: ppc: Add DCR access information to struct kvm_run
ppc: Export tlb_44x_hwater for KVM
KVM: Rename debugfs_dir to kvm_debugfs_dir
KVM: x86 emulator: fix lea to really get the effective address
KVM: x86 emulator: fix smsw and lmsw with a memory operand
KVM: x86 emulator: initialize src.val and dst.val for register operands
KVM: SVM: force a new asid when initializing the vmcb
KVM: fix kvm_vcpu_kick vs __vcpu_run race
KVM: add ioctls to save/store mpstate
KVM: Rename VCPU_MP_STATE_* to KVM_MP_STATE_*
...
Diffstat (limited to 'include')
30 files changed, 2173 insertions, 45 deletions
diff --git a/include/asm-ia64/gcc_intrin.h b/include/asm-ia64/gcc_intrin.h index de2ed2cbdd84..2fe292c275fe 100644 --- a/include/asm-ia64/gcc_intrin.h +++ b/include/asm-ia64/gcc_intrin.h | |||
| @@ -21,6 +21,10 @@ | |||
| 21 | 21 | ||
| 22 | #define ia64_invala_fr(regnum) asm volatile ("invala.e f%0" :: "i"(regnum)) | 22 | #define ia64_invala_fr(regnum) asm volatile ("invala.e f%0" :: "i"(regnum)) |
| 23 | 23 | ||
| 24 | #define ia64_flushrs() asm volatile ("flushrs;;":::"memory") | ||
| 25 | |||
| 26 | #define ia64_loadrs() asm volatile ("loadrs;;":::"memory") | ||
| 27 | |||
| 24 | extern void ia64_bad_param_for_setreg (void); | 28 | extern void ia64_bad_param_for_setreg (void); |
| 25 | extern void ia64_bad_param_for_getreg (void); | 29 | extern void ia64_bad_param_for_getreg (void); |
| 26 | 30 | ||
| @@ -517,6 +521,14 @@ do { \ | |||
| 517 | #define ia64_ptrd(addr, size) \ | 521 | #define ia64_ptrd(addr, size) \ |
| 518 | asm volatile ("ptr.d %0,%1" :: "r"(addr), "r"(size) : "memory") | 522 | asm volatile ("ptr.d %0,%1" :: "r"(addr), "r"(size) : "memory") |
| 519 | 523 | ||
| 524 | #define ia64_ttag(addr) \ | ||
| 525 | ({ \ | ||
| 526 | __u64 ia64_intri_res; \ | ||
| 527 | asm volatile ("ttag %0=%1" : "=r"(ia64_intri_res) : "r" (addr)); \ | ||
| 528 | ia64_intri_res; \ | ||
| 529 | }) | ||
| 530 | |||
| 531 | |||
| 520 | /* Values for lfhint in ia64_lfetch and ia64_lfetch_fault */ | 532 | /* Values for lfhint in ia64_lfetch and ia64_lfetch_fault */ |
| 521 | 533 | ||
| 522 | #define ia64_lfhint_none 0 | 534 | #define ia64_lfhint_none 0 |
diff --git a/include/asm-ia64/kvm.h b/include/asm-ia64/kvm.h index 030d29b4b26b..eb2d3559d089 100644 --- a/include/asm-ia64/kvm.h +++ b/include/asm-ia64/kvm.h | |||
| @@ -1,6 +1,205 @@ | |||
| 1 | #ifndef __LINUX_KVM_IA64_H | 1 | #ifndef __ASM_IA64_KVM_H |
| 2 | #define __LINUX_KVM_IA64_H | 2 | #define __ASM_IA64_KVM_H |
| 3 | 3 | ||
| 4 | /* ia64 does not support KVM */ | 4 | /* |
| 5 | * asm-ia64/kvm.h: kvm structure definitions for ia64 | ||
| 6 | * | ||
| 7 | * Copyright (C) 2007 Xiantao Zhang <xiantao.zhang@intel.com> | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify it | ||
| 10 | * under the terms and conditions of the GNU General Public License, | ||
| 11 | * version 2, as published by the Free Software Foundation. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 16 | * more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU General Public License along with | ||
| 19 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
| 20 | * Place - Suite 330, Boston, MA 02111-1307 USA. | ||
| 21 | * | ||
| 22 | */ | ||
| 23 | |||
| 24 | #include <asm/types.h> | ||
| 25 | #include <asm/fpu.h> | ||
| 26 | |||
| 27 | #include <linux/ioctl.h> | ||
| 28 | |||
| 29 | /* Architectural interrupt line count. */ | ||
| 30 | #define KVM_NR_INTERRUPTS 256 | ||
| 31 | |||
| 32 | #define KVM_IOAPIC_NUM_PINS 24 | ||
| 33 | |||
| 34 | struct kvm_ioapic_state { | ||
| 35 | __u64 base_address; | ||
| 36 | __u32 ioregsel; | ||
| 37 | __u32 id; | ||
| 38 | __u32 irr; | ||
| 39 | __u32 pad; | ||
| 40 | union { | ||
| 41 | __u64 bits; | ||
| 42 | struct { | ||
| 43 | __u8 vector; | ||
| 44 | __u8 delivery_mode:3; | ||
| 45 | __u8 dest_mode:1; | ||
| 46 | __u8 delivery_status:1; | ||
| 47 | __u8 polarity:1; | ||
| 48 | __u8 remote_irr:1; | ||
| 49 | __u8 trig_mode:1; | ||
| 50 | __u8 mask:1; | ||
| 51 | __u8 reserve:7; | ||
| 52 | __u8 reserved[4]; | ||
| 53 | __u8 dest_id; | ||
| 54 | } fields; | ||
| 55 | } redirtbl[KVM_IOAPIC_NUM_PINS]; | ||
| 56 | }; | ||
| 57 | |||
| 58 | #define KVM_IRQCHIP_PIC_MASTER 0 | ||
| 59 | #define KVM_IRQCHIP_PIC_SLAVE 1 | ||
| 60 | #define KVM_IRQCHIP_IOAPIC 2 | ||
| 61 | |||
| 62 | #define KVM_CONTEXT_SIZE 8*1024 | ||
| 63 | |||
| 64 | union context { | ||
| 65 | /* 8K size */ | ||
| 66 | char dummy[KVM_CONTEXT_SIZE]; | ||
| 67 | struct { | ||
| 68 | unsigned long psr; | ||
| 69 | unsigned long pr; | ||
| 70 | unsigned long caller_unat; | ||
| 71 | unsigned long pad; | ||
| 72 | unsigned long gr[32]; | ||
| 73 | unsigned long ar[128]; | ||
| 74 | unsigned long br[8]; | ||
| 75 | unsigned long cr[128]; | ||
| 76 | unsigned long rr[8]; | ||
| 77 | unsigned long ibr[8]; | ||
| 78 | unsigned long dbr[8]; | ||
| 79 | unsigned long pkr[8]; | ||
| 80 | struct ia64_fpreg fr[128]; | ||
| 81 | }; | ||
| 82 | }; | ||
| 83 | |||
| 84 | struct thash_data { | ||
| 85 | union { | ||
| 86 | struct { | ||
| 87 | unsigned long p : 1; /* 0 */ | ||
| 88 | unsigned long rv1 : 1; /* 1 */ | ||
| 89 | unsigned long ma : 3; /* 2-4 */ | ||
| 90 | unsigned long a : 1; /* 5 */ | ||
| 91 | unsigned long d : 1; /* 6 */ | ||
| 92 | unsigned long pl : 2; /* 7-8 */ | ||
| 93 | unsigned long ar : 3; /* 9-11 */ | ||
| 94 | unsigned long ppn : 38; /* 12-49 */ | ||
| 95 | unsigned long rv2 : 2; /* 50-51 */ | ||
| 96 | unsigned long ed : 1; /* 52 */ | ||
| 97 | unsigned long ig1 : 11; /* 53-63 */ | ||
| 98 | }; | ||
| 99 | struct { | ||
| 100 | unsigned long __rv1 : 53; /* 0-52 */ | ||
| 101 | unsigned long contiguous : 1; /*53 */ | ||
| 102 | unsigned long tc : 1; /* 54 TR or TC */ | ||
| 103 | unsigned long cl : 1; | ||
| 104 | /* 55 I side or D side cache line */ | ||
| 105 | unsigned long len : 4; /* 56-59 */ | ||
| 106 | unsigned long io : 1; /* 60 entry is for io or not */ | ||
| 107 | unsigned long nomap : 1; | ||
| 108 | /* 61 entry cann't be inserted into machine TLB.*/ | ||
| 109 | unsigned long checked : 1; | ||
| 110 | /* 62 for VTLB/VHPT sanity check */ | ||
| 111 | unsigned long invalid : 1; | ||
| 112 | /* 63 invalid entry */ | ||
| 113 | }; | ||
| 114 | unsigned long page_flags; | ||
| 115 | }; /* same for VHPT and TLB */ | ||
| 116 | |||
| 117 | union { | ||
| 118 | struct { | ||
| 119 | unsigned long rv3 : 2; | ||
| 120 | unsigned long ps : 6; | ||
| 121 | unsigned long key : 24; | ||
| 122 | unsigned long rv4 : 32; | ||
| 123 | }; | ||
| 124 | unsigned long itir; | ||
| 125 | }; | ||
| 126 | union { | ||
| 127 | struct { | ||
| 128 | unsigned long ig2 : 12; | ||
| 129 | unsigned long vpn : 49; | ||
| 130 | unsigned long vrn : 3; | ||
| 131 | }; | ||
| 132 | unsigned long ifa; | ||
| 133 | unsigned long vadr; | ||
| 134 | struct { | ||
| 135 | unsigned long tag : 63; | ||
| 136 | unsigned long ti : 1; | ||
| 137 | }; | ||
| 138 | unsigned long etag; | ||
| 139 | }; | ||
| 140 | union { | ||
| 141 | struct thash_data *next; | ||
| 142 | unsigned long rid; | ||
| 143 | unsigned long gpaddr; | ||
| 144 | }; | ||
| 145 | }; | ||
| 146 | |||
| 147 | #define NITRS 8 | ||
| 148 | #define NDTRS 8 | ||
| 149 | |||
| 150 | struct saved_vpd { | ||
| 151 | unsigned long vhpi; | ||
| 152 | unsigned long vgr[16]; | ||
| 153 | unsigned long vbgr[16]; | ||
| 154 | unsigned long vnat; | ||
| 155 | unsigned long vbnat; | ||
| 156 | unsigned long vcpuid[5]; | ||
| 157 | unsigned long vpsr; | ||
| 158 | unsigned long vpr; | ||
| 159 | unsigned long vcr[128]; | ||
| 160 | }; | ||
| 161 | |||
| 162 | struct kvm_regs { | ||
| 163 | char *saved_guest; | ||
| 164 | char *saved_stack; | ||
| 165 | struct saved_vpd vpd; | ||
| 166 | /*Arch-regs*/ | ||
| 167 | int mp_state; | ||
| 168 | unsigned long vmm_rr; | ||
| 169 | /* TR and TC. */ | ||
| 170 | struct thash_data itrs[NITRS]; | ||
| 171 | struct thash_data dtrs[NDTRS]; | ||
| 172 | /* Bit is set if there is a tr/tc for the region. */ | ||
| 173 | unsigned char itr_regions; | ||
| 174 | unsigned char dtr_regions; | ||
| 175 | unsigned char tc_regions; | ||
| 176 | |||
| 177 | char irq_check; | ||
| 178 | unsigned long saved_itc; | ||
| 179 | unsigned long itc_check; | ||
| 180 | unsigned long timer_check; | ||
| 181 | unsigned long timer_pending; | ||
| 182 | unsigned long last_itc; | ||
| 183 | |||
| 184 | unsigned long vrr[8]; | ||
| 185 | unsigned long ibr[8]; | ||
| 186 | unsigned long dbr[8]; | ||
| 187 | unsigned long insvc[4]; /* Interrupt in service. */ | ||
| 188 | unsigned long xtp; | ||
| 189 | |||
| 190 | unsigned long metaphysical_rr0; /* from kvm_arch (so is pinned) */ | ||
| 191 | unsigned long metaphysical_rr4; /* from kvm_arch (so is pinned) */ | ||
| 192 | unsigned long metaphysical_saved_rr0; /* from kvm_arch */ | ||
| 193 | unsigned long metaphysical_saved_rr4; /* from kvm_arch */ | ||
| 194 | unsigned long fp_psr; /*used for lazy float register */ | ||
| 195 | unsigned long saved_gp; | ||
| 196 | /*for phycial emulation */ | ||
| 197 | }; | ||
| 198 | |||
| 199 | struct kvm_sregs { | ||
| 200 | }; | ||
| 201 | |||
| 202 | struct kvm_fpu { | ||
| 203 | }; | ||
| 5 | 204 | ||
| 6 | #endif | 205 | #endif |
diff --git a/include/asm-ia64/kvm_host.h b/include/asm-ia64/kvm_host.h new file mode 100644 index 000000000000..c082c208c1f3 --- /dev/null +++ b/include/asm-ia64/kvm_host.h | |||
| @@ -0,0 +1,524 @@ | |||
| 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 | |||
| 42 | /* define exit reasons from vmm to kvm*/ | ||
| 43 | #define EXIT_REASON_VM_PANIC 0 | ||
| 44 | #define EXIT_REASON_MMIO_INSTRUCTION 1 | ||
| 45 | #define EXIT_REASON_PAL_CALL 2 | ||
| 46 | #define EXIT_REASON_SAL_CALL 3 | ||
| 47 | #define EXIT_REASON_SWITCH_RR6 4 | ||
| 48 | #define EXIT_REASON_VM_DESTROY 5 | ||
| 49 | #define EXIT_REASON_EXTERNAL_INTERRUPT 6 | ||
| 50 | #define EXIT_REASON_IPI 7 | ||
| 51 | #define EXIT_REASON_PTC_G 8 | ||
| 52 | |||
| 53 | /*Define vmm address space and vm data space.*/ | ||
| 54 | #define KVM_VMM_SIZE (16UL<<20) | ||
| 55 | #define KVM_VMM_SHIFT 24 | ||
| 56 | #define KVM_VMM_BASE 0xD000000000000000UL | ||
| 57 | #define VMM_SIZE (8UL<<20) | ||
| 58 | |||
| 59 | /* | ||
| 60 | * Define vm_buffer, used by PAL Services, base address. | ||
| 61 | * Note: vmbuffer is in the VMM-BLOCK, the size must be < 8M | ||
| 62 | */ | ||
| 63 | #define KVM_VM_BUFFER_BASE (KVM_VMM_BASE + VMM_SIZE) | ||
| 64 | #define KVM_VM_BUFFER_SIZE (8UL<<20) | ||
| 65 | |||
| 66 | /*Define Virtual machine data layout.*/ | ||
| 67 | #define KVM_VM_DATA_SHIFT 24 | ||
| 68 | #define KVM_VM_DATA_SIZE (1UL << KVM_VM_DATA_SHIFT) | ||
| 69 | #define KVM_VM_DATA_BASE (KVM_VMM_BASE + KVM_VMM_SIZE) | ||
| 70 | |||
| 71 | |||
| 72 | #define KVM_P2M_BASE KVM_VM_DATA_BASE | ||
| 73 | #define KVM_P2M_OFS 0 | ||
| 74 | #define KVM_P2M_SIZE (8UL << 20) | ||
| 75 | |||
| 76 | #define KVM_VHPT_BASE (KVM_P2M_BASE + KVM_P2M_SIZE) | ||
| 77 | #define KVM_VHPT_OFS KVM_P2M_SIZE | ||
| 78 | #define KVM_VHPT_BLOCK_SIZE (2UL << 20) | ||
| 79 | #define VHPT_SHIFT 18 | ||
| 80 | #define VHPT_SIZE (1UL << VHPT_SHIFT) | ||
| 81 | #define VHPT_NUM_ENTRIES (1<<(VHPT_SHIFT-5)) | ||
| 82 | |||
| 83 | #define KVM_VTLB_BASE (KVM_VHPT_BASE+KVM_VHPT_BLOCK_SIZE) | ||
| 84 | #define KVM_VTLB_OFS (KVM_VHPT_OFS+KVM_VHPT_BLOCK_SIZE) | ||
| 85 | #define KVM_VTLB_BLOCK_SIZE (1UL<<20) | ||
| 86 | #define VTLB_SHIFT 17 | ||
| 87 | #define VTLB_SIZE (1UL<<VTLB_SHIFT) | ||
| 88 | #define VTLB_NUM_ENTRIES (1<<(VTLB_SHIFT-5)) | ||
| 89 | |||
| 90 | #define KVM_VPD_BASE (KVM_VTLB_BASE+KVM_VTLB_BLOCK_SIZE) | ||
| 91 | #define KVM_VPD_OFS (KVM_VTLB_OFS+KVM_VTLB_BLOCK_SIZE) | ||
| 92 | #define KVM_VPD_BLOCK_SIZE (2UL<<20) | ||
| 93 | #define VPD_SHIFT 16 | ||
| 94 | #define VPD_SIZE (1UL<<VPD_SHIFT) | ||
| 95 | |||
| 96 | #define KVM_VCPU_BASE (KVM_VPD_BASE+KVM_VPD_BLOCK_SIZE) | ||
| 97 | #define KVM_VCPU_OFS (KVM_VPD_OFS+KVM_VPD_BLOCK_SIZE) | ||
| 98 | #define KVM_VCPU_BLOCK_SIZE (2UL<<20) | ||
| 99 | #define VCPU_SHIFT 18 | ||
| 100 | #define VCPU_SIZE (1UL<<VCPU_SHIFT) | ||
| 101 | #define MAX_VCPU_NUM KVM_VCPU_BLOCK_SIZE/VCPU_SIZE | ||
| 102 | |||
| 103 | #define KVM_VM_BASE (KVM_VCPU_BASE+KVM_VCPU_BLOCK_SIZE) | ||
| 104 | #define KVM_VM_OFS (KVM_VCPU_OFS+KVM_VCPU_BLOCK_SIZE) | ||
| 105 | #define KVM_VM_BLOCK_SIZE (1UL<<19) | ||
| 106 | |||
| 107 | #define KVM_MEM_DIRTY_LOG_BASE (KVM_VM_BASE+KVM_VM_BLOCK_SIZE) | ||
| 108 | #define KVM_MEM_DIRTY_LOG_OFS (KVM_VM_OFS+KVM_VM_BLOCK_SIZE) | ||
| 109 | #define KVM_MEM_DIRTY_LOG_SIZE (1UL<<19) | ||
| 110 | |||
| 111 | /* Get vpd, vhpt, tlb, vcpu, base*/ | ||
| 112 | #define VPD_ADDR(n) (KVM_VPD_BASE+n*VPD_SIZE) | ||
| 113 | #define VHPT_ADDR(n) (KVM_VHPT_BASE+n*VHPT_SIZE) | ||
| 114 | #define VTLB_ADDR(n) (KVM_VTLB_BASE+n*VTLB_SIZE) | ||
| 115 | #define VCPU_ADDR(n) (KVM_VCPU_BASE+n*VCPU_SIZE) | ||
| 116 | |||
| 117 | /*IO section definitions*/ | ||
| 118 | #define IOREQ_READ 1 | ||
| 119 | #define IOREQ_WRITE 0 | ||
| 120 | |||
| 121 | #define STATE_IOREQ_NONE 0 | ||
| 122 | #define STATE_IOREQ_READY 1 | ||
| 123 | #define STATE_IOREQ_INPROCESS 2 | ||
| 124 | #define STATE_IORESP_READY 3 | ||
| 125 | |||
| 126 | /*Guest Physical address layout.*/ | ||
| 127 | #define GPFN_MEM (0UL << 60) /* Guest pfn is normal mem */ | ||
| 128 | #define GPFN_FRAME_BUFFER (1UL << 60) /* VGA framebuffer */ | ||
| 129 | #define GPFN_LOW_MMIO (2UL << 60) /* Low MMIO range */ | ||
| 130 | #define GPFN_PIB (3UL << 60) /* PIB base */ | ||
| 131 | #define GPFN_IOSAPIC (4UL << 60) /* IOSAPIC base */ | ||
| 132 | #define GPFN_LEGACY_IO (5UL << 60) /* Legacy I/O base */ | ||
| 133 | #define GPFN_GFW (6UL << 60) /* Guest Firmware */ | ||
| 134 | #define GPFN_HIGH_MMIO (7UL << 60) /* High MMIO range */ | ||
| 135 | |||
| 136 | #define GPFN_IO_MASK (7UL << 60) /* Guest pfn is I/O type */ | ||
| 137 | #define GPFN_INV_MASK (1UL << 63) /* Guest pfn is invalid */ | ||
| 138 | #define INVALID_MFN (~0UL) | ||
| 139 | #define MEM_G (1UL << 30) | ||
| 140 | #define MEM_M (1UL << 20) | ||
| 141 | #define MMIO_START (3 * MEM_G) | ||
| 142 | #define MMIO_SIZE (512 * MEM_M) | ||
| 143 | #define VGA_IO_START 0xA0000UL | ||
| 144 | #define VGA_IO_SIZE 0x20000 | ||
| 145 | #define LEGACY_IO_START (MMIO_START + MMIO_SIZE) | ||
| 146 | #define LEGACY_IO_SIZE (64 * MEM_M) | ||
| 147 | #define IO_SAPIC_START 0xfec00000UL | ||
| 148 | #define IO_SAPIC_SIZE 0x100000 | ||
| 149 | #define PIB_START 0xfee00000UL | ||
| 150 | #define PIB_SIZE 0x200000 | ||
| 151 | #define GFW_START (4 * MEM_G - 16 * MEM_M) | ||
| 152 | #define GFW_SIZE (16 * MEM_M) | ||
| 153 | |||
| 154 | /*Deliver mode, defined for ioapic.c*/ | ||
| 155 | #define dest_Fixed IOSAPIC_FIXED | ||
| 156 | #define dest_LowestPrio IOSAPIC_LOWEST_PRIORITY | ||
| 157 | |||
| 158 | #define NMI_VECTOR 2 | ||
| 159 | #define ExtINT_VECTOR 0 | ||
| 160 | #define NULL_VECTOR (-1) | ||
| 161 | #define IA64_SPURIOUS_INT_VECTOR 0x0f | ||
| 162 | |||
| 163 | #define VCPU_LID(v) (((u64)(v)->vcpu_id) << 24) | ||
| 164 | |||
| 165 | /* | ||
| 166 | *Delivery mode | ||
| 167 | */ | ||
| 168 | #define SAPIC_DELIV_SHIFT 8 | ||
| 169 | #define SAPIC_FIXED 0x0 | ||
| 170 | #define SAPIC_LOWEST_PRIORITY 0x1 | ||
| 171 | #define SAPIC_PMI 0x2 | ||
| 172 | #define SAPIC_NMI 0x4 | ||
| 173 | #define SAPIC_INIT 0x5 | ||
| 174 | #define SAPIC_EXTINT 0x7 | ||
| 175 | |||
| 176 | /* | ||
| 177 | * vcpu->requests bit members for arch | ||
| 178 | */ | ||
| 179 | #define KVM_REQ_PTC_G 32 | ||
| 180 | #define KVM_REQ_RESUME 33 | ||
| 181 | |||
| 182 | #define KVM_PAGES_PER_HPAGE 1 | ||
| 183 | |||
| 184 | struct kvm; | ||
| 185 | struct kvm_vcpu; | ||
| 186 | struct kvm_guest_debug{ | ||
| 187 | }; | ||
| 188 | |||
| 189 | struct kvm_mmio_req { | ||
| 190 | uint64_t addr; /* physical address */ | ||
| 191 | uint64_t size; /* size in bytes */ | ||
| 192 | uint64_t data; /* data (or paddr of data) */ | ||
| 193 | uint8_t state:4; | ||
| 194 | uint8_t dir:1; /* 1=read, 0=write */ | ||
| 195 | }; | ||
| 196 | |||
| 197 | /*Pal data struct */ | ||
| 198 | struct kvm_pal_call{ | ||
| 199 | /*In area*/ | ||
| 200 | uint64_t gr28; | ||
| 201 | uint64_t gr29; | ||
| 202 | uint64_t gr30; | ||
| 203 | uint64_t gr31; | ||
| 204 | /*Out area*/ | ||
| 205 | struct ia64_pal_retval ret; | ||
| 206 | }; | ||
| 207 | |||
| 208 | /* Sal data structure */ | ||
| 209 | struct kvm_sal_call{ | ||
| 210 | /*In area*/ | ||
| 211 | uint64_t in0; | ||
| 212 | uint64_t in1; | ||
| 213 | uint64_t in2; | ||
| 214 | uint64_t in3; | ||
| 215 | uint64_t in4; | ||
| 216 | uint64_t in5; | ||
| 217 | uint64_t in6; | ||
| 218 | uint64_t in7; | ||
| 219 | struct sal_ret_values ret; | ||
| 220 | }; | ||
| 221 | |||
| 222 | /*Guest change rr6*/ | ||
| 223 | struct kvm_switch_rr6 { | ||
| 224 | uint64_t old_rr; | ||
| 225 | uint64_t new_rr; | ||
| 226 | }; | ||
| 227 | |||
| 228 | union ia64_ipi_a{ | ||
| 229 | unsigned long val; | ||
| 230 | struct { | ||
| 231 | unsigned long rv : 3; | ||
| 232 | unsigned long ir : 1; | ||
| 233 | unsigned long eid : 8; | ||
| 234 | unsigned long id : 8; | ||
| 235 | unsigned long ib_base : 44; | ||
| 236 | }; | ||
| 237 | }; | ||
| 238 | |||
| 239 | union ia64_ipi_d { | ||
| 240 | unsigned long val; | ||
| 241 | struct { | ||
| 242 | unsigned long vector : 8; | ||
| 243 | unsigned long dm : 3; | ||
| 244 | unsigned long ig : 53; | ||
| 245 | }; | ||
| 246 | }; | ||
| 247 | |||
| 248 | /*ipi check exit data*/ | ||
| 249 | struct kvm_ipi_data{ | ||
| 250 | union ia64_ipi_a addr; | ||
| 251 | union ia64_ipi_d data; | ||
| 252 | }; | ||
| 253 | |||
| 254 | /*global purge data*/ | ||
| 255 | struct kvm_ptc_g { | ||
| 256 | unsigned long vaddr; | ||
| 257 | unsigned long rr; | ||
| 258 | unsigned long ps; | ||
| 259 | struct kvm_vcpu *vcpu; | ||
| 260 | }; | ||
| 261 | |||
| 262 | /*Exit control data */ | ||
| 263 | struct exit_ctl_data{ | ||
| 264 | uint32_t exit_reason; | ||
| 265 | uint32_t vm_status; | ||
| 266 | union { | ||
| 267 | struct kvm_mmio_req ioreq; | ||
| 268 | struct kvm_pal_call pal_data; | ||
| 269 | struct kvm_sal_call sal_data; | ||
| 270 | struct kvm_switch_rr6 rr_data; | ||
| 271 | struct kvm_ipi_data ipi_data; | ||
| 272 | struct kvm_ptc_g ptc_g_data; | ||
| 273 | } u; | ||
| 274 | }; | ||
| 275 | |||
| 276 | union pte_flags { | ||
| 277 | unsigned long val; | ||
| 278 | struct { | ||
| 279 | unsigned long p : 1; /*0 */ | ||
| 280 | unsigned long : 1; /* 1 */ | ||
| 281 | unsigned long ma : 3; /* 2-4 */ | ||
| 282 | unsigned long a : 1; /* 5 */ | ||
| 283 | unsigned long d : 1; /* 6 */ | ||
| 284 | unsigned long pl : 2; /* 7-8 */ | ||
| 285 | unsigned long ar : 3; /* 9-11 */ | ||
| 286 | unsigned long ppn : 38; /* 12-49 */ | ||
| 287 | unsigned long : 2; /* 50-51 */ | ||
| 288 | unsigned long ed : 1; /* 52 */ | ||
| 289 | }; | ||
| 290 | }; | ||
| 291 | |||
| 292 | union ia64_pta { | ||
| 293 | unsigned long val; | ||
| 294 | struct { | ||
| 295 | unsigned long ve : 1; | ||
| 296 | unsigned long reserved0 : 1; | ||
| 297 | unsigned long size : 6; | ||
| 298 | unsigned long vf : 1; | ||
| 299 | unsigned long reserved1 : 6; | ||
| 300 | unsigned long base : 49; | ||
| 301 | }; | ||
| 302 | }; | ||
| 303 | |||
| 304 | struct thash_cb { | ||
| 305 | /* THASH base information */ | ||
| 306 | struct thash_data *hash; /* hash table pointer */ | ||
| 307 | union ia64_pta pta; | ||
| 308 | int num; | ||
| 309 | }; | ||
| 310 | |||
| 311 | struct kvm_vcpu_stat { | ||
| 312 | }; | ||
| 313 | |||
| 314 | struct kvm_vcpu_arch { | ||
| 315 | int launched; | ||
| 316 | int last_exit; | ||
| 317 | int last_run_cpu; | ||
| 318 | int vmm_tr_slot; | ||
| 319 | int vm_tr_slot; | ||
| 320 | |||
| 321 | #define KVM_MP_STATE_RUNNABLE 0 | ||
| 322 | #define KVM_MP_STATE_UNINITIALIZED 1 | ||
| 323 | #define KVM_MP_STATE_INIT_RECEIVED 2 | ||
| 324 | #define KVM_MP_STATE_HALTED 3 | ||
| 325 | int mp_state; | ||
| 326 | |||
| 327 | #define MAX_PTC_G_NUM 3 | ||
| 328 | int ptc_g_count; | ||
| 329 | struct kvm_ptc_g ptc_g_data[MAX_PTC_G_NUM]; | ||
| 330 | |||
| 331 | /*halt timer to wake up sleepy vcpus*/ | ||
| 332 | struct hrtimer hlt_timer; | ||
| 333 | long ht_active; | ||
| 334 | |||
| 335 | struct kvm_lapic *apic; /* kernel irqchip context */ | ||
| 336 | struct vpd *vpd; | ||
| 337 | |||
| 338 | /* Exit data for vmm_transition*/ | ||
| 339 | struct exit_ctl_data exit_data; | ||
| 340 | |||
| 341 | cpumask_t cache_coherent_map; | ||
| 342 | |||
| 343 | unsigned long vmm_rr; | ||
| 344 | unsigned long host_rr6; | ||
| 345 | unsigned long psbits[8]; | ||
| 346 | unsigned long cr_iipa; | ||
| 347 | unsigned long cr_isr; | ||
| 348 | unsigned long vsa_base; | ||
| 349 | unsigned long dirty_log_lock_pa; | ||
| 350 | unsigned long __gp; | ||
| 351 | /* TR and TC. */ | ||
| 352 | struct thash_data itrs[NITRS]; | ||
| 353 | struct thash_data dtrs[NDTRS]; | ||
| 354 | /* Bit is set if there is a tr/tc for the region. */ | ||
| 355 | unsigned char itr_regions; | ||
| 356 | unsigned char dtr_regions; | ||
| 357 | unsigned char tc_regions; | ||
| 358 | /* purge all */ | ||
| 359 | unsigned long ptce_base; | ||
| 360 | unsigned long ptce_count[2]; | ||
| 361 | unsigned long ptce_stride[2]; | ||
| 362 | /* itc/itm */ | ||
| 363 | unsigned long last_itc; | ||
| 364 | long itc_offset; | ||
| 365 | unsigned long itc_check; | ||
| 366 | unsigned long timer_check; | ||
| 367 | unsigned long timer_pending; | ||
| 368 | |||
| 369 | unsigned long vrr[8]; | ||
| 370 | unsigned long ibr[8]; | ||
| 371 | unsigned long dbr[8]; | ||
| 372 | unsigned long insvc[4]; /* Interrupt in service. */ | ||
| 373 | unsigned long xtp; | ||
| 374 | |||
| 375 | unsigned long metaphysical_rr0; /* from kvm_arch (so is pinned) */ | ||
| 376 | unsigned long metaphysical_rr4; /* from kvm_arch (so is pinned) */ | ||
| 377 | unsigned long metaphysical_saved_rr0; /* from kvm_arch */ | ||
| 378 | unsigned long metaphysical_saved_rr4; /* from kvm_arch */ | ||
| 379 | unsigned long fp_psr; /*used for lazy float register */ | ||
| 380 | unsigned long saved_gp; | ||
| 381 | /*for phycial emulation */ | ||
| 382 | int mode_flags; | ||
| 383 | struct thash_cb vtlb; | ||
| 384 | struct thash_cb vhpt; | ||
| 385 | char irq_check; | ||
| 386 | char irq_new_pending; | ||
| 387 | |||
| 388 | unsigned long opcode; | ||
| 389 | unsigned long cause; | ||
| 390 | union context host; | ||
| 391 | union context guest; | ||
| 392 | }; | ||
| 393 | |||
| 394 | struct kvm_vm_stat { | ||
| 395 | u64 remote_tlb_flush; | ||
| 396 | }; | ||
| 397 | |||
| 398 | struct kvm_sal_data { | ||
| 399 | unsigned long boot_ip; | ||
| 400 | unsigned long boot_gp; | ||
| 401 | }; | ||
| 402 | |||
| 403 | struct kvm_arch { | ||
| 404 | unsigned long vm_base; | ||
| 405 | unsigned long metaphysical_rr0; | ||
| 406 | unsigned long metaphysical_rr4; | ||
| 407 | unsigned long vmm_init_rr; | ||
| 408 | unsigned long vhpt_base; | ||
| 409 | unsigned long vtlb_base; | ||
| 410 | unsigned long vpd_base; | ||
| 411 | spinlock_t dirty_log_lock; | ||
| 412 | struct kvm_ioapic *vioapic; | ||
| 413 | struct kvm_vm_stat stat; | ||
| 414 | struct kvm_sal_data rdv_sal_data; | ||
| 415 | }; | ||
| 416 | |||
| 417 | union cpuid3_t { | ||
| 418 | u64 value; | ||
| 419 | struct { | ||
| 420 | u64 number : 8; | ||
| 421 | u64 revision : 8; | ||
| 422 | u64 model : 8; | ||
| 423 | u64 family : 8; | ||
| 424 | u64 archrev : 8; | ||
| 425 | u64 rv : 24; | ||
| 426 | }; | ||
| 427 | }; | ||
| 428 | |||
| 429 | struct kvm_pt_regs { | ||
| 430 | /* The following registers are saved by SAVE_MIN: */ | ||
| 431 | unsigned long b6; /* scratch */ | ||
| 432 | unsigned long b7; /* scratch */ | ||
| 433 | |||
| 434 | unsigned long ar_csd; /* used by cmp8xchg16 (scratch) */ | ||
| 435 | unsigned long ar_ssd; /* reserved for future use (scratch) */ | ||
| 436 | |||
| 437 | unsigned long r8; /* scratch (return value register 0) */ | ||
| 438 | unsigned long r9; /* scratch (return value register 1) */ | ||
| 439 | unsigned long r10; /* scratch (return value register 2) */ | ||
| 440 | unsigned long r11; /* scratch (return value register 3) */ | ||
| 441 | |||
| 442 | unsigned long cr_ipsr; /* interrupted task's psr */ | ||
| 443 | unsigned long cr_iip; /* interrupted task's instruction pointer */ | ||
| 444 | unsigned long cr_ifs; /* interrupted task's function state */ | ||
| 445 | |||
| 446 | unsigned long ar_unat; /* interrupted task's NaT register (preserved) */ | ||
| 447 | unsigned long ar_pfs; /* prev function state */ | ||
| 448 | unsigned long ar_rsc; /* RSE configuration */ | ||
| 449 | /* The following two are valid only if cr_ipsr.cpl > 0: */ | ||
| 450 | unsigned long ar_rnat; /* RSE NaT */ | ||
| 451 | unsigned long ar_bspstore; /* RSE bspstore */ | ||
| 452 | |||
| 453 | unsigned long pr; /* 64 predicate registers (1 bit each) */ | ||
| 454 | unsigned long b0; /* return pointer (bp) */ | ||
| 455 | unsigned long loadrs; /* size of dirty partition << 16 */ | ||
| 456 | |||
| 457 | unsigned long r1; /* the gp pointer */ | ||
| 458 | unsigned long r12; /* interrupted task's memory stack pointer */ | ||
| 459 | unsigned long r13; /* thread pointer */ | ||
| 460 | |||
| 461 | unsigned long ar_fpsr; /* floating point status (preserved) */ | ||
| 462 | unsigned long r15; /* scratch */ | ||
| 463 | |||
| 464 | /* The remaining registers are NOT saved for system calls. */ | ||
| 465 | unsigned long r14; /* scratch */ | ||
| 466 | unsigned long r2; /* scratch */ | ||
| 467 | unsigned long r3; /* scratch */ | ||
| 468 | unsigned long r16; /* scratch */ | ||
| 469 | unsigned long r17; /* scratch */ | ||
| 470 | unsigned long r18; /* scratch */ | ||
| 471 | unsigned long r19; /* scratch */ | ||
| 472 | unsigned long r20; /* scratch */ | ||
| 473 | unsigned long r21; /* scratch */ | ||
| 474 | unsigned long r22; /* scratch */ | ||
| 475 | unsigned long r23; /* scratch */ | ||
| 476 | unsigned long r24; /* scratch */ | ||
| 477 | unsigned long r25; /* scratch */ | ||
| 478 | unsigned long r26; /* scratch */ | ||
| 479 | unsigned long r27; /* scratch */ | ||
| 480 | unsigned long r28; /* scratch */ | ||
| 481 | unsigned long r29; /* scratch */ | ||
| 482 | unsigned long r30; /* scratch */ | ||
| 483 | unsigned long r31; /* scratch */ | ||
| 484 | unsigned long ar_ccv; /* compare/exchange value (scratch) */ | ||
| 485 | |||
| 486 | /* | ||
| 487 | * Floating point registers that the kernel considers scratch: | ||
| 488 | */ | ||
| 489 | struct ia64_fpreg f6; /* scratch */ | ||
| 490 | struct ia64_fpreg f7; /* scratch */ | ||
| 491 | struct ia64_fpreg f8; /* scratch */ | ||
| 492 | struct ia64_fpreg f9; /* scratch */ | ||
| 493 | struct ia64_fpreg f10; /* scratch */ | ||
| 494 | struct ia64_fpreg f11; /* scratch */ | ||
| 495 | |||
| 496 | unsigned long r4; /* preserved */ | ||
| 497 | unsigned long r5; /* preserved */ | ||
| 498 | unsigned long r6; /* preserved */ | ||
| 499 | unsigned long r7; /* preserved */ | ||
| 500 | unsigned long eml_unat; /* used for emulating instruction */ | ||
| 501 | unsigned long pad0; /* alignment pad */ | ||
| 502 | }; | ||
| 503 | |||
| 504 | static inline struct kvm_pt_regs *vcpu_regs(struct kvm_vcpu *v) | ||
| 505 | { | ||
| 506 | return (struct kvm_pt_regs *) ((unsigned long) v + IA64_STK_OFFSET) - 1; | ||
| 507 | } | ||
| 508 | |||
| 509 | typedef int kvm_vmm_entry(void); | ||
| 510 | typedef void kvm_tramp_entry(union context *host, union context *guest); | ||
| 511 | |||
| 512 | struct kvm_vmm_info{ | ||
| 513 | struct module *module; | ||
| 514 | kvm_vmm_entry *vmm_entry; | ||
| 515 | kvm_tramp_entry *tramp_entry; | ||
| 516 | unsigned long vmm_ivt; | ||
| 517 | }; | ||
| 518 | |||
| 519 | int kvm_highest_pending_irq(struct kvm_vcpu *vcpu); | ||
| 520 | int kvm_emulate_halt(struct kvm_vcpu *vcpu); | ||
| 521 | int kvm_pal_emul(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run); | ||
| 522 | void kvm_sal_emul(struct kvm_vcpu *vcpu); | ||
| 523 | |||
| 524 | #endif | ||
diff --git a/include/asm-ia64/kvm_para.h b/include/asm-ia64/kvm_para.h new file mode 100644 index 000000000000..9f9796bb3441 --- /dev/null +++ b/include/asm-ia64/kvm_para.h | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | #ifndef __IA64_KVM_PARA_H | ||
| 2 | #define __IA64_KVM_PARA_H | ||
| 3 | |||
| 4 | /* | ||
| 5 | * asm-ia64/kvm_para.h | ||
| 6 | * | ||
| 7 | * Copyright (C) 2007 Xiantao Zhang <xiantao.zhang@intel.com> | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify it | ||
| 10 | * under the terms and conditions of the GNU General Public License, | ||
| 11 | * version 2, as published by the Free Software Foundation. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 16 | * more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU General Public License along with | ||
| 19 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
| 20 | * Place - Suite 330, Boston, MA 02111-1307 USA. | ||
| 21 | * | ||
| 22 | */ | ||
| 23 | |||
| 24 | static inline unsigned int kvm_arch_para_features(void) | ||
| 25 | { | ||
| 26 | return 0; | ||
| 27 | } | ||
| 28 | |||
| 29 | #endif | ||
diff --git a/include/asm-ia64/processor.h b/include/asm-ia64/processor.h index 741f7ecb986a..6aff126fc07e 100644 --- a/include/asm-ia64/processor.h +++ b/include/asm-ia64/processor.h | |||
| @@ -119,6 +119,69 @@ struct ia64_psr { | |||
| 119 | __u64 reserved4 : 19; | 119 | __u64 reserved4 : 19; |
| 120 | }; | 120 | }; |
| 121 | 121 | ||
| 122 | union ia64_isr { | ||
| 123 | __u64 val; | ||
| 124 | struct { | ||
| 125 | __u64 code : 16; | ||
| 126 | __u64 vector : 8; | ||
| 127 | __u64 reserved1 : 8; | ||
| 128 | __u64 x : 1; | ||
| 129 | __u64 w : 1; | ||
| 130 | __u64 r : 1; | ||
| 131 | __u64 na : 1; | ||
| 132 | __u64 sp : 1; | ||
| 133 | __u64 rs : 1; | ||
| 134 | __u64 ir : 1; | ||
| 135 | __u64 ni : 1; | ||
| 136 | __u64 so : 1; | ||
| 137 | __u64 ei : 2; | ||
| 138 | __u64 ed : 1; | ||
| 139 | __u64 reserved2 : 20; | ||
| 140 | }; | ||
| 141 | }; | ||
| 142 | |||
| 143 | union ia64_lid { | ||
| 144 | __u64 val; | ||
| 145 | struct { | ||
| 146 | __u64 rv : 16; | ||
| 147 | __u64 eid : 8; | ||
| 148 | __u64 id : 8; | ||
| 149 | __u64 ig : 32; | ||
| 150 | }; | ||
| 151 | }; | ||
| 152 | |||
| 153 | union ia64_tpr { | ||
| 154 | __u64 val; | ||
| 155 | struct { | ||
| 156 | __u64 ig0 : 4; | ||
| 157 | __u64 mic : 4; | ||
| 158 | __u64 rsv : 8; | ||
| 159 | __u64 mmi : 1; | ||
| 160 | __u64 ig1 : 47; | ||
| 161 | }; | ||
| 162 | }; | ||
| 163 | |||
| 164 | union ia64_itir { | ||
| 165 | __u64 val; | ||
| 166 | struct { | ||
| 167 | __u64 rv3 : 2; /* 0-1 */ | ||
| 168 | __u64 ps : 6; /* 2-7 */ | ||
| 169 | __u64 key : 24; /* 8-31 */ | ||
| 170 | __u64 rv4 : 32; /* 32-63 */ | ||
| 171 | }; | ||
| 172 | }; | ||
| 173 | |||
| 174 | union ia64_rr { | ||
| 175 | __u64 val; | ||
| 176 | struct { | ||
| 177 | __u64 ve : 1; /* enable hw walker */ | ||
| 178 | __u64 reserved0: 1; /* reserved */ | ||
| 179 | __u64 ps : 6; /* log page size */ | ||
| 180 | __u64 rid : 24; /* region id */ | ||
| 181 | __u64 reserved1: 32; /* reserved */ | ||
| 182 | }; | ||
| 183 | }; | ||
| 184 | |||
| 122 | /* | 185 | /* |
| 123 | * CPU type, hardware bug flags, and per-CPU state. Frequently used | 186 | * CPU type, hardware bug flags, and per-CPU state. Frequently used |
| 124 | * state comes earlier: | 187 | * state comes earlier: |
diff --git a/include/asm-powerpc/kvm.h b/include/asm-powerpc/kvm.h index d1b530fbf8dd..f993e4198d5c 100644 --- a/include/asm-powerpc/kvm.h +++ b/include/asm-powerpc/kvm.h | |||
| @@ -1,6 +1,55 @@ | |||
| 1 | /* | ||
| 2 | * This program is free software; you can redistribute it and/or modify | ||
| 3 | * it under the terms of the GNU General Public License, version 2, as | ||
| 4 | * published by the Free Software Foundation. | ||
| 5 | * | ||
| 6 | * This program is distributed in the hope that it will be useful, | ||
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 9 | * GNU General Public License for more details. | ||
| 10 | * | ||
| 11 | * You should have received a copy of the GNU General Public License | ||
| 12 | * along with this program; if not, write to the Free Software | ||
| 13 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 14 | * | ||
| 15 | * Copyright IBM Corp. 2007 | ||
| 16 | * | ||
| 17 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> | ||
| 18 | */ | ||
| 19 | |||
| 1 | #ifndef __LINUX_KVM_POWERPC_H | 20 | #ifndef __LINUX_KVM_POWERPC_H |
| 2 | #define __LINUX_KVM_POWERPC_H | 21 | #define __LINUX_KVM_POWERPC_H |
| 3 | 22 | ||
| 4 | /* powerpc does not support KVM */ | 23 | #include <asm/types.h> |
| 24 | |||
| 25 | struct kvm_regs { | ||
| 26 | __u64 pc; | ||
| 27 | __u64 cr; | ||
| 28 | __u64 ctr; | ||
| 29 | __u64 lr; | ||
| 30 | __u64 xer; | ||
| 31 | __u64 msr; | ||
| 32 | __u64 srr0; | ||
| 33 | __u64 srr1; | ||
| 34 | __u64 pid; | ||
| 35 | |||
| 36 | __u64 sprg0; | ||
| 37 | __u64 sprg1; | ||
| 38 | __u64 sprg2; | ||
| 39 | __u64 sprg3; | ||
| 40 | __u64 sprg4; | ||
| 41 | __u64 sprg5; | ||
| 42 | __u64 sprg6; | ||
| 43 | __u64 sprg7; | ||
| 44 | |||
| 45 | __u64 gpr[32]; | ||
| 46 | }; | ||
| 47 | |||
| 48 | struct kvm_sregs { | ||
| 49 | }; | ||
| 50 | |||
| 51 | struct kvm_fpu { | ||
| 52 | __u64 fpr[32]; | ||
| 53 | }; | ||
| 5 | 54 | ||
| 6 | #endif | 55 | #endif /* __LINUX_KVM_POWERPC_H */ |
diff --git a/include/asm-powerpc/kvm_asm.h b/include/asm-powerpc/kvm_asm.h new file mode 100644 index 000000000000..2197764796d9 --- /dev/null +++ b/include/asm-powerpc/kvm_asm.h | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | /* | ||
| 2 | * This program is free software; you can redistribute it and/or modify | ||
| 3 | * it under the terms of the GNU General Public License, version 2, as | ||
| 4 | * published by the Free Software Foundation. | ||
| 5 | * | ||
| 6 | * This program is distributed in the hope that it will be useful, | ||
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 9 | * GNU General Public License for more details. | ||
| 10 | * | ||
| 11 | * You should have received a copy of the GNU General Public License | ||
| 12 | * along with this program; if not, write to the Free Software | ||
| 13 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 14 | * | ||
| 15 | * Copyright IBM Corp. 2008 | ||
| 16 | * | ||
| 17 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> | ||
| 18 | */ | ||
| 19 | |||
| 20 | #ifndef __POWERPC_KVM_ASM_H__ | ||
| 21 | #define __POWERPC_KVM_ASM_H__ | ||
| 22 | |||
| 23 | /* IVPR must be 64KiB-aligned. */ | ||
| 24 | #define VCPU_SIZE_ORDER 4 | ||
| 25 | #define VCPU_SIZE_LOG (VCPU_SIZE_ORDER + 12) | ||
| 26 | #define VCPU_TLB_PGSZ PPC44x_TLB_64K | ||
| 27 | #define VCPU_SIZE_BYTES (1<<VCPU_SIZE_LOG) | ||
| 28 | |||
| 29 | #define BOOKE_INTERRUPT_CRITICAL 0 | ||
| 30 | #define BOOKE_INTERRUPT_MACHINE_CHECK 1 | ||
| 31 | #define BOOKE_INTERRUPT_DATA_STORAGE 2 | ||
| 32 | #define BOOKE_INTERRUPT_INST_STORAGE 3 | ||
| 33 | #define BOOKE_INTERRUPT_EXTERNAL 4 | ||
| 34 | #define BOOKE_INTERRUPT_ALIGNMENT 5 | ||
| 35 | #define BOOKE_INTERRUPT_PROGRAM 6 | ||
| 36 | #define BOOKE_INTERRUPT_FP_UNAVAIL 7 | ||
| 37 | #define BOOKE_INTERRUPT_SYSCALL 8 | ||
| 38 | #define BOOKE_INTERRUPT_AP_UNAVAIL 9 | ||
| 39 | #define BOOKE_INTERRUPT_DECREMENTER 10 | ||
| 40 | #define BOOKE_INTERRUPT_FIT 11 | ||
| 41 | #define BOOKE_INTERRUPT_WATCHDOG 12 | ||
| 42 | #define BOOKE_INTERRUPT_DTLB_MISS 13 | ||
| 43 | #define BOOKE_INTERRUPT_ITLB_MISS 14 | ||
| 44 | #define BOOKE_INTERRUPT_DEBUG 15 | ||
| 45 | #define BOOKE_MAX_INTERRUPT 15 | ||
| 46 | |||
| 47 | #define RESUME_FLAG_NV (1<<0) /* Reload guest nonvolatile state? */ | ||
| 48 | #define RESUME_FLAG_HOST (1<<1) /* Resume host? */ | ||
| 49 | |||
| 50 | #define RESUME_GUEST 0 | ||
| 51 | #define RESUME_GUEST_NV RESUME_FLAG_NV | ||
| 52 | #define RESUME_HOST RESUME_FLAG_HOST | ||
| 53 | #define RESUME_HOST_NV (RESUME_FLAG_HOST|RESUME_FLAG_NV) | ||
| 54 | |||
| 55 | #endif /* __POWERPC_KVM_ASM_H__ */ | ||
diff --git a/include/asm-powerpc/kvm_host.h b/include/asm-powerpc/kvm_host.h new file mode 100644 index 000000000000..04ffbb8e0a35 --- /dev/null +++ b/include/asm-powerpc/kvm_host.h | |||
| @@ -0,0 +1,152 @@ | |||
| 1 | /* | ||
| 2 | * This program is free software; you can redistribute it and/or modify | ||
| 3 | * it under the terms of the GNU General Public License, version 2, as | ||
| 4 | * published by the Free Software Foundation. | ||
| 5 | * | ||
| 6 | * This program is distributed in the hope that it will be useful, | ||
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 9 | * GNU General Public License for more details. | ||
| 10 | * | ||
| 11 | * You should have received a copy of the GNU General Public License | ||
| 12 | * along with this program; if not, write to the Free Software | ||
| 13 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 14 | * | ||
| 15 | * Copyright IBM Corp. 2007 | ||
| 16 | * | ||
| 17 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> | ||
| 18 | */ | ||
| 19 | |||
| 20 | #ifndef __POWERPC_KVM_HOST_H__ | ||
| 21 | #define __POWERPC_KVM_HOST_H__ | ||
| 22 | |||
| 23 | #include <linux/mutex.h> | ||
| 24 | #include <linux/timer.h> | ||
| 25 | #include <linux/types.h> | ||
| 26 | #include <linux/kvm_types.h> | ||
| 27 | #include <asm/kvm_asm.h> | ||
| 28 | |||
| 29 | #define KVM_MAX_VCPUS 1 | ||
| 30 | #define KVM_MEMORY_SLOTS 32 | ||
| 31 | /* memory slots that does not exposed to userspace */ | ||
| 32 | #define KVM_PRIVATE_MEM_SLOTS 4 | ||
| 33 | |||
| 34 | /* We don't currently support large pages. */ | ||
| 35 | #define KVM_PAGES_PER_HPAGE (1<<31) | ||
| 36 | |||
| 37 | struct kvm; | ||
| 38 | struct kvm_run; | ||
| 39 | struct kvm_vcpu; | ||
| 40 | |||
| 41 | struct kvm_vm_stat { | ||
| 42 | u32 remote_tlb_flush; | ||
| 43 | }; | ||
| 44 | |||
| 45 | struct kvm_vcpu_stat { | ||
| 46 | u32 sum_exits; | ||
| 47 | u32 mmio_exits; | ||
| 48 | u32 dcr_exits; | ||
| 49 | u32 signal_exits; | ||
| 50 | u32 light_exits; | ||
| 51 | /* Account for special types of light exits: */ | ||
| 52 | u32 itlb_real_miss_exits; | ||
| 53 | u32 itlb_virt_miss_exits; | ||
| 54 | u32 dtlb_real_miss_exits; | ||
| 55 | u32 dtlb_virt_miss_exits; | ||
| 56 | u32 syscall_exits; | ||
| 57 | u32 isi_exits; | ||
| 58 | u32 dsi_exits; | ||
| 59 | u32 emulated_inst_exits; | ||
| 60 | u32 dec_exits; | ||
| 61 | u32 ext_intr_exits; | ||
| 62 | }; | ||
| 63 | |||
| 64 | struct tlbe { | ||
| 65 | u32 tid; /* Only the low 8 bits are used. */ | ||
| 66 | u32 word0; | ||
| 67 | u32 word1; | ||
| 68 | u32 word2; | ||
| 69 | }; | ||
| 70 | |||
| 71 | struct kvm_arch { | ||
| 72 | }; | ||
| 73 | |||
| 74 | struct kvm_vcpu_arch { | ||
| 75 | /* Unmodified copy of the guest's TLB. */ | ||
| 76 | struct tlbe guest_tlb[PPC44x_TLB_SIZE]; | ||
| 77 | /* TLB that's actually used when the guest is running. */ | ||
| 78 | struct tlbe shadow_tlb[PPC44x_TLB_SIZE]; | ||
| 79 | /* Pages which are referenced in the shadow TLB. */ | ||
| 80 | struct page *shadow_pages[PPC44x_TLB_SIZE]; | ||
| 81 | /* Copy of the host's TLB. */ | ||
| 82 | struct tlbe host_tlb[PPC44x_TLB_SIZE]; | ||
| 83 | |||
| 84 | u32 host_stack; | ||
| 85 | u32 host_pid; | ||
| 86 | |||
| 87 | u64 fpr[32]; | ||
| 88 | u32 gpr[32]; | ||
| 89 | |||
| 90 | u32 pc; | ||
| 91 | u32 cr; | ||
| 92 | u32 ctr; | ||
| 93 | u32 lr; | ||
| 94 | u32 xer; | ||
| 95 | |||
| 96 | u32 msr; | ||
| 97 | u32 mmucr; | ||
| 98 | u32 sprg0; | ||
| 99 | u32 sprg1; | ||
| 100 | u32 sprg2; | ||
| 101 | u32 sprg3; | ||
| 102 | u32 sprg4; | ||
| 103 | u32 sprg5; | ||
| 104 | u32 sprg6; | ||
| 105 | u32 sprg7; | ||
| 106 | u32 srr0; | ||
| 107 | u32 srr1; | ||
| 108 | u32 csrr0; | ||
| 109 | u32 csrr1; | ||
| 110 | u32 dsrr0; | ||
| 111 | u32 dsrr1; | ||
| 112 | u32 dear; | ||
| 113 | u32 esr; | ||
| 114 | u32 dec; | ||
| 115 | u32 decar; | ||
| 116 | u32 tbl; | ||
| 117 | u32 tbu; | ||
| 118 | u32 tcr; | ||
| 119 | u32 tsr; | ||
| 120 | u32 ivor[16]; | ||
| 121 | u32 ivpr; | ||
| 122 | u32 pir; | ||
| 123 | u32 pid; | ||
| 124 | u32 pvr; | ||
| 125 | u32 ccr0; | ||
| 126 | u32 ccr1; | ||
| 127 | u32 dbcr0; | ||
| 128 | u32 dbcr1; | ||
| 129 | |||
| 130 | u32 last_inst; | ||
| 131 | u32 fault_dear; | ||
| 132 | u32 fault_esr; | ||
| 133 | gpa_t paddr_accessed; | ||
| 134 | |||
| 135 | u8 io_gpr; /* GPR used as IO source/target */ | ||
| 136 | u8 mmio_is_bigendian; | ||
| 137 | u8 dcr_needed; | ||
| 138 | u8 dcr_is_write; | ||
| 139 | |||
| 140 | u32 cpr0_cfgaddr; /* holds the last set cpr0_cfgaddr */ | ||
| 141 | |||
| 142 | struct timer_list dec_timer; | ||
| 143 | unsigned long pending_exceptions; | ||
| 144 | }; | ||
| 145 | |||
| 146 | struct kvm_guest_debug { | ||
| 147 | int enabled; | ||
| 148 | unsigned long bp[4]; | ||
| 149 | int singlestep; | ||
| 150 | }; | ||
| 151 | |||
| 152 | #endif /* __POWERPC_KVM_HOST_H__ */ | ||
diff --git a/include/asm-powerpc/kvm_para.h b/include/asm-powerpc/kvm_para.h new file mode 100644 index 000000000000..2d48f6a63d0b --- /dev/null +++ b/include/asm-powerpc/kvm_para.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* | ||
| 2 | * This program is free software; you can redistribute it and/or modify | ||
| 3 | * it under the terms of the GNU General Public License, version 2, as | ||
| 4 | * published by the Free Software Foundation. | ||
| 5 | * | ||
| 6 | * This program is distributed in the hope that it will be useful, | ||
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 9 | * GNU General Public License for more details. | ||
| 10 | * | ||
| 11 | * You should have received a copy of the GNU General Public License | ||
| 12 | * along with this program; if not, write to the Free Software | ||
| 13 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 14 | * | ||
| 15 | * Copyright IBM Corp. 2008 | ||
| 16 | * | ||
| 17 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> | ||
| 18 | */ | ||
| 19 | |||
| 20 | #ifndef __POWERPC_KVM_PARA_H__ | ||
| 21 | #define __POWERPC_KVM_PARA_H__ | ||
| 22 | |||
| 23 | #ifdef __KERNEL__ | ||
| 24 | |||
| 25 | static inline int kvm_para_available(void) | ||
| 26 | { | ||
| 27 | return 0; | ||
| 28 | } | ||
| 29 | |||
| 30 | static inline unsigned int kvm_arch_para_features(void) | ||
| 31 | { | ||
| 32 | return 0; | ||
| 33 | } | ||
| 34 | |||
| 35 | #endif /* __KERNEL__ */ | ||
| 36 | |||
| 37 | #endif /* __POWERPC_KVM_PARA_H__ */ | ||
diff --git a/include/asm-powerpc/kvm_ppc.h b/include/asm-powerpc/kvm_ppc.h new file mode 100644 index 000000000000..7ac820308a7e --- /dev/null +++ b/include/asm-powerpc/kvm_ppc.h | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | /* | ||
| 2 | * This program is free software; you can redistribute it and/or modify | ||
| 3 | * it under the terms of the GNU General Public License, version 2, as | ||
| 4 | * published by the Free Software Foundation. | ||
| 5 | * | ||
| 6 | * This program is distributed in the hope that it will be useful, | ||
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 9 | * GNU General Public License for more details. | ||
| 10 | * | ||
| 11 | * You should have received a copy of the GNU General Public License | ||
| 12 | * along with this program; if not, write to the Free Software | ||
| 13 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| 14 | * | ||
| 15 | * Copyright IBM Corp. 2008 | ||
| 16 | * | ||
| 17 | * Authors: Hollis Blanchard <hollisb@us.ibm.com> | ||
| 18 | */ | ||
| 19 | |||
| 20 | #ifndef __POWERPC_KVM_PPC_H__ | ||
| 21 | #define __POWERPC_KVM_PPC_H__ | ||
| 22 | |||
| 23 | /* This file exists just so we can dereference kvm_vcpu, avoiding nested header | ||
| 24 | * dependencies. */ | ||
| 25 | |||
| 26 | #include <linux/mutex.h> | ||
| 27 | #include <linux/timer.h> | ||
| 28 | #include <linux/types.h> | ||
| 29 | #include <linux/kvm_types.h> | ||
| 30 | #include <linux/kvm_host.h> | ||
| 31 | |||
| 32 | struct kvm_tlb { | ||
| 33 | struct tlbe guest_tlb[PPC44x_TLB_SIZE]; | ||
| 34 | struct tlbe shadow_tlb[PPC44x_TLB_SIZE]; | ||
| 35 | }; | ||
| 36 | |||
| 37 | enum emulation_result { | ||
| 38 | EMULATE_DONE, /* no further processing */ | ||
| 39 | EMULATE_DO_MMIO, /* kvm_run filled with MMIO request */ | ||
| 40 | EMULATE_DO_DCR, /* kvm_run filled with DCR request */ | ||
| 41 | EMULATE_FAIL, /* can't emulate this instruction */ | ||
| 42 | }; | ||
| 43 | |||
| 44 | extern const unsigned char exception_priority[]; | ||
| 45 | extern const unsigned char priority_exception[]; | ||
| 46 | |||
| 47 | extern int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu); | ||
| 48 | extern char kvmppc_handlers_start[]; | ||
| 49 | extern unsigned long kvmppc_handler_len; | ||
| 50 | |||
| 51 | extern void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu); | ||
| 52 | extern int kvmppc_handle_load(struct kvm_run *run, struct kvm_vcpu *vcpu, | ||
| 53 | unsigned int rt, unsigned int bytes, | ||
| 54 | int is_bigendian); | ||
| 55 | extern int kvmppc_handle_store(struct kvm_run *run, struct kvm_vcpu *vcpu, | ||
| 56 | u32 val, unsigned int bytes, int is_bigendian); | ||
| 57 | |||
| 58 | extern int kvmppc_emulate_instruction(struct kvm_run *run, | ||
| 59 | struct kvm_vcpu *vcpu); | ||
| 60 | |||
| 61 | extern void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gfn_t gfn, | ||
| 62 | u64 asid, u32 flags); | ||
| 63 | extern void kvmppc_mmu_invalidate(struct kvm_vcpu *vcpu, u64 eaddr, u64 asid); | ||
| 64 | extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode); | ||
| 65 | |||
| 66 | extern void kvmppc_check_and_deliver_interrupts(struct kvm_vcpu *vcpu); | ||
| 67 | |||
| 68 | static inline void kvmppc_queue_exception(struct kvm_vcpu *vcpu, int exception) | ||
| 69 | { | ||
| 70 | unsigned int priority = exception_priority[exception]; | ||
| 71 | set_bit(priority, &vcpu->arch.pending_exceptions); | ||
| 72 | } | ||
| 73 | |||
| 74 | static inline void kvmppc_clear_exception(struct kvm_vcpu *vcpu, int exception) | ||
| 75 | { | ||
| 76 | unsigned int priority = exception_priority[exception]; | ||
| 77 | clear_bit(priority, &vcpu->arch.pending_exceptions); | ||
| 78 | } | ||
| 79 | |||
| 80 | static inline void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr) | ||
| 81 | { | ||
| 82 | if ((new_msr & MSR_PR) != (vcpu->arch.msr & MSR_PR)) | ||
| 83 | kvmppc_mmu_priv_switch(vcpu, new_msr & MSR_PR); | ||
| 84 | |||
| 85 | vcpu->arch.msr = new_msr; | ||
| 86 | } | ||
| 87 | |||
| 88 | #endif /* __POWERPC_KVM_PPC_H__ */ | ||
diff --git a/include/asm-powerpc/mmu-44x.h b/include/asm-powerpc/mmu-44x.h index c8b02d97f753..a825524c981a 100644 --- a/include/asm-powerpc/mmu-44x.h +++ b/include/asm-powerpc/mmu-44x.h | |||
| @@ -53,6 +53,8 @@ | |||
| 53 | 53 | ||
| 54 | #ifndef __ASSEMBLY__ | 54 | #ifndef __ASSEMBLY__ |
| 55 | 55 | ||
| 56 | extern unsigned int tlb_44x_hwater; | ||
| 57 | |||
| 56 | typedef struct { | 58 | typedef struct { |
| 57 | unsigned long id; | 59 | unsigned long id; |
| 58 | unsigned long vdso_base; | 60 | unsigned long vdso_base; |
diff --git a/include/asm-s390/Kbuild b/include/asm-s390/Kbuild index e92b429d2be1..13c9805349f1 100644 --- a/include/asm-s390/Kbuild +++ b/include/asm-s390/Kbuild | |||
| @@ -7,6 +7,7 @@ header-y += tape390.h | |||
| 7 | header-y += ucontext.h | 7 | header-y += ucontext.h |
| 8 | header-y += vtoc.h | 8 | header-y += vtoc.h |
| 9 | header-y += zcrypt.h | 9 | header-y += zcrypt.h |
| 10 | header-y += kvm.h | ||
| 10 | 11 | ||
| 11 | unifdef-y += cmb.h | 12 | unifdef-y += cmb.h |
| 12 | unifdef-y += debug.h | 13 | unifdef-y += debug.h |
diff --git a/include/asm-s390/kvm.h b/include/asm-s390/kvm.h index 573f2a351386..d74002f95794 100644 --- a/include/asm-s390/kvm.h +++ b/include/asm-s390/kvm.h | |||
| @@ -1,6 +1,45 @@ | |||
| 1 | #ifndef __LINUX_KVM_S390_H | 1 | #ifndef __LINUX_KVM_S390_H |
| 2 | #define __LINUX_KVM_S390_H | 2 | #define __LINUX_KVM_S390_H |
| 3 | 3 | ||
| 4 | /* s390 does not support KVM */ | 4 | /* |
| 5 | * asm-s390/kvm.h - KVM s390 specific structures and definitions | ||
| 6 | * | ||
| 7 | * Copyright IBM Corp. 2008 | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of the GNU General Public License (version 2 only) | ||
| 11 | * as published by the Free Software Foundation. | ||
| 12 | * | ||
| 13 | * Author(s): Carsten Otte <cotte@de.ibm.com> | ||
| 14 | * Christian Borntraeger <borntraeger@de.ibm.com> | ||
| 15 | */ | ||
| 16 | #include <asm/types.h> | ||
| 17 | |||
| 18 | /* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */ | ||
| 19 | struct kvm_pic_state { | ||
| 20 | /* no PIC for s390 */ | ||
| 21 | }; | ||
| 22 | |||
| 23 | struct kvm_ioapic_state { | ||
| 24 | /* no IOAPIC for s390 */ | ||
| 25 | }; | ||
| 26 | |||
| 27 | /* for KVM_GET_REGS and KVM_SET_REGS */ | ||
| 28 | struct kvm_regs { | ||
| 29 | /* general purpose regs for s390 */ | ||
| 30 | __u64 gprs[16]; | ||
| 31 | }; | ||
| 32 | |||
| 33 | /* for KVM_GET_SREGS and KVM_SET_SREGS */ | ||
| 34 | struct kvm_sregs { | ||
| 35 | __u32 acrs[16]; | ||
| 36 | __u64 crs[16]; | ||
| 37 | }; | ||
| 38 | |||
| 39 | /* for KVM_GET_FPU and KVM_SET_FPU */ | ||
| 40 | struct kvm_fpu { | ||
| 41 | __u32 fpc; | ||
| 42 | __u64 fprs[16]; | ||
| 43 | }; | ||
| 5 | 44 | ||
| 6 | #endif | 45 | #endif |
diff --git a/include/asm-s390/kvm_host.h b/include/asm-s390/kvm_host.h new file mode 100644 index 000000000000..f8204a4f2e02 --- /dev/null +++ b/include/asm-s390/kvm_host.h | |||
| @@ -0,0 +1,234 @@ | |||
| 1 | /* | ||
| 2 | * asm-s390/kvm_host.h - definition for kernel virtual machines on s390 | ||
| 3 | * | ||
| 4 | * Copyright IBM Corp. 2008 | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License (version 2 only) | ||
| 8 | * as published by the Free Software Foundation. | ||
| 9 | * | ||
| 10 | * Author(s): Carsten Otte <cotte@de.ibm.com> | ||
| 11 | */ | ||
| 12 | |||
| 13 | |||
| 14 | #ifndef ASM_KVM_HOST_H | ||
| 15 | #define ASM_KVM_HOST_H | ||
| 16 | #include <linux/kvm_host.h> | ||
| 17 | #include <asm/debug.h> | ||
| 18 | |||
| 19 | #define KVM_MAX_VCPUS 64 | ||
| 20 | #define KVM_MEMORY_SLOTS 32 | ||
| 21 | /* memory slots that does not exposed to userspace */ | ||
| 22 | #define KVM_PRIVATE_MEM_SLOTS 4 | ||
| 23 | |||
| 24 | struct kvm_guest_debug { | ||
| 25 | }; | ||
| 26 | |||
| 27 | struct sca_entry { | ||
| 28 | atomic_t scn; | ||
| 29 | __u64 reserved; | ||
| 30 | __u64 sda; | ||
| 31 | __u64 reserved2[2]; | ||
| 32 | } __attribute__((packed)); | ||
| 33 | |||
| 34 | |||
| 35 | struct sca_block { | ||
| 36 | __u64 ipte_control; | ||
| 37 | __u64 reserved[5]; | ||
| 38 | __u64 mcn; | ||
| 39 | __u64 reserved2; | ||
| 40 | struct sca_entry cpu[64]; | ||
| 41 | } __attribute__((packed)); | ||
| 42 | |||
| 43 | #define KVM_PAGES_PER_HPAGE 256 | ||
| 44 | |||
| 45 | #define CPUSTAT_HOST 0x80000000 | ||
| 46 | #define CPUSTAT_WAIT 0x10000000 | ||
| 47 | #define CPUSTAT_ECALL_PEND 0x08000000 | ||
| 48 | #define CPUSTAT_STOP_INT 0x04000000 | ||
| 49 | #define CPUSTAT_IO_INT 0x02000000 | ||
| 50 | #define CPUSTAT_EXT_INT 0x01000000 | ||
| 51 | #define CPUSTAT_RUNNING 0x00800000 | ||
| 52 | #define CPUSTAT_RETAINED 0x00400000 | ||
| 53 | #define CPUSTAT_TIMING_SUB 0x00020000 | ||
| 54 | #define CPUSTAT_SIE_SUB 0x00010000 | ||
| 55 | #define CPUSTAT_RRF 0x00008000 | ||
| 56 | #define CPUSTAT_SLSV 0x00004000 | ||
| 57 | #define CPUSTAT_SLSR 0x00002000 | ||
| 58 | #define CPUSTAT_ZARCH 0x00000800 | ||
| 59 | #define CPUSTAT_MCDS 0x00000100 | ||
| 60 | #define CPUSTAT_SM 0x00000080 | ||
| 61 | #define CPUSTAT_G 0x00000008 | ||
| 62 | #define CPUSTAT_J 0x00000002 | ||
| 63 | #define CPUSTAT_P 0x00000001 | ||
| 64 | |||
| 65 | struct sie_block { | ||
| 66 | atomic_t cpuflags; /* 0x0000 */ | ||
| 67 | __u32 prefix; /* 0x0004 */ | ||
| 68 | __u8 reserved8[32]; /* 0x0008 */ | ||
| 69 | __u64 cputm; /* 0x0028 */ | ||
| 70 | __u64 ckc; /* 0x0030 */ | ||
| 71 | __u64 epoch; /* 0x0038 */ | ||
| 72 | __u8 reserved40[4]; /* 0x0040 */ | ||
| 73 | #define LCTL_CR0 0x8000 | ||
| 74 | __u16 lctl; /* 0x0044 */ | ||
| 75 | __s16 icpua; /* 0x0046 */ | ||
| 76 | __u32 ictl; /* 0x0048 */ | ||
| 77 | __u32 eca; /* 0x004c */ | ||
| 78 | __u8 icptcode; /* 0x0050 */ | ||
| 79 | __u8 reserved51; /* 0x0051 */ | ||
| 80 | __u16 ihcpu; /* 0x0052 */ | ||
| 81 | __u8 reserved54[2]; /* 0x0054 */ | ||
| 82 | __u16 ipa; /* 0x0056 */ | ||
| 83 | __u32 ipb; /* 0x0058 */ | ||
| 84 | __u32 scaoh; /* 0x005c */ | ||
| 85 | __u8 reserved60; /* 0x0060 */ | ||
| 86 | __u8 ecb; /* 0x0061 */ | ||
| 87 | __u8 reserved62[2]; /* 0x0062 */ | ||
| 88 | __u32 scaol; /* 0x0064 */ | ||
| 89 | __u8 reserved68[4]; /* 0x0068 */ | ||
| 90 | __u32 todpr; /* 0x006c */ | ||
| 91 | __u8 reserved70[16]; /* 0x0070 */ | ||
| 92 | __u64 gmsor; /* 0x0080 */ | ||
| 93 | __u64 gmslm; /* 0x0088 */ | ||
| 94 | psw_t gpsw; /* 0x0090 */ | ||
| 95 | __u64 gg14; /* 0x00a0 */ | ||
| 96 | __u64 gg15; /* 0x00a8 */ | ||
| 97 | __u8 reservedb0[30]; /* 0x00b0 */ | ||
| 98 | __u16 iprcc; /* 0x00ce */ | ||
| 99 | __u8 reservedd0[48]; /* 0x00d0 */ | ||
| 100 | __u64 gcr[16]; /* 0x0100 */ | ||
| 101 | __u64 gbea; /* 0x0180 */ | ||
| 102 | __u8 reserved188[120]; /* 0x0188 */ | ||
| 103 | } __attribute__((packed)); | ||
| 104 | |||
| 105 | struct kvm_vcpu_stat { | ||
| 106 | u32 exit_userspace; | ||
| 107 | u32 exit_external_request; | ||
| 108 | u32 exit_external_interrupt; | ||
| 109 | u32 exit_stop_request; | ||
| 110 | u32 exit_validity; | ||
| 111 | u32 exit_instruction; | ||
| 112 | u32 instruction_lctl; | ||
| 113 | u32 instruction_lctg; | ||
| 114 | u32 exit_program_interruption; | ||
| 115 | u32 exit_instr_and_program; | ||
| 116 | u32 deliver_emergency_signal; | ||
| 117 | u32 deliver_service_signal; | ||
| 118 | u32 deliver_virtio_interrupt; | ||
| 119 | u32 deliver_stop_signal; | ||
| 120 | u32 deliver_prefix_signal; | ||
| 121 | u32 deliver_restart_signal; | ||
| 122 | u32 deliver_program_int; | ||
| 123 | u32 exit_wait_state; | ||
| 124 | u32 instruction_stidp; | ||
| 125 | u32 instruction_spx; | ||
| 126 | u32 instruction_stpx; | ||
| 127 | u32 instruction_stap; | ||
| 128 | u32 instruction_storage_key; | ||
| 129 | u32 instruction_stsch; | ||
| 130 | u32 instruction_chsc; | ||
| 131 | u32 instruction_stsi; | ||
| 132 | u32 instruction_stfl; | ||
| 133 | u32 instruction_sigp_sense; | ||
| 134 | u32 instruction_sigp_emergency; | ||
| 135 | u32 instruction_sigp_stop; | ||
| 136 | u32 instruction_sigp_arch; | ||
| 137 | u32 instruction_sigp_prefix; | ||
| 138 | u32 instruction_sigp_restart; | ||
| 139 | u32 diagnose_44; | ||
| 140 | }; | ||
| 141 | |||
| 142 | struct io_info { | ||
| 143 | __u16 subchannel_id; /* 0x0b8 */ | ||
| 144 | __u16 subchannel_nr; /* 0x0ba */ | ||
| 145 | __u32 io_int_parm; /* 0x0bc */ | ||
| 146 | __u32 io_int_word; /* 0x0c0 */ | ||
| 147 | }; | ||
| 148 | |||
| 149 | struct ext_info { | ||
| 150 | __u32 ext_params; | ||
| 151 | __u64 ext_params2; | ||
| 152 | }; | ||
| 153 | |||
| 154 | #define PGM_OPERATION 0x01 | ||
| 155 | #define PGM_PRIVILEGED_OPERATION 0x02 | ||
| 156 | #define PGM_EXECUTE 0x03 | ||
| 157 | #define PGM_PROTECTION 0x04 | ||
| 158 | #define PGM_ADDRESSING 0x05 | ||
| 159 | #define PGM_SPECIFICATION 0x06 | ||
| 160 | #define PGM_DATA 0x07 | ||
| 161 | |||
| 162 | struct pgm_info { | ||
| 163 | __u16 code; | ||
| 164 | }; | ||
| 165 | |||
| 166 | struct prefix_info { | ||
| 167 | __u32 address; | ||
| 168 | }; | ||
| 169 | |||
| 170 | struct interrupt_info { | ||
| 171 | struct list_head list; | ||
| 172 | u64 type; | ||
| 173 | union { | ||
| 174 | struct io_info io; | ||
| 175 | struct ext_info ext; | ||
| 176 | struct pgm_info pgm; | ||
| 177 | struct prefix_info prefix; | ||
| 178 | }; | ||
| 179 | }; | ||
| 180 | |||
| 181 | /* for local_interrupt.action_flags */ | ||
| 182 | #define ACTION_STORE_ON_STOP 1 | ||
| 183 | #define ACTION_STOP_ON_STOP 2 | ||
| 184 | |||
| 185 | struct local_interrupt { | ||
| 186 | spinlock_t lock; | ||
| 187 | struct list_head list; | ||
| 188 | atomic_t active; | ||
| 189 | struct float_interrupt *float_int; | ||
| 190 | int timer_due; /* event indicator for waitqueue below */ | ||
| 191 | wait_queue_head_t wq; | ||
| 192 | atomic_t *cpuflags; | ||
| 193 | unsigned int action_bits; | ||
| 194 | }; | ||
| 195 | |||
| 196 | struct float_interrupt { | ||
| 197 | spinlock_t lock; | ||
| 198 | struct list_head list; | ||
| 199 | atomic_t active; | ||
| 200 | int next_rr_cpu; | ||
| 201 | unsigned long idle_mask [(64 + sizeof(long) - 1) / sizeof(long)]; | ||
| 202 | struct local_interrupt *local_int[64]; | ||
| 203 | }; | ||
| 204 | |||
| 205 | |||
| 206 | struct kvm_vcpu_arch { | ||
| 207 | struct sie_block *sie_block; | ||
| 208 | unsigned long guest_gprs[16]; | ||
| 209 | s390_fp_regs host_fpregs; | ||
| 210 | unsigned int host_acrs[NUM_ACRS]; | ||
| 211 | s390_fp_regs guest_fpregs; | ||
| 212 | unsigned int guest_acrs[NUM_ACRS]; | ||
| 213 | struct local_interrupt local_int; | ||
| 214 | struct timer_list ckc_timer; | ||
| 215 | union { | ||
| 216 | cpuid_t cpu_id; | ||
| 217 | u64 stidp_data; | ||
| 218 | }; | ||
| 219 | }; | ||
| 220 | |||
| 221 | struct kvm_vm_stat { | ||
| 222 | u32 remote_tlb_flush; | ||
| 223 | }; | ||
| 224 | |||
| 225 | struct kvm_arch{ | ||
| 226 | unsigned long guest_origin; | ||
| 227 | unsigned long guest_memsize; | ||
| 228 | struct sca_block *sca; | ||
| 229 | debug_info_t *dbf; | ||
| 230 | struct float_interrupt float_int; | ||
| 231 | }; | ||
| 232 | |||
| 233 | extern int sie64a(struct sie_block *, __u64 *); | ||
| 234 | #endif | ||
diff --git a/include/asm-s390/kvm_para.h b/include/asm-s390/kvm_para.h new file mode 100644 index 000000000000..2c503796b619 --- /dev/null +++ b/include/asm-s390/kvm_para.h | |||
| @@ -0,0 +1,150 @@ | |||
| 1 | /* | ||
| 2 | * asm-s390/kvm_para.h - definition for paravirtual devices on s390 | ||
| 3 | * | ||
| 4 | * Copyright IBM Corp. 2008 | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License (version 2 only) | ||
| 8 | * as published by the Free Software Foundation. | ||
| 9 | * | ||
| 10 | * Author(s): Christian Borntraeger <borntraeger@de.ibm.com> | ||
| 11 | */ | ||
| 12 | |||
| 13 | #ifndef __S390_KVM_PARA_H | ||
| 14 | #define __S390_KVM_PARA_H | ||
| 15 | |||
| 16 | /* | ||
| 17 | * Hypercalls for KVM on s390. The calling convention is similar to the | ||
| 18 | * s390 ABI, so we use R2-R6 for parameters 1-5. In addition we use R1 | ||
| 19 | * as hypercall number and R7 as parameter 6. The return value is | ||
| 20 | * written to R2. We use the diagnose instruction as hypercall. To avoid | ||
| 21 | * conflicts with existing diagnoses for LPAR and z/VM, we do not use | ||
| 22 | * the instruction encoded number, but specify the number in R1 and | ||
| 23 | * use 0x500 as KVM hypercall | ||
| 24 | * | ||
| 25 | * Copyright IBM Corp. 2007,2008 | ||
| 26 | * Author(s): Christian Borntraeger <borntraeger@de.ibm.com> | ||
| 27 | * | ||
| 28 | * This work is licensed under the terms of the GNU GPL, version 2. | ||
| 29 | */ | ||
| 30 | |||
| 31 | static inline long kvm_hypercall0(unsigned long nr) | ||
| 32 | { | ||
| 33 | register unsigned long __nr asm("1") = nr; | ||
| 34 | register long __rc asm("2"); | ||
| 35 | |||
| 36 | asm volatile ("diag 2,4,0x500\n" | ||
| 37 | : "=d" (__rc) : "d" (__nr): "memory", "cc"); | ||
| 38 | return __rc; | ||
| 39 | } | ||
| 40 | |||
| 41 | static inline long kvm_hypercall1(unsigned long nr, unsigned long p1) | ||
| 42 | { | ||
| 43 | register unsigned long __nr asm("1") = nr; | ||
| 44 | register unsigned long __p1 asm("2") = p1; | ||
| 45 | register long __rc asm("2"); | ||
| 46 | |||
| 47 | asm volatile ("diag 2,4,0x500\n" | ||
| 48 | : "=d" (__rc) : "d" (__nr), "0" (__p1) : "memory", "cc"); | ||
| 49 | return __rc; | ||
| 50 | } | ||
| 51 | |||
| 52 | static inline long kvm_hypercall2(unsigned long nr, unsigned long p1, | ||
| 53 | unsigned long p2) | ||
| 54 | { | ||
| 55 | register unsigned long __nr asm("1") = nr; | ||
| 56 | register unsigned long __p1 asm("2") = p1; | ||
| 57 | register unsigned long __p2 asm("3") = p2; | ||
| 58 | register long __rc asm("2"); | ||
| 59 | |||
| 60 | asm volatile ("diag 2,4,0x500\n" | ||
| 61 | : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2) | ||
| 62 | : "memory", "cc"); | ||
| 63 | return __rc; | ||
| 64 | } | ||
| 65 | |||
| 66 | static inline long kvm_hypercall3(unsigned long nr, unsigned long p1, | ||
| 67 | unsigned long p2, unsigned long p3) | ||
| 68 | { | ||
| 69 | register unsigned long __nr asm("1") = nr; | ||
| 70 | register unsigned long __p1 asm("2") = p1; | ||
| 71 | register unsigned long __p2 asm("3") = p2; | ||
| 72 | register unsigned long __p3 asm("4") = p3; | ||
| 73 | register long __rc asm("2"); | ||
| 74 | |||
| 75 | asm volatile ("diag 2,4,0x500\n" | ||
| 76 | : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2), | ||
| 77 | "d" (__p3) : "memory", "cc"); | ||
| 78 | return __rc; | ||
| 79 | } | ||
| 80 | |||
| 81 | |||
| 82 | static inline long kvm_hypercall4(unsigned long nr, unsigned long p1, | ||
| 83 | unsigned long p2, unsigned long p3, | ||
| 84 | unsigned long p4) | ||
| 85 | { | ||
| 86 | register unsigned long __nr asm("1") = nr; | ||
| 87 | register unsigned long __p1 asm("2") = p1; | ||
| 88 | register unsigned long __p2 asm("3") = p2; | ||
| 89 | register unsigned long __p3 asm("4") = p3; | ||
| 90 | register unsigned long __p4 asm("5") = p4; | ||
| 91 | register long __rc asm("2"); | ||
| 92 | |||
| 93 | asm volatile ("diag 2,4,0x500\n" | ||
| 94 | : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2), | ||
| 95 | "d" (__p3), "d" (__p4) : "memory", "cc"); | ||
| 96 | return __rc; | ||
| 97 | } | ||
| 98 | |||
| 99 | static inline long kvm_hypercall5(unsigned long nr, unsigned long p1, | ||
| 100 | unsigned long p2, unsigned long p3, | ||
| 101 | unsigned long p4, unsigned long p5) | ||
| 102 | { | ||
| 103 | register unsigned long __nr asm("1") = nr; | ||
| 104 | register unsigned long __p1 asm("2") = p1; | ||
| 105 | register unsigned long __p2 asm("3") = p2; | ||
| 106 | register unsigned long __p3 asm("4") = p3; | ||
| 107 | register unsigned long __p4 asm("5") = p4; | ||
| 108 | register unsigned long __p5 asm("6") = p5; | ||
| 109 | register long __rc asm("2"); | ||
| 110 | |||
| 111 | asm volatile ("diag 2,4,0x500\n" | ||
| 112 | : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2), | ||
| 113 | "d" (__p3), "d" (__p4), "d" (__p5) : "memory", "cc"); | ||
| 114 | return __rc; | ||
| 115 | } | ||
| 116 | |||
| 117 | static inline long kvm_hypercall6(unsigned long nr, unsigned long p1, | ||
| 118 | unsigned long p2, unsigned long p3, | ||
| 119 | unsigned long p4, unsigned long p5, | ||
| 120 | unsigned long p6) | ||
| 121 | { | ||
| 122 | register unsigned long __nr asm("1") = nr; | ||
| 123 | register unsigned long __p1 asm("2") = p1; | ||
| 124 | register unsigned long __p2 asm("3") = p2; | ||
| 125 | register unsigned long __p3 asm("4") = p3; | ||
| 126 | register unsigned long __p4 asm("5") = p4; | ||
| 127 | register unsigned long __p5 asm("6") = p5; | ||
| 128 | register unsigned long __p6 asm("7") = p6; | ||
| 129 | register long __rc asm("2"); | ||
| 130 | |||
| 131 | asm volatile ("diag 2,4,0x500\n" | ||
| 132 | : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2), | ||
| 133 | "d" (__p3), "d" (__p4), "d" (__p5), "d" (__p6) | ||
| 134 | : "memory", "cc"); | ||
| 135 | return __rc; | ||
| 136 | } | ||
| 137 | |||
| 138 | /* kvm on s390 is always paravirtualization enabled */ | ||
| 139 | static inline int kvm_para_available(void) | ||
| 140 | { | ||
| 141 | return 1; | ||
| 142 | } | ||
| 143 | |||
| 144 | /* No feature bits are currently assigned for kvm on s390 */ | ||
| 145 | static inline unsigned int kvm_arch_para_features(void) | ||
| 146 | { | ||
| 147 | return 0; | ||
| 148 | } | ||
| 149 | |||
| 150 | #endif /* __S390_KVM_PARA_H */ | ||
diff --git a/include/asm-s390/kvm_virtio.h b/include/asm-s390/kvm_virtio.h new file mode 100644 index 000000000000..5c871a990c29 --- /dev/null +++ b/include/asm-s390/kvm_virtio.h | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | /* | ||
| 2 | * kvm_virtio.h - definition for virtio for kvm on s390 | ||
| 3 | * | ||
| 4 | * Copyright IBM Corp. 2008 | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License (version 2 only) | ||
| 8 | * as published by the Free Software Foundation. | ||
| 9 | * | ||
| 10 | * Author(s): Christian Borntraeger <borntraeger@de.ibm.com> | ||
| 11 | */ | ||
| 12 | |||
| 13 | #ifndef __KVM_S390_VIRTIO_H | ||
| 14 | #define __KVM_S390_VIRTIO_H | ||
| 15 | |||
| 16 | #include <linux/types.h> | ||
| 17 | |||
| 18 | struct kvm_device_desc { | ||
| 19 | /* The device type: console, network, disk etc. Type 0 terminates. */ | ||
| 20 | __u8 type; | ||
| 21 | /* The number of virtqueues (first in config array) */ | ||
| 22 | __u8 num_vq; | ||
| 23 | /* | ||
| 24 | * The number of bytes of feature bits. Multiply by 2: one for host | ||
| 25 | * features and one for guest acknowledgements. | ||
| 26 | */ | ||
| 27 | __u8 feature_len; | ||
| 28 | /* The number of bytes of the config array after virtqueues. */ | ||
| 29 | __u8 config_len; | ||
| 30 | /* A status byte, written by the Guest. */ | ||
| 31 | __u8 status; | ||
| 32 | __u8 config[0]; | ||
| 33 | }; | ||
| 34 | |||
| 35 | /* | ||
| 36 | * This is how we expect the device configuration field for a virtqueue | ||
| 37 | * to be laid out in config space. | ||
| 38 | */ | ||
| 39 | struct kvm_vqconfig { | ||
| 40 | /* The token returned with an interrupt. Set by the guest */ | ||
| 41 | __u64 token; | ||
| 42 | /* The address of the virtio ring */ | ||
| 43 | __u64 address; | ||
| 44 | /* The number of entries in the virtio_ring */ | ||
| 45 | __u16 num; | ||
| 46 | |||
| 47 | }; | ||
| 48 | |||
| 49 | #define KVM_S390_VIRTIO_NOTIFY 0 | ||
| 50 | #define KVM_S390_VIRTIO_RESET 1 | ||
| 51 | #define KVM_S390_VIRTIO_SET_STATUS 2 | ||
| 52 | |||
| 53 | #endif | ||
diff --git a/include/asm-s390/lowcore.h b/include/asm-s390/lowcore.h index 5de3efb31445..0bc51d52a899 100644 --- a/include/asm-s390/lowcore.h +++ b/include/asm-s390/lowcore.h | |||
| @@ -381,27 +381,32 @@ struct _lowcore | |||
| 381 | /* whether the kernel died with panic() or not */ | 381 | /* whether the kernel died with panic() or not */ |
| 382 | __u32 panic_magic; /* 0xe00 */ | 382 | __u32 panic_magic; /* 0xe00 */ |
| 383 | 383 | ||
| 384 | __u8 pad13[0x1200-0xe04]; /* 0xe04 */ | 384 | __u8 pad13[0x11b8-0xe04]; /* 0xe04 */ |
| 385 | |||
| 386 | /* 64 bit extparam used for pfault, diag 250 etc */ | ||
| 387 | __u64 ext_params2; /* 0x11B8 */ | ||
| 388 | |||
| 389 | __u8 pad14[0x1200-0x11C0]; /* 0x11C0 */ | ||
| 385 | 390 | ||
| 386 | /* System info area */ | 391 | /* System info area */ |
| 387 | 392 | ||
| 388 | __u64 floating_pt_save_area[16]; /* 0x1200 */ | 393 | __u64 floating_pt_save_area[16]; /* 0x1200 */ |
| 389 | __u64 gpregs_save_area[16]; /* 0x1280 */ | 394 | __u64 gpregs_save_area[16]; /* 0x1280 */ |
| 390 | __u32 st_status_fixed_logout[4]; /* 0x1300 */ | 395 | __u32 st_status_fixed_logout[4]; /* 0x1300 */ |
| 391 | __u8 pad14[0x1318-0x1310]; /* 0x1310 */ | 396 | __u8 pad15[0x1318-0x1310]; /* 0x1310 */ |
| 392 | __u32 prefixreg_save_area; /* 0x1318 */ | 397 | __u32 prefixreg_save_area; /* 0x1318 */ |
| 393 | __u32 fpt_creg_save_area; /* 0x131c */ | 398 | __u32 fpt_creg_save_area; /* 0x131c */ |
| 394 | __u8 pad15[0x1324-0x1320]; /* 0x1320 */ | 399 | __u8 pad16[0x1324-0x1320]; /* 0x1320 */ |
| 395 | __u32 tod_progreg_save_area; /* 0x1324 */ | 400 | __u32 tod_progreg_save_area; /* 0x1324 */ |
| 396 | __u32 cpu_timer_save_area[2]; /* 0x1328 */ | 401 | __u32 cpu_timer_save_area[2]; /* 0x1328 */ |
| 397 | __u32 clock_comp_save_area[2]; /* 0x1330 */ | 402 | __u32 clock_comp_save_area[2]; /* 0x1330 */ |
| 398 | __u8 pad16[0x1340-0x1338]; /* 0x1338 */ | 403 | __u8 pad17[0x1340-0x1338]; /* 0x1338 */ |
| 399 | __u32 access_regs_save_area[16]; /* 0x1340 */ | 404 | __u32 access_regs_save_area[16]; /* 0x1340 */ |
| 400 | __u64 cregs_save_area[16]; /* 0x1380 */ | 405 | __u64 cregs_save_area[16]; /* 0x1380 */ |
| 401 | 406 | ||
| 402 | /* align to the top of the prefix area */ | 407 | /* align to the top of the prefix area */ |
| 403 | 408 | ||
| 404 | __u8 pad17[0x2000-0x1400]; /* 0x1400 */ | 409 | __u8 pad18[0x2000-0x1400]; /* 0x1400 */ |
| 405 | #endif /* !__s390x__ */ | 410 | #endif /* !__s390x__ */ |
| 406 | } __attribute__((packed)); /* End structure*/ | 411 | } __attribute__((packed)); /* End structure*/ |
| 407 | 412 | ||
diff --git a/include/asm-s390/mmu.h b/include/asm-s390/mmu.h index 1698e29c5b20..5dd5e7b3476f 100644 --- a/include/asm-s390/mmu.h +++ b/include/asm-s390/mmu.h | |||
| @@ -7,6 +7,7 @@ typedef struct { | |||
| 7 | unsigned long asce_bits; | 7 | unsigned long asce_bits; |
| 8 | unsigned long asce_limit; | 8 | unsigned long asce_limit; |
| 9 | int noexec; | 9 | int noexec; |
| 10 | int pgstes; | ||
| 10 | } mm_context_t; | 11 | } mm_context_t; |
| 11 | 12 | ||
| 12 | #endif | 13 | #endif |
diff --git a/include/asm-s390/mmu_context.h b/include/asm-s390/mmu_context.h index b5a34c6f91a9..4c2fbf48c9c4 100644 --- a/include/asm-s390/mmu_context.h +++ b/include/asm-s390/mmu_context.h | |||
| @@ -20,7 +20,13 @@ static inline int init_new_context(struct task_struct *tsk, | |||
| 20 | #ifdef CONFIG_64BIT | 20 | #ifdef CONFIG_64BIT |
| 21 | mm->context.asce_bits |= _ASCE_TYPE_REGION3; | 21 | mm->context.asce_bits |= _ASCE_TYPE_REGION3; |
| 22 | #endif | 22 | #endif |
| 23 | mm->context.noexec = s390_noexec; | 23 | if (current->mm->context.pgstes) { |
| 24 | mm->context.noexec = 0; | ||
| 25 | mm->context.pgstes = 1; | ||
| 26 | } else { | ||
| 27 | mm->context.noexec = s390_noexec; | ||
| 28 | mm->context.pgstes = 0; | ||
| 29 | } | ||
| 24 | mm->context.asce_limit = STACK_TOP_MAX; | 30 | mm->context.asce_limit = STACK_TOP_MAX; |
| 25 | crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm)); | 31 | crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm)); |
| 26 | return 0; | 32 | return 0; |
diff --git a/include/asm-s390/pgtable.h b/include/asm-s390/pgtable.h index 65154dc9a9e5..4c0698c0dda5 100644 --- a/include/asm-s390/pgtable.h +++ b/include/asm-s390/pgtable.h | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | */ | 30 | */ |
| 31 | #ifndef __ASSEMBLY__ | 31 | #ifndef __ASSEMBLY__ |
| 32 | #include <linux/mm_types.h> | 32 | #include <linux/mm_types.h> |
| 33 | #include <asm/bitops.h> | ||
| 33 | #include <asm/bug.h> | 34 | #include <asm/bug.h> |
| 34 | #include <asm/processor.h> | 35 | #include <asm/processor.h> |
| 35 | 36 | ||
| @@ -258,6 +259,13 @@ extern char empty_zero_page[PAGE_SIZE]; | |||
| 258 | * swap pte is 1011 and 0001, 0011, 0101, 0111 are invalid. | 259 | * swap pte is 1011 and 0001, 0011, 0101, 0111 are invalid. |
| 259 | */ | 260 | */ |
| 260 | 261 | ||
| 262 | /* Page status table bits for virtualization */ | ||
| 263 | #define RCP_PCL_BIT 55 | ||
| 264 | #define RCP_HR_BIT 54 | ||
| 265 | #define RCP_HC_BIT 53 | ||
| 266 | #define RCP_GR_BIT 50 | ||
| 267 | #define RCP_GC_BIT 49 | ||
| 268 | |||
| 261 | #ifndef __s390x__ | 269 | #ifndef __s390x__ |
| 262 | 270 | ||
| 263 | /* Bits in the segment table address-space-control-element */ | 271 | /* Bits in the segment table address-space-control-element */ |
| @@ -513,6 +521,48 @@ static inline int pte_file(pte_t pte) | |||
| 513 | #define __HAVE_ARCH_PTE_SAME | 521 | #define __HAVE_ARCH_PTE_SAME |
| 514 | #define pte_same(a,b) (pte_val(a) == pte_val(b)) | 522 | #define pte_same(a,b) (pte_val(a) == pte_val(b)) |
| 515 | 523 | ||
| 524 | static inline void rcp_lock(pte_t *ptep) | ||
| 525 | { | ||
| 526 | #ifdef CONFIG_PGSTE | ||
| 527 | unsigned long *pgste = (unsigned long *) (ptep + PTRS_PER_PTE); | ||
| 528 | preempt_disable(); | ||
| 529 | while (test_and_set_bit(RCP_PCL_BIT, pgste)) | ||
| 530 | ; | ||
| 531 | #endif | ||
| 532 | } | ||
| 533 | |||
| 534 | static inline void rcp_unlock(pte_t *ptep) | ||
| 535 | { | ||
| 536 | #ifdef CONFIG_PGSTE | ||
| 537 | unsigned long *pgste = (unsigned long *) (ptep + PTRS_PER_PTE); | ||
| 538 | clear_bit(RCP_PCL_BIT, pgste); | ||
| 539 | preempt_enable(); | ||
| 540 | #endif | ||
| 541 | } | ||
| 542 | |||
| 543 | /* forward declaration for SetPageUptodate in page-flags.h*/ | ||
| 544 | static inline void page_clear_dirty(struct page *page); | ||
| 545 | #include <linux/page-flags.h> | ||
| 546 | |||
| 547 | static inline void ptep_rcp_copy(pte_t *ptep) | ||
| 548 | { | ||
| 549 | #ifdef CONFIG_PGSTE | ||
| 550 | struct page *page = virt_to_page(pte_val(*ptep)); | ||
| 551 | unsigned int skey; | ||
| 552 | unsigned long *pgste = (unsigned long *) (ptep + PTRS_PER_PTE); | ||
| 553 | |||
| 554 | skey = page_get_storage_key(page_to_phys(page)); | ||
| 555 | if (skey & _PAGE_CHANGED) | ||
| 556 | set_bit_simple(RCP_GC_BIT, pgste); | ||
| 557 | if (skey & _PAGE_REFERENCED) | ||
| 558 | set_bit_simple(RCP_GR_BIT, pgste); | ||
| 559 | if (test_and_clear_bit_simple(RCP_HC_BIT, pgste)) | ||
| 560 | SetPageDirty(page); | ||
| 561 | if (test_and_clear_bit_simple(RCP_HR_BIT, pgste)) | ||
| 562 | SetPageReferenced(page); | ||
| 563 | #endif | ||
| 564 | } | ||
| 565 | |||
| 516 | /* | 566 | /* |
| 517 | * query functions pte_write/pte_dirty/pte_young only work if | 567 | * query functions pte_write/pte_dirty/pte_young only work if |
| 518 | * pte_present() is true. Undefined behaviour if not.. | 568 | * pte_present() is true. Undefined behaviour if not.. |
| @@ -599,6 +649,8 @@ static inline void pmd_clear(pmd_t *pmd) | |||
| 599 | 649 | ||
| 600 | static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) | 650 | static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) |
| 601 | { | 651 | { |
| 652 | if (mm->context.pgstes) | ||
| 653 | ptep_rcp_copy(ptep); | ||
| 602 | pte_val(*ptep) = _PAGE_TYPE_EMPTY; | 654 | pte_val(*ptep) = _PAGE_TYPE_EMPTY; |
| 603 | if (mm->context.noexec) | 655 | if (mm->context.noexec) |
| 604 | pte_val(ptep[PTRS_PER_PTE]) = _PAGE_TYPE_EMPTY; | 656 | pte_val(ptep[PTRS_PER_PTE]) = _PAGE_TYPE_EMPTY; |
| @@ -667,6 +719,24 @@ static inline pte_t pte_mkyoung(pte_t pte) | |||
| 667 | static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, | 719 | static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, |
| 668 | unsigned long addr, pte_t *ptep) | 720 | unsigned long addr, pte_t *ptep) |
| 669 | { | 721 | { |
| 722 | #ifdef CONFIG_PGSTE | ||
| 723 | unsigned long physpage; | ||
| 724 | int young; | ||
| 725 | unsigned long *pgste; | ||
| 726 | |||
| 727 | if (!vma->vm_mm->context.pgstes) | ||
| 728 | return 0; | ||
| 729 | physpage = pte_val(*ptep) & PAGE_MASK; | ||
| 730 | pgste = (unsigned long *) (ptep + PTRS_PER_PTE); | ||
| 731 | |||
| 732 | young = ((page_get_storage_key(physpage) & _PAGE_REFERENCED) != 0); | ||
| 733 | rcp_lock(ptep); | ||
| 734 | if (young) | ||
| 735 | set_bit_simple(RCP_GR_BIT, pgste); | ||
| 736 | young |= test_and_clear_bit_simple(RCP_HR_BIT, pgste); | ||
| 737 | rcp_unlock(ptep); | ||
| 738 | return young; | ||
| 739 | #endif | ||
| 670 | return 0; | 740 | return 0; |
| 671 | } | 741 | } |
| 672 | 742 | ||
| @@ -674,7 +744,13 @@ static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, | |||
| 674 | static inline int ptep_clear_flush_young(struct vm_area_struct *vma, | 744 | static inline int ptep_clear_flush_young(struct vm_area_struct *vma, |
| 675 | unsigned long address, pte_t *ptep) | 745 | unsigned long address, pte_t *ptep) |
| 676 | { | 746 | { |
| 677 | /* No need to flush TLB; bits are in storage key */ | 747 | /* No need to flush TLB |
| 748 | * On s390 reference bits are in storage key and never in TLB | ||
| 749 | * With virtualization we handle the reference bit, without we | ||
| 750 | * we can simply return */ | ||
| 751 | #ifdef CONFIG_PGSTE | ||
| 752 | return ptep_test_and_clear_young(vma, address, ptep); | ||
| 753 | #endif | ||
| 678 | return 0; | 754 | return 0; |
| 679 | } | 755 | } |
| 680 | 756 | ||
| @@ -693,15 +769,25 @@ static inline void __ptep_ipte(unsigned long address, pte_t *ptep) | |||
| 693 | : "=m" (*ptep) : "m" (*ptep), | 769 | : "=m" (*ptep) : "m" (*ptep), |
| 694 | "a" (pto), "a" (address)); | 770 | "a" (pto), "a" (address)); |
| 695 | } | 771 | } |
| 696 | pte_val(*ptep) = _PAGE_TYPE_EMPTY; | ||
| 697 | } | 772 | } |
| 698 | 773 | ||
| 699 | static inline void ptep_invalidate(struct mm_struct *mm, | 774 | static inline void ptep_invalidate(struct mm_struct *mm, |
| 700 | unsigned long address, pte_t *ptep) | 775 | unsigned long address, pte_t *ptep) |
| 701 | { | 776 | { |
| 777 | if (mm->context.pgstes) { | ||
| 778 | rcp_lock(ptep); | ||
| 779 | __ptep_ipte(address, ptep); | ||
| 780 | ptep_rcp_copy(ptep); | ||
| 781 | pte_val(*ptep) = _PAGE_TYPE_EMPTY; | ||
| 782 | rcp_unlock(ptep); | ||
| 783 | return; | ||
| 784 | } | ||
| 702 | __ptep_ipte(address, ptep); | 785 | __ptep_ipte(address, ptep); |
| 703 | if (mm->context.noexec) | 786 | pte_val(*ptep) = _PAGE_TYPE_EMPTY; |
| 787 | if (mm->context.noexec) { | ||
| 704 | __ptep_ipte(address, ptep + PTRS_PER_PTE); | 788 | __ptep_ipte(address, ptep + PTRS_PER_PTE); |
| 789 | pte_val(*(ptep + PTRS_PER_PTE)) = _PAGE_TYPE_EMPTY; | ||
| 790 | } | ||
| 705 | } | 791 | } |
| 706 | 792 | ||
| 707 | /* | 793 | /* |
| @@ -966,6 +1052,7 @@ static inline pte_t mk_swap_pte(unsigned long type, unsigned long offset) | |||
| 966 | 1052 | ||
| 967 | extern int add_shared_memory(unsigned long start, unsigned long size); | 1053 | extern int add_shared_memory(unsigned long start, unsigned long size); |
| 968 | extern int remove_shared_memory(unsigned long start, unsigned long size); | 1054 | extern int remove_shared_memory(unsigned long start, unsigned long size); |
| 1055 | extern int s390_enable_sie(void); | ||
| 969 | 1056 | ||
| 970 | /* | 1057 | /* |
| 971 | * No page table caches to initialise | 1058 | * No page table caches to initialise |
diff --git a/include/asm-s390/setup.h b/include/asm-s390/setup.h index a76a6b8fd887..aaf4b518b940 100644 --- a/include/asm-s390/setup.h +++ b/include/asm-s390/setup.h | |||
| @@ -62,6 +62,7 @@ extern unsigned long machine_flags; | |||
| 62 | #define MACHINE_IS_VM (machine_flags & 1) | 62 | #define MACHINE_IS_VM (machine_flags & 1) |
| 63 | #define MACHINE_IS_P390 (machine_flags & 4) | 63 | #define MACHINE_IS_P390 (machine_flags & 4) |
| 64 | #define MACHINE_HAS_MVPG (machine_flags & 16) | 64 | #define MACHINE_HAS_MVPG (machine_flags & 16) |
| 65 | #define MACHINE_IS_KVM (machine_flags & 64) | ||
| 65 | #define MACHINE_HAS_IDTE (machine_flags & 128) | 66 | #define MACHINE_HAS_IDTE (machine_flags & 128) |
| 66 | #define MACHINE_HAS_DIAG9C (machine_flags & 256) | 67 | #define MACHINE_HAS_DIAG9C (machine_flags & 256) |
| 67 | 68 | ||
diff --git a/include/asm-x86/kvm.h b/include/asm-x86/kvm.h index 7a71120426a3..80eefef2cc76 100644 --- a/include/asm-x86/kvm.h +++ b/include/asm-x86/kvm.h | |||
| @@ -188,4 +188,45 @@ struct kvm_cpuid2 { | |||
| 188 | struct kvm_cpuid_entry2 entries[0]; | 188 | struct kvm_cpuid_entry2 entries[0]; |
| 189 | }; | 189 | }; |
| 190 | 190 | ||
| 191 | /* for KVM_GET_PIT and KVM_SET_PIT */ | ||
| 192 | struct kvm_pit_channel_state { | ||
| 193 | __u32 count; /* can be 65536 */ | ||
| 194 | __u16 latched_count; | ||
| 195 | __u8 count_latched; | ||
| 196 | __u8 status_latched; | ||
| 197 | __u8 status; | ||
| 198 | __u8 read_state; | ||
| 199 | __u8 write_state; | ||
| 200 | __u8 write_latch; | ||
| 201 | __u8 rw_mode; | ||
| 202 | __u8 mode; | ||
| 203 | __u8 bcd; | ||
| 204 | __u8 gate; | ||
| 205 | __s64 count_load_time; | ||
| 206 | }; | ||
| 207 | |||
| 208 | struct kvm_pit_state { | ||
| 209 | struct kvm_pit_channel_state channels[3]; | ||
| 210 | }; | ||
| 211 | |||
| 212 | #define KVM_TRC_INJ_VIRQ (KVM_TRC_HANDLER + 0x02) | ||
| 213 | #define KVM_TRC_REDELIVER_EVT (KVM_TRC_HANDLER + 0x03) | ||
| 214 | #define KVM_TRC_PEND_INTR (KVM_TRC_HANDLER + 0x04) | ||
| 215 | #define KVM_TRC_IO_READ (KVM_TRC_HANDLER + 0x05) | ||
| 216 | #define KVM_TRC_IO_WRITE (KVM_TRC_HANDLER + 0x06) | ||
| 217 | #define KVM_TRC_CR_READ (KVM_TRC_HANDLER + 0x07) | ||
| 218 | #define KVM_TRC_CR_WRITE (KVM_TRC_HANDLER + 0x08) | ||
| 219 | #define KVM_TRC_DR_READ (KVM_TRC_HANDLER + 0x09) | ||
| 220 | #define KVM_TRC_DR_WRITE (KVM_TRC_HANDLER + 0x0A) | ||
| 221 | #define KVM_TRC_MSR_READ (KVM_TRC_HANDLER + 0x0B) | ||
| 222 | #define KVM_TRC_MSR_WRITE (KVM_TRC_HANDLER + 0x0C) | ||
| 223 | #define KVM_TRC_CPUID (KVM_TRC_HANDLER + 0x0D) | ||
| 224 | #define KVM_TRC_INTR (KVM_TRC_HANDLER + 0x0E) | ||
| 225 | #define KVM_TRC_NMI (KVM_TRC_HANDLER + 0x0F) | ||
| 226 | #define KVM_TRC_VMMCALL (KVM_TRC_HANDLER + 0x10) | ||
| 227 | #define KVM_TRC_HLT (KVM_TRC_HANDLER + 0x11) | ||
| 228 | #define KVM_TRC_CLTS (KVM_TRC_HANDLER + 0x12) | ||
| 229 | #define KVM_TRC_LMSW (KVM_TRC_HANDLER + 0x13) | ||
| 230 | #define KVM_TRC_APIC_ACCESS (KVM_TRC_HANDLER + 0x14) | ||
| 231 | |||
| 191 | #endif | 232 | #endif |
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h index 68ee390b2844..9d963cd6533c 100644 --- a/include/asm-x86/kvm_host.h +++ b/include/asm-x86/kvm_host.h | |||
| @@ -20,6 +20,13 @@ | |||
| 20 | 20 | ||
| 21 | #include <asm/desc.h> | 21 | #include <asm/desc.h> |
| 22 | 22 | ||
| 23 | #define KVM_MAX_VCPUS 16 | ||
| 24 | #define KVM_MEMORY_SLOTS 32 | ||
| 25 | /* memory slots that does not exposed to userspace */ | ||
| 26 | #define KVM_PRIVATE_MEM_SLOTS 4 | ||
| 27 | |||
| 28 | #define KVM_PIO_PAGE_OFFSET 1 | ||
| 29 | |||
| 23 | #define CR3_PAE_RESERVED_BITS ((X86_CR3_PWT | X86_CR3_PCD) - 1) | 30 | #define CR3_PAE_RESERVED_BITS ((X86_CR3_PWT | X86_CR3_PCD) - 1) |
| 24 | #define CR3_NONPAE_RESERVED_BITS ((PAGE_SIZE-1) & ~(X86_CR3_PWT | X86_CR3_PCD)) | 31 | #define CR3_NONPAE_RESERVED_BITS ((PAGE_SIZE-1) & ~(X86_CR3_PWT | X86_CR3_PCD)) |
| 25 | #define CR3_L_MODE_RESERVED_BITS (CR3_NONPAE_RESERVED_BITS | \ | 32 | #define CR3_L_MODE_RESERVED_BITS (CR3_NONPAE_RESERVED_BITS | \ |
| @@ -39,6 +46,13 @@ | |||
| 39 | #define INVALID_PAGE (~(hpa_t)0) | 46 | #define INVALID_PAGE (~(hpa_t)0) |
| 40 | #define UNMAPPED_GVA (~(gpa_t)0) | 47 | #define UNMAPPED_GVA (~(gpa_t)0) |
| 41 | 48 | ||
| 49 | /* shadow tables are PAE even on non-PAE hosts */ | ||
| 50 | #define KVM_HPAGE_SHIFT 21 | ||
| 51 | #define KVM_HPAGE_SIZE (1UL << KVM_HPAGE_SHIFT) | ||
| 52 | #define KVM_HPAGE_MASK (~(KVM_HPAGE_SIZE - 1)) | ||
| 53 | |||
| 54 | #define KVM_PAGES_PER_HPAGE (KVM_HPAGE_SIZE / PAGE_SIZE) | ||
| 55 | |||
| 42 | #define DE_VECTOR 0 | 56 | #define DE_VECTOR 0 |
| 43 | #define UD_VECTOR 6 | 57 | #define UD_VECTOR 6 |
| 44 | #define NM_VECTOR 7 | 58 | #define NM_VECTOR 7 |
| @@ -48,6 +62,7 @@ | |||
| 48 | #define SS_VECTOR 12 | 62 | #define SS_VECTOR 12 |
| 49 | #define GP_VECTOR 13 | 63 | #define GP_VECTOR 13 |
| 50 | #define PF_VECTOR 14 | 64 | #define PF_VECTOR 14 |
| 65 | #define MC_VECTOR 18 | ||
| 51 | 66 | ||
| 52 | #define SELECTOR_TI_MASK (1 << 2) | 67 | #define SELECTOR_TI_MASK (1 << 2) |
| 53 | #define SELECTOR_RPL_MASK 0x03 | 68 | #define SELECTOR_RPL_MASK 0x03 |
| @@ -58,7 +73,8 @@ | |||
| 58 | 73 | ||
| 59 | #define KVM_PERMILLE_MMU_PAGES 20 | 74 | #define KVM_PERMILLE_MMU_PAGES 20 |
| 60 | #define KVM_MIN_ALLOC_MMU_PAGES 64 | 75 | #define KVM_MIN_ALLOC_MMU_PAGES 64 |
| 61 | #define KVM_NUM_MMU_PAGES 1024 | 76 | #define KVM_MMU_HASH_SHIFT 10 |
| 77 | #define KVM_NUM_MMU_PAGES (1 << KVM_MMU_HASH_SHIFT) | ||
| 62 | #define KVM_MIN_FREE_MMU_PAGES 5 | 78 | #define KVM_MIN_FREE_MMU_PAGES 5 |
| 63 | #define KVM_REFILL_PAGES 25 | 79 | #define KVM_REFILL_PAGES 25 |
| 64 | #define KVM_MAX_CPUID_ENTRIES 40 | 80 | #define KVM_MAX_CPUID_ENTRIES 40 |
| @@ -106,6 +122,12 @@ enum { | |||
| 106 | 122 | ||
| 107 | #define KVM_NR_MEM_OBJS 40 | 123 | #define KVM_NR_MEM_OBJS 40 |
| 108 | 124 | ||
| 125 | struct kvm_guest_debug { | ||
| 126 | int enabled; | ||
| 127 | unsigned long bp[4]; | ||
| 128 | int singlestep; | ||
| 129 | }; | ||
| 130 | |||
| 109 | /* | 131 | /* |
| 110 | * We don't want allocation failures within the mmu code, so we preallocate | 132 | * We don't want allocation failures within the mmu code, so we preallocate |
| 111 | * enough memory for a single page fault in a cache. | 133 | * enough memory for a single page fault in a cache. |
| @@ -140,6 +162,7 @@ union kvm_mmu_page_role { | |||
| 140 | unsigned pad_for_nice_hex_output:6; | 162 | unsigned pad_for_nice_hex_output:6; |
| 141 | unsigned metaphysical:1; | 163 | unsigned metaphysical:1; |
| 142 | unsigned access:3; | 164 | unsigned access:3; |
| 165 | unsigned invalid:1; | ||
| 143 | }; | 166 | }; |
| 144 | }; | 167 | }; |
| 145 | 168 | ||
| @@ -204,11 +227,6 @@ struct kvm_vcpu_arch { | |||
| 204 | u64 shadow_efer; | 227 | u64 shadow_efer; |
| 205 | u64 apic_base; | 228 | u64 apic_base; |
| 206 | struct kvm_lapic *apic; /* kernel irqchip context */ | 229 | struct kvm_lapic *apic; /* kernel irqchip context */ |
| 207 | #define VCPU_MP_STATE_RUNNABLE 0 | ||
| 208 | #define VCPU_MP_STATE_UNINITIALIZED 1 | ||
| 209 | #define VCPU_MP_STATE_INIT_RECEIVED 2 | ||
| 210 | #define VCPU_MP_STATE_SIPI_RECEIVED 3 | ||
| 211 | #define VCPU_MP_STATE_HALTED 4 | ||
| 212 | int mp_state; | 230 | int mp_state; |
| 213 | int sipi_vector; | 231 | int sipi_vector; |
| 214 | u64 ia32_misc_enable_msr; | 232 | u64 ia32_misc_enable_msr; |
| @@ -226,8 +244,9 @@ struct kvm_vcpu_arch { | |||
| 226 | u64 *last_pte_updated; | 244 | u64 *last_pte_updated; |
| 227 | 245 | ||
| 228 | struct { | 246 | struct { |
| 229 | gfn_t gfn; /* presumed gfn during guest pte update */ | 247 | gfn_t gfn; /* presumed gfn during guest pte update */ |
| 230 | struct page *page; /* page corresponding to that gfn */ | 248 | pfn_t pfn; /* pfn corresponding to that gfn */ |
| 249 | int largepage; | ||
| 231 | } update_pte; | 250 | } update_pte; |
| 232 | 251 | ||
| 233 | struct i387_fxsave_struct host_fx_image; | 252 | struct i387_fxsave_struct host_fx_image; |
| @@ -261,6 +280,11 @@ struct kvm_vcpu_arch { | |||
| 261 | /* emulate context */ | 280 | /* emulate context */ |
| 262 | 281 | ||
| 263 | struct x86_emulate_ctxt emulate_ctxt; | 282 | struct x86_emulate_ctxt emulate_ctxt; |
| 283 | |||
| 284 | gpa_t time; | ||
| 285 | struct kvm_vcpu_time_info hv_clock; | ||
| 286 | unsigned int time_offset; | ||
| 287 | struct page *time_page; | ||
| 264 | }; | 288 | }; |
| 265 | 289 | ||
| 266 | struct kvm_mem_alias { | 290 | struct kvm_mem_alias { |
| @@ -283,10 +307,13 @@ struct kvm_arch{ | |||
| 283 | struct list_head active_mmu_pages; | 307 | struct list_head active_mmu_pages; |
| 284 | struct kvm_pic *vpic; | 308 | struct kvm_pic *vpic; |
| 285 | struct kvm_ioapic *vioapic; | 309 | struct kvm_ioapic *vioapic; |
| 310 | struct kvm_pit *vpit; | ||
| 286 | 311 | ||
| 287 | int round_robin_prev_vcpu; | 312 | int round_robin_prev_vcpu; |
| 288 | unsigned int tss_addr; | 313 | unsigned int tss_addr; |
| 289 | struct page *apic_access_page; | 314 | struct page *apic_access_page; |
| 315 | |||
| 316 | gpa_t wall_clock; | ||
| 290 | }; | 317 | }; |
| 291 | 318 | ||
| 292 | struct kvm_vm_stat { | 319 | struct kvm_vm_stat { |
| @@ -298,6 +325,7 @@ struct kvm_vm_stat { | |||
| 298 | u32 mmu_recycled; | 325 | u32 mmu_recycled; |
| 299 | u32 mmu_cache_miss; | 326 | u32 mmu_cache_miss; |
| 300 | u32 remote_tlb_flush; | 327 | u32 remote_tlb_flush; |
| 328 | u32 lpages; | ||
| 301 | }; | 329 | }; |
| 302 | 330 | ||
| 303 | struct kvm_vcpu_stat { | 331 | struct kvm_vcpu_stat { |
| @@ -320,6 +348,7 @@ struct kvm_vcpu_stat { | |||
| 320 | u32 fpu_reload; | 348 | u32 fpu_reload; |
| 321 | u32 insn_emulation; | 349 | u32 insn_emulation; |
| 322 | u32 insn_emulation_fail; | 350 | u32 insn_emulation_fail; |
| 351 | u32 hypercalls; | ||
| 323 | }; | 352 | }; |
| 324 | 353 | ||
| 325 | struct descriptor_table { | 354 | struct descriptor_table { |
| @@ -355,6 +384,7 @@ struct kvm_x86_ops { | |||
| 355 | u64 (*get_segment_base)(struct kvm_vcpu *vcpu, int seg); | 384 | u64 (*get_segment_base)(struct kvm_vcpu *vcpu, int seg); |
| 356 | void (*get_segment)(struct kvm_vcpu *vcpu, | 385 | void (*get_segment)(struct kvm_vcpu *vcpu, |
| 357 | struct kvm_segment *var, int seg); | 386 | struct kvm_segment *var, int seg); |
| 387 | int (*get_cpl)(struct kvm_vcpu *vcpu); | ||
| 358 | void (*set_segment)(struct kvm_vcpu *vcpu, | 388 | void (*set_segment)(struct kvm_vcpu *vcpu, |
| 359 | struct kvm_segment *var, int seg); | 389 | struct kvm_segment *var, int seg); |
| 360 | void (*get_cs_db_l_bits)(struct kvm_vcpu *vcpu, int *db, int *l); | 390 | void (*get_cs_db_l_bits)(struct kvm_vcpu *vcpu, int *db, int *l); |
| @@ -410,6 +440,15 @@ void kvm_mmu_zap_all(struct kvm *kvm); | |||
| 410 | unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm); | 440 | unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm); |
| 411 | void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages); | 441 | void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages); |
| 412 | 442 | ||
| 443 | int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3); | ||
| 444 | |||
| 445 | int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa, | ||
| 446 | const void *val, int bytes); | ||
| 447 | int kvm_pv_mmu_op(struct kvm_vcpu *vcpu, unsigned long bytes, | ||
| 448 | gpa_t addr, unsigned long *ret); | ||
| 449 | |||
| 450 | extern bool tdp_enabled; | ||
| 451 | |||
| 413 | enum emulation_result { | 452 | enum emulation_result { |
| 414 | EMULATE_DONE, /* no further processing */ | 453 | EMULATE_DONE, /* no further processing */ |
| 415 | EMULATE_DO_MMIO, /* kvm_run filled with mmio request */ | 454 | EMULATE_DO_MMIO, /* kvm_run filled with mmio request */ |
| @@ -429,6 +468,7 @@ void realmode_lmsw(struct kvm_vcpu *vcpu, unsigned long msw, | |||
| 429 | unsigned long realmode_get_cr(struct kvm_vcpu *vcpu, int cr); | 468 | unsigned long realmode_get_cr(struct kvm_vcpu *vcpu, int cr); |
| 430 | void realmode_set_cr(struct kvm_vcpu *vcpu, int cr, unsigned long value, | 469 | void realmode_set_cr(struct kvm_vcpu *vcpu, int cr, unsigned long value, |
| 431 | unsigned long *rflags); | 470 | unsigned long *rflags); |
| 471 | void kvm_enable_efer_bits(u64); | ||
| 432 | int kvm_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *data); | 472 | int kvm_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *data); |
| 433 | int kvm_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data); | 473 | int kvm_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data); |
| 434 | 474 | ||
| @@ -448,12 +488,14 @@ int emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr, | |||
| 448 | int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, | 488 | int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, |
| 449 | unsigned long value); | 489 | unsigned long value); |
| 450 | 490 | ||
| 451 | void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0); | 491 | int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason); |
| 452 | void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr0); | 492 | |
| 453 | void set_cr4(struct kvm_vcpu *vcpu, unsigned long cr0); | 493 | void kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0); |
| 454 | void set_cr8(struct kvm_vcpu *vcpu, unsigned long cr0); | 494 | void kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3); |
| 455 | unsigned long get_cr8(struct kvm_vcpu *vcpu); | 495 | void kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4); |
| 456 | void lmsw(struct kvm_vcpu *vcpu, unsigned long msw); | 496 | void kvm_set_cr8(struct kvm_vcpu *vcpu, unsigned long cr8); |
| 497 | unsigned long kvm_get_cr8(struct kvm_vcpu *vcpu); | ||
| 498 | void kvm_lmsw(struct kvm_vcpu *vcpu, unsigned long msw); | ||
| 457 | void kvm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l); | 499 | void kvm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l); |
| 458 | 500 | ||
| 459 | int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata); | 501 | int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata); |
| @@ -491,6 +533,8 @@ int kvm_fix_hypercall(struct kvm_vcpu *vcpu); | |||
| 491 | 533 | ||
| 492 | int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code); | 534 | int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code); |
| 493 | 535 | ||
| 536 | void kvm_enable_tdp(void); | ||
| 537 | |||
| 494 | int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3); | 538 | int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3); |
| 495 | int complete_pio(struct kvm_vcpu *vcpu); | 539 | int complete_pio(struct kvm_vcpu *vcpu); |
| 496 | 540 | ||
| @@ -600,6 +644,7 @@ static inline void kvm_inject_gp(struct kvm_vcpu *vcpu, u32 error_code) | |||
| 600 | #define ASM_VMX_VMWRITE_RSP_RDX ".byte 0x0f, 0x79, 0xd4" | 644 | #define ASM_VMX_VMWRITE_RSP_RDX ".byte 0x0f, 0x79, 0xd4" |
| 601 | #define ASM_VMX_VMXOFF ".byte 0x0f, 0x01, 0xc4" | 645 | #define ASM_VMX_VMXOFF ".byte 0x0f, 0x01, 0xc4" |
| 602 | #define ASM_VMX_VMXON_RAX ".byte 0xf3, 0x0f, 0xc7, 0x30" | 646 | #define ASM_VMX_VMXON_RAX ".byte 0xf3, 0x0f, 0xc7, 0x30" |
| 647 | #define ASM_VMX_INVVPID ".byte 0x66, 0x0f, 0x38, 0x81, 0x08" | ||
| 603 | 648 | ||
| 604 | #define MSR_IA32_TIME_STAMP_COUNTER 0x010 | 649 | #define MSR_IA32_TIME_STAMP_COUNTER 0x010 |
| 605 | 650 | ||
| @@ -610,4 +655,30 @@ static inline void kvm_inject_gp(struct kvm_vcpu *vcpu, u32 error_code) | |||
| 610 | #define RMODE_TSS_SIZE \ | 655 | #define RMODE_TSS_SIZE \ |
| 611 | (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1) | 656 | (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1) |
| 612 | 657 | ||
| 658 | enum { | ||
| 659 | TASK_SWITCH_CALL = 0, | ||
| 660 | TASK_SWITCH_IRET = 1, | ||
| 661 | TASK_SWITCH_JMP = 2, | ||
| 662 | TASK_SWITCH_GATE = 3, | ||
| 663 | }; | ||
| 664 | |||
| 665 | #define KVMTRACE_5D(evt, vcpu, d1, d2, d3, d4, d5, name) \ | ||
| 666 | trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ | ||
| 667 | vcpu, 5, d1, d2, d3, d4, d5) | ||
| 668 | #define KVMTRACE_4D(evt, vcpu, d1, d2, d3, d4, name) \ | ||
| 669 | trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ | ||
| 670 | vcpu, 4, d1, d2, d3, d4, 0) | ||
| 671 | #define KVMTRACE_3D(evt, vcpu, d1, d2, d3, name) \ | ||
| 672 | trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ | ||
| 673 | vcpu, 3, d1, d2, d3, 0, 0) | ||
| 674 | #define KVMTRACE_2D(evt, vcpu, d1, d2, name) \ | ||
| 675 | trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ | ||
| 676 | vcpu, 2, d1, d2, 0, 0, 0) | ||
| 677 | #define KVMTRACE_1D(evt, vcpu, d1, name) \ | ||
| 678 | trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ | ||
| 679 | vcpu, 1, d1, 0, 0, 0, 0) | ||
| 680 | #define KVMTRACE_0D(evt, vcpu, name) \ | ||
| 681 | trace_mark(kvm_trace_##name, "%u %p %u %u %u %u %u %u", KVM_TRC_##evt, \ | ||
| 682 | vcpu, 0, 0, 0, 0, 0, 0) | ||
| 683 | |||
| 613 | #endif | 684 | #endif |
diff --git a/include/asm-x86/kvm_para.h b/include/asm-x86/kvm_para.h index c6f3fd8d8c53..509845942070 100644 --- a/include/asm-x86/kvm_para.h +++ b/include/asm-x86/kvm_para.h | |||
| @@ -10,10 +10,65 @@ | |||
| 10 | * paravirtualization, the appropriate feature bit should be checked. | 10 | * paravirtualization, the appropriate feature bit should be checked. |
| 11 | */ | 11 | */ |
| 12 | #define KVM_CPUID_FEATURES 0x40000001 | 12 | #define KVM_CPUID_FEATURES 0x40000001 |
| 13 | #define KVM_FEATURE_CLOCKSOURCE 0 | ||
| 14 | #define KVM_FEATURE_NOP_IO_DELAY 1 | ||
| 15 | #define KVM_FEATURE_MMU_OP 2 | ||
| 16 | |||
| 17 | #define MSR_KVM_WALL_CLOCK 0x11 | ||
| 18 | #define MSR_KVM_SYSTEM_TIME 0x12 | ||
| 19 | |||
| 20 | #define KVM_MAX_MMU_OP_BATCH 32 | ||
| 21 | |||
| 22 | /* Operations for KVM_HC_MMU_OP */ | ||
| 23 | #define KVM_MMU_OP_WRITE_PTE 1 | ||
| 24 | #define KVM_MMU_OP_FLUSH_TLB 2 | ||
| 25 | #define KVM_MMU_OP_RELEASE_PT 3 | ||
| 26 | |||
| 27 | /* Payload for KVM_HC_MMU_OP */ | ||
| 28 | struct kvm_mmu_op_header { | ||
| 29 | __u32 op; | ||
| 30 | __u32 pad; | ||
| 31 | }; | ||
| 32 | |||
| 33 | struct kvm_mmu_op_write_pte { | ||
| 34 | struct kvm_mmu_op_header header; | ||
| 35 | __u64 pte_phys; | ||
| 36 | __u64 pte_val; | ||
| 37 | }; | ||
| 38 | |||
| 39 | struct kvm_mmu_op_flush_tlb { | ||
| 40 | struct kvm_mmu_op_header header; | ||
| 41 | }; | ||
| 42 | |||
| 43 | struct kvm_mmu_op_release_pt { | ||
| 44 | struct kvm_mmu_op_header header; | ||
| 45 | __u64 pt_phys; | ||
| 46 | }; | ||
| 13 | 47 | ||
| 14 | #ifdef __KERNEL__ | 48 | #ifdef __KERNEL__ |
| 15 | #include <asm/processor.h> | 49 | #include <asm/processor.h> |
| 16 | 50 | ||
| 51 | /* xen binary-compatible interface. See xen headers for details */ | ||
| 52 | struct kvm_vcpu_time_info { | ||
| 53 | uint32_t version; | ||
| 54 | uint32_t pad0; | ||
| 55 | uint64_t tsc_timestamp; | ||
| 56 | uint64_t system_time; | ||
| 57 | uint32_t tsc_to_system_mul; | ||
| 58 | int8_t tsc_shift; | ||
| 59 | int8_t pad[3]; | ||
| 60 | } __attribute__((__packed__)); /* 32 bytes */ | ||
| 61 | |||
| 62 | struct kvm_wall_clock { | ||
| 63 | uint32_t wc_version; | ||
| 64 | uint32_t wc_sec; | ||
| 65 | uint32_t wc_nsec; | ||
| 66 | } __attribute__((__packed__)); | ||
| 67 | |||
| 68 | |||
| 69 | extern void kvmclock_init(void); | ||
| 70 | |||
| 71 | |||
| 17 | /* This instruction is vmcall. On non-VT architectures, it will generate a | 72 | /* This instruction is vmcall. On non-VT architectures, it will generate a |
| 18 | * trap that we will then rewrite to the appropriate instruction. | 73 | * trap that we will then rewrite to the appropriate instruction. |
| 19 | */ | 74 | */ |
diff --git a/include/asm-x86/reboot.h b/include/asm-x86/reboot.h index 6b5233b4f84b..e63741f19392 100644 --- a/include/asm-x86/reboot.h +++ b/include/asm-x86/reboot.h | |||
| @@ -15,5 +15,7 @@ struct machine_ops { | |||
| 15 | extern struct machine_ops machine_ops; | 15 | extern struct machine_ops machine_ops; |
| 16 | 16 | ||
| 17 | void machine_real_restart(unsigned char *code, int length); | 17 | void machine_real_restart(unsigned char *code, int length); |
| 18 | void native_machine_crash_shutdown(struct pt_regs *regs); | ||
| 19 | void native_machine_shutdown(void); | ||
| 18 | 20 | ||
| 19 | #endif /* _ASM_REBOOT_H */ | 21 | #endif /* _ASM_REBOOT_H */ |
diff --git a/include/linux/kvm.h b/include/linux/kvm.h index c1ec04fd000d..a281afeddfbb 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h | |||
| @@ -8,11 +8,18 @@ | |||
| 8 | */ | 8 | */ |
| 9 | 9 | ||
| 10 | #include <asm/types.h> | 10 | #include <asm/types.h> |
| 11 | #include <linux/compiler.h> | ||
| 11 | #include <linux/ioctl.h> | 12 | #include <linux/ioctl.h> |
| 12 | #include <asm/kvm.h> | 13 | #include <asm/kvm.h> |
| 13 | 14 | ||
| 14 | #define KVM_API_VERSION 12 | 15 | #define KVM_API_VERSION 12 |
| 15 | 16 | ||
| 17 | /* for KVM_TRACE_ENABLE */ | ||
| 18 | struct kvm_user_trace_setup { | ||
| 19 | __u32 buf_size; /* sub_buffer size of each per-cpu */ | ||
| 20 | __u32 buf_nr; /* the number of sub_buffers of each per-cpu */ | ||
| 21 | }; | ||
| 22 | |||
| 16 | /* for KVM_CREATE_MEMORY_REGION */ | 23 | /* for KVM_CREATE_MEMORY_REGION */ |
| 17 | struct kvm_memory_region { | 24 | struct kvm_memory_region { |
| 18 | __u32 slot; | 25 | __u32 slot; |
| @@ -73,6 +80,9 @@ struct kvm_irqchip { | |||
| 73 | #define KVM_EXIT_INTR 10 | 80 | #define KVM_EXIT_INTR 10 |
| 74 | #define KVM_EXIT_SET_TPR 11 | 81 | #define KVM_EXIT_SET_TPR 11 |
| 75 | #define KVM_EXIT_TPR_ACCESS 12 | 82 | #define KVM_EXIT_TPR_ACCESS 12 |
| 83 | #define KVM_EXIT_S390_SIEIC 13 | ||
| 84 | #define KVM_EXIT_S390_RESET 14 | ||
| 85 | #define KVM_EXIT_DCR 15 | ||
| 76 | 86 | ||
| 77 | /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ | 87 | /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ |
| 78 | struct kvm_run { | 88 | struct kvm_run { |
| @@ -137,6 +147,27 @@ struct kvm_run { | |||
| 137 | __u32 is_write; | 147 | __u32 is_write; |
| 138 | __u32 pad; | 148 | __u32 pad; |
| 139 | } tpr_access; | 149 | } tpr_access; |
| 150 | /* KVM_EXIT_S390_SIEIC */ | ||
| 151 | struct { | ||
| 152 | __u8 icptcode; | ||
| 153 | __u64 mask; /* psw upper half */ | ||
| 154 | __u64 addr; /* psw lower half */ | ||
| 155 | __u16 ipa; | ||
| 156 | __u32 ipb; | ||
| 157 | } s390_sieic; | ||
| 158 | /* KVM_EXIT_S390_RESET */ | ||
| 159 | #define KVM_S390_RESET_POR 1 | ||
| 160 | #define KVM_S390_RESET_CLEAR 2 | ||
| 161 | #define KVM_S390_RESET_SUBSYSTEM 4 | ||
| 162 | #define KVM_S390_RESET_CPU_INIT 8 | ||
| 163 | #define KVM_S390_RESET_IPL 16 | ||
| 164 | __u64 s390_reset_flags; | ||
| 165 | /* KVM_EXIT_DCR */ | ||
| 166 | struct { | ||
| 167 | __u32 dcrn; | ||
| 168 | __u32 data; | ||
| 169 | __u8 is_write; | ||
| 170 | } dcr; | ||
| 140 | /* Fix the size of the union. */ | 171 | /* Fix the size of the union. */ |
| 141 | char padding[256]; | 172 | char padding[256]; |
| 142 | }; | 173 | }; |
| @@ -204,6 +235,74 @@ struct kvm_vapic_addr { | |||
| 204 | __u64 vapic_addr; | 235 | __u64 vapic_addr; |
| 205 | }; | 236 | }; |
| 206 | 237 | ||
| 238 | /* for KVM_SET_MPSTATE */ | ||
| 239 | |||
| 240 | #define KVM_MP_STATE_RUNNABLE 0 | ||
| 241 | #define KVM_MP_STATE_UNINITIALIZED 1 | ||
| 242 | #define KVM_MP_STATE_INIT_RECEIVED 2 | ||
| 243 | #define KVM_MP_STATE_HALTED 3 | ||
| 244 | #define KVM_MP_STATE_SIPI_RECEIVED 4 | ||
| 245 | |||
| 246 | struct kvm_mp_state { | ||
| 247 | __u32 mp_state; | ||
| 248 | }; | ||
| 249 | |||
| 250 | struct kvm_s390_psw { | ||
| 251 | __u64 mask; | ||
| 252 | __u64 addr; | ||
| 253 | }; | ||
| 254 | |||
| 255 | /* valid values for type in kvm_s390_interrupt */ | ||
| 256 | #define KVM_S390_SIGP_STOP 0xfffe0000u | ||
| 257 | #define KVM_S390_PROGRAM_INT 0xfffe0001u | ||
| 258 | #define KVM_S390_SIGP_SET_PREFIX 0xfffe0002u | ||
| 259 | #define KVM_S390_RESTART 0xfffe0003u | ||
| 260 | #define KVM_S390_INT_VIRTIO 0xffff2603u | ||
| 261 | #define KVM_S390_INT_SERVICE 0xffff2401u | ||
| 262 | #define KVM_S390_INT_EMERGENCY 0xffff1201u | ||
| 263 | |||
| 264 | struct kvm_s390_interrupt { | ||
| 265 | __u32 type; | ||
| 266 | __u32 parm; | ||
| 267 | __u64 parm64; | ||
| 268 | }; | ||
| 269 | |||
| 270 | #define KVM_TRC_SHIFT 16 | ||
| 271 | /* | ||
| 272 | * kvm trace categories | ||
| 273 | */ | ||
| 274 | #define KVM_TRC_ENTRYEXIT (1 << KVM_TRC_SHIFT) | ||
| 275 | #define KVM_TRC_HANDLER (1 << (KVM_TRC_SHIFT + 1)) /* only 12 bits */ | ||
| 276 | |||
| 277 | /* | ||
| 278 | * kvm trace action | ||
| 279 | */ | ||
| 280 | #define KVM_TRC_VMENTRY (KVM_TRC_ENTRYEXIT + 0x01) | ||
| 281 | #define KVM_TRC_VMEXIT (KVM_TRC_ENTRYEXIT + 0x02) | ||
| 282 | #define KVM_TRC_PAGE_FAULT (KVM_TRC_HANDLER + 0x01) | ||
| 283 | |||
| 284 | #define KVM_TRC_HEAD_SIZE 12 | ||
| 285 | #define KVM_TRC_CYCLE_SIZE 8 | ||
| 286 | #define KVM_TRC_EXTRA_MAX 7 | ||
| 287 | |||
| 288 | /* This structure represents a single trace buffer record. */ | ||
| 289 | struct kvm_trace_rec { | ||
| 290 | __u32 event:28; | ||
| 291 | __u32 extra_u32:3; | ||
| 292 | __u32 cycle_in:1; | ||
| 293 | __u32 pid; | ||
| 294 | __u32 vcpu_id; | ||
| 295 | union { | ||
| 296 | struct { | ||
| 297 | __u32 cycle_lo, cycle_hi; | ||
| 298 | __u32 extra_u32[KVM_TRC_EXTRA_MAX]; | ||
| 299 | } cycle; | ||
| 300 | struct { | ||
| 301 | __u32 extra_u32[KVM_TRC_EXTRA_MAX]; | ||
| 302 | } nocycle; | ||
| 303 | } u; | ||
| 304 | }; | ||
| 305 | |||
| 207 | #define KVMIO 0xAE | 306 | #define KVMIO 0xAE |
| 208 | 307 | ||
| 209 | /* | 308 | /* |
| @@ -212,6 +311,8 @@ struct kvm_vapic_addr { | |||
| 212 | #define KVM_GET_API_VERSION _IO(KVMIO, 0x00) | 311 | #define KVM_GET_API_VERSION _IO(KVMIO, 0x00) |
| 213 | #define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */ | 312 | #define KVM_CREATE_VM _IO(KVMIO, 0x01) /* returns a VM fd */ |
| 214 | #define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list) | 313 | #define KVM_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0x02, struct kvm_msr_list) |
| 314 | |||
| 315 | #define KVM_S390_ENABLE_SIE _IO(KVMIO, 0x06) | ||
| 215 | /* | 316 | /* |
| 216 | * Check if a kvm extension is available. Argument is extension number, | 317 | * Check if a kvm extension is available. Argument is extension number, |
| 217 | * return is 1 (yes) or 0 (no, sorry). | 318 | * return is 1 (yes) or 0 (no, sorry). |
| @@ -222,7 +323,12 @@ struct kvm_vapic_addr { | |||
| 222 | */ | 323 | */ |
| 223 | #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ | 324 | #define KVM_GET_VCPU_MMAP_SIZE _IO(KVMIO, 0x04) /* in bytes */ |
| 224 | #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2) | 325 | #define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x05, struct kvm_cpuid2) |
| 225 | 326 | /* | |
| 327 | * ioctls for kvm trace | ||
| 328 | */ | ||
| 329 | #define KVM_TRACE_ENABLE _IOW(KVMIO, 0x06, struct kvm_user_trace_setup) | ||
| 330 | #define KVM_TRACE_PAUSE _IO(KVMIO, 0x07) | ||
| 331 | #define KVM_TRACE_DISABLE _IO(KVMIO, 0x08) | ||
| 226 | /* | 332 | /* |
| 227 | * Extension capability list. | 333 | * Extension capability list. |
| 228 | */ | 334 | */ |
| @@ -233,6 +339,13 @@ struct kvm_vapic_addr { | |||
| 233 | #define KVM_CAP_SET_TSS_ADDR 4 | 339 | #define KVM_CAP_SET_TSS_ADDR 4 |
| 234 | #define KVM_CAP_VAPIC 6 | 340 | #define KVM_CAP_VAPIC 6 |
| 235 | #define KVM_CAP_EXT_CPUID 7 | 341 | #define KVM_CAP_EXT_CPUID 7 |
| 342 | #define KVM_CAP_CLOCKSOURCE 8 | ||
| 343 | #define KVM_CAP_NR_VCPUS 9 /* returns max vcpus per vm */ | ||
| 344 | #define KVM_CAP_NR_MEMSLOTS 10 /* returns max memory slots per vm */ | ||
| 345 | #define KVM_CAP_PIT 11 | ||
| 346 | #define KVM_CAP_NOP_IO_DELAY 12 | ||
| 347 | #define KVM_CAP_PV_MMU 13 | ||
| 348 | #define KVM_CAP_MP_STATE 14 | ||
| 236 | 349 | ||
| 237 | /* | 350 | /* |
| 238 | * ioctls for VM fds | 351 | * ioctls for VM fds |
| @@ -255,6 +368,9 @@ struct kvm_vapic_addr { | |||
| 255 | #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) | 368 | #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) |
| 256 | #define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip) | 369 | #define KVM_GET_IRQCHIP _IOWR(KVMIO, 0x62, struct kvm_irqchip) |
| 257 | #define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip) | 370 | #define KVM_SET_IRQCHIP _IOR(KVMIO, 0x63, struct kvm_irqchip) |
| 371 | #define KVM_CREATE_PIT _IO(KVMIO, 0x64) | ||
| 372 | #define KVM_GET_PIT _IOWR(KVMIO, 0x65, struct kvm_pit_state) | ||
| 373 | #define KVM_SET_PIT _IOR(KVMIO, 0x66, struct kvm_pit_state) | ||
| 258 | 374 | ||
| 259 | /* | 375 | /* |
| 260 | * ioctls for vcpu fds | 376 | * ioctls for vcpu fds |
| @@ -281,5 +397,17 @@ struct kvm_vapic_addr { | |||
| 281 | #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl) | 397 | #define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl) |
| 282 | /* Available with KVM_CAP_VAPIC */ | 398 | /* Available with KVM_CAP_VAPIC */ |
| 283 | #define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr) | 399 | #define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr) |
| 400 | /* valid for virtual machine (for floating interrupt)_and_ vcpu */ | ||
| 401 | #define KVM_S390_INTERRUPT _IOW(KVMIO, 0x94, struct kvm_s390_interrupt) | ||
| 402 | /* store status for s390 */ | ||
| 403 | #define KVM_S390_STORE_STATUS_NOADDR (-1ul) | ||
| 404 | #define KVM_S390_STORE_STATUS_PREFIXED (-2ul) | ||
| 405 | #define KVM_S390_STORE_STATUS _IOW(KVMIO, 0x95, unsigned long) | ||
| 406 | /* initial ipl psw for s390 */ | ||
| 407 | #define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw) | ||
| 408 | /* initial reset for s390 */ | ||
| 409 | #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97) | ||
| 410 | #define KVM_GET_MP_STATE _IOR(KVMIO, 0x98, struct kvm_mp_state) | ||
| 411 | #define KVM_SET_MP_STATE _IOW(KVMIO, 0x99, struct kvm_mp_state) | ||
| 284 | 412 | ||
| 285 | #endif | 413 | #endif |
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 928b0d59e9ba..398978972b7a 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
| 16 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
| 17 | #include <linux/preempt.h> | 17 | #include <linux/preempt.h> |
| 18 | #include <linux/marker.h> | ||
| 18 | #include <asm/signal.h> | 19 | #include <asm/signal.h> |
| 19 | 20 | ||
| 20 | #include <linux/kvm.h> | 21 | #include <linux/kvm.h> |
| @@ -24,29 +25,18 @@ | |||
| 24 | 25 | ||
| 25 | #include <asm/kvm_host.h> | 26 | #include <asm/kvm_host.h> |
| 26 | 27 | ||
| 27 | #define KVM_MAX_VCPUS 4 | ||
| 28 | #define KVM_MEMORY_SLOTS 8 | ||
| 29 | /* memory slots that does not exposed to userspace */ | ||
| 30 | #define KVM_PRIVATE_MEM_SLOTS 4 | ||
| 31 | |||
| 32 | #define KVM_PIO_PAGE_OFFSET 1 | ||
| 33 | |||
| 34 | /* | 28 | /* |
| 35 | * vcpu->requests bit members | 29 | * vcpu->requests bit members |
| 36 | */ | 30 | */ |
| 37 | #define KVM_REQ_TLB_FLUSH 0 | 31 | #define KVM_REQ_TLB_FLUSH 0 |
| 38 | #define KVM_REQ_MIGRATE_TIMER 1 | 32 | #define KVM_REQ_MIGRATE_TIMER 1 |
| 39 | #define KVM_REQ_REPORT_TPR_ACCESS 2 | 33 | #define KVM_REQ_REPORT_TPR_ACCESS 2 |
| 34 | #define KVM_REQ_MMU_RELOAD 3 | ||
| 35 | #define KVM_REQ_TRIPLE_FAULT 4 | ||
| 40 | 36 | ||
| 41 | struct kvm_vcpu; | 37 | struct kvm_vcpu; |
| 42 | extern struct kmem_cache *kvm_vcpu_cache; | 38 | extern struct kmem_cache *kvm_vcpu_cache; |
| 43 | 39 | ||
| 44 | struct kvm_guest_debug { | ||
| 45 | int enabled; | ||
| 46 | unsigned long bp[4]; | ||
| 47 | int singlestep; | ||
| 48 | }; | ||
| 49 | |||
| 50 | /* | 40 | /* |
| 51 | * It would be nice to use something smarter than a linear search, TBD... | 41 | * It would be nice to use something smarter than a linear search, TBD... |
| 52 | * Thankfully we dont expect many devices to register (famous last words :), | 42 | * Thankfully we dont expect many devices to register (famous last words :), |
| @@ -67,7 +57,9 @@ void kvm_io_bus_register_dev(struct kvm_io_bus *bus, | |||
| 67 | 57 | ||
| 68 | struct kvm_vcpu { | 58 | struct kvm_vcpu { |
| 69 | struct kvm *kvm; | 59 | struct kvm *kvm; |
| 60 | #ifdef CONFIG_PREEMPT_NOTIFIERS | ||
| 70 | struct preempt_notifier preempt_notifier; | 61 | struct preempt_notifier preempt_notifier; |
| 62 | #endif | ||
| 71 | int vcpu_id; | 63 | int vcpu_id; |
| 72 | struct mutex mutex; | 64 | struct mutex mutex; |
| 73 | int cpu; | 65 | int cpu; |
| @@ -100,6 +92,10 @@ struct kvm_memory_slot { | |||
| 100 | unsigned long flags; | 92 | unsigned long flags; |
| 101 | unsigned long *rmap; | 93 | unsigned long *rmap; |
| 102 | unsigned long *dirty_bitmap; | 94 | unsigned long *dirty_bitmap; |
| 95 | struct { | ||
| 96 | unsigned long rmap_pde; | ||
| 97 | int write_count; | ||
| 98 | } *lpage_info; | ||
| 103 | unsigned long userspace_addr; | 99 | unsigned long userspace_addr; |
| 104 | int user_alloc; | 100 | int user_alloc; |
| 105 | }; | 101 | }; |
| @@ -114,11 +110,11 @@ struct kvm { | |||
| 114 | KVM_PRIVATE_MEM_SLOTS]; | 110 | KVM_PRIVATE_MEM_SLOTS]; |
| 115 | struct kvm_vcpu *vcpus[KVM_MAX_VCPUS]; | 111 | struct kvm_vcpu *vcpus[KVM_MAX_VCPUS]; |
| 116 | struct list_head vm_list; | 112 | struct list_head vm_list; |
| 117 | struct file *filp; | ||
| 118 | struct kvm_io_bus mmio_bus; | 113 | struct kvm_io_bus mmio_bus; |
| 119 | struct kvm_io_bus pio_bus; | 114 | struct kvm_io_bus pio_bus; |
| 120 | struct kvm_vm_stat stat; | 115 | struct kvm_vm_stat stat; |
| 121 | struct kvm_arch arch; | 116 | struct kvm_arch arch; |
| 117 | atomic_t users_count; | ||
| 122 | }; | 118 | }; |
| 123 | 119 | ||
| 124 | /* The guest did something we don't support. */ | 120 | /* The guest did something we don't support. */ |
| @@ -145,14 +141,19 @@ int kvm_init(void *opaque, unsigned int vcpu_size, | |||
| 145 | struct module *module); | 141 | struct module *module); |
| 146 | void kvm_exit(void); | 142 | void kvm_exit(void); |
| 147 | 143 | ||
| 144 | void kvm_get_kvm(struct kvm *kvm); | ||
| 145 | void kvm_put_kvm(struct kvm *kvm); | ||
| 146 | |||
| 148 | #define HPA_MSB ((sizeof(hpa_t) * 8) - 1) | 147 | #define HPA_MSB ((sizeof(hpa_t) * 8) - 1) |
| 149 | #define HPA_ERR_MASK ((hpa_t)1 << HPA_MSB) | 148 | #define HPA_ERR_MASK ((hpa_t)1 << HPA_MSB) |
| 150 | static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; } | 149 | static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; } |
| 151 | struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva); | 150 | struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva); |
| 152 | 151 | ||
| 153 | extern struct page *bad_page; | 152 | extern struct page *bad_page; |
| 153 | extern pfn_t bad_pfn; | ||
| 154 | 154 | ||
| 155 | int is_error_page(struct page *page); | 155 | int is_error_page(struct page *page); |
| 156 | int is_error_pfn(pfn_t pfn); | ||
| 156 | int kvm_is_error_hva(unsigned long addr); | 157 | int kvm_is_error_hva(unsigned long addr); |
| 157 | int kvm_set_memory_region(struct kvm *kvm, | 158 | int kvm_set_memory_region(struct kvm *kvm, |
| 158 | struct kvm_userspace_memory_region *mem, | 159 | struct kvm_userspace_memory_region *mem, |
| @@ -166,8 +167,19 @@ int kvm_arch_set_memory_region(struct kvm *kvm, | |||
| 166 | int user_alloc); | 167 | int user_alloc); |
| 167 | gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn); | 168 | gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn); |
| 168 | struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); | 169 | struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); |
| 170 | unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn); | ||
| 169 | void kvm_release_page_clean(struct page *page); | 171 | void kvm_release_page_clean(struct page *page); |
| 170 | void kvm_release_page_dirty(struct page *page); | 172 | void kvm_release_page_dirty(struct page *page); |
| 173 | void kvm_set_page_dirty(struct page *page); | ||
| 174 | void kvm_set_page_accessed(struct page *page); | ||
| 175 | |||
| 176 | pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn); | ||
| 177 | void kvm_release_pfn_dirty(pfn_t); | ||
| 178 | void kvm_release_pfn_clean(pfn_t pfn); | ||
| 179 | void kvm_set_pfn_dirty(pfn_t pfn); | ||
| 180 | void kvm_set_pfn_accessed(pfn_t pfn); | ||
| 181 | void kvm_get_pfn(pfn_t pfn); | ||
| 182 | |||
| 171 | int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset, | 183 | int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset, |
| 172 | int len); | 184 | int len); |
| 173 | int kvm_read_guest_atomic(struct kvm *kvm, gpa_t gpa, void *data, | 185 | int kvm_read_guest_atomic(struct kvm *kvm, gpa_t gpa, void *data, |
| @@ -188,6 +200,7 @@ void kvm_resched(struct kvm_vcpu *vcpu); | |||
| 188 | void kvm_load_guest_fpu(struct kvm_vcpu *vcpu); | 200 | void kvm_load_guest_fpu(struct kvm_vcpu *vcpu); |
| 189 | void kvm_put_guest_fpu(struct kvm_vcpu *vcpu); | 201 | void kvm_put_guest_fpu(struct kvm_vcpu *vcpu); |
| 190 | void kvm_flush_remote_tlbs(struct kvm *kvm); | 202 | void kvm_flush_remote_tlbs(struct kvm *kvm); |
| 203 | void kvm_reload_remote_mmus(struct kvm *kvm); | ||
| 191 | 204 | ||
| 192 | long kvm_arch_dev_ioctl(struct file *filp, | 205 | long kvm_arch_dev_ioctl(struct file *filp, |
| 193 | unsigned int ioctl, unsigned long arg); | 206 | unsigned int ioctl, unsigned long arg); |
| @@ -223,6 +236,10 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, | |||
| 223 | struct kvm_sregs *sregs); | 236 | struct kvm_sregs *sregs); |
| 224 | int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, | 237 | int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, |
| 225 | struct kvm_sregs *sregs); | 238 | struct kvm_sregs *sregs); |
| 239 | int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, | ||
| 240 | struct kvm_mp_state *mp_state); | ||
| 241 | int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, | ||
| 242 | struct kvm_mp_state *mp_state); | ||
| 226 | int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu, | 243 | int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu, |
| 227 | struct kvm_debug_guest *dbg); | 244 | struct kvm_debug_guest *dbg); |
| 228 | int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run); | 245 | int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run); |
| @@ -255,6 +272,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm); | |||
| 255 | 272 | ||
| 256 | int kvm_cpu_get_interrupt(struct kvm_vcpu *v); | 273 | int kvm_cpu_get_interrupt(struct kvm_vcpu *v); |
| 257 | int kvm_cpu_has_interrupt(struct kvm_vcpu *v); | 274 | int kvm_cpu_has_interrupt(struct kvm_vcpu *v); |
| 275 | int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu); | ||
| 258 | void kvm_vcpu_kick(struct kvm_vcpu *vcpu); | 276 | void kvm_vcpu_kick(struct kvm_vcpu *vcpu); |
| 259 | 277 | ||
| 260 | static inline void kvm_guest_enter(void) | 278 | static inline void kvm_guest_enter(void) |
| @@ -296,5 +314,18 @@ struct kvm_stats_debugfs_item { | |||
| 296 | struct dentry *dentry; | 314 | struct dentry *dentry; |
| 297 | }; | 315 | }; |
| 298 | extern struct kvm_stats_debugfs_item debugfs_entries[]; | 316 | extern struct kvm_stats_debugfs_item debugfs_entries[]; |
| 317 | extern struct dentry *kvm_debugfs_dir; | ||
| 318 | |||
| 319 | #ifdef CONFIG_KVM_TRACE | ||
| 320 | int kvm_trace_ioctl(unsigned int ioctl, unsigned long arg); | ||
| 321 | void kvm_trace_cleanup(void); | ||
| 322 | #else | ||
| 323 | static inline | ||
| 324 | int kvm_trace_ioctl(unsigned int ioctl, unsigned long arg) | ||
| 325 | { | ||
| 326 | return -EINVAL; | ||
| 327 | } | ||
| 328 | #define kvm_trace_cleanup() ((void)0) | ||
| 329 | #endif | ||
| 299 | 330 | ||
| 300 | #endif | 331 | #endif |
diff --git a/include/linux/kvm_para.h b/include/linux/kvm_para.h index 5497aac0d2f8..3ddce03766ca 100644 --- a/include/linux/kvm_para.h +++ b/include/linux/kvm_para.h | |||
| @@ -11,8 +11,11 @@ | |||
| 11 | 11 | ||
| 12 | /* Return values for hypercalls */ | 12 | /* Return values for hypercalls */ |
| 13 | #define KVM_ENOSYS 1000 | 13 | #define KVM_ENOSYS 1000 |
| 14 | #define KVM_EFAULT EFAULT | ||
| 15 | #define KVM_E2BIG E2BIG | ||
| 14 | 16 | ||
| 15 | #define KVM_HC_VAPIC_POLL_IRQ 1 | 17 | #define KVM_HC_VAPIC_POLL_IRQ 1 |
| 18 | #define KVM_HC_MMU_OP 2 | ||
| 16 | 19 | ||
| 17 | /* | 20 | /* |
| 18 | * hypercalls use architecture specific | 21 | * hypercalls use architecture specific |
| @@ -20,6 +23,12 @@ | |||
| 20 | #include <asm/kvm_para.h> | 23 | #include <asm/kvm_para.h> |
| 21 | 24 | ||
| 22 | #ifdef __KERNEL__ | 25 | #ifdef __KERNEL__ |
| 26 | #ifdef CONFIG_KVM_GUEST | ||
| 27 | void __init kvm_guest_init(void); | ||
| 28 | #else | ||
| 29 | #define kvm_guest_init() do { } while (0) | ||
| 30 | #endif | ||
| 31 | |||
| 23 | static inline int kvm_para_has_feature(unsigned int feature) | 32 | static inline int kvm_para_has_feature(unsigned int feature) |
| 24 | { | 33 | { |
| 25 | if (kvm_arch_para_features() & (1UL << feature)) | 34 | if (kvm_arch_para_features() & (1UL << feature)) |
diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h index 1c4e46decb22..9b6f395c9625 100644 --- a/include/linux/kvm_types.h +++ b/include/linux/kvm_types.h | |||
| @@ -38,6 +38,8 @@ typedef unsigned long hva_t; | |||
| 38 | typedef u64 hpa_t; | 38 | typedef u64 hpa_t; |
| 39 | typedef unsigned long hfn_t; | 39 | typedef unsigned long hfn_t; |
| 40 | 40 | ||
| 41 | typedef hfn_t pfn_t; | ||
| 42 | |||
| 41 | struct kvm_pio_request { | 43 | struct kvm_pio_request { |
| 42 | unsigned long count; | 44 | unsigned long count; |
| 43 | int cur_count; | 45 | int cur_count; |
diff --git a/include/linux/sched.h b/include/linux/sched.h index d0bd97044abd..9a4f3e63e3bf 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -1798,6 +1798,8 @@ extern void mmput(struct mm_struct *); | |||
| 1798 | extern struct mm_struct *get_task_mm(struct task_struct *task); | 1798 | extern struct mm_struct *get_task_mm(struct task_struct *task); |
| 1799 | /* Remove the current tasks stale references to the old mm_struct */ | 1799 | /* Remove the current tasks stale references to the old mm_struct */ |
| 1800 | extern void mm_release(struct task_struct *, struct mm_struct *); | 1800 | extern void mm_release(struct task_struct *, struct mm_struct *); |
| 1801 | /* Allocate a new mm structure and copy contents from tsk->mm */ | ||
| 1802 | extern struct mm_struct *dup_mm(struct task_struct *tsk); | ||
| 1801 | 1803 | ||
| 1802 | extern int copy_thread(int, unsigned long, unsigned long, unsigned long, struct task_struct *, struct pt_regs *); | 1804 | extern int copy_thread(int, unsigned long, unsigned long, unsigned long, struct task_struct *, struct pt_regs *); |
| 1803 | extern void flush_thread(void); | 1805 | extern void flush_thread(void); |
