Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 06 Feb 2002 11:59:18 -0800
From:      Peter Wemm <peter@wemm.org>
To:        Dan Eischen <eischen@vigrid.com>
Cc:        arch@freebsd.org
Subject:   Re: getsetcontext system call 
Message-ID:  <20020206195918.6350039F1@overcee.wemm.org>
In-Reply-To: <3C5FF99D.87719821@vigrid.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
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 <sys/malloc.h>
+#include <sys/proc.h>
+
+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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020206195918.6350039F1>