Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 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 | |
Laurent Vivier | 588968b | 2008-05-30 16:05:56 +0200 | [diff] [blame] | 34 | #define KVM_COALESCED_MMIO_PAGE_OFFSET 1 |
| 35 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 36 | /* We don't currently support large pages. */ |
| 37 | #define KVM_PAGES_PER_HPAGE (1<<31) |
| 38 | |
| 39 | struct kvm; |
| 40 | struct kvm_run; |
| 41 | struct kvm_vcpu; |
| 42 | |
| 43 | struct kvm_vm_stat { |
| 44 | u32 remote_tlb_flush; |
| 45 | }; |
| 46 | |
| 47 | struct kvm_vcpu_stat { |
| 48 | u32 sum_exits; |
| 49 | u32 mmio_exits; |
| 50 | u32 dcr_exits; |
| 51 | u32 signal_exits; |
| 52 | u32 light_exits; |
| 53 | /* Account for special types of light exits: */ |
| 54 | u32 itlb_real_miss_exits; |
| 55 | u32 itlb_virt_miss_exits; |
| 56 | u32 dtlb_real_miss_exits; |
| 57 | u32 dtlb_virt_miss_exits; |
| 58 | u32 syscall_exits; |
| 59 | u32 isi_exits; |
| 60 | u32 dsi_exits; |
| 61 | u32 emulated_inst_exits; |
| 62 | u32 dec_exits; |
| 63 | u32 ext_intr_exits; |
Hollis Blanchard | 45c5eb6 | 2008-04-25 17:55:49 -0500 | [diff] [blame] | 64 | u32 halt_wakeup; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 65 | }; |
| 66 | |
Hollis Blanchard | 0f55dc4 | 2008-11-05 09:36:12 -0600 | [diff] [blame] | 67 | struct kvmppc_44x_tlbe { |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 68 | u32 tid; /* Only the low 8 bits are used. */ |
| 69 | u32 word0; |
| 70 | u32 word1; |
| 71 | u32 word2; |
| 72 | }; |
| 73 | |
Hollis Blanchard | 73e75b4 | 2008-12-02 15:51:57 -0600 | [diff] [blame] | 74 | enum kvm_exit_types { |
| 75 | MMIO_EXITS, |
| 76 | DCR_EXITS, |
| 77 | SIGNAL_EXITS, |
| 78 | ITLB_REAL_MISS_EXITS, |
| 79 | ITLB_VIRT_MISS_EXITS, |
| 80 | DTLB_REAL_MISS_EXITS, |
| 81 | DTLB_VIRT_MISS_EXITS, |
| 82 | SYSCALL_EXITS, |
| 83 | ISI_EXITS, |
| 84 | DSI_EXITS, |
| 85 | EMULATED_INST_EXITS, |
| 86 | EMULATED_MTMSRWE_EXITS, |
| 87 | EMULATED_WRTEE_EXITS, |
| 88 | EMULATED_MTSPR_EXITS, |
| 89 | EMULATED_MFSPR_EXITS, |
| 90 | EMULATED_MTMSR_EXITS, |
| 91 | EMULATED_MFMSR_EXITS, |
| 92 | EMULATED_TLBSX_EXITS, |
| 93 | EMULATED_TLBWE_EXITS, |
| 94 | EMULATED_RFI_EXITS, |
| 95 | DEC_EXITS, |
| 96 | EXT_INTR_EXITS, |
| 97 | HALT_WAKEUP, |
| 98 | USR_PR_INST, |
| 99 | FP_UNAVAIL, |
| 100 | DEBUG_EXITS, |
| 101 | TIMEINGUEST, |
| 102 | __NUMBER_OF_KVM_EXIT_TYPES |
| 103 | }; |
| 104 | |
Hollis Blanchard | 73e75b4 | 2008-12-02 15:51:57 -0600 | [diff] [blame] | 105 | /* allow access to big endian 32bit upper/lower parts and 64bit var */ |
Hollis Blanchard | 7b70159 | 2008-12-02 15:51:58 -0600 | [diff] [blame^] | 106 | struct kvmppc_exit_timing { |
Hollis Blanchard | 73e75b4 | 2008-12-02 15:51:57 -0600 | [diff] [blame] | 107 | union { |
| 108 | u64 tv64; |
| 109 | struct { |
| 110 | u32 tbu, tbl; |
| 111 | } tv32; |
| 112 | }; |
| 113 | }; |
Hollis Blanchard | 73e75b4 | 2008-12-02 15:51:57 -0600 | [diff] [blame] | 114 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 115 | struct kvm_arch { |
| 116 | }; |
| 117 | |
| 118 | struct kvm_vcpu_arch { |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 119 | u32 host_stack; |
| 120 | u32 host_pid; |
Hollis Blanchard | 6a0ab73 | 2008-07-25 13:54:49 -0500 | [diff] [blame] | 121 | u32 host_dbcr0; |
| 122 | u32 host_dbcr1; |
| 123 | u32 host_dbcr2; |
| 124 | u32 host_iac[4]; |
| 125 | u32 host_msr; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 126 | |
| 127 | u64 fpr[32]; |
Hollis Blanchard | 5cf8ca2 | 2008-11-05 09:36:19 -0600 | [diff] [blame] | 128 | ulong gpr[32]; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 129 | |
Hollis Blanchard | 5cf8ca2 | 2008-11-05 09:36:19 -0600 | [diff] [blame] | 130 | ulong pc; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 131 | u32 cr; |
Hollis Blanchard | 5cf8ca2 | 2008-11-05 09:36:19 -0600 | [diff] [blame] | 132 | ulong ctr; |
| 133 | ulong lr; |
| 134 | ulong xer; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 135 | |
Hollis Blanchard | 5cf8ca2 | 2008-11-05 09:36:19 -0600 | [diff] [blame] | 136 | ulong msr; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 137 | u32 mmucr; |
Hollis Blanchard | 5cf8ca2 | 2008-11-05 09:36:19 -0600 | [diff] [blame] | 138 | ulong sprg0; |
| 139 | ulong sprg1; |
| 140 | ulong sprg2; |
| 141 | ulong sprg3; |
| 142 | ulong sprg4; |
| 143 | ulong sprg5; |
| 144 | ulong sprg6; |
| 145 | ulong sprg7; |
| 146 | ulong srr0; |
| 147 | ulong srr1; |
| 148 | ulong csrr0; |
| 149 | ulong csrr1; |
| 150 | ulong dsrr0; |
| 151 | ulong dsrr1; |
| 152 | ulong dear; |
| 153 | ulong esr; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 154 | u32 dec; |
| 155 | u32 decar; |
| 156 | u32 tbl; |
| 157 | u32 tbu; |
| 158 | u32 tcr; |
| 159 | u32 tsr; |
| 160 | u32 ivor[16]; |
Hollis Blanchard | 5cf8ca2 | 2008-11-05 09:36:19 -0600 | [diff] [blame] | 161 | ulong ivpr; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 162 | u32 pir; |
Hollis Blanchard | 49dd2c4 | 2008-07-25 13:54:53 -0500 | [diff] [blame] | 163 | |
| 164 | u32 shadow_pid; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 165 | u32 pid; |
Hollis Blanchard | 49dd2c4 | 2008-07-25 13:54:53 -0500 | [diff] [blame] | 166 | u32 swap_pid; |
| 167 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 168 | u32 pvr; |
| 169 | u32 ccr0; |
| 170 | u32 ccr1; |
| 171 | u32 dbcr0; |
| 172 | u32 dbcr1; |
| 173 | |
Hollis Blanchard | 73e75b4 | 2008-12-02 15:51:57 -0600 | [diff] [blame] | 174 | #ifdef CONFIG_KVM_EXIT_TIMING |
Hollis Blanchard | 7b70159 | 2008-12-02 15:51:58 -0600 | [diff] [blame^] | 175 | struct kvmppc_exit_timing timing_exit; |
| 176 | struct kvmppc_exit_timing timing_last_enter; |
Hollis Blanchard | 73e75b4 | 2008-12-02 15:51:57 -0600 | [diff] [blame] | 177 | u32 last_exit_type; |
| 178 | u32 timing_count_type[__NUMBER_OF_KVM_EXIT_TYPES]; |
| 179 | u64 timing_sum_duration[__NUMBER_OF_KVM_EXIT_TYPES]; |
| 180 | u64 timing_sum_quad_duration[__NUMBER_OF_KVM_EXIT_TYPES]; |
| 181 | u64 timing_min_duration[__NUMBER_OF_KVM_EXIT_TYPES]; |
| 182 | u64 timing_max_duration[__NUMBER_OF_KVM_EXIT_TYPES]; |
| 183 | u64 timing_last_exit; |
| 184 | struct dentry *debugfs_exit_timing; |
| 185 | #endif |
| 186 | |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 187 | u32 last_inst; |
Hollis Blanchard | 5cf8ca2 | 2008-11-05 09:36:19 -0600 | [diff] [blame] | 188 | ulong fault_dear; |
| 189 | ulong fault_esr; |
Hollis Blanchard | bbf45ba | 2008-04-16 23:28:09 -0500 | [diff] [blame] | 190 | gpa_t paddr_accessed; |
| 191 | |
| 192 | u8 io_gpr; /* GPR used as IO source/target */ |
| 193 | u8 mmio_is_bigendian; |
| 194 | u8 dcr_needed; |
| 195 | u8 dcr_is_write; |
| 196 | |
| 197 | u32 cpr0_cfgaddr; /* holds the last set cpr0_cfgaddr */ |
| 198 | |
| 199 | struct timer_list dec_timer; |
| 200 | unsigned long pending_exceptions; |
| 201 | }; |
| 202 | |
| 203 | struct kvm_guest_debug { |
| 204 | int enabled; |
| 205 | unsigned long bp[4]; |
| 206 | int singlestep; |
| 207 | }; |
| 208 | |
| 209 | #endif /* __POWERPC_KVM_HOST_H__ */ |