[PATCH v22 02/16] KVM: arm64: Drop the SPSR_EL1 and ELR_EL1 trap accessors

From: Mark Brown

Date: Mon Nov 30 2026 - 11:43:14 EST


An EL1 access to SPSR_EL1 or ELR_EL1 traps to EL2 only when the
effective HCR_EL2.{NV2,NV1,NV} is 011. The hypervisor itself never runs
a guest with this mode, and since commit 0f1bdabb82be ("KVM: arm64:
Force HCR_EL2.NV1 to RES0 unconditionally") guests cannot configure it
either so we do not need to emulate it.

Remove the unreachable accessors and their sysreg descriptors, they are
redundant and if this were not the case would need to be extended to
enforce EXLOCK once support for GCS guests is added. Userspace accesses
both registers through the core register interface so is unaffected.

Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
---
arch/arm64/kvm/sys_regs.c | 27 ---------------------------
1 file changed, 27 deletions(-)

diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 5555e17a7710..399dfcf102ae 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -2852,30 +2852,6 @@ static bool access_sp_el1(struct kvm_vcpu *vcpu,
return true;
}

-static bool access_elr(struct kvm_vcpu *vcpu,
- struct sys_reg_params *p,
- const struct sys_reg_desc *r)
-{
- if (p->is_write)
- vcpu_write_sys_reg(vcpu, p->regval, ELR_EL1);
- else
- p->regval = vcpu_read_sys_reg(vcpu, ELR_EL1);
-
- return true;
-}
-
-static bool access_spsr(struct kvm_vcpu *vcpu,
- struct sys_reg_params *p,
- const struct sys_reg_desc *r)
-{
- if (p->is_write)
- __vcpu_assign_sys_reg(vcpu, SPSR_EL1, p->regval);
- else
- p->regval = __vcpu_sys_reg(vcpu, SPSR_EL1);
-
- return true;
-}
-
static bool access_cntkctl_el12(struct kvm_vcpu *vcpu,
struct sys_reg_params *p,
const struct sys_reg_desc *r)
@@ -3510,9 +3486,6 @@ static const struct sys_reg_desc sys_reg_descs[] = {
PTRAUTH_KEY(APDB),
PTRAUTH_KEY(APGA),

- { SYS_DESC(SYS_SPSR_EL1), access_spsr},
- { SYS_DESC(SYS_ELR_EL1), access_elr},
-
{ SYS_DESC(SYS_ICC_PMR_EL1), undef_access },

{ SYS_DESC(SYS_AFSR0_EL1), access_vm_reg, reset_unknown, AFSR0_EL1 },

--
2.47.3