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 11:15:24AM -0600, Steven Munroe wrote:
> This is similar to the patch I submitted on 12/13/06, 
> http://sources.redhat.com/ml/libc-alpha/2006-12/msg00115.html.

I don't understand the getcontext/swapcontext bits in the patch.
There is no need to touch oldctx->uc_mcontext.uc_regs when
oldctx is immediately passed as first argument to swapcontext(2),
that syscall overwrites it anyway:

long sys_swapcontext(struct ucontext __user *old_ctx,
                     struct ucontext __user *new_ctx,
                     int ctx_size, int r6, int r7, int r8, struct pt_regs
                     *regs)
{
        unsigned char tmp;

        /* Context size is for future use. Right now, we only make sure
         * we are passed something we understand
         */
        if (ctx_size < sizeof(struct ucontext))
                return -EINVAL;

        if (old_ctx != NULL) {
                if (!access_ok(VERIFY_WRITE, old_ctx, sizeof(*old_ctx))
                    || save_user_regs(regs, &old_ctx->uc_mcontext, 0)
                    || put_sigset_t(&old_ctx->uc_sigmask, &current->blocked)
                    || __put_user(to_user_ptr(&old_ctx->uc_mcontext),
                            &old_ctx->uc_regs))
                        return -EFAULT;
        }
...

Even when Paul fixes kernel to align it, it IMHO still needs not to look
at the previous old_ctx->uc_regs value to be backwards compatible with
current glibcs which didn't initialize it in any way.

> This is fine if all cases that create/initialize a ucontext set the 
> pointer and align the reg save area. At the moment the makecontext only 
> sets up integer/pointer parms to pass to the func. But to be complete it 
> really should handle floating point and vector parms, which requires 
> that the regs save area is quadword aligned (even if the kernel can 
> handle unaligned VRs that ABI for parameter passing does not.

??  makecontext arguments are just ints, I don't think we should invent
new makecontext like APIs when makecontext is obsolescent in current POSIX.
So IMHO we should not touch floating point nor altivec regs in makecontext,
they should be inherited from getcontext call.

	Jakub


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