Re: [PATCH 1/6] kselftest/arm64: Add utilities and a test to validate mte memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 21, 2020 at 03:18:19PM +0100, Catalin Marinas wrote:
> On Tue, Sep 01, 2020 at 02:57:14PM +0530, Amit Daniel Kachhap wrote:
> > diff --git a/tools/testing/selftests/arm64/mte/mte_helper.S b/tools/testing/selftests/arm64/mte/mte_helper.S
> > new file mode 100644
> > index 000000000000..91af6d1293f8
> > --- /dev/null
> > +++ b/tools/testing/selftests/arm64/mte/mte_helper.S
> > @@ -0,0 +1,116 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +/* Copyright (C) 2020 ARM Limited */
> > +
> > +#include "mte_def.h"
> > +
> > +#define ENTRY(name) \
> > +	.globl name ;\
> > +	.p2align 2;\
> > +	.type name, @function ;\
> > +name:
> > +
> > +#define ENDPROC(name) \
> > +	.size name, .-name ;
> > +
> > +	.text
> > +/*
> > + * mte_insert_random_tag: Insert random tag and different from
> > + *			 the orginal tag if source pointer has it.
> > + * Input:
> > + *		x0 - source pointer with a tag/no-tag
> > + * Return:
> > + *		x0 - pointer with random tag
> > + */
> > +ENTRY(mte_insert_random_tag)
> > +	mov	x1, #0x0
> > +	gmi	x1, x0, x1
> > +	irg	x0, x0, x1
> > +	ret
> > +ENDPROC(mte_insert_random_tag)
> 
> What was the reason for gmi here? The test fails when you have an
> include mask of 0x8000 (exclude mask 0x7fff) and x0 has tag 0xf. In this
> case we exclude the only allowed tag here, so the CPU falls back to the
> default tag 0.
> 
> You can (a) stop the check_multiple_included_tags() earlier to have two
> allowed tags here, (b) clear the pointer old tag so that you don't end
> up in this scenario or (c) simply remove the gmi. My preference is the
> latter, we don't test the hardware here, we only want to check whether
> the kernel sets the GCR_EL1 correctly.
> 
> BTW, you also remove mov x1, #0, just:
> 
> 	irg	x0, x0, xzr

Ah, removing gmi breaks the check_user_mem test as it occasionally gets
the same tag when it expects to be different. I'll leave this to you to
fix, maybe use two different functions, one with gmi and another
without.

In addition, could you please add the PR_MTE_* definitions and PROT_MTE
to a header file in the MTE kselftests (mte-def.h maybe)? They should be
bracketed with #ifndef ... #endif. The reason is that we'd like to queue
these patches on their own branch on top of vanilla 5.9-rc3 rather than
on top of for-next/mte.

Thanks.

-- 
Catalin



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux