kselftest/arm64: Miscelaneous MTE test updates
v2 cover kselftest/arm64: Miscelaneous MTE test updates
This series is just a set of minor tweaks and improvements for the MTE tests that I did while working on the asymmetric mode support for userspace which seemed like they might be worth keeping even though the prctl() for asymmetric mode got removed.
v2:
- Rebase onto v5.18-rc3
Mark Brown (4):
kselftest/arm64: Handle more kselftest result codes in MTE helpers kselftest/arm64: Log unexpected asynchronous MTE faults kselftest/arm64: Refactor parameter checking in mte_switch_mode() kselftest/arm64: Add simple test for MTE prctl
tools/testing/selftests/arm64/mte/.gitignore | 1 + .../testing/selftests/arm64/mte/check_prctl.c | 119 ++++++++++++++++++ .../selftests/arm64/mte/mte_common_util.c | 19 ++- .../selftests/arm64/mte/mte_common_util.h | 15 ++- 4 files changed, 149 insertions(+), 5 deletions(-) create mode 100644 tools/testing/selftests/arm64/mte/check_prctl.c
base-commit: b2d229d4ddb17db541098b83524d901257e93845
Signature · 1 line
2.30.2
PATCH v2 1/4 kselftest/arm64: Handle more kselftest result codes in MTE helpers
The MTE selftests have a helper evaluate_test() which translates a return code into a call to ksft_test_result_*(). Currently this only handles pass and fail, silently ignoring any other code. Update the helper to support skipped tests and log any unknown return codes as an error so we get at least some diagnostic if anything goes wrong.
--- .../testing/selftests/arm64/mte/mte_common_util.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
tools/testing/selftests/arm64/mte/mte_common_util.h +13 -2
@@ -75,10 +75,21 @@ unsigned int mte_get_pstate_tco(void);/* Test framework static inline functions/macros */ static inline void evaluate_test (int err,const char *msg) { -if (err ==KSFT_PASS ) +switch (err) { +case KSFT_PASS :ksft_test_result_pass (msg); -else if (err ==KSFT_FAIL ) +break ; +case KSFT_FAIL :ksft_test_result_fail (msg); +break ; +case KSFT_SKIP : +ksft_test_result_skip (msg); +break ; +default : +ksft_test_result_error ("Unknown return code %d from %s" , + err, msg); +break ; + } } static inline int check_allocated_memory(void *ptr, size_t size,
Signature · 1 line
2.30.2
PATCH v2 2/4 kselftest/arm64: Log unexpected asynchronous MTE faults
In reply to Mark BrownHelp people figure out problems by printing a diagnostic when we get an unexpected asynchronous fault.
--- tools/testing/selftests/arm64/mte/mte_common_util.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/arm64/mte/mte_common_util.c +4 -0
@@ -37,6 +37,10 @@ void mte_default_handler(int signum, siginfo_t *si, void *uc)if (si->si_code ==SEGV_MTEAERR ) {if (cur_mte_cxt.trig_si_code == si->si_code) cur_mte_cxt.fault_valid = true; +else +ksft_print_msg ("Got unexpected SEGV_MTEAERR at pc=$lx, fault addr=%lx\n" , + ((ucontext_t *)uc)->uc_mcontext.pc, + addr);return ; }/* Compare the context for precise error */
Signature · 1 line
2.30.2
PATCH v2 4/4 kselftest/arm64: Add simple test for MTE prctl
In reply to Mark BrownThe current tests use the prctls for various things but there's no coverage of the edges of the interface so add some basics. This isn't hugely useful as it is (it originally had some coverage for the combinations with asymmetric mode but we removed the prctl() for that) but it might be a helpful starting point for future work, for example covering error handling.
--- tools/testing/selftests/arm64/mte/.gitignore | 1 + .../testing/selftests/arm64/mte/check_prctl.c | 119 ++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 tools/testing/selftests/arm64/mte/check_prctl.c
tools/testing/selftests/arm64/mte/.gitignore +1 -0
@@ -3,5 +3,6 @@ check_gcr_el1_cswitch check_tags_inclusion check_child_memory check_mmap_options +check_prctl check_ksm_options check_user_mem
tools/testing/selftests/arm64/mte/check_prctl.c new file +119 -0
119 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v2 3/4 kselftest/arm64: Refactor parameter checking in mte_switch_mode()
In reply to Mark BrownCurrently we just have a big if statement with a non-specific diagnostic checking both the mode and the tag. Since we'll need to dynamically check for asymmetric mode support in the system and to improve debugability split these checks out.
--- .../testing/selftests/arm64/mte/mte_common_util.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
tools/testing/selftests/arm64/mte/mte_common_util.c +12 -3
@@ -273,9 +273,18 @@ int mte_switch_mode(int mte_option, unsigned long incl_mask) {unsigned long en =0 ; -if (!(mte_option ==MTE_SYNC_ERR || mte_option ==MTE_ASYNC_ERR || - mte_option ==MTE_NONE_ERR || incl_mask <=MTE_ALLOW_NON_ZERO_TAG )) { -ksft_print_msg ("FAIL: Invalid mte config option\n" ); +switch (mte_option) { +case MTE_NONE_ERR : +case MTE_SYNC_ERR : +case MTE_ASYNC_ERR : +break ; +default : +ksft_print_msg ("FAIL: Invalid MTE option %x\n" , mte_option); +return -EINVAL ; + } + +if (!(incl_mask <=MTE_ALLOW_NON_ZERO_TAG )) { +ksft_print_msg ("FAIL: Invalid incl_mask %lx\n" , incl_mask);return -EINVAL ; } en =PR_TAGGED_ADDR_ENABLE ;
Signature · 1 line
2.30.2