From owner-freebsd-arch Wed Feb 6 11:59:33 2002 Delivered-To: freebsd-arch@freebsd.org Received: from rwcrmhc54.attbi.com (rwcrmhc54.attbi.com [216.148.227.87]) by hub.freebsd.org (Postfix) with ESMTP id 0B27E37B419 for ; Wed, 6 Feb 2002 11:59:24 -0800 (PST) Received: from peter3.wemm.org ([12.232.27.13]) by rwcrmhc54.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020206195923.SKSE7443.rwcrmhc54.attbi.com@peter3.wemm.org> for ; Wed, 6 Feb 2002 19:59:23 +0000 Received: from overcee.wemm.org (overcee.wemm.org [10.0.0.3]) by peter3.wemm.org (8.11.0/8.11.0) with ESMTP id g16JxNs82275 for ; Wed, 6 Feb 2002 11:59:23 -0800 (PST) (envelope-from peter@wemm.org) Received: from wemm.org (localhost [127.0.0.1]) by overcee.wemm.org (Postfix) with ESMTP id 6350039F1; Wed, 6 Feb 2002 11:59:18 -0800 (PST) (envelope-from peter@wemm.org) X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: Dan Eischen Cc: arch@freebsd.org Subject: Re: getsetcontext system call In-Reply-To: <3C5FF99D.87719821@vigrid.com> Date: Wed, 06 Feb 2002 11:59:18 -0800 From: Peter Wemm Message-Id: <20020206195918.6350039F1@overcee.wemm.org> Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Dan Eischen wrote: > Diffs are at: > > http://people.freebsd.org/~deischen/ucontext/uc-sys.diffs > http://people.freebsd.org/~deischen/ucontext/uc-libc.diffs Possible problem: +struct fp387 { + unsigned long fp387_regs[44]; +}; + +struct fpxmm { + unsigned long fpxmm_regs[126]; +} __attribute__((aligned(16))); ... - unsigned long fpr_env[7]; - unsigned char fpr_acc[8][10]; - unsigned long fpr_ex_sw; - unsigned char fpr_pad[64]; + union { + struct fp387 fps_87; + struct fpxmm fps_xmm; + } fpu_state; .... - int sc_fpregs[28]; /* machine state (FPU): */ - int sc_spare[17]; + int sc_fpformat; + int sc_ownedfp; + int sc_spare1[1]; + int sc_fpregs[128]; + int sc_spare2[8]; ... and: #ifdef CPU_ENABLE_SSE if (cpu_fxsr) { - set_fpregs_xmm((struct save87 *)fpregs, - &td->td_pcb->pcb_save.sv_xmm); + set_fpregs_xmm((struct save87 *)&fpregs->fpu_state.fps_87, + &td->td_pcb->pcb_save.sv_xmm); return (0); } #endif /* CPU_ENABLE_SSE */ - bcopy(fpregs, &td->td_pcb->pcb_save.sv_87, sizeof *fpregs); + bcopy(&fpregs->fpu_state.fps_87, &td->td_pcb->pcb_save.sv_87, + sizeof(fpregs->fpu_state.fps_87)); return (0); The 'long fpxmm_regs[126];' looks mighty suspicious.. I think it should be 128, since the fxsave dump area is 512 bytes long. Secondly, why does the xmm state save/restore code use the fps_87 union member instead of the fps_xmm member? #if 0 +#ifdef _KERNEL +/* grrr, arghh, what's the correct way to ensure struct thread is declared? */ +#include +#include + +void get_mcontext(struct thread *, mcontext_t *mcp); +int set_mcontext(struct thread *, const mcontext_t *mcp); +#endif +#endif #endif /* !_MACHINE_UCONTEXT_H_ */ just forward declare 'struct thread;' - you've done that elsewhere. eg: #ifdef _KERNEL +struct fpreg; struct pcb; .. do the same for 'struct thread;' right there instead. Cheers, -Peter -- Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message