diff --git a/cr-check.c b/cr-check.c index ee3556893..6ecc99834 100644 --- a/cr-check.c +++ b/cr-check.c @@ -808,7 +808,7 @@ struct clone_arg { * Reserve some space for clone() to locate arguments * and retcode in this place */ - char stack[128] __attribute__((aligned (16))); + char stack[128] __stack_aligned__; char stack_ptr[0]; }; diff --git a/cr-restore.c b/cr-restore.c index e12207f75..f9621b6a8 100644 --- a/cr-restore.c +++ b/cr-restore.c @@ -1075,7 +1075,7 @@ struct cr_clone_arg { * Reserve some space for clone() to locate arguments * and retcode in this place */ - char stack[128] __attribute__((aligned (16))); + char stack[128] __stack_aligned__; char stack_ptr[0]; struct pstree_item *item; unsigned long clone_flags; diff --git a/include/compiler.h b/include/compiler.h index 894393e9d..6bce93562 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -38,6 +38,12 @@ #define __aligned(x) __attribute__((aligned(x))) +/* + * Macro to define stack alignment. + * aarch64 requires stack to be aligned to 16 bytes. + */ +#define __stack_aligned__ __attribute__((aligned(16))) + #ifndef offsetof # define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif diff --git a/include/restorer.h b/include/restorer.h index fe3af18e6..4c4377cda 100644 --- a/include/restorer.h +++ b/include/restorer.h @@ -50,7 +50,7 @@ struct restore_mem_zone { u8 redzone[RESTORE_STACK_REDZONE]; u8 stack[RESTORE_STACK_SIZE]; u8 rt_sigframe[RESTORE_STACK_SIGFRAME]; -} __aligned(16); +} __stack_aligned__; struct rst_sched_param { int policy; diff --git a/test/zdtm/lib/ns.c b/test/zdtm/lib/ns.c index 8d7e7afcc..bc5c39554 100644 --- a/test/zdtm/lib/ns.c +++ b/test/zdtm/lib/ns.c @@ -16,6 +16,7 @@ #include #include +#include "zdtmtst.h" #include "ns.h" extern int pivot_root(const char *new_root, const char *put_old); @@ -143,7 +144,7 @@ static int prepare_namespaces(void) /* All arguments should be above stack, because it grows down */ struct ns_exec_args { - char stack[NS_STACK_SIZE] __attribute__((aligned (16))); + char stack[NS_STACK_SIZE] __stack_aligned__; char stack_ptr[0]; int argc; char **argv; diff --git a/test/zdtm/lib/zdtmtst.h b/test/zdtm/lib/zdtmtst.h index f58435fa5..a8f9e02ce 100644 --- a/test/zdtm/lib/zdtmtst.h +++ b/test/zdtm/lib/zdtmtst.h @@ -99,6 +99,12 @@ extern int parse_opt_string(char *param, void *arg); #define __stringify_1(x) #x #define __stringify(x) __stringify_1(x) +/* + * Macro to define stack alignment. + * aarch64 requires stack to be aligned to 16 bytes. + */ +#define __stack_aligned__ __attribute__((aligned(16))) + /* message helpers */ extern int test_log_init(const char *outfile, const char *suffix); extern int zdtm_seccomp; diff --git a/test/zdtm/live/static/fdt_shared.c b/test/zdtm/live/static/fdt_shared.c index 605bb6db8..908f6bcd0 100644 --- a/test/zdtm/live/static/fdt_shared.c +++ b/test/zdtm/live/static/fdt_shared.c @@ -48,7 +48,7 @@ static void wait_children() static pid_t clone_child(int (*fn)(void *), int flags) { - char stack[STACK_SIZE] __attribute__((aligned (16))); + char stack[STACK_SIZE] __stack_aligned__; pid_t pid; pid = clone(fn, stack + STACK_SIZE, diff --git a/test/zdtm/live/static/mntns_link_remap.c b/test/zdtm/live/static/mntns_link_remap.c index 6d629204e..210188bae 100644 --- a/test/zdtm/live/static/mntns_link_remap.c +++ b/test/zdtm/live/static/mntns_link_remap.c @@ -29,7 +29,7 @@ TEST_OPTION(dirname, string, "directory name", 1); #define NS_STACK_SIZE 4096 /* All arguments should be above stack, because it grows down */ struct ns_exec_args { - char stack[NS_STACK_SIZE] __attribute__((aligned (16))); + char stack[NS_STACK_SIZE] __stack_aligned__; char stack_ptr[0]; int fd; int sync; diff --git a/test/zdtm/live/static/mntns_open.c b/test/zdtm/live/static/mntns_open.c index 2f9180149..629d76275 100644 --- a/test/zdtm/live/static/mntns_open.c +++ b/test/zdtm/live/static/mntns_open.c @@ -29,7 +29,7 @@ char fpath[PATH_MAX]; #define NS_STACK_SIZE 4096 /* All arguments should be above stack, because it grows down */ struct ns_exec_args { - char stack[NS_STACK_SIZE] __attribute__((aligned (16))); + char stack[NS_STACK_SIZE] __stack_aligned__; char stack_ptr[0]; int fd; }; diff --git a/test/zdtm/live/static/mountpoints.c b/test/zdtm/live/static/mountpoints.c index 7ad5c929a..0b46480e0 100644 --- a/test/zdtm/live/static/mountpoints.c +++ b/test/zdtm/live/static/mountpoints.c @@ -22,7 +22,7 @@ static char buf[1024]; #define NS_STACK_SIZE 4096 /* All arguments should be above stack, because it grows down */ struct ns_exec_args { - char stack[NS_STACK_SIZE] __attribute__((aligned (16))); + char stack[NS_STACK_SIZE] __stack_aligned__; char stack_ptr[0]; int status_pipe[2]; }; diff --git a/test/zdtm/live/static/session02.c b/test/zdtm/live/static/session02.c index c4c3922cd..6c5e77121 100644 --- a/test/zdtm/live/static/session02.c +++ b/test/zdtm/live/static/session02.c @@ -67,7 +67,7 @@ static void mainloop() #define CLONE_STACK_SIZE 4096 /* All arguments should be above stack, because it grows down */ struct clone_args { - char stack[CLONE_STACK_SIZE] __attribute__((aligned (16))); + char stack[CLONE_STACK_SIZE] __stack_aligned__; char stack_ptr[0]; int id; }; diff --git a/test/zdtm/live/static/session03.c b/test/zdtm/live/static/session03.c index a8e14b168..ef268e552 100644 --- a/test/zdtm/live/static/session03.c +++ b/test/zdtm/live/static/session03.c @@ -109,7 +109,7 @@ static void mainloop() #define CLONE_STACK_SIZE 4096 /* All arguments should be above stack, because it grows down */ struct clone_args { - char stack[CLONE_STACK_SIZE] __attribute__((aligned (16))); + char stack[CLONE_STACK_SIZE] __stack_aligned__; char stack_ptr[0]; int id; }; diff --git a/test/zdtm/live/static/sigaltstack.c b/test/zdtm/live/static/sigaltstack.c index d84c35cdb..be5ddf792 100644 --- a/test/zdtm/live/static/sigaltstack.c +++ b/test/zdtm/live/static/sigaltstack.c @@ -16,8 +16,8 @@ const char *test_doc = "Check for alternate signal stack"; const char *test_author = "Cyrill Gorcunov "; -static char stack_thread[SIGSTKSZ + TEST_MSG_BUFFER_SIZE]; -static char stack_main[SIGSTKSZ + TEST_MSG_BUFFER_SIZE]; +static char stack_thread[SIGSTKSZ + TEST_MSG_BUFFER_SIZE] __stack_aligned__; +static char stack_main[SIGSTKSZ + TEST_MSG_BUFFER_SIZE] __stack_aligned__; enum { SAS_MAIN_OLD,