Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH 0/2] kselftest/arm64: mte: Minor fixes to the MTE hugetlb test
@ 2025-02-21  9:33 Catalin Marinas
  2025-02-21  9:33 ` [PATCH 1/2] kselftest/arm64: mte: Use the correct naming for tag check modes in check_hugetlb_options.c Catalin Marinas
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Catalin Marinas @ 2025-02-21  9:33 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kselftest; +Cc: Naresh Kamboju, Yang Shi, Shuah Khan

The first patch makes use of the correct terminology for synchronous and
asynchronous errors. The second patch checks whether PROT_MTE is
supported on hugetlb mappings before continuing with the tests. Such
support was added in 6.13 but people tend to use current kselftests on
older kernels. Avoid the failure reporting on such kernels, just skip
the tests.

Catalin Marinas (2):
  kselftest/arm64: mte: Use the correct naming for tag check modes in
    check_hugetlb_options.c
  kselftest/arm64: mte: Skip the hugetlb tests if MTE not supported on
    such mappings

 .../arm64/mte/check_hugetlb_options.c         | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] kselftest/arm64: mte: Use the correct naming for tag check modes in check_hugetlb_options.c
  2025-02-21  9:33 [PATCH 0/2] kselftest/arm64: mte: Minor fixes to the MTE hugetlb test Catalin Marinas
@ 2025-02-21  9:33 ` Catalin Marinas
  2025-02-21 17:21   ` Yang Shi
  2025-02-21  9:33 ` [PATCH 2/2] kselftest/arm64: mte: Skip the hugetlb tests if MTE not supported on such mappings Catalin Marinas
  2025-03-05 19:28 ` [PATCH 0/2] kselftest/arm64: mte: Minor fixes to the MTE hugetlb test Catalin Marinas
  2 siblings, 1 reply; 7+ messages in thread
From: Catalin Marinas @ 2025-02-21  9:33 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kselftest; +Cc: Naresh Kamboju, Yang Shi, Shuah Khan

The architecture doesn't define precise/imprecise MTE tag check modes,
only synchronous and asynchronous. Use the correct naming and also
ensure they match the MTE_{ASYNC,SYNC}_ERR type.

Fixes: 27879e8cb6b0 ("selftests: arm64: add hugetlb mte tests")
Cc: Yang Shi <yang@os.amperecomputing.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---
 tools/testing/selftests/arm64/mte/check_hugetlb_options.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/arm64/mte/check_hugetlb_options.c b/tools/testing/selftests/arm64/mte/check_hugetlb_options.c
index 303260a6dc65..11f812635b51 100644
--- a/tools/testing/selftests/arm64/mte/check_hugetlb_options.c
+++ b/tools/testing/selftests/arm64/mte/check_hugetlb_options.c
@@ -270,13 +270,13 @@ int main(int argc, char *argv[])
 	"Check clear PROT_MTE flags with private mapping and sync error mode and mmap/mprotect memory\n");
 
 	evaluate_test(check_child_hugetlb_memory_mapping(USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE | MAP_HUGETLB),
-		"Check child hugetlb memory with private mapping, precise mode and mmap memory\n");
+		"Check child hugetlb memory with private mapping, sync error mode and mmap memory\n");
 	evaluate_test(check_child_hugetlb_memory_mapping(USE_MMAP, MTE_ASYNC_ERR, MAP_PRIVATE | MAP_HUGETLB),
-		"Check child hugetlb memory with private mapping, precise mode and mmap memory\n");
+		"Check child hugetlb memory with private mapping, async error mode and mmap memory\n");
 	evaluate_test(check_child_hugetlb_memory_mapping(USE_MPROTECT, MTE_SYNC_ERR, MAP_PRIVATE | MAP_HUGETLB),
-		"Check child hugetlb memory with private mapping, precise mode and mmap/mprotect memory\n");
+		"Check child hugetlb memory with private mapping, sync error mode and mmap/mprotect memory\n");
 	evaluate_test(check_child_hugetlb_memory_mapping(USE_MPROTECT, MTE_ASYNC_ERR, MAP_PRIVATE | MAP_HUGETLB),
-		"Check child hugetlb memory with private mapping, precise mode and mmap/mprotect memory\n");
+		"Check child hugetlb memory with private mapping, async error mode and mmap/mprotect memory\n");
 
 	mte_restore_setup();
 	free_hugetlb();

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] kselftest/arm64: mte: Skip the hugetlb tests if MTE not supported on such mappings
  2025-02-21  9:33 [PATCH 0/2] kselftest/arm64: mte: Minor fixes to the MTE hugetlb test Catalin Marinas
  2025-02-21  9:33 ` [PATCH 1/2] kselftest/arm64: mte: Use the correct naming for tag check modes in check_hugetlb_options.c Catalin Marinas
@ 2025-02-21  9:33 ` Catalin Marinas
  2025-02-21 17:22   ` Yang Shi
  2025-02-21 17:38   ` Dev Jain
  2025-03-05 19:28 ` [PATCH 0/2] kselftest/arm64: mte: Minor fixes to the MTE hugetlb test Catalin Marinas
  2 siblings, 2 replies; 7+ messages in thread
From: Catalin Marinas @ 2025-02-21  9:33 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kselftest; +Cc: Naresh Kamboju, Yang Shi, Shuah Khan

While the kselftest was added at the same time with the kernel support
for MTE on hugetlb mappings, the tests may be run on older kernels. Skip
the tests if PROT_MTE is not supported on MAP_HUGETLB mappings.

Fixes: 27879e8cb6b0 ("selftests: arm64: add hugetlb mte tests")
Cc: Yang Shi <yang@os.amperecomputing.com>
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---
 .../selftests/arm64/mte/check_hugetlb_options.c       | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/testing/selftests/arm64/mte/check_hugetlb_options.c b/tools/testing/selftests/arm64/mte/check_hugetlb_options.c
index 11f812635b51..3bfcd3848432 100644
--- a/tools/testing/selftests/arm64/mte/check_hugetlb_options.c
+++ b/tools/testing/selftests/arm64/mte/check_hugetlb_options.c
@@ -227,6 +227,8 @@ static int check_child_hugetlb_memory_mapping(int mem_type, int mode, int mappin
 int main(int argc, char *argv[])
 {
 	int err;
+	void *map_ptr;
+	unsigned long map_size;
 
 	err = mte_default_setup();
 	if (err)
@@ -243,6 +245,15 @@ int main(int argc, char *argv[])
 		return KSFT_FAIL;
 	}
 
+	/* Check if MTE supports hugetlb mappings */
+	map_size = default_huge_page_size();
+	map_ptr = mmap(NULL, map_size, PROT_READ | PROT_MTE,
+		       MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
+	if (map_ptr == MAP_FAILED)
+		ksft_exit_skip("PROT_MTE not supported with MAP_HUGETLB mappings\n");
+	else
+		munmap(map_ptr, map_size);
+
 	/* Set test plan */
 	ksft_set_plan(12);
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] kselftest/arm64: mte: Use the correct naming for tag check modes in check_hugetlb_options.c
  2025-02-21  9:33 ` [PATCH 1/2] kselftest/arm64: mte: Use the correct naming for tag check modes in check_hugetlb_options.c Catalin Marinas
@ 2025-02-21 17:21   ` Yang Shi
  0 siblings, 0 replies; 7+ messages in thread
From: Yang Shi @ 2025-02-21 17:21 UTC (permalink / raw)
  To: Catalin Marinas, linux-arm-kernel, linux-kselftest
  Cc: Naresh Kamboju, Shuah Khan




On 2/21/25 1:33 AM, Catalin Marinas wrote:
> The architecture doesn't define precise/imprecise MTE tag check modes,
> only synchronous and asynchronous. Use the correct naming and also
> ensure they match the MTE_{ASYNC,SYNC}_ERR type.
>
> Fixes: 27879e8cb6b0 ("selftests: arm64: add hugetlb mte tests")
> Cc: Yang Shi <yang@os.amperecomputing.com>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> ---
>   tools/testing/selftests/arm64/mte/check_hugetlb_options.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)

Reviewed-by: Yang Shi <yang@os.amperecomputing.com>

>
> diff --git a/tools/testing/selftests/arm64/mte/check_hugetlb_options.c b/tools/testing/selftests/arm64/mte/check_hugetlb_options.c
> index 303260a6dc65..11f812635b51 100644
> --- a/tools/testing/selftests/arm64/mte/check_hugetlb_options.c
> +++ b/tools/testing/selftests/arm64/mte/check_hugetlb_options.c
> @@ -270,13 +270,13 @@ int main(int argc, char *argv[])
>   	"Check clear PROT_MTE flags with private mapping and sync error mode and mmap/mprotect memory\n");
>   
>   	evaluate_test(check_child_hugetlb_memory_mapping(USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE | MAP_HUGETLB),
> -		"Check child hugetlb memory with private mapping, precise mode and mmap memory\n");
> +		"Check child hugetlb memory with private mapping, sync error mode and mmap memory\n");
>   	evaluate_test(check_child_hugetlb_memory_mapping(USE_MMAP, MTE_ASYNC_ERR, MAP_PRIVATE | MAP_HUGETLB),
> -		"Check child hugetlb memory with private mapping, precise mode and mmap memory\n");
> +		"Check child hugetlb memory with private mapping, async error mode and mmap memory\n");
>   	evaluate_test(check_child_hugetlb_memory_mapping(USE_MPROTECT, MTE_SYNC_ERR, MAP_PRIVATE | MAP_HUGETLB),
> -		"Check child hugetlb memory with private mapping, precise mode and mmap/mprotect memory\n");
> +		"Check child hugetlb memory with private mapping, sync error mode and mmap/mprotect memory\n");
>   	evaluate_test(check_child_hugetlb_memory_mapping(USE_MPROTECT, MTE_ASYNC_ERR, MAP_PRIVATE | MAP_HUGETLB),
> -		"Check child hugetlb memory with private mapping, precise mode and mmap/mprotect memory\n");
> +		"Check child hugetlb memory with private mapping, async error mode and mmap/mprotect memory\n");
>   
>   	mte_restore_setup();
>   	free_hugetlb();


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] kselftest/arm64: mte: Skip the hugetlb tests if MTE not supported on such mappings
  2025-02-21  9:33 ` [PATCH 2/2] kselftest/arm64: mte: Skip the hugetlb tests if MTE not supported on such mappings Catalin Marinas
@ 2025-02-21 17:22   ` Yang Shi
  2025-02-21 17:38   ` Dev Jain
  1 sibling, 0 replies; 7+ messages in thread
From: Yang Shi @ 2025-02-21 17:22 UTC (permalink / raw)
  To: Catalin Marinas, linux-arm-kernel, linux-kselftest
  Cc: Naresh Kamboju, Shuah Khan




On 2/21/25 1:33 AM, Catalin Marinas wrote:
> While the kselftest was added at the same time with the kernel support
> for MTE on hugetlb mappings, the tests may be run on older kernels. Skip
> the tests if PROT_MTE is not supported on MAP_HUGETLB mappings.
>
> Fixes: 27879e8cb6b0 ("selftests: arm64: add hugetlb mte tests")
> Cc: Yang Shi <yang@os.amperecomputing.com>
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> ---
>   .../selftests/arm64/mte/check_hugetlb_options.c       | 11 +++++++++++
>   1 file changed, 11 insertions(+)

Reviewed-by: Yang Shi <yang@os.amperecomputing.com>

>
> diff --git a/tools/testing/selftests/arm64/mte/check_hugetlb_options.c b/tools/testing/selftests/arm64/mte/check_hugetlb_options.c
> index 11f812635b51..3bfcd3848432 100644
> --- a/tools/testing/selftests/arm64/mte/check_hugetlb_options.c
> +++ b/tools/testing/selftests/arm64/mte/check_hugetlb_options.c
> @@ -227,6 +227,8 @@ static int check_child_hugetlb_memory_mapping(int mem_type, int mode, int mappin
>   int main(int argc, char *argv[])
>   {
>   	int err;
> +	void *map_ptr;
> +	unsigned long map_size;
>   
>   	err = mte_default_setup();
>   	if (err)
> @@ -243,6 +245,15 @@ int main(int argc, char *argv[])
>   		return KSFT_FAIL;
>   	}
>   
> +	/* Check if MTE supports hugetlb mappings */
> +	map_size = default_huge_page_size();
> +	map_ptr = mmap(NULL, map_size, PROT_READ | PROT_MTE,
> +		       MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
> +	if (map_ptr == MAP_FAILED)
> +		ksft_exit_skip("PROT_MTE not supported with MAP_HUGETLB mappings\n");
> +	else
> +		munmap(map_ptr, map_size);
> +
>   	/* Set test plan */
>   	ksft_set_plan(12);
>   


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] kselftest/arm64: mte: Skip the hugetlb tests if MTE not supported on such mappings
  2025-02-21  9:33 ` [PATCH 2/2] kselftest/arm64: mte: Skip the hugetlb tests if MTE not supported on such mappings Catalin Marinas
  2025-02-21 17:22   ` Yang Shi
@ 2025-02-21 17:38   ` Dev Jain
  1 sibling, 0 replies; 7+ messages in thread
From: Dev Jain @ 2025-02-21 17:38 UTC (permalink / raw)
  To: Catalin Marinas, linux-arm-kernel, linux-kselftest
  Cc: Naresh Kamboju, Yang Shi, Shuah Khan



On 21/02/25 3:03 pm, Catalin Marinas wrote:
> While the kselftest was added at the same time with the kernel support
> for MTE on hugetlb mappings, the tests may be run on older kernels. Skip
> the tests if PROT_MTE is not supported on MAP_HUGETLB mappings.
> 
> Fixes: 27879e8cb6b0 ("selftests: arm64: add hugetlb mte tests")
> Cc: Yang Shi <yang@os.amperecomputing.com>
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Reviewed-by: Dev Jain <dev.jain@arm.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] kselftest/arm64: mte: Minor fixes to the MTE hugetlb test
  2025-02-21  9:33 [PATCH 0/2] kselftest/arm64: mte: Minor fixes to the MTE hugetlb test Catalin Marinas
  2025-02-21  9:33 ` [PATCH 1/2] kselftest/arm64: mte: Use the correct naming for tag check modes in check_hugetlb_options.c Catalin Marinas
  2025-02-21  9:33 ` [PATCH 2/2] kselftest/arm64: mte: Skip the hugetlb tests if MTE not supported on such mappings Catalin Marinas
@ 2025-03-05 19:28 ` Catalin Marinas
  2 siblings, 0 replies; 7+ messages in thread
From: Catalin Marinas @ 2025-03-05 19:28 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kselftest, Catalin Marinas
  Cc: Will Deacon, Naresh Kamboju, Yang Shi, Shuah Khan

On Fri, 21 Feb 2025 09:33:29 +0000, Catalin Marinas wrote:
> The first patch makes use of the correct terminology for synchronous and
> asynchronous errors. The second patch checks whether PROT_MTE is
> supported on hugetlb mappings before continuing with the tests. Such
> support was added in 6.13 but people tend to use current kselftests on
> older kernels. Avoid the failure reporting on such kernels, just skip
> the tests.
> 
> [...]

Applied to arm64 (for-next/kselftest), thanks!

[1/2] kselftest/arm64: mte: Use the correct naming for tag check modes in check_hugetlb_options.c
      https://git.kernel.org/arm64/c/7ae95109c64d
[2/2] kselftest/arm64: mte: Skip the hugetlb tests if MTE not supported on such mappings
      https://git.kernel.org/arm64/c/306219d59b72

-- 
Catalin


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-03-05 19:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-21  9:33 [PATCH 0/2] kselftest/arm64: mte: Minor fixes to the MTE hugetlb test Catalin Marinas
2025-02-21  9:33 ` [PATCH 1/2] kselftest/arm64: mte: Use the correct naming for tag check modes in check_hugetlb_options.c Catalin Marinas
2025-02-21 17:21   ` Yang Shi
2025-02-21  9:33 ` [PATCH 2/2] kselftest/arm64: mte: Skip the hugetlb tests if MTE not supported on such mappings Catalin Marinas
2025-02-21 17:22   ` Yang Shi
2025-02-21 17:38   ` Dev Jain
2025-03-05 19:28 ` [PATCH 0/2] kselftest/arm64: mte: Minor fixes to the MTE hugetlb test Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox