blob: d4caa6127f558c05e3261a2664d44b2e6d3fff01 [file] [log] [blame]
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -05001/*
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 Vivier588968b2008-05-30 16:05:56 +020034#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
35
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -050036/* We don't currently support large pages. */
Stephen Rothwellc428dcc2009-06-17 15:04:19 +100037#define KVM_PAGES_PER_HPAGE (1UL << 31)
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -050038
39struct kvm;
40struct kvm_run;
41struct kvm_vcpu;
42
43struct kvm_vm_stat {
44 u32 remote_tlb_flush;
45};
46
47struct 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 Blanchard45c5eb62008-04-25 17:55:49 -050064 u32 halt_wakeup;
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -050065};
66
Hollis Blanchard73e75b42008-12-02 15:51:57 -060067enum kvm_exit_types {
68 MMIO_EXITS,
69 DCR_EXITS,
70 SIGNAL_EXITS,
71 ITLB_REAL_MISS_EXITS,
72 ITLB_VIRT_MISS_EXITS,
73 DTLB_REAL_MISS_EXITS,
74 DTLB_VIRT_MISS_EXITS,
75 SYSCALL_EXITS,
76 ISI_EXITS,
77 DSI_EXITS,
78 EMULATED_INST_EXITS,
79 EMULATED_MTMSRWE_EXITS,
80 EMULATED_WRTEE_EXITS,
81 EMULATED_MTSPR_EXITS,
82 EMULATED_MFSPR_EXITS,
83 EMULATED_MTMSR_EXITS,
84 EMULATED_MFMSR_EXITS,
85 EMULATED_TLBSX_EXITS,
86 EMULATED_TLBWE_EXITS,
87 EMULATED_RFI_EXITS,
88 DEC_EXITS,
89 EXT_INTR_EXITS,
90 HALT_WAKEUP,
91 USR_PR_INST,
92 FP_UNAVAIL,
93 DEBUG_EXITS,
94 TIMEINGUEST,
95 __NUMBER_OF_KVM_EXIT_TYPES
96};
97
Hollis Blanchard73e75b42008-12-02 15:51:57 -060098/* allow access to big endian 32bit upper/lower parts and 64bit var */
Hollis Blanchard7b701592008-12-02 15:51:58 -060099struct kvmppc_exit_timing {
Hollis Blanchard73e75b42008-12-02 15:51:57 -0600100 union {
101 u64 tv64;
102 struct {
103 u32 tbu, tbl;
104 } tv32;
105 };
106};
Hollis Blanchard73e75b42008-12-02 15:51:57 -0600107
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500108struct kvm_arch {
109};
110
111struct kvm_vcpu_arch {
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500112 u32 host_stack;
113 u32 host_pid;
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500114
115 u64 fpr[32];
Hollis Blanchard5cf8ca22008-11-05 09:36:19 -0600116 ulong gpr[32];
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500117
Hollis Blanchard5cf8ca22008-11-05 09:36:19 -0600118 ulong pc;
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500119 u32 cr;
Hollis Blanchard5cf8ca22008-11-05 09:36:19 -0600120 ulong ctr;
121 ulong lr;
122 ulong xer;
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500123
Hollis Blanchard5cf8ca22008-11-05 09:36:19 -0600124 ulong msr;
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500125 u32 mmucr;
Hollis Blanchard5cf8ca22008-11-05 09:36:19 -0600126 ulong sprg0;
127 ulong sprg1;
128 ulong sprg2;
129 ulong sprg3;
130 ulong sprg4;
131 ulong sprg5;
132 ulong sprg6;
133 ulong sprg7;
134 ulong srr0;
135 ulong srr1;
136 ulong csrr0;
137 ulong csrr1;
138 ulong dsrr0;
139 ulong dsrr1;
140 ulong dear;
141 ulong esr;
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500142 u32 dec;
143 u32 decar;
144 u32 tbl;
145 u32 tbu;
146 u32 tcr;
147 u32 tsr;
Hollis Blanchardbb3a8a12009-01-03 16:23:13 -0600148 u32 ivor[64];
Hollis Blanchard5cf8ca22008-11-05 09:36:19 -0600149 ulong ivpr;
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500150 u32 pir;
Hollis Blanchard49dd2c42008-07-25 13:54:53 -0500151
152 u32 shadow_pid;
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500153 u32 pid;
Hollis Blanchard49dd2c42008-07-25 13:54:53 -0500154 u32 swap_pid;
155
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500156 u32 ccr0;
157 u32 ccr1;
158 u32 dbcr0;
159 u32 dbcr1;
Hollis Blanchardf7b200a2009-01-03 16:23:07 -0600160 u32 dbsr;
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500161
Hollis Blanchard73e75b42008-12-02 15:51:57 -0600162#ifdef CONFIG_KVM_EXIT_TIMING
Hollis Blanchard7b701592008-12-02 15:51:58 -0600163 struct kvmppc_exit_timing timing_exit;
164 struct kvmppc_exit_timing timing_last_enter;
Hollis Blanchard73e75b42008-12-02 15:51:57 -0600165 u32 last_exit_type;
166 u32 timing_count_type[__NUMBER_OF_KVM_EXIT_TYPES];
167 u64 timing_sum_duration[__NUMBER_OF_KVM_EXIT_TYPES];
168 u64 timing_sum_quad_duration[__NUMBER_OF_KVM_EXIT_TYPES];
169 u64 timing_min_duration[__NUMBER_OF_KVM_EXIT_TYPES];
170 u64 timing_max_duration[__NUMBER_OF_KVM_EXIT_TYPES];
171 u64 timing_last_exit;
172 struct dentry *debugfs_exit_timing;
173#endif
174
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500175 u32 last_inst;
Hollis Blanchard5cf8ca22008-11-05 09:36:19 -0600176 ulong fault_dear;
177 ulong fault_esr;
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500178 gpa_t paddr_accessed;
179
180 u8 io_gpr; /* GPR used as IO source/target */
181 u8 mmio_is_bigendian;
182 u8 dcr_needed;
183 u8 dcr_is_write;
184
185 u32 cpr0_cfgaddr; /* holds the last set cpr0_cfgaddr */
186
187 struct timer_list dec_timer;
188 unsigned long pending_exceptions;
189};
190
Hollis Blanchardbbf45ba2008-04-16 23:28:09 -0500191#endif /* __POWERPC_KVM_HOST_H__ */