]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: Move GICv3 trap configuration to kvm_calculate_traps()
authorMarc Zyngier <maz@kernel.org>
Tue, 27 Aug 2024 15:25:07 +0000 (16:25 +0100)
committerMarc Zyngier <maz@kernel.org>
Tue, 27 Aug 2024 17:32:55 +0000 (18:32 +0100)
Follow the pattern introduced with vcpu_set_hcr(), and introduce
vcpu_set_ich_hcr(), which configures the GICv3 traps at the same
point.

This will allow future changes to introduce trap configuration on
a per-VM basis.

Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20240827152517.3909653-2-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/sys_regs.c
arch/arm64/kvm/vgic/vgic-v3.c
arch/arm64/kvm/vgic/vgic.h

index 31e49da867ffc32ecb66bf30bd0e667ef441170f..257c8da23a4e67ec933a648822b3e108407cd54c 100644 (file)
@@ -4551,6 +4551,7 @@ void kvm_calculate_traps(struct kvm_vcpu *vcpu)
 
        mutex_lock(&kvm->arch.config_lock);
        vcpu_set_hcr(vcpu);
+       vcpu_set_ich_hcr(vcpu);
 
        if (cpus_have_final_cap(ARM64_HAS_HCX)) {
                /*
index 3eecdd2f4b8f552665096a2c3d1528c66f468c77..11718412921fd4438d2a3b1ddf2ce6d24ebe34a3 100644 (file)
@@ -292,6 +292,15 @@ void vgic_v3_enable(struct kvm_vcpu *vcpu)
 
        /* Get the show on the road... */
        vgic_v3->vgic_hcr = ICH_HCR_EN;
+}
+
+void vcpu_set_ich_hcr(struct kvm_vcpu *vcpu)
+{
+       struct vgic_v3_cpu_if *vgic_v3 = &vcpu->arch.vgic_cpu.vgic_v3;
+
+       if (!kvm_has_gicv3(vcpu->kvm))
+               return;
+
        if (group0_trap)
                vgic_v3->vgic_hcr |= ICH_HCR_TALL0;
        if (group1_trap)
index 8532bfe3fed40c6fcfb05515bf0709e59278d07b..c72c38b442340fdb6eac2a7936e04e4258b1091e 100644 (file)
@@ -346,6 +346,8 @@ void vgic_v4_configure_vsgis(struct kvm *kvm);
 void vgic_v4_get_vlpi_state(struct vgic_irq *irq, bool *val);
 int vgic_v4_request_vpe_irq(struct kvm_vcpu *vcpu, int irq);
 
+void vcpu_set_ich_hcr(struct kvm_vcpu *vcpu);
+
 static inline bool kvm_has_gicv3(struct kvm *kvm)
 {
        return (static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif) &&