Re: [PATCH v2 3/5] KVM: arm64: Add context-switch of ACCDATA_EL1

From: Arnd Bergmann

Date: Mon Oct 26 2026 - 13:35:48 EST


On Sun, Oct 25, 2026, at 08:51, Fuad Tabba wrote:
> return kvm_has_sctlr2(kern_hyp_va(vcpu->kvm));
> }
>
> +static inline bool ctxt_has_accdata(struct kvm_cpu_context *ctxt)
> +{
> + struct kvm_vcpu *vcpu;
> +
> + /* The host never uses ACCDATA_EL1 */
> + if (!cpus_have_final_cap(ARM64_HAS_LS64_ACCDATA) ||
> !ctxt_is_guest(ctxt))
> + return false;

Maybe add a wrapper for this as we have for other features?

In my patch I've converted the check to use this one now:

--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -909,6 +909,11 @@ static inline bool system_supports_bbml3(void)
return alternative_has_cap_unlikely(ARM64_HAS_BBML3);
}

+static inline bool system_supports_ls64_accdata(void)
+{
+ return cpus_have_final_cap(ARM64_HAS_LS64_ACCDATA);
+}
+
int do_emulate_mrs(struct pt_regs *regs, u32 sys_reg, u32 rt);
bool try_emulate_mrs(struct pt_regs *regs, u32 isn);

which makes sense to add in your patch first.

I think we'll also want a HWCAP3_LS64_ACCDATA exported to
userspace, but we can keep that separate.

Arnd