[PATCH 3/4] KVM: arm64: nv: Don't mask VTCR_EL2.HA if FEAT_HAFDBS is present

Marc Zyngier maz at kernel.org
Fri Nov 28 07:46:44 PST 2025


On Fri, 28 Nov 2025 10:09:45 +0000,
Alexandru Elisei <alexandru.elisei at arm.com> wrote:
> 
> Commit 39db933ba67f ("KVM: arm64: nv: Implement HW access flag management
> in stage-2 SW PTW") added support for hardware updates to the access flag
> to stage 2 if the feature is available to the virtual machine, but forgot
> to remove the VTCR_EL2.HA bit from the res0 mask for the register. Remove
> it from the mask to allow the VM to use the feature.
> 
> Fixes: 39db933ba67f ("KVM: arm64: nv: Implement HW access flag management in stage-2 SW PTW")
> Signed-off-by: Alexandru Elisei <alexandru.elisei at arm.com>
> ---
>  arch/arm64/kvm/nested.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
> index 911fc99ed99d..7a34163f6c68 100644
> --- a/arch/arm64/kvm/nested.c
> +++ b/arch/arm64/kvm/nested.c
> @@ -1719,7 +1719,9 @@ int kvm_init_nv_sysregs(struct kvm_vcpu *vcpu)
>  	set_sysreg_masks(kvm, VTTBR_EL2, res0, res1);
>  
>  	/* VTCR_EL2 */
> -	res0 = GENMASK(63, 32) | GENMASK(30, 20);
> +	res0 = GENMASK(63, 32) | GENMASK(30, 22) | BIT(20);
> +	if (!kvm_has_feat(kvm, ID_AA64MMFR1_EL1, HAFDBS, AF))
> +		res0 |= VTCR_EL2_HA;
>  	res1 = BIT(31);
>  	set_sysreg_masks(kvm, VTCR_EL2, res0, res1);
>  

The fix is correct, but I really do not want to add more of these
tedious checks, one after the other. We should fix this once and for
all by converting VTCR_EL2 to the feature dependency infrastructure
and be done with it.

I've pushed a small series at [1] that does that (very lightly
tested).

Thanks,

	M.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/vtcr

-- 
Without deviation from the norm, progress is not possible.



More information about the linux-arm-kernel mailing list