This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: {make,set,swap}context broken on powerpc32


On Tue, Dec 19, 2006 at 04:48:09PM +1100, Paul Mackerras wrote:
> Steven Munroe writes:
> 
> > >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.
> 
> I don't understand why makecontext has to set the regs pointer at all,
> given that the user has to call getcontext first.  Why can't
> makecontext just use the pointer that getcontext has set?
> 
> If you do that then there is no problem using the sys_swapcontext
> syscall even on kernels that have the alignment bug, as long as you
> use sys_swapcontext for setcontext and swapcontext.  (And yes I will
> fix the alignment bug in the kernel.)

I completely agree, I also see no reason to align in
makecontext@@GLIBC_2.3.4.  POSIX requires that the ucontext_t passed
to makecontext has been initialized by a getcontext call, and either
glibc is configured to use swapcontext syscall (in this case
the kernel should make sure it is aligned, but even if it does not,
we are using swapcontext syscall everywhere and the kernel doesn't
need it aligned), or we are not using swapcontext syscall anywhere
and getcontext@@GLIBC_2.3.4 pure userland implementation initializes
uc_mcontext.uc_regs to an aligned value.

Attached is a patch to change makecontext.c as well as a testcase
I posted just inline when starting this thread.

	Jakub

Attachment: P
Description: Text document

Attachment: Q
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]