[PATCH v2 2/2] arm64: mte: DC {GVA,GZVA} shouldn't be used when DCZID_EL0.DZP == 1

Catalin Marinas catalin.marinas at arm.com
Fri Dec 3 10:51:55 PST 2021


On Fri, Dec 03, 2021 at 06:29:48PM +0000, Catalin Marinas wrote:
> On Sun, Nov 07, 2021 at 11:11:49PM -0800, Reiji Watanabe wrote:
> > diff --git a/arch/arm64/lib/mte.S b/arch/arm64/lib/mte.S
> > index e83643b3995f..e62c048af337 100644
> > --- a/arch/arm64/lib/mte.S
> > +++ b/arch/arm64/lib/mte.S
> > @@ -43,17 +43,23 @@ SYM_FUNC_END(mte_clear_page_tags)
> >   *	x0 - address to the beginning of the page
> >   */
> >  SYM_FUNC_START(mte_zero_clear_page_tags)
> > +	and	x0, x0, #(1 << MTE_TAG_SHIFT) - 1	// clear the tag
> >  	mrs	x1, dczid_el0
> > +	tbnz	x1, #4, 2f	// Branch if DC GZVA is prohibited
> >  	and	w1, w1, #0xf
> >  	mov	x2, #4
> >  	lsl	x1, x2, x1
> > -	and	x0, x0, #(1 << MTE_TAG_SHIFT) - 1	// clear the tag
> >  
> >  1:	dc	gzva, x0
> >  	add	x0, x0, x1
> >  	tst	x0, #(PAGE_SIZE - 1)
> >  	b.ne	1b
> >  	ret
> > +
> > +2:	stzg	x0, [x0], #16
> 
> Nitpick: MTE_GRANULE_SIZE instead of 16.
> 
> > +	tst	x0, #(PAGE_SIZE - 1)
> > +	b.ne	2b
> > +	ret
> >  SYM_FUNC_END(mte_zero_clear_page_tags)
> 
> We can use stz2g here since we know it's always a PAGE_SIZE and an even
> number of tag granules.

I should have replied on v3. The comment is the same.

-- 
Catalin



More information about the linux-arm-kernel mailing list