2019-05-19 13:08:55 +01:00
// SPDX-License-Identifier: GPL-2.0-only
2005-04-16 15:20:36 -07:00
/*
* Copyright ( C ) 1994 Linus Torvalds
*
* Pentium III FXSR , SSE support
* General FPU state handling cleanups
* Gareth Hughes < gareth @ valinux . com > , May 2000
*/
2015-04-24 02:54:44 +02:00
# include <asm/fpu/internal.h>
2015-04-30 08:53:18 +02:00
# include <asm/fpu/regset.h>
2015-04-30 08:45:02 +02:00
# include <asm/fpu/signal.h>
2016-07-11 09:18:56 -07:00
# include <asm/fpu/types.h>
2015-04-30 09:29:38 +02:00
# include <asm/traps.h>
2018-07-29 12:15:33 +02:00
# include <asm/irq_regs.h>
2015-04-30 08:45:02 +02:00
2015-04-26 16:57:55 +02:00
# include <linux/hardirq.h>
x86/pkeys: Default to a restrictive init PKRU
PKRU is the register that lets you disallow writes or all access to a given
protection key.
The XSAVE hardware defines an "init state" of 0 for PKRU: its most
permissive state, allowing access/writes to everything. Since we start off
all new processes with the init state, we start all processes off with the
most permissive possible PKRU.
This is unfortunate. If a thread is clone()'d [1] before a program has
time to set PKRU to a restrictive value, that thread will be able to write
to all data, no matter what pkey is set on it. This weakens any integrity
guarantees that we want pkeys to provide.
To fix this, we define a very restrictive PKRU to override the
XSAVE-provided value when we create a new FPU context. We choose a value
that only allows access to pkey 0, which is as restrictive as we can
practically make it.
This does not cause any practical problems with applications using
protection keys because we require them to specify initial permissions for
each key when it is allocated, which override the restrictive default.
In the end, this ensures that threads which do not know how to manage their
own pkey rights can not do damage to data which is pkey-protected.
I would have thought this was a pretty contrived scenario, except that I
heard a bug report from an MPX user who was creating threads in some very
early code before main(). It may be crazy, but folks evidently _do_ it.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-arch@vger.kernel.org
Cc: Dave Hansen <dave@sr71.net>
Cc: mgorman@techsingularity.net
Cc: arnd@arndb.de
Cc: linux-api@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: luto@kernel.org
Cc: akpm@linux-foundation.org
Cc: torvalds@linux-foundation.org
Link: http://lkml.kernel.org/r/20160729163021.F3C25D4A@viggo.jf.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2016-07-29 09:30:21 -07:00
# include <linux/pkeys.h>
2005-04-16 15:20:36 -07:00
2016-06-01 10:42:20 -07:00
# define CREATE_TRACE_POINTS
# include <asm/trace/fpu.h>
2015-04-30 11:07:06 +02:00
/*
* Represents the initial FPU state . It ' s mostly ( but not completely ) zeroes ,
* depending on the FPU hardware format :
*/
2015-04-30 17:15:32 +02:00
union fpregs_state init_fpstate __read_mostly ;
2015-04-30 11:07:06 +02:00
2015-04-22 16:52:03 +02:00
/*
* Track whether the kernel is using the FPU state
* currently .
*
* This flag is used :
*
* - by IRQ context code to potentially use the FPU
* if it ' s unused .
*
* - to debug kernel_fpu_begin ( ) / end ( ) correctness
*/
2015-01-15 20:19:43 +01:00
static DEFINE_PER_CPU ( bool , in_kernel_fpu ) ;
2015-04-23 12:13:04 +02:00
/*
2015-04-23 12:18:28 +02:00
* Track which context is using the FPU on the CPU :
2015-04-23 12:13:04 +02:00
*/
2015-04-23 12:18:28 +02:00
DEFINE_PER_CPU ( struct fpu * , fpu_fpregs_owner_ctx ) ;
2015-04-23 12:13:04 +02:00
2015-04-22 16:52:03 +02:00
static bool kernel_fpu_disabled ( void )
{
return this_cpu_read ( in_kernel_fpu ) ;
}
2015-04-22 16:33:08 +02:00
static bool interrupted_kernel_fpu_idle ( void )
2012-02-21 10:25:45 -08:00
{
2016-10-04 20:34:33 -04:00
return ! kernel_fpu_disabled ( ) ;
2012-02-21 10:25:45 -08:00
}
/*
* Were we in user mode ( or vm86 mode ) when we were
* interrupted ?
*
* Doing kernel_fpu_begin / end ( ) is ok if we are running
* in an interrupt context from user mode - we ' ll just
* save the FPU state as required .
*/
2015-04-22 16:33:08 +02:00
static bool interrupted_user_mode ( void )
2012-02-21 10:25:45 -08:00
{
struct pt_regs * regs = get_irq_regs ( ) ;
2015-03-18 18:33:33 -07:00
return regs & & user_mode ( regs ) ;
2012-02-21 10:25:45 -08:00
}
/*
* Can we use the FPU in kernel mode with the
* whole " kernel_fpu_begin/end() " sequence ?
*
* It ' s always ok in process context ( ie " not interrupt " )
* but it is sometimes ok even from an irq .
*/
bool irq_fpu_usable ( void )
{
return ! in_interrupt ( ) | |
interrupted_user_mode ( ) | |
interrupted_kernel_fpu_idle ( ) ;
}
EXPORT_SYMBOL ( irq_fpu_usable ) ;
2019-06-04 09:15:23 +02:00
void kernel_fpu_begin ( void )
2012-02-21 10:25:45 -08:00
{
2019-06-04 09:15:23 +02:00
preempt_disable ( ) ;
2012-02-21 10:25:45 -08:00
2015-05-05 11:34:49 +02:00
WARN_ON_FPU ( ! irq_fpu_usable ( ) ) ;
2019-06-04 09:15:23 +02:00
WARN_ON_FPU ( this_cpu_read ( in_kernel_fpu ) ) ;
2015-05-01 10:54:22 +02:00
2019-06-04 09:15:23 +02:00
this_cpu_write ( in_kernel_fpu , true ) ;
if ( ! ( current - > flags & PF_KTHREAD ) & &
! test_thread_flag ( TIF_NEED_FPU_LOAD ) ) {
set_thread_flag ( TIF_NEED_FPU_LOAD ) ;
/*
* Ignore return value - - we don ' t care if reg state
* is clobbered .
*/
copy_fpregs_to_fpstate ( & current - > thread . fpu ) ;
2012-02-21 10:25:45 -08:00
}
2019-04-03 18:41:52 +02:00
__cpu_invalidate_fpregs_state ( ) ;
2012-02-21 10:25:45 -08:00
}
2015-04-26 12:07:18 +02:00
EXPORT_SYMBOL_GPL ( kernel_fpu_begin ) ;
void kernel_fpu_end ( void )
{
2019-06-04 09:15:22 +02:00
WARN_ON_FPU ( ! this_cpu_read ( in_kernel_fpu ) ) ;
this_cpu_write ( in_kernel_fpu , false ) ;
2015-04-26 12:07:18 +02:00
preempt_enable ( ) ;
}
EXPORT_SYMBOL_GPL ( kernel_fpu_end ) ;
2015-04-03 11:01:36 +02:00
/*
2015-04-27 09:45:12 +02:00
* Save the FPU state ( mark it for reload if necessary ) :
2015-04-03 11:06:43 +02:00
*
* This only ever gets called for the current task .
2015-04-03 11:01:36 +02:00
*/
2015-04-23 17:57:24 +02:00
void fpu__save ( struct fpu * fpu )
2012-02-21 10:25:45 -08:00
{
2015-05-05 11:34:49 +02:00
WARN_ON_FPU ( fpu ! = & current - > thread . fpu ) ;
2015-04-03 11:06:43 +02:00
2019-04-03 18:41:52 +02:00
fpregs_lock ( ) ;
2016-06-01 10:42:20 -07:00
trace_x86_fpu_before_save ( fpu ) ;
2019-04-03 18:41:36 +02:00
2019-04-03 18:41:52 +02:00
if ( ! test_thread_flag ( TIF_NEED_FPU_LOAD ) ) {
if ( ! copy_fpregs_to_fpstate ( fpu ) ) {
copy_kernel_to_fpregs ( & fpu - > state ) ;
}
}
2019-04-03 18:41:36 +02:00
2016-06-01 10:42:20 -07:00
trace_x86_fpu_after_save ( fpu ) ;
2019-04-03 18:41:52 +02:00
fpregs_unlock ( ) ;
2012-02-21 10:25:45 -08:00
}
2015-04-30 10:08:36 +02:00
/*
* Legacy x87 fpstate state init :
*/
2015-04-30 17:15:32 +02:00
static inline void fpstate_init_fstate ( struct fregs_state * fp )
2015-04-30 10:08:36 +02:00
{
fp - > cwd = 0xffff037fu ;
fp - > swd = 0xffff0000u ;
fp - > twd = 0xffffffffu ;
fp - > fos = 0xffff0000u ;
}
2015-04-30 17:15:32 +02:00
void fpstate_init ( union fpregs_state * state )
2005-04-16 15:20:36 -07:00
{
2016-04-04 22:24:58 +02:00
if ( ! static_cpu_has ( X86_FEATURE_FPU ) ) {
2015-04-30 10:23:42 +02:00
fpstate_init_soft ( & state - > soft ) ;
2010-05-06 11:45:46 +03:00
return ;
2008-05-23 16:26:37 -07:00
}
2016-05-20 10:47:06 -07:00
memset ( state , 0 , fpu_kernel_xstate_size ) ;
2015-03-10 07:06:25 +01:00
2016-07-11 09:18:56 -07:00
if ( static_cpu_has ( X86_FEATURE_XSAVES ) )
2017-01-24 10:25:46 -08:00
fpstate_init_xstate ( & state - > xsave ) ;
2016-04-04 22:25:01 +02:00
if ( static_cpu_has ( X86_FEATURE_FXSR ) )
2015-04-30 10:23:42 +02:00
fpstate_init_fxstate ( & state - > fxsave ) ;
2015-04-30 10:08:36 +02:00
else
2015-04-30 10:23:42 +02:00
fpstate_init_fstate ( & state - > fsave ) ;
2010-05-06 11:45:46 +03:00
}
2015-04-03 13:01:52 +02:00
EXPORT_SYMBOL_GPL ( fpstate_init ) ;
2010-05-06 11:45:46 +03:00
2019-04-03 18:41:52 +02:00
int fpu__copy ( struct task_struct * dst , struct task_struct * src )
2015-04-22 20:09:29 +02:00
{
2019-04-03 18:41:52 +02:00
struct fpu * dst_fpu = & dst - > thread . fpu ;
struct fpu * src_fpu = & src - > thread . fpu ;
2016-01-24 14:38:08 -08:00
dst_fpu - > last_cpu = - 1 ;
2019-04-03 18:41:36 +02:00
if ( ! static_cpu_has ( X86_FEATURE_FPU ) )
2016-01-24 14:38:08 -08:00
return 0 ;
2015-05-05 11:34:49 +02:00
WARN_ON_FPU ( src_fpu ! = & current - > thread . fpu ) ;
2015-04-23 08:55:34 +02:00
2015-04-27 10:08:39 +02:00
/*
* Don ' t let ' init optimized ' areas of the XSAVE area
* leak into the child task :
*/
2016-10-04 20:34:33 -04:00
memset ( & dst_fpu - > state . xsave , 0 , fpu_kernel_xstate_size ) ;
2015-04-27 10:08:39 +02:00
/*
2019-04-03 18:41:52 +02:00
* If the FPU registers are not current just memcpy ( ) the state .
* Otherwise save current FPU registers directly into the child ' s FPU
* context , without any memory - to - memory copying .
2015-04-27 10:08:39 +02:00
*
2017-09-23 15:00:14 +02:00
* ( The function ' fails ' in the FNSAVE case , which destroys
2019-04-03 18:41:52 +02:00
* register contents so we have to load them back . )
2015-04-27 10:08:39 +02:00
*/
2019-04-03 18:41:52 +02:00
fpregs_lock ( ) ;
if ( test_thread_flag ( TIF_NEED_FPU_LOAD ) )
memcpy ( & dst_fpu - > state , & src_fpu - > state , fpu_kernel_xstate_size ) ;
else if ( ! copy_fpregs_to_fpstate ( dst_fpu ) )
copy_kernel_to_fpregs ( & dst_fpu - > state ) ;
fpregs_unlock ( ) ;
set_tsk_thread_flag ( dst , TIF_NEED_FPU_LOAD ) ;
2015-04-27 05:52:40 +02:00
2016-06-01 10:42:20 -07:00
trace_x86_fpu_copy_src ( src_fpu ) ;
trace_x86_fpu_copy_dst ( dst_fpu ) ;
2015-04-22 15:47:05 +02:00
return 0 ;
}
2015-04-03 12:02:02 +02:00
/*
2015-04-27 07:18:17 +02:00
* Activate the current task ' s in - memory FPU context ,
* if it has not been used before :
2015-04-03 12:02:02 +02:00
*/
2019-04-03 18:41:33 +02:00
static void fpu__initialize ( struct fpu * fpu )
2015-04-03 12:02:02 +02:00
{
2015-05-05 11:34:49 +02:00
WARN_ON_FPU ( fpu ! = & current - > thread . fpu ) ;
2015-04-03 12:02:02 +02:00
2019-04-03 18:41:52 +02:00
set_thread_flag ( TIF_NEED_FPU_LOAD ) ;
2019-04-03 18:41:36 +02:00
fpstate_init ( & fpu - > state ) ;
trace_x86_fpu_init_state ( fpu ) ;
2015-04-03 12:02:02 +02:00
}
2015-05-27 12:22:29 +02:00
/*
* This function must be called before we read a task ' s fpstate .
*
2017-09-23 15:00:10 +02:00
* There ' s two cases where this gets called :
*
* - for the current task ( when coredumping ) , in which case we have
* to save the latest FPU registers into the fpstate ,
*
* - or it ' s called for stopped tasks ( ptrace ) , in which case the
* registers were already saved by the context - switch code when
2019-04-03 18:41:36 +02:00
* the task scheduled out .
2015-05-27 12:22:29 +02:00
*
* If the task has used the FPU before then save it .
*/
2017-09-23 13:37:45 +02:00
void fpu__prepare_read ( struct fpu * fpu )
2015-05-27 12:22:29 +02:00
{
2019-04-03 18:41:36 +02:00
if ( fpu = = & current - > thread . fpu )
2015-05-27 12:22:29 +02:00
fpu__save ( fpu ) ;
}
2010-05-06 11:45:46 +03:00
/*
2015-05-27 12:22:29 +02:00
* This function must be called before we write a task ' s fpstate .
2015-04-23 14:06:05 +02:00
*
2019-04-03 18:41:36 +02:00
* Invalidate any cached FPU registers .
2015-04-23 14:06:05 +02:00
*
2015-05-27 12:22:29 +02:00
* After this function call , after registers in the fpstate are
* modified and the child task has woken up , the child task will
* restore the modified FPU state from the modified context . If we
2017-09-23 15:00:13 +02:00
* didn ' t clear its cached status here then the cached in - registers
2015-05-27 12:22:29 +02:00
* state pending on its former CPU could be restored , corrupting
* the modifications .
2010-05-06 11:45:46 +03:00
*/
2017-09-23 13:37:45 +02:00
void fpu__prepare_write ( struct fpu * fpu )
2010-05-06 11:45:46 +03:00
{
2015-05-27 12:22:29 +02:00
/*
2015-05-27 12:22:29 +02:00
* Only stopped child tasks can be used to modify the FPU
* state in the fpstate buffer :
2015-05-27 12:22:29 +02:00
*/
2015-05-27 12:22:29 +02:00
WARN_ON_FPU ( fpu = = & current - > thread . fpu ) ;
2019-04-03 18:41:36 +02:00
/* Invalidate any cached state: */
__fpu_invalidate_fpregs_state ( fpu ) ;
2005-04-16 15:20:36 -07:00
}
2015-04-29 20:24:14 +02:00
/*
* Drops current FPU state : deactivates the fpregs and
* the fpstate . NOTE : it still leaves previous contents
* in the fpregs in the eager - FPU case .
*
* This function can be used in cases where we know that
* a state - restore is coming : either an explicit one ,
* or a reschedule .
*/
void fpu__drop ( struct fpu * fpu )
{
preempt_disable ( ) ;
2017-09-23 15:00:00 +02:00
if ( fpu = = & current - > thread . fpu ) {
2019-04-03 18:41:36 +02:00
/* Ignore delayed exceptions from user space */
asm volatile ( " 1: fwait \n "
" 2: \n "
_ASM_EXTABLE ( 1 b , 2 b ) ) ;
fpregs_deactivate ( fpu ) ;
2015-04-29 20:24:14 +02:00
}
2016-06-01 10:42:20 -07:00
trace_x86_fpu_dropped ( fpu ) ;
2015-04-29 20:24:14 +02:00
preempt_enable ( ) ;
}
2015-04-30 11:21:59 +02:00
/*
* Clear FPU registers by setting them up from
* the init fpstate :
*/
static inline void copy_init_fpstate_to_fpregs ( void )
{
2019-04-03 18:41:52 +02:00
fpregs_lock ( ) ;
2015-04-30 11:21:59 +02:00
if ( use_xsave ( ) )
2015-04-30 11:34:09 +02:00
copy_kernel_to_xregs ( & init_fpstate . xsave , - 1 ) ;
2016-03-11 12:32:06 +01:00
else if ( static_cpu_has ( X86_FEATURE_FXSR ) )
2015-04-30 11:34:09 +02:00
copy_kernel_to_fxregs ( & init_fpstate . fxsave ) ;
2016-03-11 12:32:06 +01:00
else
copy_kernel_to_fregs ( & init_fpstate . fsave ) ;
x86/pkeys: Default to a restrictive init PKRU
PKRU is the register that lets you disallow writes or all access to a given
protection key.
The XSAVE hardware defines an "init state" of 0 for PKRU: its most
permissive state, allowing access/writes to everything. Since we start off
all new processes with the init state, we start all processes off with the
most permissive possible PKRU.
This is unfortunate. If a thread is clone()'d [1] before a program has
time to set PKRU to a restrictive value, that thread will be able to write
to all data, no matter what pkey is set on it. This weakens any integrity
guarantees that we want pkeys to provide.
To fix this, we define a very restrictive PKRU to override the
XSAVE-provided value when we create a new FPU context. We choose a value
that only allows access to pkey 0, which is as restrictive as we can
practically make it.
This does not cause any practical problems with applications using
protection keys because we require them to specify initial permissions for
each key when it is allocated, which override the restrictive default.
In the end, this ensures that threads which do not know how to manage their
own pkey rights can not do damage to data which is pkey-protected.
I would have thought this was a pretty contrived scenario, except that I
heard a bug report from an MPX user who was creating threads in some very
early code before main(). It may be crazy, but folks evidently _do_ it.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-arch@vger.kernel.org
Cc: Dave Hansen <dave@sr71.net>
Cc: mgorman@techsingularity.net
Cc: arnd@arndb.de
Cc: linux-api@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: luto@kernel.org
Cc: akpm@linux-foundation.org
Cc: torvalds@linux-foundation.org
Link: http://lkml.kernel.org/r/20160729163021.F3C25D4A@viggo.jf.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2016-07-29 09:30:21 -07:00
if ( boot_cpu_has ( X86_FEATURE_OSPKE ) )
copy_init_pkru_to_fpregs ( ) ;
2019-04-03 18:41:52 +02:00
fpregs_mark_activate ( ) ;
fpregs_unlock ( ) ;
2015-04-30 11:21:59 +02:00
}
2015-04-29 20:24:14 +02:00
/*
2015-04-30 07:12:46 +02:00
* Clear the FPU state back to init state .
*
* Called by sys_execve ( ) , by the signal handler code and by various
* error paths .
2015-04-29 08:46:26 +02:00
*/
2015-04-29 20:35:33 +02:00
void fpu__clear ( struct fpu * fpu )
2015-04-22 11:52:13 +02:00
{
2015-05-05 11:34:49 +02:00
WARN_ON_FPU ( fpu ! = & current - > thread . fpu ) ; /* Almost certainly an anomaly */
2015-04-23 12:46:20 +02:00
2016-11-17 09:11:35 -08:00
fpu__drop ( fpu ) ;
/*
* Make sure fpstate is cleared and initialized .
*/
2019-04-03 18:41:33 +02:00
fpu__initialize ( fpu ) ;
2019-04-03 18:41:37 +02:00
if ( static_cpu_has ( X86_FEATURE_FPU ) )
2015-04-30 11:21:59 +02:00
copy_init_fpstate_to_fpregs ( ) ;
2015-04-22 11:52:13 +02:00
}
2019-04-03 18:41:52 +02:00
/*
* Load FPU context before returning to userspace .
*/
void switch_fpu_return ( void )
{
if ( ! static_cpu_has ( X86_FEATURE_FPU ) )
return ;
__fpregs_load_activate ( ) ;
}
EXPORT_SYMBOL_GPL ( switch_fpu_return ) ;
# ifdef CONFIG_X86_DEBUG_FPU
/*
* If current FPU state according to its tracking ( loaded FPU context on this
* CPU ) is not valid then we must have TIF_NEED_FPU_LOAD set so the context is
* loaded on return to userland .
*/
void fpregs_assert_state_consistent ( void )
{
struct fpu * fpu = & current - > thread . fpu ;
if ( test_thread_flag ( TIF_NEED_FPU_LOAD ) )
return ;
WARN_ON_FPU ( ! fpregs_state_valid ( fpu , smp_processor_id ( ) ) ) ;
}
EXPORT_SYMBOL_GPL ( fpregs_assert_state_consistent ) ;
# endif
void fpregs_mark_activate ( void )
{
struct fpu * fpu = & current - > thread . fpu ;
fpregs_activate ( fpu ) ;
fpu - > last_cpu = smp_processor_id ( ) ;
clear_thread_flag ( TIF_NEED_FPU_LOAD ) ;
}
EXPORT_SYMBOL_GPL ( fpregs_mark_activate ) ;
2015-04-30 09:29:38 +02:00
/*
* x87 math exception handling :
*/
int fpu__exception_code ( struct fpu * fpu , int trap_nr )
{
int err ;
if ( trap_nr = = X86_TRAP_MF ) {
unsigned short cwd , swd ;
/*
* ( ~ cwd & swd ) will mask out exceptions that are not set to unmasked
* status . 0x3f is the exception bits in these regs , 0x200 is the
* C1 reg you need in case of a stack fault , 0x040 is the stack
* fault bit . We should only be taking one exception at a time ,
* so if this combination doesn ' t produce any single exception ,
* then we have a bad program that isn ' t synchronizing its FPU usage
* and it will suffer the consequences since we won ' t be able to
2016-04-05 08:29:55 +02:00
* fully reproduce the context of the exception .
2015-04-30 09:29:38 +02:00
*/
2016-04-05 08:29:55 +02:00
if ( boot_cpu_has ( X86_FEATURE_FXSR ) ) {
cwd = fpu - > state . fxsave . cwd ;
swd = fpu - > state . fxsave . swd ;
} else {
cwd = ( unsigned short ) fpu - > state . fsave . cwd ;
swd = ( unsigned short ) fpu - > state . fsave . swd ;
}
2015-04-30 09:29:38 +02:00
err = swd & ~ cwd ;
} else {
/*
* The SIMD FPU exceptions are handled a little differently , as there
* is only a single status / control register . Thus , to determine which
* unmasked exception was caught we must mask the exception mask bits
* at 0x1f80 , and then use these to mask the exception bits at 0x3f .
*/
2016-04-05 08:29:55 +02:00
unsigned short mxcsr = MXCSR_DEFAULT ;
if ( boot_cpu_has ( X86_FEATURE_XMM ) )
mxcsr = fpu - > state . fxsave . mxcsr ;
2015-04-30 09:29:38 +02:00
err = ~ ( mxcsr > > 7 ) & mxcsr ;
}
if ( err & 0x001 ) { /* Invalid op */
/*
* swd & 0x240 = = 0x040 : Stack Underflow
* swd & 0x240 = = 0x240 : Stack Overflow
* User must clear the SF bit ( 0x40 ) if set
*/
return FPE_FLTINV ;
} else if ( err & 0x004 ) { /* Divide by Zero */
return FPE_FLTDIV ;
} else if ( err & 0x008 ) { /* Overflow */
return FPE_FLTOVF ;
} else if ( err & 0x012 ) { /* Denormal, Underflow */
return FPE_FLTUND ;
} else if ( err & 0x020 ) { /* Precision */
return FPE_FLTRES ;
}
/*
* If we ' re using IRQ 13 , or supposedly even some trap
* X86_TRAP_MF implementations , it ' s possible
* we get a spurious trap , which is not an error .
*/
return 0 ;
}