On 03/10/2023 07:41, Chaitanya S Prakash wrote:
[...]
diff --git a/tools/testing/selftests/arm64/morello/freestanding.c b/tools/testing/selftests/arm64/morello/freestanding.c index 45c0fa8b0914..a3d72482db7c 100644 --- a/tools/testing/selftests/arm64/morello/freestanding.c +++ b/tools/testing/selftests/arm64/morello/freestanding.c @@ -6,7 +6,7 @@ #include <stdbool.h> #include <linux/errno.h>
Nit: that empty line was intentional - it's common to have one between global and local includes.
+#include <linux/auxvec.h> #include "freestanding.h" /* @@ -93,6 +93,20 @@ static ssize_t __write_all(const char *str, size_t len) return written; } +unsigned long get_pagesize(struct morello_auxv *auxv) +{
- unsigned long page_size = 0;
- while (auxv->a_type != AT_NULL) {
if (auxv->a_type == AT_PAGESZ) {
page_size = auxv->a_val;
break;
}
++auxv;
- }
- return page_size;
+}
/*
- formats supported: %d, %x, %s, %p,
- modifiers l/z/u are accepted and ignored. To compensate, values are always
diff --git a/tools/testing/selftests/arm64/morello/freestanding.h b/tools/testing/selftests/arm64/morello/freestanding.h index 901521bde55d..ed85165dbb70 100644 --- a/tools/testing/selftests/arm64/morello/freestanding.h +++ b/tools/testing/selftests/arm64/morello/freestanding.h @@ -43,6 +43,21 @@ struct __test_meta { int message; }; +struct morello_auxv {
- long a_type;
- long _padding;
- uintcap_t a_val;
+};
+struct initial_data {
- int argc;
- char **argv;
- char **envp;
- struct morello_auxv *auxv;
+};
+unsigned long get_pagesize(struct morello_auxv *auxv);
void install_kernel_stack(void); uintcap_t __syscall(uintcap_t, uintcap_t, uintcap_t, uintcap_t, uintcap_t, uintcap_t, uintcap_t); diff --git a/tools/testing/selftests/arm64/morello/mmap.c b/tools/testing/selftests/arm64/morello/mmap.c index 2dd4ccdb0d2a..18b0cc6b3549 100644 --- a/tools/testing/selftests/arm64/morello/mmap.c +++ b/tools/testing/selftests/arm64/morello/mmap.c @@ -19,6 +19,9 @@ #define PROBE_MODE_TOUCH 0x01 #define PROBE_MODE_VERIFY 0x02 +static struct initial_data reg_data;
It doesn't look like we actually need this global - get_pagesize() could be called with the auxv passed to main() directly.
Kevin
+static unsigned long pagesize; static inline int probe_mem_range(void *addr, size_t size, int mode) { @@ -127,8 +130,15 @@ TEST(test_syscall_mmap2) syscall_mmap2(); } -int main(void) +int main(int argc, char **argv, char **envp, struct morello_auxv *auxv) {
- reg_data.argc = argc;
- reg_data.argv = argv;
- reg_data.envp = envp;
- reg_data.auxv = auxv;
- pagesize = get_pagesize(reg_data.auxv);
- test_syscall_mmap(); test_syscall_mmap2(); return 0;