Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Feb 2002 17:26:15 -0500 (EST)
From:      Daniel Eischen <eischen@pcnet1.pcnet.com>
To:        Peter Wemm <peter@wemm.org>
Cc:        Dan Eischen <eischen@vigrid.com>, arch@FreeBSD.ORG
Subject:   Re: getsetcontext system call 
Message-ID:  <Pine.GSO.4.10.10202061700570.29032-100000@pcnet1.pcnet.com>
In-Reply-To: <20020206195918.6350039F1@overcee.wemm.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <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:

OK.

-- 
Dan Eischen


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?Pine.GSO.4.10.10202061700570.29032-100000>