aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuresh Warrier <warrier@linux.vnet.ibm.com>2016-08-19 01:35:48 -0400
committerPaul Mackerras <paulus@ozlabs.org>2016-09-09 02:26:19 -0400
commit8daaafc88b46fb3af952e92d7c2816a8950e1363 (patch)
tree904a4f0df30057dd12654644597186f63b59236c
parent9576730d0e6e301343c5aead5418ad53fcecfd14 (diff)
KVM: PPC: Book3S HV: Introduce kvmppc_passthru_irqmap
This patch introduces an IRQ mapping structure, the kvmppc_passthru_irqmap structure that is to be used to map the real hardware IRQ in the host with the virtual hardware IRQ (gsi) that is injected into a guest by KVM for passthrough adapters. Currently, we assume a separate IRQ mapping structure for each guest. Each kvmppc_passthru_irqmap has a mapping arrays, containing all defined real<->virtual IRQs. [paulus@ozlabs.org - removed irq_chip field from struct kvmppc_passthru_irqmap; changed parameter for kvmppc_get_passthru_irqmap from struct kvm_vcpu * to struct kvm *, removed small cached array.] Signed-off-by: Suresh Warrier <warrier@linux.vnet.ibm.com> Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
-rw-r--r--arch/powerpc/include/asm/kvm_host.h17
-rw-r--r--arch/powerpc/include/asm/kvm_ppc.h14
-rw-r--r--arch/powerpc/kvm/book3s_hv.c13
3 files changed, 44 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index 373003f4551d..89ac1f6c2cb2 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -203,6 +203,8 @@ struct kvmppc_spapr_tce_table {
203struct kvmppc_xics; 203struct kvmppc_xics;
204struct kvmppc_icp; 204struct kvmppc_icp;
205 205
206struct kvmppc_passthru_irqmap;
207
206/* 208/*
207 * The reverse mapping array has one entry for each HPTE, 209 * The reverse mapping array has one entry for each HPTE,
208 * which stores the guest's view of the second word of the HPTE 210 * which stores the guest's view of the second word of the HPTE
@@ -273,6 +275,7 @@ struct kvm_arch {
273#endif 275#endif
274#ifdef CONFIG_KVM_XICS 276#ifdef CONFIG_KVM_XICS
275 struct kvmppc_xics *xics; 277 struct kvmppc_xics *xics;
278 struct kvmppc_passthru_irqmap *pimap;
276#endif 279#endif
277 struct kvmppc_ops *kvm_ops; 280 struct kvmppc_ops *kvm_ops;
278#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 281#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
@@ -369,6 +372,20 @@ struct kvmhv_tb_accumulator {
369 u64 tb_max; /* max time */ 372 u64 tb_max; /* max time */
370}; 373};
371 374
375#ifdef CONFIG_PPC_BOOK3S_64
376struct kvmppc_irq_map {
377 u32 r_hwirq;
378 u32 v_hwirq;
379 struct irq_desc *desc;
380};
381
382#define KVMPPC_PIRQ_MAPPED 1024
383struct kvmppc_passthru_irqmap {
384 int n_mapped;
385 struct kvmppc_irq_map mapped[KVMPPC_PIRQ_MAPPED];
386};
387#endif
388
372# ifdef CONFIG_PPC_FSL_BOOK3E 389# ifdef CONFIG_PPC_FSL_BOOK3E
373#define KVMPPC_BOOKE_IAC_NUM 2 390#define KVMPPC_BOOKE_IAC_NUM 2
374#define KVMPPC_BOOKE_DAC_NUM 2 391#define KVMPPC_BOOKE_DAC_NUM 2
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index 94715e22d6a2..4ca2ba36a860 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -457,8 +457,18 @@ static inline int kvmppc_xics_enabled(struct kvm_vcpu *vcpu)
457{ 457{
458 return vcpu->arch.irq_type == KVMPPC_IRQ_XICS; 458 return vcpu->arch.irq_type == KVMPPC_IRQ_XICS;
459} 459}
460
461static inline struct kvmppc_passthru_irqmap *kvmppc_get_passthru_irqmap(
462 struct kvm *kvm)
463{
464 if (kvm)
465 return kvm->arch.pimap;
466 return NULL;
467}
468
460extern void kvmppc_alloc_host_rm_ops(void); 469extern void kvmppc_alloc_host_rm_ops(void);
461extern void kvmppc_free_host_rm_ops(void); 470extern void kvmppc_free_host_rm_ops(void);
471extern void kvmppc_free_pimap(struct kvm *kvm);
462extern void kvmppc_xics_free_icp(struct kvm_vcpu *vcpu); 472extern void kvmppc_xics_free_icp(struct kvm_vcpu *vcpu);
463extern int kvmppc_xics_create_icp(struct kvm_vcpu *vcpu, unsigned long server); 473extern int kvmppc_xics_create_icp(struct kvm_vcpu *vcpu, unsigned long server);
464extern int kvm_vm_ioctl_xics_irq(struct kvm *kvm, struct kvm_irq_level *args); 474extern int kvm_vm_ioctl_xics_irq(struct kvm *kvm, struct kvm_irq_level *args);
@@ -470,8 +480,12 @@ extern int kvmppc_xics_connect_vcpu(struct kvm_device *dev,
470extern void kvmppc_xics_ipi_action(void); 480extern void kvmppc_xics_ipi_action(void);
471extern int h_ipi_redirect; 481extern int h_ipi_redirect;
472#else 482#else
483static inline struct kvmppc_passthru_irqmap *kvmppc_get_passthru_irqmap(
484 struct kvm *kvm)
485 { return NULL; }
473static inline void kvmppc_alloc_host_rm_ops(void) {}; 486static inline void kvmppc_alloc_host_rm_ops(void) {};
474static inline void kvmppc_free_host_rm_ops(void) {}; 487static inline void kvmppc_free_host_rm_ops(void) {};
488static inline void kvmppc_free_pimap(struct kvm *kvm) {};
475static inline int kvmppc_xics_enabled(struct kvm_vcpu *vcpu) 489static inline int kvmppc_xics_enabled(struct kvm_vcpu *vcpu)
476 { return 0; } 490 { return 0; }
477static inline void kvmppc_xics_free_icp(struct kvm_vcpu *vcpu) { } 491static inline void kvmppc_xics_free_icp(struct kvm_vcpu *vcpu) { }
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 30ff8ab5aba1..d5c7061b9045 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -3412,6 +3412,19 @@ static int kvmppc_core_check_processor_compat_hv(void)
3412 return 0; 3412 return 0;
3413} 3413}
3414 3414
3415#ifdef CONFIG_KVM_XICS
3416
3417void kvmppc_free_pimap(struct kvm *kvm)
3418{
3419 kfree(kvm->arch.pimap);
3420}
3421
3422struct kvmppc_passthru_irqmap *kvmppc_alloc_pimap(void)
3423{
3424 return kzalloc(sizeof(struct kvmppc_passthru_irqmap), GFP_KERNEL);
3425}
3426#endif
3427
3415static long kvm_arch_vm_ioctl_hv(struct file *filp, 3428static long kvm_arch_vm_ioctl_hv(struct file *filp,
3416 unsigned int ioctl, unsigned long arg) 3429 unsigned int ioctl, unsigned long arg)
3417{ 3430{