summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/arm64/gcs
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing/selftests/arm64/gcs')
-rw-r--r--tools/testing/selftests/arm64/gcs/basic-gcs.c40
-rw-r--r--tools/testing/selftests/arm64/gcs/gcs-util.h6
-rw-r--r--tools/testing/selftests/arm64/gcs/libc-gcs.c3
3 files changed, 18 insertions, 31 deletions
diff --git a/tools/testing/selftests/arm64/gcs/basic-gcs.c b/tools/testing/selftests/arm64/gcs/basic-gcs.c
index 250977abc398..ae4cce6afe2b 100644
--- a/tools/testing/selftests/arm64/gcs/basic-gcs.c
+++ b/tools/testing/selftests/arm64/gcs/basic-gcs.c
@@ -22,7 +22,7 @@ static size_t page_size = 65536;
static __attribute__((noinline)) void valid_gcs_function(void)
{
/* Do something the compiler can't optimise out */
- my_syscall1(__NR_prctl, PR_SVE_GET_VL);
+ syscall(__NR_prctl, PR_SVE_GET_VL);
}
static inline int gcs_set_status(unsigned long mode)
@@ -36,12 +36,10 @@ static inline int gcs_set_status(unsigned long mode)
* other 3 values passed in registers to the syscall are zero
* since the kernel validates them.
*/
- ret = my_syscall5(__NR_prctl, PR_SET_SHADOW_STACK_STATUS, mode,
- 0, 0, 0);
+ ret = syscall(__NR_prctl, PR_SET_SHADOW_STACK_STATUS, mode, 0, 0, 0);
if (ret == 0) {
- ret = my_syscall5(__NR_prctl, PR_GET_SHADOW_STACK_STATUS,
- &new_mode, 0, 0, 0);
+ ret = syscall(__NR_prctl, PR_GET_SHADOW_STACK_STATUS, &new_mode, 0, 0, 0);
if (ret == 0) {
if (new_mode != mode) {
ksft_print_msg("Mode set to %lx not %lx\n",
@@ -49,7 +47,7 @@ static inline int gcs_set_status(unsigned long mode)
ret = -EINVAL;
}
} else {
- ksft_print_msg("Failed to validate mode: %d\n", ret);
+ ksft_print_msg("Failed to validate mode: %d\n", errno);
}
if (enabling != chkfeat_gcs()) {
@@ -69,10 +67,9 @@ static bool read_status(void)
unsigned long state;
int ret;
- ret = my_syscall5(__NR_prctl, PR_GET_SHADOW_STACK_STATUS,
- &state, 0, 0, 0);
+ ret = syscall(__NR_prctl, PR_GET_SHADOW_STACK_STATUS, &state, 0, 0, 0);
if (ret != 0) {
- ksft_print_msg("Failed to read state: %d\n", ret);
+ ksft_print_msg("Failed to read state: %d\n", errno);
return false;
}
@@ -188,9 +185,8 @@ static bool map_guarded_stack(void)
int elem;
bool pass = true;
- buf = (void *)my_syscall3(__NR_map_shadow_stack, 0, page_size,
- SHADOW_STACK_SET_MARKER |
- SHADOW_STACK_SET_TOKEN);
+ buf = (void *)syscall(__NR_map_shadow_stack, 0, page_size,
+ SHADOW_STACK_SET_MARKER | SHADOW_STACK_SET_TOKEN);
if (buf == MAP_FAILED) {
ksft_print_msg("Failed to map %lu byte GCS: %d\n",
page_size, errno);
@@ -257,8 +253,7 @@ static bool test_fork(void)
valid_gcs_function();
get_gcspr();
- ret = my_syscall5(__NR_prctl, PR_GET_SHADOW_STACK_STATUS,
- &child_mode, 0, 0, 0);
+ ret = syscall(__NR_prctl, PR_GET_SHADOW_STACK_STATUS, &child_mode, 0, 0, 0);
if (ret == 0 && !(child_mode & PR_SHADOW_STACK_ENABLE)) {
ksft_print_msg("GCS not enabled in child\n");
ret = -EINVAL;
@@ -321,8 +316,7 @@ static bool test_vfork(void)
valid_gcs_function();
get_gcspr();
- ret = my_syscall5(__NR_prctl, PR_GET_SHADOW_STACK_STATUS,
- &child_mode, 0, 0, 0);
+ ret = syscall(__NR_prctl, PR_GET_SHADOW_STACK_STATUS, &child_mode, 0, 0, 0);
if (ret == 0 && !(child_mode & PR_SHADOW_STACK_ENABLE)) {
ksft_print_msg("GCS not enabled in child\n");
ret = EXIT_FAILURE;
@@ -390,17 +384,15 @@ int main(void)
if (!(getauxval(AT_HWCAP) & HWCAP_GCS))
ksft_exit_skip("SKIP GCS not supported\n");
- ret = my_syscall5(__NR_prctl, PR_GET_SHADOW_STACK_STATUS,
- &gcs_mode, 0, 0, 0);
+ ret = syscall(__NR_prctl, PR_GET_SHADOW_STACK_STATUS, &gcs_mode, 0, 0, 0);
if (ret != 0)
- ksft_exit_fail_msg("Failed to read GCS state: %d\n", ret);
+ ksft_exit_fail_msg("Failed to read GCS state: %d\n", errno);
if (!(gcs_mode & PR_SHADOW_STACK_ENABLE)) {
gcs_mode = PR_SHADOW_STACK_ENABLE;
- ret = my_syscall5(__NR_prctl, PR_SET_SHADOW_STACK_STATUS,
- gcs_mode, 0, 0, 0);
+ ret = syscall(__NR_prctl, PR_SET_SHADOW_STACK_STATUS, gcs_mode, 0, 0, 0);
if (ret != 0)
- ksft_exit_fail_msg("Failed to enable GCS: %d\n", ret);
+ ksft_exit_fail_msg("Failed to enable GCS: %d\n", errno);
}
ksft_set_plan(ARRAY_SIZE(tests));
@@ -410,9 +402,9 @@ int main(void)
}
/* One last test: disable GCS, we can do this one time */
- ret = my_syscall5(__NR_prctl, PR_SET_SHADOW_STACK_STATUS, 0, 0, 0, 0);
+ ret = syscall(__NR_prctl, PR_SET_SHADOW_STACK_STATUS, 0, 0, 0, 0);
if (ret != 0)
- ksft_print_msg("Failed to disable GCS: %d\n", ret);
+ ksft_print_msg("Failed to disable GCS: %d\n", errno);
ksft_finished();
diff --git a/tools/testing/selftests/arm64/gcs/gcs-util.h b/tools/testing/selftests/arm64/gcs/gcs-util.h
index c99a6b39ac14..7a81bb07ed4b 100644
--- a/tools/testing/selftests/arm64/gcs/gcs-util.h
+++ b/tools/testing/selftests/arm64/gcs/gcs-util.h
@@ -18,12 +18,6 @@
#ifndef NT_ARM_GCS
#define NT_ARM_GCS 0x410
-
-struct user_gcs {
- __u64 features_enabled;
- __u64 features_locked;
- __u64 gcspr_el0;
-};
#endif
/* Shadow Stack/Guarded Control Stack interface */
diff --git a/tools/testing/selftests/arm64/gcs/libc-gcs.c b/tools/testing/selftests/arm64/gcs/libc-gcs.c
index 17b2fabfec38..ddb0b2b20155 100644
--- a/tools/testing/selftests/arm64/gcs/libc-gcs.c
+++ b/tools/testing/selftests/arm64/gcs/libc-gcs.c
@@ -16,6 +16,7 @@
#include <asm/hwcap.h>
#include <asm/mman.h>
+#include <asm/ptrace.h>
#include <linux/compiler.h>
@@ -129,7 +130,7 @@ TEST(gcs_find_terminator)
* We can access a GCS via ptrace
*
* This could usefully have a fixture but note that each test is
- * fork()ed into a new child whcih causes issues. Might be better to
+ * fork()ed into a new child which causes issues. Might be better to
* lift at least some of this out into a separate, non-harness, test
* program.
*/