Skip to content

Commit d78a14d

Browse files
author
Marc Zyngier
committed
KVM: arm64: Handle FEAT_IDST for sysregs without specific handlers
Add a bit of infrastrtcture to triage_sysreg_trap() to handle the case of registers falling into the Feature ID space that do not have a local handler. For these, we can directly apply the FEAT_IDST semantics and inject an EC=0x18 exception. Otherwise, an UNDEF will do. Reviewed-by: Joey Gouly <joey.gouly@arm.com> Reviewed-by: Yuan Yao <yaoyuan@linux.alibaba.com> Link: https://patch.msgid.link/20260108173233.2911955-5-maz@kernel.org Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 19f7567 commit d78a14d

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

arch/arm64/kvm/emulate-nested.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,6 +2588,19 @@ bool triage_sysreg_trap(struct kvm_vcpu *vcpu, int *sr_index)
25882588

25892589
params = esr_sys64_to_params(esr);
25902590

2591+
/*
2592+
* This implements the pseudocode UnimplementedIDRegister()
2593+
* helper for the purpose of dealing with FEAT_IDST.
2594+
*/
2595+
if (in_feat_id_space(&params)) {
2596+
if (kvm_has_feat(vcpu->kvm, ID_AA64MMFR2_EL1, IDS, IMP))
2597+
kvm_inject_sync(vcpu, kvm_vcpu_get_esr(vcpu));
2598+
else
2599+
kvm_inject_undefined(vcpu);
2600+
2601+
return true;
2602+
}
2603+
25912604
/*
25922605
* Check for the IMPDEF range, as per DDI0487 J.a,
25932606
* D18.3.2 Reserved encodings for IMPLEMENTATION

arch/arm64/kvm/sys_regs.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ struct sys_reg_params {
4949
.Op2 = ((esr) >> 17) & 0x7, \
5050
.is_write = !((esr) & 1) })
5151

52+
/*
53+
* The Feature ID space is defined as the System register space in AArch64
54+
* with op0==3, op1=={0, 1, 3}, CRn==0, CRm=={0-7}, op2=={0-7}.
55+
*/
56+
static inline bool in_feat_id_space(struct sys_reg_params *p)
57+
{
58+
return (p->Op0 == 3 && !(p->Op1 & 0b100) && p->Op1 != 2 &&
59+
p->CRn == 0 && !(p->CRm & 0b1000));
60+
}
61+
5262
struct sys_reg_desc {
5363
/* Sysreg string for debug */
5464
const char *name;

0 commit comments

Comments
 (0)