parlib: Always align the sigdata struct
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 15 Jun 2018 19:07:33 +0000 (15:07 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Fri, 15 Jun 2018 19:15:00 +0000 (15:15 -0400)
The two cases were very similar, but only one had the alignment check.
Odds are, that was an oversight.  When we handled the FP state separately
based on the UTHREAD_SAVED cases, this wasn't as clear.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
user/parlib/signal.c

index dbe6b42..e8d2351 100644 (file)
@@ -153,17 +153,14 @@ static void __prep_sighandler(struct uthread *uthread,
 
        if (uthread->flags & UTHREAD_SAVED) {
                ctx = &uthread->u_ctx;
 
        if (uthread->flags & UTHREAD_SAVED) {
                ctx = &uthread->u_ctx;
-               stack = get_user_ctx_sp(ctx) - sizeof(struct sigdata);
-               assert(stack_ptr_is_sane(stack));
-               uthread->sigstate.data = (struct sigdata*)stack;
        } else {
                assert(current_uthread == uthread);
                ctx = &vcpd_of(vcore_id())->uthread_ctx;
        } else {
                assert(current_uthread == uthread);
                ctx = &vcpd_of(vcore_id())->uthread_ctx;
-               stack = get_user_ctx_sp(ctx) - sizeof(struct sigdata);
-               stack = ROUNDDOWN(stack, __alignof__(struct sigdata));
-               assert(stack_ptr_is_sane(stack));
-               uthread->sigstate.data = (struct sigdata*)stack;
        }
        }
+       stack = get_user_ctx_sp(ctx) - sizeof(struct sigdata);
+       stack = ROUNDDOWN(stack, __alignof__(struct sigdata));
+       assert(stack_ptr_is_sane(stack));
+       uthread->sigstate.data = (struct sigdata*)stack;
        /* Parlib aggressively saves the FP state for HW and VM ctxs.  SW ctxs
         * should not have FP state saved. */
        switch (uthread->u_ctx.type) {
        /* Parlib aggressively saves the FP state for HW and VM ctxs.  SW ctxs
         * should not have FP state saved. */
        switch (uthread->u_ctx.type) {