Skip to contentSkip to conversation

Clearing of exception status before calling IA32 user sig

PATCH New Pallipadi, Venkatesh 1 participant 1 message Oct 16, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Clearing of exception status before calling IA32 user sig

Hi,

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.

Thanks,
-Venkatesh

arch/ia64/ia32/ia32_signal.c renamed from arch/ia64/ia32/ia32_signal.c.org2 +8 -0
@@ -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);

<<fpe.2418_finit.patch>>

arch/ia64/ia32/ia32_signal.c renamed from arch/ia64/ia32/ia32_signal.c.org2 +8 -0
@@ -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);