Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jul 2001 20:45:25 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Tor.Egge@fast.no
Cc:        juriy@aviaport.ru, freebsd-current@FreeBSD.ORG, peter@FreeBSD.ORG
Subject:   Re: kernel with SSE is unstable
Message-ID:  <Pine.BSF.4.21.0107172021310.65829-100000@besplex.bde.org>
In-Reply-To: <200107170951.LAA72393@midten.fast.no>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 17 Jul 2001 Tor.Egge@fast.no wrote:

> > I want all use of the cpu number removed.  It seems to be just to avoid
> > alignment problems that shouldn't happen in practice (the save area
> > should always be suitably aligned if it isn't already, and I think it
> > is already).
> 
> The pcb_save area has the proper alignment but the dummy variable used
> in npxinit might not have the proper alignment when on the stack.

I see.  __attribute__((__^H^Haligned(16))) doesn't actually work even for
gcc because we use -mpreferred-stack-boundary=2 for the kernel.

The dummy variable should go away for other reasons: the dummy npxsave()
has no effect except possibly for the first call (from npxattach()) and
the second call (for the first call from setregs()).  For subsequent
calls from setregs(), the state must have already been saved in the pcb
of the previous owner of the CPU, or else we would be stealing the state
from the current owner.

> The enclosed patch should be a step in the right direction.

Yes, please commit it.

> @@ -926,30 +926,21 @@
>  fpusave(addr)
>  	union savefpu *addr;
>  {
> -	static struct savexmm svxmm[MAXCPU];
> -	u_char oncpu = PCPU_GET(cpuid);
>  	
>  	if (!cpu_fxsr)
>  		fnsave(addr);
> -	else {
> -		fxsave(&svxmm[oncpu]);
> -		bcopy(&svxmm[oncpu], addr, sizeof(struct savexmm));
> -	}
> +	else
> +		fxsave(addr);
>  }

I like to use the conditional operator for simple conditionals like this:

	(cpu_fxsr ? fxsave : fnsave)(addr);

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0107172021310.65829-100000>