Skip to content

Commit ce7a1cf

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Define helper for ICH_VTR_EL2
Move the computation of the ICH_VTR_EL2 value to a common location, so that it can be reused by the save/restore code. Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20250714122634.3334816-5-maz@kernel.org Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent c6ef468 commit ce7a1cf

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

arch/arm64/kvm/sys_regs.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,11 +2521,7 @@ static bool access_gic_vtr(struct kvm_vcpu *vcpu,
25212521
if (p->is_write)
25222522
return write_to_read_only(vcpu, p, r);
25232523

2524-
p->regval = kvm_vgic_global_state.ich_vtr_el2;
2525-
p->regval &= ~(ICH_VTR_EL2_DVIM |
2526-
ICH_VTR_EL2_A3V |
2527-
ICH_VTR_EL2_IDbits);
2528-
p->regval |= ICH_VTR_EL2_nV4;
2524+
p->regval = kvm_get_guest_vtr_el2();
25292525

25302526
return true;
25312527
}

arch/arm64/kvm/vgic/vgic.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@
6666

6767
#define KVM_ICC_SRE_EL2 (ICC_SRE_EL2_ENABLE | ICC_SRE_EL2_SRE | \
6868
ICC_SRE_EL1_DIB | ICC_SRE_EL1_DFB)
69+
#define KVM_ICH_VTR_EL2_RES0 (ICH_VTR_EL2_DVIM | \
70+
ICH_VTR_EL2_A3V | \
71+
ICH_VTR_EL2_IDbits)
72+
#define KVM_ICH_VTR_EL2_RES1 ICH_VTR_EL2_nV4
73+
74+
static inline u64 kvm_get_guest_vtr_el2(void)
75+
{
76+
u64 vtr;
77+
78+
vtr = kvm_vgic_global_state.ich_vtr_el2;
79+
vtr &= ~KVM_ICH_VTR_EL2_RES0;
80+
vtr |= KVM_ICH_VTR_EL2_RES1;
81+
82+
return vtr;
83+
}
6984

7085
/*
7186
* As per Documentation/virt/kvm/devices/arm-vgic-its.rst,

0 commit comments

Comments
 (0)