Date: Mon, 19 Aug 2002 11:10:50 -0700 (PDT) From: Jonathan Mini <mini@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 16284 for review Message-ID: <200208191810.g7JIAoxE016199@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <machine/ucontext.h> */ -#define UC_FP_VALID 0x0002 /* __UC_FP_VALID <machine/ucontext.h> */ -#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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208191810.g7JIAoxE016199>