All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: Joey Gouly <joey.gouly@arm.com>, linux-arm-kernel@lists.infradead.org
Cc: nd@arm.com, broonie@kernel.org, catalin.marinas@arm.com,
	shuah@kernel.org, will@kernel.org,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v2 4/6] kselftest/arm64: mte: user_mem: add test type enum
Date: Fri, 4 Feb 2022 08:59:03 -0700	[thread overview]
Message-ID: <4303f271-83ef-4181-4e62-49b0535d5abf@linuxfoundation.org> (raw)
In-Reply-To: <20220203143620.30629-5-joey.gouly@arm.com>

On 2/3/22 7:36 AM, Joey Gouly wrote:
> This enum will be used to parameterise the test to perform other syscalls
> than 'read'.
> 

More information here.

> Signed-off-by: Joey Gouly <joey.gouly@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Shuah Khan <shuah@kernel.org>
> ---
>   .../selftests/arm64/mte/check_user_mem.c      | 38 +++++++++++++------
>   1 file changed, 26 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/testing/selftests/arm64/mte/check_user_mem.c b/tools/testing/selftests/arm64/mte/check_user_mem.c
> index 35061ae23ed5..6d4aeb14027b 100644
> --- a/tools/testing/selftests/arm64/mte/check_user_mem.c
> +++ b/tools/testing/selftests/arm64/mte/check_user_mem.c
> @@ -19,12 +19,18 @@
>   
>   static size_t page_sz;
>   
> +enum test_type {
> +	READ_TEST,
> +	LAST_TEST,
> +};
> +
>   static int check_usermem_access_fault(int mem_type, int mode, int mapping,
> -                                      int tag_offset, int tag_len)
> +                                      int tag_offset, int tag_len,
> +                                      enum test_type test_type)
>   {
>   	int fd, i, err;
>   	char val = 'A';
> -	size_t len, read_len;
> +	ssize_t len, syscall_len;
>   	void *ptr, *ptr_next;
>   	int fileoff, ptroff, size;
>   	int sizes[] = {1, 2, 3, 8, 16, 32, 4096, page_sz};
> @@ -46,9 +52,9 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping,
>   	}
>   	mte_initialize_current_context(mode, (uintptr_t)ptr, len);
>   	/* Copy from file into buffer with valid tag */
> -	read_len = read(fd, ptr, len);
> +	syscall_len = read(fd, ptr, len);
>   	mte_wait_after_trig();
> -	if (cur_mte_cxt.fault_valid || read_len < len) {
> +	if (cur_mte_cxt.fault_valid || syscall_len < len) {
>   		err = KSFT_FAIL;
>   		goto usermem_acc_err;
>   	}
> @@ -73,8 +79,16 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping,
>   			for (i = 0; i < ARRAY_SIZE(sizes); i++) {
>   				size = sizes[i];
>   				lseek(fd, 0, 0);
> -				/* Copy from file into buffer with invalid tag */
> -				read_len = read(fd, ptr + ptroff, size);
> +
> +				/* perform file operation on buffer with invalid tag */
> +				switch (test_type) {
> +				case READ_TEST:
> +					syscall_len = read(fd, ptr + ptroff, size);
> +					break;
> +				case LAST_TEST:
> +					goto usermem_acc_err;
> +				}
> +
>   				mte_wait_after_trig();
>   				/*
>   				 * Accessing user memory in kernel with invalid tag should fail in sync
> @@ -85,9 +99,9 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping,
>   					err = KSFT_FAIL;
>   					goto usermem_acc_err;
>   				}
> -				if (mode == MTE_SYNC_ERR && read_len < len) {
> +				if (mode == MTE_SYNC_ERR && syscall_len < len) {
>   					/* test passed */
> -				} else if (mode == MTE_ASYNC_ERR && read_len == size) {
> +				} else if (mode == MTE_ASYNC_ERR && syscall_len == size) {
>   					/* test passed */
>   				} else {
>   					err = KSFT_FAIL;
> @@ -121,14 +135,14 @@ int main(int argc, char *argv[])
>   	/* Set test plan */
>   	ksft_set_plan(4);
>   
> -	evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE, page_sz, 0),
> +	evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE, page_sz, 0, READ_TEST),
>   		"Check memory access from kernel in sync mode, private mapping and mmap memory\n");
> -	evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_SHARED, page_sz, 0),
> +	evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_SHARED, page_sz, 0, READ_TEST),
>   		"Check memory access from kernel in sync mode, shared mapping and mmap memory\n");
>   
> -	evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_PRIVATE, page_sz, 0),
> +	evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_PRIVATE, page_sz, 0, READ_TEST),
>   		"Check memory access from kernel in async mode, private mapping and mmap memory\n");
> -	evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_SHARED, page_sz, 0),
> +	evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_SHARED, page_sz, 0, READ_TEST),
>   		"Check memory access from kernel in async mode, shared mapping and mmap memory\n");
>   
>   	mte_restore_setup();
> 

The rest looks good

With the above requested changes -

Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah

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

  reply	other threads:[~2022-02-04 16:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03 14:36 [PATCH v2 0/6] add more tests to MTE kselftests Joey Gouly
2022-02-03 14:36 ` [PATCH v2 1/6] kselftest/arm64: mte: user_mem: introduce tag_offset and tag_len Joey Gouly
2022-02-04 15:51   ` Shuah Khan
2022-02-03 14:36 ` [PATCH v2 2/6] kselftest/arm64: mte: user_mem: rework error handling Joey Gouly
2022-02-04 15:54   ` Shuah Khan
2022-02-03 14:36 ` [PATCH v2 3/6] kselftest/arm64: mte: user_mem: check different offsets and sizes Joey Gouly
2022-02-04 15:57   ` Shuah Khan
2022-02-03 14:36 ` [PATCH v2 4/6] kselftest/arm64: mte: user_mem: add test type enum Joey Gouly
2022-02-04 15:59   ` Shuah Khan [this message]
2022-02-03 14:36 ` [PATCH v2 5/6] kselftest/arm64: mte: user_mem: add more test types Joey Gouly
2022-02-04 16:01   ` Shuah Khan
2022-02-03 14:36 ` [PATCH v2 6/6] kselftest/arm64: mte: user_mem: test more combinations of values Joey Gouly
2022-02-04 16:02   ` Shuah Khan
2022-02-04 14:18 ` [PATCH v2 0/6] add more tests to MTE kselftests Mark Brown
2022-02-04 16:06 ` Shuah Khan

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=4303f271-83ef-4181-4e62-49b0535d5abf@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=nd@arm.com \
    --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.