aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include/asm/kvm_host.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/include/asm/kvm_host.h')
-rw-r--r--arch/powerpc/include/asm/kvm_host.h90
1 files changed, 75 insertions, 15 deletions
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index bf8af5d5d5dc..52eb9c1f4fe0 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -32,17 +32,32 @@
32#include <linux/atomic.h> 32#include <linux/atomic.h>
33#include <asm/kvm_asm.h> 33#include <asm/kvm_asm.h>
34#include <asm/processor.h> 34#include <asm/processor.h>
35#include <asm/page.h>
35 36
36#define KVM_MAX_VCPUS NR_CPUS 37#define KVM_MAX_VCPUS NR_CPUS
37#define KVM_MAX_VCORES NR_CPUS 38#define KVM_MAX_VCORES NR_CPUS
38#define KVM_MEMORY_SLOTS 32 39#define KVM_MEMORY_SLOTS 32
39/* memory slots that does not exposed to userspace */ 40/* memory slots that does not exposed to userspace */
40#define KVM_PRIVATE_MEM_SLOTS 4 41#define KVM_PRIVATE_MEM_SLOTS 4
42#define KVM_MEM_SLOTS_NUM (KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS)
41 43
42#ifdef CONFIG_KVM_MMIO 44#ifdef CONFIG_KVM_MMIO
43#define KVM_COALESCED_MMIO_PAGE_OFFSET 1 45#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
44#endif 46#endif
45 47
48#ifdef CONFIG_KVM_BOOK3S_64_HV
49#include <linux/mmu_notifier.h>
50
51#define KVM_ARCH_WANT_MMU_NOTIFIER
52
53struct kvm;
54extern int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
55extern int kvm_age_hva(struct kvm *kvm, unsigned long hva);
56extern int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
57extern void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
58
59#endif
60
46/* We don't currently support large pages. */ 61/* We don't currently support large pages. */
47#define KVM_HPAGE_GFN_SHIFT(x) 0 62#define KVM_HPAGE_GFN_SHIFT(x) 0
48#define KVM_NR_PAGE_SIZES 1 63#define KVM_NR_PAGE_SIZES 1
@@ -158,34 +173,72 @@ struct kvmppc_spapr_tce_table {
158 struct page *pages[0]; 173 struct page *pages[0];
159}; 174};
160 175
161struct kvmppc_rma_info { 176struct kvmppc_linear_info {
162 void *base_virt; 177 void *base_virt;
163 unsigned long base_pfn; 178 unsigned long base_pfn;
164 unsigned long npages; 179 unsigned long npages;
165 struct list_head list; 180 struct list_head list;
166 atomic_t use_count; 181 atomic_t use_count;
182 int type;
183};
184
185/*
186 * The reverse mapping array has one entry for each HPTE,
187 * which stores the guest's view of the second word of the HPTE
188 * (including the guest physical address of the mapping),
189 * plus forward and backward pointers in a doubly-linked ring
190 * of HPTEs that map the same host page. The pointers in this
191 * ring are 32-bit HPTE indexes, to save space.
192 */
193struct revmap_entry {
194 unsigned long guest_rpte;
195 unsigned int forw, back;
196};
197
198/*
199 * We use the top bit of each memslot->rmap entry as a lock bit,
200 * and bit 32 as a present flag. The bottom 32 bits are the
201 * index in the guest HPT of a HPTE that points to the page.
202 */
203#define KVMPPC_RMAP_LOCK_BIT 63
204#define KVMPPC_RMAP_RC_SHIFT 32
205#define KVMPPC_RMAP_REFERENCED (HPTE_R_R << KVMPPC_RMAP_RC_SHIFT)
206#define KVMPPC_RMAP_CHANGED (HPTE_R_C << KVMPPC_RMAP_RC_SHIFT)
207#define KVMPPC_RMAP_PRESENT 0x100000000ul
208#define KVMPPC_RMAP_INDEX 0xfffffffful
209
210/* Low-order bits in kvm->arch.slot_phys[][] */
211#define KVMPPC_PAGE_ORDER_MASK 0x1f
212#define KVMPPC_PAGE_NO_CACHE HPTE_R_I /* 0x20 */
213#define KVMPPC_PAGE_WRITETHRU HPTE_R_W /* 0x40 */
214#define KVMPPC_GOT_PAGE 0x80
215
216struct kvm_arch_memory_slot {
167}; 217};
168 218
169struct kvm_arch { 219struct kvm_arch {
170#ifdef CONFIG_KVM_BOOK3S_64_HV 220#ifdef CONFIG_KVM_BOOK3S_64_HV
171 unsigned long hpt_virt; 221 unsigned long hpt_virt;
172 unsigned long ram_npages; 222 struct revmap_entry *revmap;
173 unsigned long ram_psize;
174 unsigned long ram_porder;
175 struct kvmppc_pginfo *ram_pginfo;
176 unsigned int lpid; 223 unsigned int lpid;
177 unsigned int host_lpid; 224 unsigned int host_lpid;
178 unsigned long host_lpcr; 225 unsigned long host_lpcr;
179 unsigned long sdr1; 226 unsigned long sdr1;
180 unsigned long host_sdr1; 227 unsigned long host_sdr1;
181 int tlbie_lock; 228 int tlbie_lock;
182 int n_rma_pages;
183 unsigned long lpcr; 229 unsigned long lpcr;
184 unsigned long rmor; 230 unsigned long rmor;
185 struct kvmppc_rma_info *rma; 231 struct kvmppc_linear_info *rma;
232 unsigned long vrma_slb_v;
233 int rma_setup_done;
234 int using_mmu_notifiers;
186 struct list_head spapr_tce_tables; 235 struct list_head spapr_tce_tables;
236 spinlock_t slot_phys_lock;
237 unsigned long *slot_phys[KVM_MEM_SLOTS_NUM];
238 int slot_npages[KVM_MEM_SLOTS_NUM];
187 unsigned short last_vcpu[NR_CPUS]; 239 unsigned short last_vcpu[NR_CPUS];
188 struct kvmppc_vcore *vcores[KVM_MAX_VCORES]; 240 struct kvmppc_vcore *vcores[KVM_MAX_VCORES];
241 struct kvmppc_linear_info *hpt_li;
189#endif /* CONFIG_KVM_BOOK3S_64_HV */ 242#endif /* CONFIG_KVM_BOOK3S_64_HV */
190}; 243};
191 244
@@ -318,10 +371,6 @@ struct kvm_vcpu_arch {
318 u32 vrsave; /* also USPRG0 */ 371 u32 vrsave; /* also USPRG0 */
319 u32 mmucr; 372 u32 mmucr;
320 ulong shadow_msr; 373 ulong shadow_msr;
321 ulong sprg4;
322 ulong sprg5;
323 ulong sprg6;
324 ulong sprg7;
325 ulong csrr0; 374 ulong csrr0;
326 ulong csrr1; 375 ulong csrr1;
327 ulong dsrr0; 376 ulong dsrr0;
@@ -329,16 +378,14 @@ struct kvm_vcpu_arch {
329 ulong mcsrr0; 378 ulong mcsrr0;
330 ulong mcsrr1; 379 ulong mcsrr1;
331 ulong mcsr; 380 ulong mcsr;
332 ulong esr;
333 u32 dec; 381 u32 dec;
334 u32 decar; 382 u32 decar;
335 u32 tbl; 383 u32 tbl;
336 u32 tbu; 384 u32 tbu;
337 u32 tcr; 385 u32 tcr;
338 u32 tsr; 386 ulong tsr; /* we need to perform set/clr_bits() which requires ulong */
339 u32 ivor[64]; 387 u32 ivor[64];
340 ulong ivpr; 388 ulong ivpr;
341 u32 pir;
342 u32 pvr; 389 u32 pvr;
343 390
344 u32 shadow_pid; 391 u32 shadow_pid;
@@ -427,9 +474,14 @@ struct kvm_vcpu_arch {
427#ifdef CONFIG_KVM_BOOK3S_64_HV 474#ifdef CONFIG_KVM_BOOK3S_64_HV
428 struct kvm_vcpu_arch_shared shregs; 475 struct kvm_vcpu_arch_shared shregs;
429 476
477 unsigned long pgfault_addr;
478 long pgfault_index;
479 unsigned long pgfault_hpte[2];
480
430 struct list_head run_list; 481 struct list_head run_list;
431 struct task_struct *run_task; 482 struct task_struct *run_task;
432 struct kvm_run *kvm_run; 483 struct kvm_run *kvm_run;
484 pgd_t *pgdir;
433#endif 485#endif
434}; 486};
435 487
@@ -438,4 +490,12 @@ struct kvm_vcpu_arch {
438#define KVMPPC_VCPU_BUSY_IN_HOST 1 490#define KVMPPC_VCPU_BUSY_IN_HOST 1
439#define KVMPPC_VCPU_RUNNABLE 2 491#define KVMPPC_VCPU_RUNNABLE 2
440 492
493/* Values for vcpu->arch.io_gpr */
494#define KVM_MMIO_REG_MASK 0x001f
495#define KVM_MMIO_REG_EXT_MASK 0xffe0
496#define KVM_MMIO_REG_GPR 0x0000
497#define KVM_MMIO_REG_FPR 0x0020
498#define KVM_MMIO_REG_QPR 0x0040
499#define KVM_MMIO_REG_FQPR 0x0060
500
441#endif /* __POWERPC_KVM_HOST_H__ */ 501#endif /* __POWERPC_KVM_HOST_H__ */