All of lore.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Amit Daniel Kachhap <amit.kachhap@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	Shuah Khan <shuah@kernel.org>, Will Deacon <will@kernel.org>,
	Vincenzo Frascino <Vincenzo.Frascino@arm.com>,
	Gabor Kertesz <gabor.kertesz@arm.com>
Subject: Re: [PATCH 1/6] kselftest/arm64: Add utilities and a test to validate mte memory
Date: Mon, 21 Sep 2020 15:18:19 +0100	[thread overview]
Message-ID: <20200921141817.GC13882@gaia> (raw)
In-Reply-To: <20200901092719.9918-2-amit.kachhap@arm.com>

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

-- 
Catalin

WARNING: multiple messages have this Message-ID (diff)
From: Catalin Marinas <catalin.marinas@arm.com>
To: Amit Daniel Kachhap <amit.kachhap@arm.com>
Cc: Shuah Khan <shuah@kernel.org>,
	linux-kernel@vger.kernel.org,
	Gabor Kertesz <gabor.kertesz@arm.com>,
	linux-kselftest@vger.kernel.org,
	Vincenzo Frascino <Vincenzo.Frascino@arm.com>,
	Will Deacon <will@kernel.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/6] kselftest/arm64: Add utilities and a test to validate mte memory
Date: Mon, 21 Sep 2020 15:18:19 +0100	[thread overview]
Message-ID: <20200921141817.GC13882@gaia> (raw)
In-Reply-To: <20200901092719.9918-2-amit.kachhap@arm.com>

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

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-09-21 14:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01  9:27 [PATCH 0/6] kselftest: arm64/mte: Tests for user-space MTE Amit Daniel Kachhap
2020-09-01  9:27 ` Amit Daniel Kachhap
2020-09-01  9:27 ` [PATCH 1/6] kselftest/arm64: Add utilities and a test to validate mte memory Amit Daniel Kachhap
2020-09-01  9:27   ` Amit Daniel Kachhap
2020-09-21 11:36   ` Catalin Marinas
2020-09-21 11:36     ` Catalin Marinas
2020-09-21 14:18   ` Catalin Marinas [this message]
2020-09-21 14:18     ` Catalin Marinas
2020-09-21 16:43     ` Catalin Marinas
2020-09-21 16:43       ` Catalin Marinas
2020-09-01  9:27 ` [PATCH 2/6] kselftest/arm64: Verify mte tag inclusion via prctl Amit Daniel Kachhap
2020-09-01  9:27   ` Amit Daniel Kachhap
2020-09-01  9:27 ` [PATCH 3/6] kselftest/arm64: Check forked child mte memory accessibility Amit Daniel Kachhap
2020-09-01  9:27   ` Amit Daniel Kachhap
2020-09-01  9:27 ` [PATCH 4/6] kselftest/arm64: Verify all different mmap MTE options Amit Daniel Kachhap
2020-09-01  9:27   ` Amit Daniel Kachhap
2020-09-01  9:27 ` [PATCH 5/6] kselftest/arm64: Verify KSM page merge for MTE pages Amit Daniel Kachhap
2020-09-01  9:27   ` Amit Daniel Kachhap
2020-09-01  9:27 ` [PATCH 6/6] kselftest/arm64: Check mte tagged user address in kernel Amit Daniel Kachhap
2020-09-01  9:27   ` Amit Daniel Kachhap
2020-09-22 10:41   ` Catalin Marinas
2020-09-22 10:41     ` Catalin Marinas
2020-09-23  7:06     ` Amit Kachhap
2020-09-23  7:06       ` Amit Kachhap
2020-09-23  8:49       ` Catalin Marinas
2020-09-23  8:49         ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200921141817.GC13882@gaia \
    --to=catalin.marinas@arm.com \
    --cc=Vincenzo.Frascino@arm.com \
    --cc=amit.kachhap@arm.com \
    --cc=gabor.kertesz@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.