Commit 8a7c006b authored by Vijaya Kumar K's avatar Vijaya Kumar K Committed by Pavel Emelyanov

define macro for stack alignment

Replace stack alignment magic constant with
__stack_aligned__ macro.
Also align stack for sigaltstack test case.
Signed-off-by: 's avatarVijaya Kumar K <vijayak@caviumnetworks.com>
Reviewed-by: 's avatarChristopher Covington <cov@codeaurora.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 831f7b91
...@@ -808,7 +808,7 @@ struct clone_arg { ...@@ -808,7 +808,7 @@ struct clone_arg {
* Reserve some space for clone() to locate arguments * Reserve some space for clone() to locate arguments
* and retcode in this place * and retcode in this place
*/ */
char stack[128] __attribute__((aligned (16))); char stack[128] __stack_aligned__;
char stack_ptr[0]; char stack_ptr[0];
}; };
......
...@@ -1075,7 +1075,7 @@ struct cr_clone_arg { ...@@ -1075,7 +1075,7 @@ struct cr_clone_arg {
* Reserve some space for clone() to locate arguments * Reserve some space for clone() to locate arguments
* and retcode in this place * and retcode in this place
*/ */
char stack[128] __attribute__((aligned (16))); char stack[128] __stack_aligned__;
char stack_ptr[0]; char stack_ptr[0];
struct pstree_item *item; struct pstree_item *item;
unsigned long clone_flags; unsigned long clone_flags;
......
...@@ -38,6 +38,12 @@ ...@@ -38,6 +38,12 @@
#define __aligned(x) __attribute__((aligned(x))) #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 #ifndef offsetof
# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) # define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif #endif
......
...@@ -50,7 +50,7 @@ struct restore_mem_zone { ...@@ -50,7 +50,7 @@ struct restore_mem_zone {
u8 redzone[RESTORE_STACK_REDZONE]; u8 redzone[RESTORE_STACK_REDZONE];
u8 stack[RESTORE_STACK_SIZE]; u8 stack[RESTORE_STACK_SIZE];
u8 rt_sigframe[RESTORE_STACK_SIGFRAME]; u8 rt_sigframe[RESTORE_STACK_SIGFRAME];
} __aligned(16); } __stack_aligned__;
struct rst_sched_param { struct rst_sched_param {
int policy; int policy;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <sched.h> #include <sched.h>
#include <sys/socket.h> #include <sys/socket.h>
#include "zdtmtst.h"
#include "ns.h" #include "ns.h"
extern int pivot_root(const char *new_root, const char *put_old); extern int pivot_root(const char *new_root, const char *put_old);
...@@ -143,7 +144,7 @@ static int prepare_namespaces(void) ...@@ -143,7 +144,7 @@ static int prepare_namespaces(void)
/* All arguments should be above stack, because it grows down */ /* All arguments should be above stack, because it grows down */
struct ns_exec_args { struct ns_exec_args {
char stack[NS_STACK_SIZE] __attribute__((aligned (16))); char stack[NS_STACK_SIZE] __stack_aligned__;
char stack_ptr[0]; char stack_ptr[0];
int argc; int argc;
char **argv; char **argv;
......
...@@ -99,6 +99,12 @@ extern int parse_opt_string(char *param, void *arg); ...@@ -99,6 +99,12 @@ extern int parse_opt_string(char *param, void *arg);
#define __stringify_1(x) #x #define __stringify_1(x) #x
#define __stringify(x) __stringify_1(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 */ /* message helpers */
extern int test_log_init(const char *outfile, const char *suffix); extern int test_log_init(const char *outfile, const char *suffix);
extern int zdtm_seccomp; extern int zdtm_seccomp;
......
...@@ -48,7 +48,7 @@ static void wait_children() ...@@ -48,7 +48,7 @@ static void wait_children()
static pid_t clone_child(int (*fn)(void *), int flags) 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_t pid;
pid = clone(fn, stack + STACK_SIZE, pid = clone(fn, stack + STACK_SIZE,
......
...@@ -29,7 +29,7 @@ TEST_OPTION(dirname, string, "directory name", 1); ...@@ -29,7 +29,7 @@ TEST_OPTION(dirname, string, "directory name", 1);
#define NS_STACK_SIZE 4096 #define NS_STACK_SIZE 4096
/* All arguments should be above stack, because it grows down */ /* All arguments should be above stack, because it grows down */
struct ns_exec_args { struct ns_exec_args {
char stack[NS_STACK_SIZE] __attribute__((aligned (16))); char stack[NS_STACK_SIZE] __stack_aligned__;
char stack_ptr[0]; char stack_ptr[0];
int fd; int fd;
int sync; int sync;
......
...@@ -29,7 +29,7 @@ char fpath[PATH_MAX]; ...@@ -29,7 +29,7 @@ char fpath[PATH_MAX];
#define NS_STACK_SIZE 4096 #define NS_STACK_SIZE 4096
/* All arguments should be above stack, because it grows down */ /* All arguments should be above stack, because it grows down */
struct ns_exec_args { struct ns_exec_args {
char stack[NS_STACK_SIZE] __attribute__((aligned (16))); char stack[NS_STACK_SIZE] __stack_aligned__;
char stack_ptr[0]; char stack_ptr[0];
int fd; int fd;
}; };
......
...@@ -22,7 +22,7 @@ static char buf[1024]; ...@@ -22,7 +22,7 @@ static char buf[1024];
#define NS_STACK_SIZE 4096 #define NS_STACK_SIZE 4096
/* All arguments should be above stack, because it grows down */ /* All arguments should be above stack, because it grows down */
struct ns_exec_args { struct ns_exec_args {
char stack[NS_STACK_SIZE] __attribute__((aligned (16))); char stack[NS_STACK_SIZE] __stack_aligned__;
char stack_ptr[0]; char stack_ptr[0];
int status_pipe[2]; int status_pipe[2];
}; };
......
...@@ -67,7 +67,7 @@ static void mainloop() ...@@ -67,7 +67,7 @@ static void mainloop()
#define CLONE_STACK_SIZE 4096 #define CLONE_STACK_SIZE 4096
/* All arguments should be above stack, because it grows down */ /* All arguments should be above stack, because it grows down */
struct clone_args { struct clone_args {
char stack[CLONE_STACK_SIZE] __attribute__((aligned (16))); char stack[CLONE_STACK_SIZE] __stack_aligned__;
char stack_ptr[0]; char stack_ptr[0];
int id; int id;
}; };
......
...@@ -109,7 +109,7 @@ static void mainloop() ...@@ -109,7 +109,7 @@ static void mainloop()
#define CLONE_STACK_SIZE 4096 #define CLONE_STACK_SIZE 4096
/* All arguments should be above stack, because it grows down */ /* All arguments should be above stack, because it grows down */
struct clone_args { struct clone_args {
char stack[CLONE_STACK_SIZE] __attribute__((aligned (16))); char stack[CLONE_STACK_SIZE] __stack_aligned__;
char stack_ptr[0]; char stack_ptr[0];
int id; int id;
}; };
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
const char *test_doc = "Check for alternate signal stack"; const char *test_doc = "Check for alternate signal stack";
const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>";
static char stack_thread[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]; static char stack_main[SIGSTKSZ + TEST_MSG_BUFFER_SIZE] __stack_aligned__;
enum { enum {
SAS_MAIN_OLD, SAS_MAIN_OLD,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment