Skip to content

Commit d2137ba

Browse files
author
Marc Zyngier
committed
KVM: arm64: Move GICv3 trap configuration to kvm_calculate_traps()
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>
1 parent 5be63fc commit d2137ba

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

arch/arm64/kvm/sys_regs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4551,6 +4551,7 @@ void kvm_calculate_traps(struct kvm_vcpu *vcpu)
45514551

45524552
mutex_lock(&kvm->arch.config_lock);
45534553
vcpu_set_hcr(vcpu);
4554+
vcpu_set_ich_hcr(vcpu);
45544555

45554556
if (cpus_have_final_cap(ARM64_HAS_HCX)) {
45564557
/*

arch/arm64/kvm/vgic/vgic-v3.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,15 @@ void vgic_v3_enable(struct kvm_vcpu *vcpu)
292292

293293
/* Get the show on the road... */
294294
vgic_v3->vgic_hcr = ICH_HCR_EN;
295+
}
296+
297+
void vcpu_set_ich_hcr(struct kvm_vcpu *vcpu)
298+
{
299+
struct vgic_v3_cpu_if *vgic_v3 = &vcpu->arch.vgic_cpu.vgic_v3;
300+
301+
if (!kvm_has_gicv3(vcpu->kvm))
302+
return;
303+
295304
if (group0_trap)
296305
vgic_v3->vgic_hcr |= ICH_HCR_TALL0;
297306
if (group1_trap)

arch/arm64/kvm/vgic/vgic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ void vgic_v4_configure_vsgis(struct kvm *kvm);
346346
void vgic_v4_get_vlpi_state(struct vgic_irq *irq, bool *val);
347347
int vgic_v4_request_vpe_irq(struct kvm_vcpu *vcpu, int irq);
348348

349+
void vcpu_set_ich_hcr(struct kvm_vcpu *vcpu);
350+
349351
static inline bool kvm_has_gicv3(struct kvm *kvm)
350352
{
351353
return (static_branch_unlikely(&kvm_vgic_global_state.gicv3_cpuif) &&

0 commit comments

Comments
 (0)