From 4fd5e9c2c18fa71ebc6dce5fcfe077f8c9f29bab Mon Sep 17 00:00:00 2001 From: Flavio Cruz Date: Sun, 2 Apr 2023 23:56:31 -0400 Subject: Align the user stack correctly for 64 bit programs. * i386/i386/thread.h: Define USER_STACK_ALIGN which is 16-byte for 64 bit programs as recommended by the System V AMD64 guidelines. Also define KERNEL_STACK_ALIGN which can differ from user land. * i386/i386/pcb.c: Use USER_STACK_ALIGN to align the bootstrap arguments and ultimately the stack where the program starts on. * kern/bootstrap.c: Do not align arg_len here since it will be aligned in set_user_regs. Message-Id: --- kern/bootstrap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'kern/bootstrap.c') diff --git a/kern/bootstrap.c b/kern/bootstrap.c index 8f66a4b5..49358ac6 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -610,17 +610,16 @@ build_args_and_stack(struct exec_info *boot_exec_info, * trailing 0 pointer * pointers to environment variables * trailing 0 pointer - * and align to integer boundary */ arg_len += (sizeof(rpc_vm_offset_t) + (arg_count + 1 + envc + 1) * sizeof(rpc_vm_offset_t)); - arg_len = (arg_len + sizeof(integer_t) - 1) & ~(sizeof(integer_t)-1); /* * Allocate the stack. */ stack_size = round_page(STACK_SIZE); stack_base = user_stack_low(stack_size); + (void) vm_allocate(current_task()->map, &stack_base, stack_size, -- cgit v1.2.3