Advertisement
jintack

Printout physical IRQ number on kvm exit

Jun 2nd, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.43 KB | None | 0 0
  1. diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
  2. index 81f18ed..6009f72 100644
  3. --- a/arch/arm/kvm/arm.c
  4. +++ b/arch/arm/kvm/arm.c
  5. @@ -654,7 +654,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
  6. * guest time.
  7. */
  8. kvm_guest_exit();
  9. - trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu));
  10. + trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu),
  11. + (ret == ARM_EXCEPTION_IRQ ?
  12. + vcpu->arch.hppir & 0x3ff : 0));
  13.  
  14. /*
  15. * We must sync the PMU and timer state before the vgic state so
  16. diff --git a/arch/arm/kvm/trace.h b/arch/arm/kvm/trace.h
  17. index 59749cd..83f53ad 100644
  18. --- a/arch/arm/kvm/trace.h
  19. +++ b/arch/arm/kvm/trace.h
  20. @@ -27,26 +27,28 @@ TRACE_EVENT(kvm_entry,
  21. );
  22.  
  23. TRACE_EVENT(kvm_exit,
  24. - TP_PROTO(int idx, unsigned int exit_reason, unsigned long vcpu_pc),
  25. - TP_ARGS(idx, exit_reason, vcpu_pc),
  26. + TP_PROTO(int idx, unsigned int exit_reason, unsigned long vcpu_pc, int irq),
  27. + TP_ARGS(idx, exit_reason, vcpu_pc, irq),
  28.  
  29. TP_STRUCT__entry(
  30. __field( int, idx )
  31. __field( unsigned int, exit_reason )
  32. __field( unsigned long, vcpu_pc )
  33. + __field( int, irq )
  34. ),
  35.  
  36. TP_fast_assign(
  37. __entry->idx = idx;
  38. __entry->exit_reason = exit_reason;
  39. __entry->vcpu_pc = vcpu_pc;
  40. + __entry->irq = irq;
  41. ),
  42.  
  43. - TP_printk("%s: HSR_EC: 0x%04x (%s), PC: 0x%08lx",
  44. + TP_printk("%s: HSR_EC: 0x%04x (%s), PC: 0x%08lx irq: %d",
  45. __print_symbolic(__entry->idx, kvm_arm_exception_type),
  46. __entry->exit_reason,
  47. __print_symbolic(__entry->exit_reason, kvm_arm_exception_class),
  48. - __entry->vcpu_pc)
  49. + __entry->vcpu_pc, __entry->irq)
  50. );
  51.  
  52. TRACE_EVENT(kvm_guest_fault,
  53. diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
  54. index aeb4862..3929547 100644
  55. --- a/arch/arm64/include/asm/kvm_host.h
  56. +++ b/arch/arm64/include/asm/kvm_host.h
  57. @@ -239,6 +239,8 @@ struct kvm_vcpu_arch {
  58.  
  59. /* Stage 2 paging state used by the hardware on next switch */
  60. struct kvm_s2_mmu *hw_mmu;
  61. +
  62. + u32 hppir;
  63. };
  64.  
  65. #define vcpu_gp_regs(v) (&(v)->arch.ctxt.gp_regs)
  66. diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c
  67. index 77a349b..b633642 100644
  68. --- a/arch/arm64/kvm/hyp/switch.c
  69. +++ b/arch/arm64/kvm/hyp/switch.c
  70. @@ -236,6 +236,7 @@ static bool __hyp_text __populate_fault_info(struct kvm_vcpu *vcpu)
  71. return true;
  72. }
  73.  
  74. +extern void __hyp_text __vgic_v2_check_pend(struct kvm_vcpu *vcpu);
  75. static int __hyp_text __guest_run(struct kvm_vcpu *vcpu)
  76. {
  77. struct kvm_cpu_context *host_ctxt;
  78. @@ -274,6 +275,9 @@ again:
  79. if (exit_code == ARM_EXCEPTION_TRAP && !__populate_fault_info(vcpu))
  80. goto again;
  81.  
  82. + if (exit_code == ARM_EXCEPTION_IRQ)
  83. + __vgic_v2_check_pend(vcpu);
  84. +
  85. fp_enabled = __fpsimd_enabled();
  86.  
  87. __sysreg_save_guest_state(guest_ctxt);
  88. diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
  89. index c44e98b..f7009d6 100644
  90. --- a/drivers/irqchip/irq-gic.c
  91. +++ b/drivers/irqchip/irq-gic.c
  92. @@ -102,6 +102,13 @@ static struct static_key supports_deactivate = STATIC_KEY_INIT_TRUE;
  93.  
  94. static struct gic_chip_data gic_data[CONFIG_ARM_GIC_MAX_NR] __read_mostly;
  95.  
  96. +
  97. +void __iomem *kvm_get_rcpu_base(void)
  98. +{
  99. + struct gic_chip_data *gic = &gic_data[0];
  100. + return gic->cpu_base.common_base;
  101. +}
  102. +
  103. #ifdef CONFIG_GIC_NON_BANKED
  104. static void __iomem *gic_get_percpu_base(union gic_base *base)
  105. {
  106. diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
  107. index 1fa3ad9..6c90b1a 100644
  108. --- a/include/kvm/arm_vgic.h
  109. +++ b/include/kvm/arm_vgic.h
  110. @@ -137,6 +137,8 @@ struct vgic_params {
  111. int max_gic_vcpus;
  112. /* Only needed for the legacy KVM_CREATE_IRQCHIP */
  113. bool can_emulate_gicv2;
  114. +
  115. + void __iomem *rcpu_base;
  116. };
  117.  
  118. struct vgic_vm_ops {
  119. @@ -180,6 +182,8 @@ struct vgic_dist {
  120. /* Virtual control interface mapping */
  121. void __iomem *vctrl_base;
  122.  
  123. + void __iomem *rcpu_base;
  124. +
  125. /* Distributor and vcpu interface mapping in the guest */
  126. phys_addr_t vgic_dist_base;
  127. /* GICv2 and GICv3 use different mapped register blocks */
  128. diff --git a/virt/kvm/arm/hyp/vgic-v2-sr.c b/virt/kvm/arm/hyp/vgic-v2-sr.c
  129. index d5e3754..48f3102 100644
  130. --- a/virt/kvm/arm/hyp/vgic-v2-sr.c
  131. +++ b/virt/kvm/arm/hyp/vgic-v2-sr.c
  132. @@ -174,3 +174,14 @@ void __hyp_text __vgic_v2_restore_state(struct kvm_vcpu *vcpu)
  133. writel_relaxed(cpu_if->vgic_vmcr, base + GICH_VMCR);
  134. vcpu->arch.vgic_cpu.live_lrs = live_lrs;
  135. }
  136. +
  137. +void __hyp_text __vgic_v2_check_pend(struct kvm_vcpu *vcpu)
  138. +{
  139. + struct kvm *kvm = kern_hyp_va(vcpu->kvm);
  140. + struct vgic_dist *vgic = &kvm->arch.vgic;
  141. + void __iomem *rcpu_base = kern_hyp_va(vgic->rcpu_base);
  142. + u32 hppir;
  143. +
  144. + hppir = readl_relaxed(rcpu_base + GIC_CPU_HIGHPRI);
  145. + vcpu->arch.hppir = hppir;
  146. +}
  147. diff --git a/virt/kvm/arm/vgic-v2.c b/virt/kvm/arm/vgic-v2.c
  148. index e4cca00..6ecf848 100644
  149. --- a/virt/kvm/arm/vgic-v2.c
  150. +++ b/virt/kvm/arm/vgic-v2.c
  151. @@ -195,11 +195,13 @@ static void vgic_cpu_init_lrs(void *params)
  152. * in *ops and the HW parameters in *params. Returns an error code
  153. * otherwise.
  154. */
  155. +extern void __iomem *kvm_get_rcpu_base(void);
  156. int vgic_v2_probe(struct device_node *vgic_node,
  157. const struct vgic_ops **ops,
  158. const struct vgic_params **params)
  159. {
  160. int ret;
  161. + struct resource rcpu_res;
  162. struct resource vctrl_res;
  163. struct resource vcpu_res;
  164. struct vgic_params *vgic = &vgic_v2_params;
  165. @@ -217,6 +219,22 @@ int vgic_v2_probe(struct device_node *vgic_node,
  166. goto out;
  167. }
  168.  
  169. +#ifdef CONFIG_KVM_ARM_NESTED_HYP
  170. + ret = of_address_to_resource(vgic_node, 1, &rcpu_res);
  171. + if (ret) {
  172. + kvm_err("Cannot obtain DIST resource\n");
  173. + goto out;
  174. + }
  175. +
  176. + vgic->rcpu_base = kvm_get_rcpu_base();
  177. + BUG_ON(!vgic->rcpu_base);
  178. +
  179. + ret = create_hyp_io_mappings(vgic->rcpu_base,
  180. + vgic->rcpu_base + SZ_4K,
  181. + rcpu_res.start);
  182. + WARN_ON(ret);
  183. +#endif
  184. +
  185. vgic->vctrl_base = of_iomap(vgic_node, 2);
  186. if (!vgic->vctrl_base) {
  187. kvm_err("Cannot ioremap GICH\n");
  188. diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
  189. index de83675..1d02d13 100644
  190. --- a/virt/kvm/arm/vgic.c
  191. +++ b/virt/kvm/arm/vgic.c
  192. @@ -2168,6 +2168,7 @@ int kvm_vgic_create(struct kvm *kvm, u32 type)
  193. kvm->arch.vgic.in_kernel = true;
  194. kvm->arch.vgic.vgic_model = type;
  195. kvm->arch.vgic.vctrl_base = vgic->vctrl_base;
  196. + kvm->arch.vgic.rcpu_base = vgic->rcpu_base;
  197. kvm->arch.vgic.vgic_dist_base = VGIC_ADDR_UNDEF;
  198. kvm->arch.vgic.vgic_cpu_base = VGIC_ADDR_UNDEF;
  199. kvm->arch.vgic.vgic_redist_base = VGIC_ADDR_UNDEF;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement