Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
- index 81f18ed..6009f72 100644
- --- a/arch/arm/kvm/arm.c
- +++ b/arch/arm/kvm/arm.c
- @@ -654,7 +654,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
- * guest time.
- */
- kvm_guest_exit();
- - trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu));
- + trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu),
- + (ret == ARM_EXCEPTION_IRQ ?
- + vcpu->arch.hppir & 0x3ff : 0));
- /*
- * We must sync the PMU and timer state before the vgic state so
- diff --git a/arch/arm/kvm/trace.h b/arch/arm/kvm/trace.h
- index 59749cd..83f53ad 100644
- --- a/arch/arm/kvm/trace.h
- +++ b/arch/arm/kvm/trace.h
- @@ -27,26 +27,28 @@ TRACE_EVENT(kvm_entry,
- );
- TRACE_EVENT(kvm_exit,
- - TP_PROTO(int idx, unsigned int exit_reason, unsigned long vcpu_pc),
- - TP_ARGS(idx, exit_reason, vcpu_pc),
- + TP_PROTO(int idx, unsigned int exit_reason, unsigned long vcpu_pc, int irq),
- + TP_ARGS(idx, exit_reason, vcpu_pc, irq),
- TP_STRUCT__entry(
- __field( int, idx )
- __field( unsigned int, exit_reason )
- __field( unsigned long, vcpu_pc )
- + __field( int, irq )
- ),
- TP_fast_assign(
- __entry->idx = idx;
- __entry->exit_reason = exit_reason;
- __entry->vcpu_pc = vcpu_pc;
- + __entry->irq = irq;
- ),
- - TP_printk("%s: HSR_EC: 0x%04x (%s), PC: 0x%08lx",
- + TP_printk("%s: HSR_EC: 0x%04x (%s), PC: 0x%08lx irq: %d",
- __print_symbolic(__entry->idx, kvm_arm_exception_type),
- __entry->exit_reason,
- __print_symbolic(__entry->exit_reason, kvm_arm_exception_class),
- - __entry->vcpu_pc)
- + __entry->vcpu_pc, __entry->irq)
- );
- TRACE_EVENT(kvm_guest_fault,
- diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
- index aeb4862..3929547 100644
- --- a/arch/arm64/include/asm/kvm_host.h
- +++ b/arch/arm64/include/asm/kvm_host.h
- @@ -239,6 +239,8 @@ struct kvm_vcpu_arch {
- /* Stage 2 paging state used by the hardware on next switch */
- struct kvm_s2_mmu *hw_mmu;
- +
- + u32 hppir;
- };
- #define vcpu_gp_regs(v) (&(v)->arch.ctxt.gp_regs)
- diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c
- index 77a349b..b633642 100644
- --- a/arch/arm64/kvm/hyp/switch.c
- +++ b/arch/arm64/kvm/hyp/switch.c
- @@ -236,6 +236,7 @@ static bool __hyp_text __populate_fault_info(struct kvm_vcpu *vcpu)
- return true;
- }
- +extern void __hyp_text __vgic_v2_check_pend(struct kvm_vcpu *vcpu);
- static int __hyp_text __guest_run(struct kvm_vcpu *vcpu)
- {
- struct kvm_cpu_context *host_ctxt;
- @@ -274,6 +275,9 @@ again:
- if (exit_code == ARM_EXCEPTION_TRAP && !__populate_fault_info(vcpu))
- goto again;
- + if (exit_code == ARM_EXCEPTION_IRQ)
- + __vgic_v2_check_pend(vcpu);
- +
- fp_enabled = __fpsimd_enabled();
- __sysreg_save_guest_state(guest_ctxt);
- diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
- index c44e98b..f7009d6 100644
- --- a/drivers/irqchip/irq-gic.c
- +++ b/drivers/irqchip/irq-gic.c
- @@ -102,6 +102,13 @@ static struct static_key supports_deactivate = STATIC_KEY_INIT_TRUE;
- static struct gic_chip_data gic_data[CONFIG_ARM_GIC_MAX_NR] __read_mostly;
- +
- +void __iomem *kvm_get_rcpu_base(void)
- +{
- + struct gic_chip_data *gic = &gic_data[0];
- + return gic->cpu_base.common_base;
- +}
- +
- #ifdef CONFIG_GIC_NON_BANKED
- static void __iomem *gic_get_percpu_base(union gic_base *base)
- {
- diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
- index 1fa3ad9..6c90b1a 100644
- --- a/include/kvm/arm_vgic.h
- +++ b/include/kvm/arm_vgic.h
- @@ -137,6 +137,8 @@ struct vgic_params {
- int max_gic_vcpus;
- /* Only needed for the legacy KVM_CREATE_IRQCHIP */
- bool can_emulate_gicv2;
- +
- + void __iomem *rcpu_base;
- };
- struct vgic_vm_ops {
- @@ -180,6 +182,8 @@ struct vgic_dist {
- /* Virtual control interface mapping */
- void __iomem *vctrl_base;
- + void __iomem *rcpu_base;
- +
- /* Distributor and vcpu interface mapping in the guest */
- phys_addr_t vgic_dist_base;
- /* GICv2 and GICv3 use different mapped register blocks */
- diff --git a/virt/kvm/arm/hyp/vgic-v2-sr.c b/virt/kvm/arm/hyp/vgic-v2-sr.c
- index d5e3754..48f3102 100644
- --- a/virt/kvm/arm/hyp/vgic-v2-sr.c
- +++ b/virt/kvm/arm/hyp/vgic-v2-sr.c
- @@ -174,3 +174,14 @@ void __hyp_text __vgic_v2_restore_state(struct kvm_vcpu *vcpu)
- writel_relaxed(cpu_if->vgic_vmcr, base + GICH_VMCR);
- vcpu->arch.vgic_cpu.live_lrs = live_lrs;
- }
- +
- +void __hyp_text __vgic_v2_check_pend(struct kvm_vcpu *vcpu)
- +{
- + struct kvm *kvm = kern_hyp_va(vcpu->kvm);
- + struct vgic_dist *vgic = &kvm->arch.vgic;
- + void __iomem *rcpu_base = kern_hyp_va(vgic->rcpu_base);
- + u32 hppir;
- +
- + hppir = readl_relaxed(rcpu_base + GIC_CPU_HIGHPRI);
- + vcpu->arch.hppir = hppir;
- +}
- diff --git a/virt/kvm/arm/vgic-v2.c b/virt/kvm/arm/vgic-v2.c
- index e4cca00..6ecf848 100644
- --- a/virt/kvm/arm/vgic-v2.c
- +++ b/virt/kvm/arm/vgic-v2.c
- @@ -195,11 +195,13 @@ static void vgic_cpu_init_lrs(void *params)
- * in *ops and the HW parameters in *params. Returns an error code
- * otherwise.
- */
- +extern void __iomem *kvm_get_rcpu_base(void);
- int vgic_v2_probe(struct device_node *vgic_node,
- const struct vgic_ops **ops,
- const struct vgic_params **params)
- {
- int ret;
- + struct resource rcpu_res;
- struct resource vctrl_res;
- struct resource vcpu_res;
- struct vgic_params *vgic = &vgic_v2_params;
- @@ -217,6 +219,22 @@ int vgic_v2_probe(struct device_node *vgic_node,
- goto out;
- }
- +#ifdef CONFIG_KVM_ARM_NESTED_HYP
- + ret = of_address_to_resource(vgic_node, 1, &rcpu_res);
- + if (ret) {
- + kvm_err("Cannot obtain DIST resource\n");
- + goto out;
- + }
- +
- + vgic->rcpu_base = kvm_get_rcpu_base();
- + BUG_ON(!vgic->rcpu_base);
- +
- + ret = create_hyp_io_mappings(vgic->rcpu_base,
- + vgic->rcpu_base + SZ_4K,
- + rcpu_res.start);
- + WARN_ON(ret);
- +#endif
- +
- vgic->vctrl_base = of_iomap(vgic_node, 2);
- if (!vgic->vctrl_base) {
- kvm_err("Cannot ioremap GICH\n");
- diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
- index de83675..1d02d13 100644
- --- a/virt/kvm/arm/vgic.c
- +++ b/virt/kvm/arm/vgic.c
- @@ -2168,6 +2168,7 @@ int kvm_vgic_create(struct kvm *kvm, u32 type)
- kvm->arch.vgic.in_kernel = true;
- kvm->arch.vgic.vgic_model = type;
- kvm->arch.vgic.vctrl_base = vgic->vctrl_base;
- + kvm->arch.vgic.rcpu_base = vgic->rcpu_base;
- kvm->arch.vgic.vgic_dist_base = VGIC_ADDR_UNDEF;
- kvm->arch.vgic.vgic_cpu_base = VGIC_ADDR_UNDEF;
- kvm->arch.vgic.vgic_redist_base = VGIC_ADDR_UNDEF;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement