diff options
Diffstat (limited to 'arch/powerpc/include/asm')
-rw-r--r-- | arch/powerpc/include/asm/hvcall.h | 3 | ||||
-rw-r--r-- | arch/powerpc/include/asm/kvm_book3s.h | 7 | ||||
-rw-r--r-- | arch/powerpc/include/asm/kvm_book3s_64.h | 13 | ||||
-rw-r--r-- | arch/powerpc/include/asm/kvm_book3s_asm.h | 8 | ||||
-rw-r--r-- | arch/powerpc/include/asm/kvm_booke.h | 2 | ||||
-rw-r--r-- | arch/powerpc/include/asm/kvm_host.h | 41 | ||||
-rw-r--r-- | arch/powerpc/include/asm/kvm_ppc.h | 114 | ||||
-rw-r--r-- | arch/powerpc/include/asm/reg.h | 1 |
8 files changed, 181 insertions, 8 deletions
diff --git a/arch/powerpc/include/asm/hvcall.h b/arch/powerpc/include/asm/hvcall.h index 4bc2c3dad6ad..cf4df8e2139a 100644 --- a/arch/powerpc/include/asm/hvcall.h +++ b/arch/powerpc/include/asm/hvcall.h | |||
@@ -270,6 +270,9 @@ | |||
270 | #define H_SET_MODE 0x31C | 270 | #define H_SET_MODE 0x31C |
271 | #define MAX_HCALL_OPCODE H_SET_MODE | 271 | #define MAX_HCALL_OPCODE H_SET_MODE |
272 | 272 | ||
273 | /* Platform specific hcalls, used by KVM */ | ||
274 | #define H_RTAS 0xf000 | ||
275 | |||
273 | #ifndef __ASSEMBLY__ | 276 | #ifndef __ASSEMBLY__ |
274 | 277 | ||
275 | /** | 278 | /** |
diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h index 5a56e1c5f851..349ed85c7d61 100644 --- a/arch/powerpc/include/asm/kvm_book3s.h +++ b/arch/powerpc/include/asm/kvm_book3s.h | |||
@@ -142,6 +142,8 @@ extern int kvmppc_mmu_hv_init(void); | |||
142 | extern int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, bool data); | 142 | extern int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, bool data); |
143 | extern int kvmppc_st(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, bool data); | 143 | extern int kvmppc_st(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, bool data); |
144 | extern void kvmppc_book3s_queue_irqprio(struct kvm_vcpu *vcpu, unsigned int vec); | 144 | extern void kvmppc_book3s_queue_irqprio(struct kvm_vcpu *vcpu, unsigned int vec); |
145 | extern void kvmppc_book3s_dequeue_irqprio(struct kvm_vcpu *vcpu, | ||
146 | unsigned int vec); | ||
145 | extern void kvmppc_inject_interrupt(struct kvm_vcpu *vcpu, int vec, u64 flags); | 147 | extern void kvmppc_inject_interrupt(struct kvm_vcpu *vcpu, int vec, u64 flags); |
146 | extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat, | 148 | extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat, |
147 | bool upper, u32 val); | 149 | bool upper, u32 val); |
@@ -156,7 +158,8 @@ void kvmppc_clear_ref_hpte(struct kvm *kvm, unsigned long *hptep, | |||
156 | unsigned long pte_index); | 158 | unsigned long pte_index); |
157 | extern void *kvmppc_pin_guest_page(struct kvm *kvm, unsigned long addr, | 159 | extern void *kvmppc_pin_guest_page(struct kvm *kvm, unsigned long addr, |
158 | unsigned long *nb_ret); | 160 | unsigned long *nb_ret); |
159 | extern void kvmppc_unpin_guest_page(struct kvm *kvm, void *addr); | 161 | extern void kvmppc_unpin_guest_page(struct kvm *kvm, void *addr, |
162 | unsigned long gpa, bool dirty); | ||
160 | extern long kvmppc_virtmode_h_enter(struct kvm_vcpu *vcpu, unsigned long flags, | 163 | extern long kvmppc_virtmode_h_enter(struct kvm_vcpu *vcpu, unsigned long flags, |
161 | long pte_index, unsigned long pteh, unsigned long ptel); | 164 | long pte_index, unsigned long pteh, unsigned long ptel); |
162 | extern long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags, | 165 | extern long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags, |
@@ -458,6 +461,8 @@ static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu) | |||
458 | #define OSI_SC_MAGIC_R4 0x77810F9B | 461 | #define OSI_SC_MAGIC_R4 0x77810F9B |
459 | 462 | ||
460 | #define INS_DCBZ 0x7c0007ec | 463 | #define INS_DCBZ 0x7c0007ec |
464 | /* TO = 31 for unconditional trap */ | ||
465 | #define INS_TW 0x7fe00008 | ||
461 | 466 | ||
462 | /* LPIDs we support with this build -- runtime limit may be lower */ | 467 | /* LPIDs we support with this build -- runtime limit may be lower */ |
463 | #define KVMPPC_NR_LPIDS (LPID_RSVD + 1) | 468 | #define KVMPPC_NR_LPIDS (LPID_RSVD + 1) |
diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h b/arch/powerpc/include/asm/kvm_book3s_64.h index 38bec1dc9928..9c1ff330c805 100644 --- a/arch/powerpc/include/asm/kvm_book3s_64.h +++ b/arch/powerpc/include/asm/kvm_book3s_64.h | |||
@@ -268,4 +268,17 @@ static inline int is_vrma_hpte(unsigned long hpte_v) | |||
268 | (HPTE_V_1TB_SEG | (VRMA_VSID << (40 - 16))); | 268 | (HPTE_V_1TB_SEG | (VRMA_VSID << (40 - 16))); |
269 | } | 269 | } |
270 | 270 | ||
271 | #ifdef CONFIG_KVM_BOOK3S_64_HV | ||
272 | /* | ||
273 | * Note modification of an HPTE; set the HPTE modified bit | ||
274 | * if anyone is interested. | ||
275 | */ | ||
276 | static inline void note_hpte_modification(struct kvm *kvm, | ||
277 | struct revmap_entry *rev) | ||
278 | { | ||
279 | if (atomic_read(&kvm->arch.hpte_mod_interest)) | ||
280 | rev->guest_rpte |= HPTE_GR_MODIFIED; | ||
281 | } | ||
282 | #endif /* CONFIG_KVM_BOOK3S_64_HV */ | ||
283 | |||
271 | #endif /* __ASM_KVM_BOOK3S_64_H__ */ | 284 | #endif /* __ASM_KVM_BOOK3S_64_H__ */ |
diff --git a/arch/powerpc/include/asm/kvm_book3s_asm.h b/arch/powerpc/include/asm/kvm_book3s_asm.h index cdc3d2717cc6..9039d3c97eec 100644 --- a/arch/powerpc/include/asm/kvm_book3s_asm.h +++ b/arch/powerpc/include/asm/kvm_book3s_asm.h | |||
@@ -20,6 +20,11 @@ | |||
20 | #ifndef __ASM_KVM_BOOK3S_ASM_H__ | 20 | #ifndef __ASM_KVM_BOOK3S_ASM_H__ |
21 | #define __ASM_KVM_BOOK3S_ASM_H__ | 21 | #define __ASM_KVM_BOOK3S_ASM_H__ |
22 | 22 | ||
23 | /* XICS ICP register offsets */ | ||
24 | #define XICS_XIRR 4 | ||
25 | #define XICS_MFRR 0xc | ||
26 | #define XICS_IPI 2 /* interrupt source # for IPIs */ | ||
27 | |||
23 | #ifdef __ASSEMBLY__ | 28 | #ifdef __ASSEMBLY__ |
24 | 29 | ||
25 | #ifdef CONFIG_KVM_BOOK3S_HANDLER | 30 | #ifdef CONFIG_KVM_BOOK3S_HANDLER |
@@ -81,10 +86,11 @@ struct kvmppc_host_state { | |||
81 | #ifdef CONFIG_KVM_BOOK3S_64_HV | 86 | #ifdef CONFIG_KVM_BOOK3S_64_HV |
82 | u8 hwthread_req; | 87 | u8 hwthread_req; |
83 | u8 hwthread_state; | 88 | u8 hwthread_state; |
84 | 89 | u8 host_ipi; | |
85 | struct kvm_vcpu *kvm_vcpu; | 90 | struct kvm_vcpu *kvm_vcpu; |
86 | struct kvmppc_vcore *kvm_vcore; | 91 | struct kvmppc_vcore *kvm_vcore; |
87 | unsigned long xics_phys; | 92 | unsigned long xics_phys; |
93 | u32 saved_xirr; | ||
88 | u64 dabr; | 94 | u64 dabr; |
89 | u64 host_mmcr[3]; | 95 | u64 host_mmcr[3]; |
90 | u32 host_pmc[8]; | 96 | u32 host_pmc[8]; |
diff --git a/arch/powerpc/include/asm/kvm_booke.h b/arch/powerpc/include/asm/kvm_booke.h index b7cd3356a532..d3c1eb34c986 100644 --- a/arch/powerpc/include/asm/kvm_booke.h +++ b/arch/powerpc/include/asm/kvm_booke.h | |||
@@ -26,6 +26,8 @@ | |||
26 | /* LPIDs we support with this build -- runtime limit may be lower */ | 26 | /* LPIDs we support with this build -- runtime limit may be lower */ |
27 | #define KVMPPC_NR_LPIDS 64 | 27 | #define KVMPPC_NR_LPIDS 64 |
28 | 28 | ||
29 | #define KVMPPC_INST_EHPRIV 0x7c00021c | ||
30 | |||
29 | static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val) | 31 | static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val) |
30 | { | 32 | { |
31 | vcpu->arch.gpr[num] = val; | 33 | vcpu->arch.gpr[num] = val; |
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index d1bb86074721..af326cde7cb6 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h | |||
@@ -44,6 +44,10 @@ | |||
44 | #define KVM_COALESCED_MMIO_PAGE_OFFSET 1 | 44 | #define KVM_COALESCED_MMIO_PAGE_OFFSET 1 |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | /* These values are internal and can be increased later */ | ||
48 | #define KVM_NR_IRQCHIPS 1 | ||
49 | #define KVM_IRQCHIP_NUM_PINS 256 | ||
50 | |||
47 | #if !defined(CONFIG_KVM_440) | 51 | #if !defined(CONFIG_KVM_440) |
48 | #include <linux/mmu_notifier.h> | 52 | #include <linux/mmu_notifier.h> |
49 | 53 | ||
@@ -188,6 +192,10 @@ struct kvmppc_linear_info { | |||
188 | int type; | 192 | int type; |
189 | }; | 193 | }; |
190 | 194 | ||
195 | /* XICS components, defined in book3s_xics.c */ | ||
196 | struct kvmppc_xics; | ||
197 | struct kvmppc_icp; | ||
198 | |||
191 | /* | 199 | /* |
192 | * The reverse mapping array has one entry for each HPTE, | 200 | * The reverse mapping array has one entry for each HPTE, |
193 | * which stores the guest's view of the second word of the HPTE | 201 | * which stores the guest's view of the second word of the HPTE |
@@ -255,6 +263,13 @@ struct kvm_arch { | |||
255 | #endif /* CONFIG_KVM_BOOK3S_64_HV */ | 263 | #endif /* CONFIG_KVM_BOOK3S_64_HV */ |
256 | #ifdef CONFIG_PPC_BOOK3S_64 | 264 | #ifdef CONFIG_PPC_BOOK3S_64 |
257 | struct list_head spapr_tce_tables; | 265 | struct list_head spapr_tce_tables; |
266 | struct list_head rtas_tokens; | ||
267 | #endif | ||
268 | #ifdef CONFIG_KVM_MPIC | ||
269 | struct openpic *mpic; | ||
270 | #endif | ||
271 | #ifdef CONFIG_KVM_XICS | ||
272 | struct kvmppc_xics *xics; | ||
258 | #endif | 273 | #endif |
259 | }; | 274 | }; |
260 | 275 | ||
@@ -301,11 +316,13 @@ struct kvmppc_vcore { | |||
301 | * that a guest can register. | 316 | * that a guest can register. |
302 | */ | 317 | */ |
303 | struct kvmppc_vpa { | 318 | struct kvmppc_vpa { |
319 | unsigned long gpa; /* Current guest phys addr */ | ||
304 | void *pinned_addr; /* Address in kernel linear mapping */ | 320 | void *pinned_addr; /* Address in kernel linear mapping */ |
305 | void *pinned_end; /* End of region */ | 321 | void *pinned_end; /* End of region */ |
306 | unsigned long next_gpa; /* Guest phys addr for update */ | 322 | unsigned long next_gpa; /* Guest phys addr for update */ |
307 | unsigned long len; /* Number of bytes required */ | 323 | unsigned long len; /* Number of bytes required */ |
308 | u8 update_pending; /* 1 => update pinned_addr from next_gpa */ | 324 | u8 update_pending; /* 1 => update pinned_addr from next_gpa */ |
325 | bool dirty; /* true => area has been modified by kernel */ | ||
309 | }; | 326 | }; |
310 | 327 | ||
311 | struct kvmppc_pte { | 328 | struct kvmppc_pte { |
@@ -359,6 +376,11 @@ struct kvmppc_slb { | |||
359 | #define KVMPPC_BOOKE_MAX_IAC 4 | 376 | #define KVMPPC_BOOKE_MAX_IAC 4 |
360 | #define KVMPPC_BOOKE_MAX_DAC 2 | 377 | #define KVMPPC_BOOKE_MAX_DAC 2 |
361 | 378 | ||
379 | /* KVMPPC_EPR_USER takes precedence over KVMPPC_EPR_KERNEL */ | ||
380 | #define KVMPPC_EPR_NONE 0 /* EPR not supported */ | ||
381 | #define KVMPPC_EPR_USER 1 /* exit to userspace to fill EPR */ | ||
382 | #define KVMPPC_EPR_KERNEL 2 /* in-kernel irqchip */ | ||
383 | |||
362 | struct kvmppc_booke_debug_reg { | 384 | struct kvmppc_booke_debug_reg { |
363 | u32 dbcr0; | 385 | u32 dbcr0; |
364 | u32 dbcr1; | 386 | u32 dbcr1; |
@@ -370,6 +392,12 @@ struct kvmppc_booke_debug_reg { | |||
370 | u64 dac[KVMPPC_BOOKE_MAX_DAC]; | 392 | u64 dac[KVMPPC_BOOKE_MAX_DAC]; |
371 | }; | 393 | }; |
372 | 394 | ||
395 | #define KVMPPC_IRQ_DEFAULT 0 | ||
396 | #define KVMPPC_IRQ_MPIC 1 | ||
397 | #define KVMPPC_IRQ_XICS 2 | ||
398 | |||
399 | struct openpic; | ||
400 | |||
373 | struct kvm_vcpu_arch { | 401 | struct kvm_vcpu_arch { |
374 | ulong host_stack; | 402 | ulong host_stack; |
375 | u32 host_pid; | 403 | u32 host_pid; |
@@ -502,8 +530,11 @@ struct kvm_vcpu_arch { | |||
502 | spinlock_t wdt_lock; | 530 | spinlock_t wdt_lock; |
503 | struct timer_list wdt_timer; | 531 | struct timer_list wdt_timer; |
504 | u32 tlbcfg[4]; | 532 | u32 tlbcfg[4]; |
533 | u32 tlbps[4]; | ||
505 | u32 mmucfg; | 534 | u32 mmucfg; |
535 | u32 eptcfg; | ||
506 | u32 epr; | 536 | u32 epr; |
537 | u32 crit_save; | ||
507 | struct kvmppc_booke_debug_reg dbg_reg; | 538 | struct kvmppc_booke_debug_reg dbg_reg; |
508 | #endif | 539 | #endif |
509 | gpa_t paddr_accessed; | 540 | gpa_t paddr_accessed; |
@@ -521,7 +552,7 @@ struct kvm_vcpu_arch { | |||
521 | u8 sane; | 552 | u8 sane; |
522 | u8 cpu_type; | 553 | u8 cpu_type; |
523 | u8 hcall_needed; | 554 | u8 hcall_needed; |
524 | u8 epr_enabled; | 555 | u8 epr_flags; /* KVMPPC_EPR_xxx */ |
525 | u8 epr_needed; | 556 | u8 epr_needed; |
526 | 557 | ||
527 | u32 cpr0_cfgaddr; /* holds the last set cpr0_cfgaddr */ | 558 | u32 cpr0_cfgaddr; /* holds the last set cpr0_cfgaddr */ |
@@ -548,6 +579,13 @@ struct kvm_vcpu_arch { | |||
548 | unsigned long magic_page_pa; /* phys addr to map the magic page to */ | 579 | unsigned long magic_page_pa; /* phys addr to map the magic page to */ |
549 | unsigned long magic_page_ea; /* effect. addr to map the magic page to */ | 580 | unsigned long magic_page_ea; /* effect. addr to map the magic page to */ |
550 | 581 | ||
582 | int irq_type; /* one of KVM_IRQ_* */ | ||
583 | int irq_cpu_id; | ||
584 | struct openpic *mpic; /* KVM_IRQ_MPIC */ | ||
585 | #ifdef CONFIG_KVM_XICS | ||
586 | struct kvmppc_icp *icp; /* XICS presentation controller */ | ||
587 | #endif | ||
588 | |||
551 | #ifdef CONFIG_KVM_BOOK3S_64_HV | 589 | #ifdef CONFIG_KVM_BOOK3S_64_HV |
552 | struct kvm_vcpu_arch_shared shregs; | 590 | struct kvm_vcpu_arch_shared shregs; |
553 | 591 | ||
@@ -588,5 +626,6 @@ struct kvm_vcpu_arch { | |||
588 | #define KVM_MMIO_REG_FQPR 0x0060 | 626 | #define KVM_MMIO_REG_FQPR 0x0060 |
589 | 627 | ||
590 | #define __KVM_HAVE_ARCH_WQP | 628 | #define __KVM_HAVE_ARCH_WQP |
629 | #define __KVM_HAVE_CREATE_DEVICE | ||
591 | 630 | ||
592 | #endif /* __POWERPC_KVM_HOST_H__ */ | 631 | #endif /* __POWERPC_KVM_HOST_H__ */ |
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 44a657adf416..a5287fe03d77 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h | |||
@@ -44,7 +44,7 @@ enum emulation_result { | |||
44 | EMULATE_DO_DCR, /* kvm_run filled with DCR request */ | 44 | EMULATE_DO_DCR, /* kvm_run filled with DCR request */ |
45 | EMULATE_FAIL, /* can't emulate this instruction */ | 45 | EMULATE_FAIL, /* can't emulate this instruction */ |
46 | EMULATE_AGAIN, /* something went wrong. go again */ | 46 | EMULATE_AGAIN, /* something went wrong. go again */ |
47 | EMULATE_DO_PAPR, /* kvm_run filled with PAPR request */ | 47 | EMULATE_EXIT_USER, /* emulation requires exit to user-space */ |
48 | }; | 48 | }; |
49 | 49 | ||
50 | extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu); | 50 | extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu); |
@@ -104,8 +104,7 @@ extern void kvmppc_core_queue_dec(struct kvm_vcpu *vcpu); | |||
104 | extern void kvmppc_core_dequeue_dec(struct kvm_vcpu *vcpu); | 104 | extern void kvmppc_core_dequeue_dec(struct kvm_vcpu *vcpu); |
105 | extern void kvmppc_core_queue_external(struct kvm_vcpu *vcpu, | 105 | extern void kvmppc_core_queue_external(struct kvm_vcpu *vcpu, |
106 | struct kvm_interrupt *irq); | 106 | struct kvm_interrupt *irq); |
107 | extern void kvmppc_core_dequeue_external(struct kvm_vcpu *vcpu, | 107 | extern void kvmppc_core_dequeue_external(struct kvm_vcpu *vcpu); |
108 | struct kvm_interrupt *irq); | ||
109 | extern void kvmppc_core_flush_tlb(struct kvm_vcpu *vcpu); | 108 | extern void kvmppc_core_flush_tlb(struct kvm_vcpu *vcpu); |
110 | 109 | ||
111 | extern int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, | 110 | extern int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, |
@@ -131,6 +130,7 @@ extern long kvmppc_prepare_vrma(struct kvm *kvm, | |||
131 | extern void kvmppc_map_vrma(struct kvm_vcpu *vcpu, | 130 | extern void kvmppc_map_vrma(struct kvm_vcpu *vcpu, |
132 | struct kvm_memory_slot *memslot, unsigned long porder); | 131 | struct kvm_memory_slot *memslot, unsigned long porder); |
133 | extern int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu); | 132 | extern int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu); |
133 | |||
134 | extern long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, | 134 | extern long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, |
135 | struct kvm_create_spapr_tce *args); | 135 | struct kvm_create_spapr_tce *args); |
136 | extern long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn, | 136 | extern long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn, |
@@ -152,7 +152,7 @@ extern int kvmppc_core_prepare_memory_region(struct kvm *kvm, | |||
152 | struct kvm_userspace_memory_region *mem); | 152 | struct kvm_userspace_memory_region *mem); |
153 | extern void kvmppc_core_commit_memory_region(struct kvm *kvm, | 153 | extern void kvmppc_core_commit_memory_region(struct kvm *kvm, |
154 | struct kvm_userspace_memory_region *mem, | 154 | struct kvm_userspace_memory_region *mem, |
155 | struct kvm_memory_slot old); | 155 | const struct kvm_memory_slot *old); |
156 | extern int kvm_vm_ioctl_get_smmu_info(struct kvm *kvm, | 156 | extern int kvm_vm_ioctl_get_smmu_info(struct kvm *kvm, |
157 | struct kvm_ppc_smmu_info *info); | 157 | struct kvm_ppc_smmu_info *info); |
158 | extern void kvmppc_core_flush_memslot(struct kvm *kvm, | 158 | extern void kvmppc_core_flush_memslot(struct kvm *kvm, |
@@ -165,6 +165,18 @@ extern int kvmppc_prepare_to_enter(struct kvm_vcpu *vcpu); | |||
165 | 165 | ||
166 | extern int kvm_vm_ioctl_get_htab_fd(struct kvm *kvm, struct kvm_get_htab_fd *); | 166 | extern int kvm_vm_ioctl_get_htab_fd(struct kvm *kvm, struct kvm_get_htab_fd *); |
167 | 167 | ||
168 | int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq); | ||
169 | |||
170 | extern int kvm_vm_ioctl_rtas_define_token(struct kvm *kvm, void __user *argp); | ||
171 | extern int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu); | ||
172 | extern void kvmppc_rtas_tokens_free(struct kvm *kvm); | ||
173 | extern int kvmppc_xics_set_xive(struct kvm *kvm, u32 irq, u32 server, | ||
174 | u32 priority); | ||
175 | extern int kvmppc_xics_get_xive(struct kvm *kvm, u32 irq, u32 *server, | ||
176 | u32 *priority); | ||
177 | extern int kvmppc_xics_int_on(struct kvm *kvm, u32 irq); | ||
178 | extern int kvmppc_xics_int_off(struct kvm *kvm, u32 irq); | ||
179 | |||
168 | /* | 180 | /* |
169 | * Cuts out inst bits with ordering according to spec. | 181 | * Cuts out inst bits with ordering according to spec. |
170 | * That means the leftmost bit is zero. All given bits are included. | 182 | * That means the leftmost bit is zero. All given bits are included. |
@@ -246,12 +258,29 @@ int kvmppc_set_one_reg(struct kvm_vcpu *vcpu, u64 id, union kvmppc_one_reg *); | |||
246 | 258 | ||
247 | void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid); | 259 | void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid); |
248 | 260 | ||
261 | struct openpic; | ||
262 | |||
249 | #ifdef CONFIG_KVM_BOOK3S_64_HV | 263 | #ifdef CONFIG_KVM_BOOK3S_64_HV |
250 | static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) | 264 | static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) |
251 | { | 265 | { |
252 | paca[cpu].kvm_hstate.xics_phys = addr; | 266 | paca[cpu].kvm_hstate.xics_phys = addr; |
253 | } | 267 | } |
254 | 268 | ||
269 | static inline u32 kvmppc_get_xics_latch(void) | ||
270 | { | ||
271 | u32 xirr = get_paca()->kvm_hstate.saved_xirr; | ||
272 | |||
273 | get_paca()->kvm_hstate.saved_xirr = 0; | ||
274 | |||
275 | return xirr; | ||
276 | } | ||
277 | |||
278 | static inline void kvmppc_set_host_ipi(int cpu, u8 host_ipi) | ||
279 | { | ||
280 | paca[cpu].kvm_hstate.host_ipi = host_ipi; | ||
281 | } | ||
282 | |||
283 | extern void kvmppc_fast_vcpu_kick(struct kvm_vcpu *vcpu); | ||
255 | extern void kvm_linear_init(void); | 284 | extern void kvm_linear_init(void); |
256 | 285 | ||
257 | #else | 286 | #else |
@@ -260,6 +289,46 @@ static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) | |||
260 | 289 | ||
261 | static inline void kvm_linear_init(void) | 290 | static inline void kvm_linear_init(void) |
262 | {} | 291 | {} |
292 | |||
293 | static inline u32 kvmppc_get_xics_latch(void) | ||
294 | { | ||
295 | return 0; | ||
296 | } | ||
297 | |||
298 | static inline void kvmppc_set_host_ipi(int cpu, u8 host_ipi) | ||
299 | {} | ||
300 | |||
301 | static inline void kvmppc_fast_vcpu_kick(struct kvm_vcpu *vcpu) | ||
302 | { | ||
303 | kvm_vcpu_kick(vcpu); | ||
304 | } | ||
305 | #endif | ||
306 | |||
307 | #ifdef CONFIG_KVM_XICS | ||
308 | static inline int kvmppc_xics_enabled(struct kvm_vcpu *vcpu) | ||
309 | { | ||
310 | return vcpu->arch.irq_type == KVMPPC_IRQ_XICS; | ||
311 | } | ||
312 | extern void kvmppc_xics_free_icp(struct kvm_vcpu *vcpu); | ||
313 | extern int kvmppc_xics_create_icp(struct kvm_vcpu *vcpu, unsigned long server); | ||
314 | extern int kvm_vm_ioctl_xics_irq(struct kvm *kvm, struct kvm_irq_level *args); | ||
315 | extern int kvmppc_xics_hcall(struct kvm_vcpu *vcpu, u32 cmd); | ||
316 | extern u64 kvmppc_xics_get_icp(struct kvm_vcpu *vcpu); | ||
317 | extern int kvmppc_xics_set_icp(struct kvm_vcpu *vcpu, u64 icpval); | ||
318 | extern int kvmppc_xics_connect_vcpu(struct kvm_device *dev, | ||
319 | struct kvm_vcpu *vcpu, u32 cpu); | ||
320 | #else | ||
321 | static inline int kvmppc_xics_enabled(struct kvm_vcpu *vcpu) | ||
322 | { return 0; } | ||
323 | static inline void kvmppc_xics_free_icp(struct kvm_vcpu *vcpu) { } | ||
324 | static inline int kvmppc_xics_create_icp(struct kvm_vcpu *vcpu, | ||
325 | unsigned long server) | ||
326 | { return -EINVAL; } | ||
327 | static inline int kvm_vm_ioctl_xics_irq(struct kvm *kvm, | ||
328 | struct kvm_irq_level *args) | ||
329 | { return -ENOTTY; } | ||
330 | static inline int kvmppc_xics_hcall(struct kvm_vcpu *vcpu, u32 cmd) | ||
331 | { return 0; } | ||
263 | #endif | 332 | #endif |
264 | 333 | ||
265 | static inline void kvmppc_set_epr(struct kvm_vcpu *vcpu, u32 epr) | 334 | static inline void kvmppc_set_epr(struct kvm_vcpu *vcpu, u32 epr) |
@@ -271,6 +340,32 @@ static inline void kvmppc_set_epr(struct kvm_vcpu *vcpu, u32 epr) | |||
271 | #endif | 340 | #endif |
272 | } | 341 | } |
273 | 342 | ||
343 | #ifdef CONFIG_KVM_MPIC | ||
344 | |||
345 | void kvmppc_mpic_set_epr(struct kvm_vcpu *vcpu); | ||
346 | int kvmppc_mpic_connect_vcpu(struct kvm_device *dev, struct kvm_vcpu *vcpu, | ||
347 | u32 cpu); | ||
348 | void kvmppc_mpic_disconnect_vcpu(struct openpic *opp, struct kvm_vcpu *vcpu); | ||
349 | |||
350 | #else | ||
351 | |||
352 | static inline void kvmppc_mpic_set_epr(struct kvm_vcpu *vcpu) | ||
353 | { | ||
354 | } | ||
355 | |||
356 | static inline int kvmppc_mpic_connect_vcpu(struct kvm_device *dev, | ||
357 | struct kvm_vcpu *vcpu, u32 cpu) | ||
358 | { | ||
359 | return -EINVAL; | ||
360 | } | ||
361 | |||
362 | static inline void kvmppc_mpic_disconnect_vcpu(struct openpic *opp, | ||
363 | struct kvm_vcpu *vcpu) | ||
364 | { | ||
365 | } | ||
366 | |||
367 | #endif /* CONFIG_KVM_MPIC */ | ||
368 | |||
274 | int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu, | 369 | int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu, |
275 | struct kvm_config_tlb *cfg); | 370 | struct kvm_config_tlb *cfg); |
276 | int kvm_vcpu_ioctl_dirty_tlb(struct kvm_vcpu *vcpu, | 371 | int kvm_vcpu_ioctl_dirty_tlb(struct kvm_vcpu *vcpu, |
@@ -283,8 +378,15 @@ void kvmppc_init_lpid(unsigned long nr_lpids); | |||
283 | 378 | ||
284 | static inline void kvmppc_mmu_flush_icache(pfn_t pfn) | 379 | static inline void kvmppc_mmu_flush_icache(pfn_t pfn) |
285 | { | 380 | { |
286 | /* Clear i-cache for new pages */ | ||
287 | struct page *page; | 381 | struct page *page; |
382 | /* | ||
383 | * We can only access pages that the kernel maps | ||
384 | * as memory. Bail out for unmapped ones. | ||
385 | */ | ||
386 | if (!pfn_valid(pfn)) | ||
387 | return; | ||
388 | |||
389 | /* Clear i-cache for new pages */ | ||
288 | page = pfn_to_page(pfn); | 390 | page = pfn_to_page(pfn); |
289 | if (!test_bit(PG_arch_1, &page->flags)) { | 391 | if (!test_bit(PG_arch_1, &page->flags)) { |
290 | flush_dcache_icache_page(page); | 392 | flush_dcache_icache_page(page); |
@@ -324,4 +426,6 @@ static inline ulong kvmppc_get_ea_indexed(struct kvm_vcpu *vcpu, int ra, int rb) | |||
324 | return ea; | 426 | return ea; |
325 | } | 427 | } |
326 | 428 | ||
429 | extern void xics_wake_cpu(int cpu); | ||
430 | |||
327 | #endif /* __POWERPC_KVM_PPC_H__ */ | 431 | #endif /* __POWERPC_KVM_PPC_H__ */ |
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h index 3d17427e4fd7..a6136515c7f2 100644 --- a/arch/powerpc/include/asm/reg.h +++ b/arch/powerpc/include/asm/reg.h | |||
@@ -300,6 +300,7 @@ | |||
300 | #define LPCR_PECE1 0x00002000 /* decrementer can cause exit */ | 300 | #define LPCR_PECE1 0x00002000 /* decrementer can cause exit */ |
301 | #define LPCR_PECE2 0x00001000 /* machine check etc can cause exit */ | 301 | #define LPCR_PECE2 0x00001000 /* machine check etc can cause exit */ |
302 | #define LPCR_MER 0x00000800 /* Mediated External Exception */ | 302 | #define LPCR_MER 0x00000800 /* Mediated External Exception */ |
303 | #define LPCR_MER_SH 11 | ||
303 | #define LPCR_LPES 0x0000000c | 304 | #define LPCR_LPES 0x0000000c |
304 | #define LPCR_LPES0 0x00000008 /* LPAR Env selector 0 */ | 305 | #define LPCR_LPES0 0x00000008 /* LPAR Env selector 0 */ |
305 | #define LPCR_LPES1 0x00000004 /* LPAR Env selector 1 */ | 306 | #define LPCR_LPES1 0x00000004 /* LPAR Env selector 1 */ |