Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+23
+13
arch/arm64/kvm/emulate-nested.c
··· 2589 2589 params = esr_sys64_to_params(esr); 2590 2590 2591 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 + 2604 + /* 2592 2605 * Check for the IMPDEF range, as per DDI0487 J.a, 2593 2606 * D18.3.2 Reserved encodings for IMPLEMENTATION 2594 2607 * DEFINED registers.
+10
arch/arm64/kvm/sys_regs.h
··· 49 49 .Op2 = ((esr) >> 17) & 0x7, \ 50 50 .is_write = !((esr) & 1) }) 51 51 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 + 52 62 struct sys_reg_desc { 53 63 /* Sysreg string for debug */ 54 64 const char *name;