From owner-freebsd-arch Wed Feb 6 14:26:27 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mail.pcnet.com (pcnet1.pcnet.com [204.213.232.3]) by hub.freebsd.org (Postfix) with ESMTP id 780DE37B41E for ; Wed, 6 Feb 2002 14:26:17 -0800 (PST) Received: from localhost (eischen@localhost) by mail.pcnet.com (8.12.1/8.12.1) with ESMTP id g16MQFCv002321; Wed, 6 Feb 2002 17:26:16 -0500 (EST) Date: Wed, 6 Feb 2002 17:26:15 -0500 (EST) From: Daniel Eischen To: Peter Wemm Cc: Dan Eischen , arch@FreeBSD.ORG Subject: Re: getsetcontext system call In-Reply-To: <20020206195918.6350039F1@overcee.wemm.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 On Wed, 6 Feb 2002, Peter Wemm wrote: > 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? Concur; will change size of pxmm_regs to 128. As to set_fpregs(), it looks like it wants to convert an x87 FPU state to an SSE FPU state. The opposite seems to be the case for fill_fpregs(). I'm not exactly sure how and why fill_fpregs() and set_fpregs() are used. Since we make struct fpreg large enough to hold either x87 or SSE FPU state, do we even care about converting between the two different formats any longer? > #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: OK. -- Dan Eischen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message