[PATCH v2 2/5] KVM: arm64: Force trap of GMID_EL1 when the guest doesn't have MTE

Marc Zyngier maz at kernel.org
Thu Nov 27 08:31:39 PST 2025


On Thu, 27 Nov 2025 06:37:13 +0000,
Oliver Upton <oupton at kernel.org> wrote:
> 
> On Wed, Nov 26, 2025 at 03:59:48PM +0000, Marc Zyngier wrote:
> > If our host has MTE, but the guest doesn't, make sure we set HCR_EL2.TID5
> > to force GMID_EL1 being trapped.
> > 
> > Reviewed-by: Joey Gouly <joey.gouly at arm.com>
> > Signed-off-by: Marc Zyngier <maz at kernel.org>
> > ---
> >  arch/arm64/kvm/sys_regs.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> > index 9e4c46fbfd802..2ca6862e935b5 100644
> > --- a/arch/arm64/kvm/sys_regs.c
> > +++ b/arch/arm64/kvm/sys_regs.c
> > @@ -5561,6 +5561,8 @@ static void vcpu_set_hcr(struct kvm_vcpu *vcpu)
> >  
> >  	if (kvm_has_mte(vcpu->kvm))
> >  		vcpu->arch.hcr_el2 |= HCR_ATA;
> > +	else if (id_aa64pfr1_mte(read_sanitised_ftr_reg(SYS_ID_AA64PFR1_EL1)))
> 
> This helper is ugly!

You think? :D

> 
> > +		vcpu->arch.hcr_el2 |= HCR_TID5;
> 
> How about setting the trap unconditionally when !kvm_has_mte()? Even in
> the case of asymmetry we'd want GMID_EL1 to trap.

Yup, that's a good point. I'll fix that.

	M.

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



More information about the linux-arm-kernel mailing list