bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH gnumach] Align the user stack correctly for 64 bit programs.


From: Luca
Subject: Re: [PATCH gnumach] Align the user stack correctly for 64 bit programs.
Date: Tue, 21 Mar 2023 08:52:11 +0100

Il 21/03/23 04:58, Flávio Cruz ha scritto:
    Il 20/03/23 05:59, Flavio Cruz ha scritto:
     > diff --git a/i386/i386/thread.h b/i386/i386/thread.h
     > index cb317bee..c5da7522 100644
     > --- a/i386/i386/thread.h
     > +++ b/i386/i386/thread.h
     > @@ -225,6 +225,17 @@ typedef struct pcb {
     >   #define STACK_IEL(stack)    \
     >       ((struct i386_exception_link *)STACK_IKS(stack) - 1)
     >
     > +#ifdef __x86_64__
     > +#ifdef USER32
     > +#define STACK_ALIGN 4
     > +#else
     > +/* Follow System V AMD64 ABI guidelines. */
     > +#define STACK_ALIGN 16
     > +#endif
     > +#else
     > +#define STACK_ALIGN 4
     > +#endif  /* __x86_64__ */
     > +
     >   #define USER_REGS(thread)   (&(thread)->pcb->iss)

    Maybe this should be BOOTSTRAP_STACK_ALIGN or something similar?
    Just to
    differentiate from the alignment set in pcb_module_init(), which is for
    the exception stack.


Is the exception stack only used in kernel space? In that case, we could define
KERNEL_STACK_ALIGN and USER_STACK_ALIGN to differentiate between the
two cases. 64 bit user programs always need to have a 16-byte aligned stack when
calling functions (at least gcc expects that).

Yes, the exception stack is not visible from user space, and it must follow the kernel arch rather than the user arch.


Luca



reply via email to

[Prev in Thread] Current Thread [Next in Thread]