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

Marc Zyngier maz at kernel.org
Thu Nov 20 06:51:44 PST 2025


On Thu, 20 Nov 2025 14:34:19 +0000,
Joey Gouly <joey.gouly at arm.com> wrote:
> 
> On Thu, Nov 20, 2025 at 01:31:59PM +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.
> > 
> > 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 84e6f04220589..40f32b017f107 100644
> > --- a/arch/arm64/kvm/sys_regs.c
> > +++ b/arch/arm64/kvm/sys_regs.c
> > @@ -5558,6 +5558,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)))
> > +		vcpu->arch.hcr_el2 |= HCR_TID5;
> 
> This is because we want to enable the trapping regardless of CONFIG_ARM64_MTE
> (so we can't use system_supports_mte()).

Indeed. In general, we cannot rely on the kernel's own configuration,
since the guest sees most of the actual HW.

> 
> Reviewed-by: Joey Gouly <joey.gouly at arm.com>

Thanks!

	M.

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



More information about the linux-arm-kernel mailing list