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 {
* 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];
};
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
......
......@@ -16,6 +16,7 @@
#include <sched.h>
#include <sys/socket.h>
#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;
......
......@@ -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;
......
......@@ -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,
......
......@@ -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;
......
......@@ -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;
};
......
......@@ -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];
};
......
......@@ -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;
};
......
......@@ -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;
};
......
......@@ -16,8 +16,8 @@
const char *test_doc = "Check for alternate signal stack";
const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>";
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,
......
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