[PATCH v9 03/10] arm64/kvm: expose FEAT_MTE_TAGGED_FAR feature to guest

Marc Zyngier maz at kernel.org
Wed Jun 18 09:43:07 PDT 2025


In general, please use a patch title format that matches the one used
for the subsystem. For KVM, that'd be "KVM: arm64: Expose ..."/

On Wed, 18 Jun 2025 09:45:06 +0100,
Yeoreum Yun <yeoreum.yun at arm.com> wrote:
> 
> expose FEAT_MTE_TAGGED_FAR feature to guest.
> 
> Signed-off-by: Yeoreum Yun <yeoreum.yun at arm.com>
> ---
>  arch/arm64/kvm/sys_regs.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index 76c2f0da821f..c8c92cb9da01 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -1586,7 +1586,7 @@ static u64 __kvm_read_sanitised_id_reg(const struct kvm_vcpu *vcpu,
>  				       const struct sys_reg_desc *r)
>  {
>  	u32 id = reg_to_encoding(r);
> -	u64 val;
> +	u64 val, mask;
>  
>  	if (sysreg_visible_as_raz(vcpu, r))
>  		return 0;
> @@ -1617,8 +1617,12 @@ static u64 __kvm_read_sanitised_id_reg(const struct kvm_vcpu *vcpu,
>  		val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_MPAM_frac);
>  		break;
>  	case SYS_ID_AA64PFR2_EL1:
> -		/* We only expose FPMR */
> -		val &= ID_AA64PFR2_EL1_FPMR;
> +		mask = ID_AA64PFR2_EL1_FPMR;
> +
> +		if (kvm_has_mte(vcpu->kvm))
> +			mask |= ID_AA64PFR2_EL1_MTEFAR;
> +
> +		val &= mask;

I don't think there is a need for an extra variable, and you could
follow the pattern established in this file by writing this as:

	val &= (ID_AA64PFR2_EL1_FPMR |
		(kvm_has_mte(vcpu->kvm) ? ID_AA64PFR2_EL1_MTEFAR : 0));

Not a big deal though.

Thanks,

	M.

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



More information about the linux-arm-kernel mailing list