--- Begin Message ---
Paul Mackerras wrote:
>Jakub Jelinek writes:
>
>
>>uc_mcontext.uc_regs pointer the swapcontext call creates is not
>>aligned though:
>>
>
>Now that I can believe, since the register saving code is derived from
>the code used to construct signal frames, and therefore assumes that
>the ucontext is 16-byte aligned. So yes, that's a kernel bug.
>
>Note that sys_swapcontext can happily use, as its second argument, a
>ucontext where the uc_mcontext.uc_regs field is not 16-byte aligned,
>though, so glibc could work around the kernel bug by doing the memmove
>in makecontext as you suggest.
>
>
I would like to avoid any memmove by aligning the regs buffer properly
in the first place.
>When I fix the kernel bug, which of these two options would you
>prefer?
>
>(a) the kernel sets ucp->uc_mcontext.uc_regs to the value it uses now,
>rounded up to a 16-byte boundary, and stores the registers there; or
>
>
When the kernel allocates the ucontext (signals) , the kernel should
align the regs buffer and set uc_mcontext.uc_regs appropriately.
>(b) the kernel relies on glibc to have set ucp->uc_mcontext.uc_regs
>appropriately and stores the registers where it points to (i.e. the
>kernel does not alter ucp->uc_mcontext.uc_regs).
>
>
When the user or glibc allocate the ucontext (get/swapcontext), glibc
should align the regs buffer and set uc_mcontext.uc_regs. Then
set/makecontext can safely use uc_mcontext.uc_regs (#ifdef
__ASSUME_SWAPCONTEXT_SYSCALL) without forcing alignment.
--- End Message ---