From owner-p4-projects Mon Aug 19 11:11: 0 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CF16B37B401; Mon, 19 Aug 2002 11:10:51 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 585C737B400 for ; Mon, 19 Aug 2002 11:10:51 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0A65D43E7B for ; Mon, 19 Aug 2002 11:10:51 -0700 (PDT) (envelope-from mini@freebsd.org) Received: from freefall.freebsd.org (perforce@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g7JIAoJU016206 for ; Mon, 19 Aug 2002 11:10:50 -0700 (PDT) (envelope-from mini@freebsd.org) Received: (from perforce@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g7JIAoxE016199 for perforce@freebsd.org; Mon, 19 Aug 2002 11:10:50 -0700 (PDT) Date: Mon, 19 Aug 2002 11:10:50 -0700 (PDT) Message-Id: <200208191810.g7JIAoxE016199@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to mini@freebsd.org using -f From: Jonathan Mini Subject: PERFORCE change 16284 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=16284 Change 16284 by mini@mini_stylus on 2002/08/19 11:09:56 Properly use mcontext_t information from userland. Affected files ... .. //depot/projects/kse/lib/libc/i386/gen/getcontext.S#2 edit .. //depot/projects/kse/lib/libc/i386/gen/makecontext.c#3 edit Differences ... ==== //depot/projects/kse/lib/libc/i386/gen/getcontext.S#2 (text+ko) ==== @@ -30,14 +30,14 @@ /* * Where do we define these? */ -#define UC_MC_VALID 0x0001 /* __UC_MC_VALID */ -#define UC_FP_VALID 0x0002 /* __UC_FP_VALID */ -#define MC_FP_VALID UC_MC_VALID | UC_FP_VALID +#define MC_SIZE 640 /* sizeof mcontext_t */ #define UC_MC_OFFSET 16 /* offset to mcontext from ucontext */ #define UC_FLAGS_OFFSET 208 /* offset to flags from ucontext */ -#define MC_FLAGS_OFFSET 192 /* offset to flags from mcontext */ -#define MC_FP_REGS_OFFSET 80 /* offset to FP regs from mcontext */ -#define MC_FP_CW_OFFSET 80 /* offset to FP control word */ +#define UC_MC_LEN_OFFSET 96 /* offset to mc_len from mcontext */ +#define MC_LEN_OFFSET 80 /* offset to mc_len from mcontext */ +#define MC_FP_REGS_OFFSET 96 /* offset to FP regs from mcontext */ +#define MC_FP_CW_OFFSET 96 /* offset to FP control word */ +#define MC_OWNEDFP_OFFSET 88 /* offset to mc_ownedfp from mcontext */ /* * int setcontext(ucontext_t *ucp); @@ -54,7 +54,7 @@ jne 1f movl $-1, %eax jmp 5f -1: testl $UC_MC_VALID, UC_FLAGS_OFFSET(%eax) /* is context valid? */ +1: cmpl $MC_SIZE, UC_MC_LEN_OFFSET(%eax) /* is context valid? */ jnz 2f movl $-1, %eax /* bzzzt, invalid context */ jmp 5f @@ -73,6 +73,7 @@ movl 8(%edx), %fs movl 12(%edx), %es movl 16(%edx), %ds + movl 76(%edx), %ss movl 20(%edx), %edi movl 24(%edx), %esi movl 28(%edx), %ebp @@ -80,7 +81,7 @@ subl $4, %esp /* leave space for the return address */ movl 60(%edx), %eax /* put return address at top of stack */ movl %eax, (%esp) - testl $UC_FP_VALID, MC_FLAGS_OFFSET(%edx) /* are FP regs valid? */ + cmpl $0, MC_OWNEDFP_OFFSET(%edx) /* are FP regs valid? */ jz 3f frstor MC_FP_REGS_OFFSET(%edx) /* restore FP regs */ jmp 4f @@ -136,6 +137,7 @@ movl %ecx, 44(%edx) movl (%esp), %eax /* get return address */ movl %eax, 60(%edx) /* save return address */ + movl %ss, 76(%edx) /* * XXX - Do we really need to save floating point registers? * @@ -150,7 +152,7 @@ */ #if 1 fnstcw MC_FP_CW_OFFSET(%edx) - movl $UC_MC_VALID, MC_FLAGS_OFFSET(%edx) /* mcontext valid, no FP */ + movl $0, MC_OWNEDFP_OFFSET(%edx) /* no FP */ #else fnsave MC_FP_REGS_OFFSET(%edx) /* save FP regs */ movl $MC_FP_VALID, MC_FLAGS_OFFSET(%edx) /* mcontext and FP valid */ @@ -160,6 +162,7 @@ movl %esp, %eax /* setcontext pushes the return */ addl $4, %eax /* address onto the top of the */ movl %eax, 72(%edx) /* stack; account for this */ + movl $MC_SIZE, MC_LEN_OFFSET(%edx) /* context is now valid */ movl 40(%edx), %edx /* restore edx -- is this needed? */ xorl %eax, %eax /* return 0 */ 2: ret ==== //depot/projects/kse/lib/libc/i386/gen/makecontext.c#3 (text+ko) ==== @@ -53,7 +53,7 @@ * to be restarted without being reinitialized (via * setcontext or swapcontext). */ - ucp->uc_mcontext.mc_flags = 0; + ucp->uc_mcontext.mc_len = 0; /* Set context to next one in link */ /* XXX - what to do for error, abort? */ @@ -80,14 +80,14 @@ * a void function. At least make sure that the context * isn't valid so it can't be used without an error. */ - ucp->uc_mcontext.mc_flags = 0; + ucp->uc_mcontext.mc_len = 0; } /* XXX - Do we want to sanity check argc? */ else if ((argc < 0) || (argc > NCARGS)) { - ucp->uc_mcontext.mc_flags = 0; + ucp->uc_mcontext.mc_len = 0; } /* Make sure the context is valid. */ - else if ((ucp->uc_mcontext.mc_flags & __UC_MC_VALID) != 0) { + else if (ucp->uc_mcontext.mc_len == sizeof(mcontext_t)) { /* * Arrange the stack as follows: * To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message