From: Joey Gouly <joey.gouly@arm.com>
To: <linux-arm-kernel@lists.infradead.org>
Cc: <nd@arm.com>, <broonie@kernel.org>, <catalin.marinas@arm.com>,
<joey.gouly@arm.com>, <shuah@kernel.org>, <will@kernel.org>
Subject: [PATCH v2 2/6] kselftest/arm64: mte: user_mem: rework error handling
Date: Thu, 3 Feb 2022 14:36:16 +0000 [thread overview]
Message-ID: <20220203143620.30629-3-joey.gouly@arm.com> (raw)
In-Reply-To: <20220203143620.30629-1-joey.gouly@arm.com>
This makes it easier to have multiple iterations in the test.
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 | 27 ++++++++++++-------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/arm64/mte/check_user_mem.c b/tools/testing/selftests/arm64/mte/check_user_mem.c
index 5a5a7e1f5789..e5bfeaeb64bb 100644
--- a/tools/testing/selftests/arm64/mte/check_user_mem.c
+++ b/tools/testing/selftests/arm64/mte/check_user_mem.c
@@ -27,7 +27,7 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping,
size_t len, read_len;
void *ptr, *ptr_next;
- err = KSFT_FAIL;
+ err = KSFT_PASS;
len = 2 * page_sz;
mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG);
fd = create_temp_file();
@@ -46,14 +46,18 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping,
/* Copy from file into buffer with valid tag */
read_len = read(fd, ptr, len);
mte_wait_after_trig();
- if (cur_mte_cxt.fault_valid || read_len < len)
+ if (cur_mte_cxt.fault_valid || read_len < len) {
+ err = KSFT_FAIL;
goto usermem_acc_err;
+ }
/* Verify same pattern is read */
for (i = 0; i < len; i++)
if (*(char *)(ptr + i) != val)
break;
- if (i < len)
+ if (i < len) {
+ err = KSFT_FAIL;
goto usermem_acc_err;
+ }
if (!tag_len)
tag_len = len - tag_offset;
@@ -71,12 +75,17 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping,
* mode without fault but may not fail in async mode as per the
* implemented MTE userspace support in Arm64 kernel.
*/
- if (mode == MTE_SYNC_ERR &&
- !cur_mte_cxt.fault_valid && read_len < len) {
- err = KSFT_PASS;
- } else if (mode == MTE_ASYNC_ERR &&
- !cur_mte_cxt.fault_valid && read_len == len) {
- err = KSFT_PASS;
+ if (cur_mte_cxt.fault_valid) {
+ err = KSFT_FAIL;
+ goto usermem_acc_err;
+ }
+ if (mode == MTE_SYNC_ERR && read_len < len) {
+ /* test passed */
+ } else if (mode == MTE_ASYNC_ERR && read_len == len) {
+ /* test passed */
+ } else {
+ err = KSFT_FAIL;
+ goto usermem_acc_err;
}
usermem_acc_err:
mte_free_memory((void *)ptr, len, mem_type, true);
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-02-03 14:40 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 ` Joey Gouly [this message]
2022-02-04 15:54 ` [PATCH v2 2/6] kselftest/arm64: mte: user_mem: rework error handling 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
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=20220203143620.30629-3-joey.gouly@arm.com \
--to=joey.gouly@arm.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).