[Linux-ia64] [PATCH] Clearing of exception status before calling IA32 user sig nal handler

From: Pallipadi, Venkatesh <venkatesh.pallipadi_at_intel.com>
Date: 2002-10-16 11:26:21

   One more bug fix for IA32 exception handler. IA32 exception handler is
not clearing the exception status, before calling the user signal handler
routine. The issue was first observed due to an IA32 binary (which runs fine
on IA32 system), failing on Itanium based system. The binary was trying to
do an "finit" in the user SIGFPE handler. As the exception state was not
cleared before calling the user signal handler, the finit there was failing,
due to the pending exception.

   The attached patch fixes the issue. [Note: Applies over <base> + <IA32
fpstate Save/Restore patch which was sent previously>.]

   Please let me know, if you need any more information on this.


--- ia64-fpe/arch/ia64/ia32/ia32_signal.c.org2	Mon Oct 14 19:10:48 2002
+++ ia64-fpe/arch/ia64/ia32/ia32_signal.c	Tue Oct 15 16:16:23 2002
@@ -219,6 +219,7 @@
 	struct _fpreg_ia32 *fpregp;
 	char buf[32];
 	unsigned long fsr, fcr, fir, fdr;
+	unsigned long new_fsr;
 	unsigned long num128[2];
 	unsigned long mxcsr=0;
 	int fp_tos, fr8_st_map;
@@ -231,6 +232,13 @@
 	asm volatile ( "mov %0=ar.fcr;" : "=r"(fcr));
 	asm volatile ( "mov %0=ar.fir;" : "=r"(fir));
 	asm volatile ( "mov %0=ar.fdr;" : "=r"(fdr));
+	/*
+	 * We need to clear the exception state before calling the signal
+	 * handler. Clear the bits 15, bits 0-7 in fp status word. Similar
+	 * to the functionality of fnclex instruction.
+	 */ 
+	new_fsr = fsr & (~0x80ff) ;
+	asm volatile ( "mov ar.fsr=%0;" :: "r"(new_fsr));
 	__put_user(fcr & 0xffff, &save->cw);
 	__put_user(fsr & 0xffff, &save->sw);

Received on Tue Oct 15 18:26:25 2002

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:10 EST