Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Jan 1997 23:28:37 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        dtc@scrooge.ee.swin.oz.au, freebsd-current@FreeBSD.ORG
Subject:   Re: i586-optimized copyin/out still broken
Message-ID:  <199701031228.XAA31459@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> preserving the state would mainly slow down signal handlers.
>
>Will it solve the problem to add a FPU save/restore in the interrupt
>handler when needed?
>
>>From example using Martin's code example in PR 2142, the interrupt
>handler would become:
>
>void interrupt(int sig)
>{
>  int n,i;
>  static int wieviel=0;
>  int fpu_state[27];
>
>  fpu_save(fpu_state); /* <<<<< */

That sort of works for the interrupt handlers that you change.  Except of
course on i386/i387 systems, fpu_save() and fpu_restore() may cause a
SIGFPE, so you need lots more code to support such systems.

>_fpu_save:
>	movl	4(%esp),%eax
>	fnsave	(%eax)		# Save the NPX state - Resets NPX

Resetting it puts it into a possibly non-default state:

control word state after fnsave:  0x037f (64 bit precision, mask all exceptions)
FreeBSD default cw state:         0x1272 (53 bit precision, unmask 3 exceptions)
application default cw state:     who knows

This is a problem for doing the context switch in the kernel.  The FreeBSD
default cw is correct if the process hasn't changed its cw, but the
kernel has no way of telling if the process has changed its cw or if it
wants the change to apply in signal handlers.  In particular, the cw is
always changed on the fly for doing float <-> int conversions, and this
change should certainly not apply in signal handlers.

Bruce



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