[PATCH 0/5] KVM: arm64: Make ICH_VTR_EL2 accesses an inlined literal
Marc Zyngier
maz at kernel.org
Mon Jul 20 06:22:14 PDT 2026
I did it again.
I was looking at NV traces, and realised that we were trapping a whole
lot of accesses to ICH_VTR_EL2. But ICH_VTR_EL2 really is a constant
from a hypervisor perspective, and we usually cache this in memory, just
like any other ID register.
We do have a variable for this in kvm_vgic_global_state, but we don't
map this one at EL2 since 8aaf3f7dce746 ("KVM: arm64: Don't map
'kvm_vgic_global_state' at EL2 with pKVM").
So what can we do? We can revert back to mapping the global state, but
that's not a very good idea. Or we can be creative and turn the
ICH_VTR_EL2 accesses into a runtime constant patched into the
code. Since we already have a bunch of similar things for the GICv3
traps, that's no big deal.
And for consistency, let's kill kvm_vgic_global_state.ich_vtr_el2
altogether, so that there is only a single efficient way to read
ICH_VTR_EL2.
As usual, this has a significant impact on deeply nested workloads, a
solid 5% reduction in elapsed time for an L3 Linux guest running under
nested KVM instances. I expect this to benefit KVM running under other
hypervisors as well.
Patches on top of -rc3.
Marc Zyngier (5):
KVM: arm64: vgic-v3: Make vtr_to_* helpers use architectural field
symbols
KVM: arm64: Add a helper providing an inlined literal value for
ICH_VTR_EL2
KVM: arm64: Convert most ICH_VTR_EL2 accesses to inlined literal value
KVM: arm64: vgic-v3: Simplify initial GICv3 configuration sampling
KVM: arm64: vgic-v3: Kill kvm_vgic_global_state.ich_vtr_el2
arch/arm64/kernel/image-vars.h | 1 +
arch/arm64/kvm/hyp/vgic-v3-sr.c | 29 ++++++--------
arch/arm64/kvm/nested.c | 3 +-
arch/arm64/kvm/vgic-sys-reg-v3.c | 8 ++--
arch/arm64/kvm/vgic/vgic-v3.c | 69 +++++++++++++++++++++++++++-----
arch/arm64/kvm/vgic/vgic-v5.c | 5 +--
arch/arm64/kvm/vgic/vgic.h | 39 +++++++++++++-----
include/kvm/arm_vgic.h | 2 -
8 files changed, 108 insertions(+), 48 deletions(-)
--
2.47.3
More information about the linux-arm-kernel
mailing list