public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [Linux-ia64] [PATCH] Clearing of exception status before calling IA32 user sig
@ 2002-10-16  1:26 Pallipadi, Venkatesh
  0 siblings, 0 replies; only message in thread
From: Pallipadi, Venkatesh @ 2002-10-16  1:26 UTC (permalink / raw)
  To: linux-ia64

[-- Attachment #1: Type: text/plain, Size: 1600 bytes --]


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

--- 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);
 <<fpe.2418_finit.patch>> 

[-- Attachment #2: fpe.2418_finit.patch --]
[-- Type: application/octet-stream, Size: 893 bytes --]

--- 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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-16  1:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-16  1:26 [Linux-ia64] [PATCH] Clearing of exception status before calling IA32 user sig Pallipadi, Venkatesh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox