Skip to contentSkip to conversation

2.4.18-ia64-020226 generalize exception recovery

PATCH David Mosberger 2 participants 3 messages Mar 14, 2002

lore
Share & tools
lore
#0 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Keith Owens
  Keith> +#ifdef GAS_HAS_LOCAL_TAGS
  Keith> +#define HANDLE_EXCEPTION_1(regs) search_exception_table(regs->cr_iip + ia64_psr(regs)->ri);
  Keith> +#else
  Keith> +#define HANDLE_EXCEPTION_1(regs) search_exception_table(regs->cr_iip);
  Keith> +#endif
  Keith> +#define HANDLE_EXCEPTION(regs)			\
  Keith> +{						\
  Keith> +	struct exception_fixup fix;		\
  Keith> +	fix = HANDLE_EXCEPTION_1(regs);		\
  Keith> +	if (fix.cont) {				\
  Keith> +		handle_exception(regs, fix);	\
  Keith> +		return;				\
  Keith> +	}					\
  Keith> +}

I'm OK with the first macro (rename it to SEARCH_EXCEPTION_TABLE, though), but the HANDLE_EXCEPTION() macro is ugly: it looks like a statement, when in fact it's a conditional return.

	--david
#1 lore raw
Quoted 3 lines · David Mosberger

I'm OK with the first macro (rename it to SEARCH_EXCEPTION_TABLE, though), but the HANDLE_EXCEPTION() macro is ugly: it looks like a statement, when in fact it's a conditional return.

Take 2.

Index: 18.5/include/asm-ia64/uaccess.h

include/asm-ia64/uaccess.h Thu, 14 Mar 2002 15:30:16 +1100 kaos (linux-2.4/s/20_uaccess.h 1.1.1.1 644) renamed from include/asm-ia64/uaccess.h Sun, 08 Apr 2001 14:10:15 +1000 kaos (linux-2.4/s/20_uaccess.h 1.1.1.1 644) +17 -0
@@ -320,4 +320,21 @@ struct exception_fixup {
 extern struct exception_fixup search_exception_table (unsigned long addr);
 extern void handle_exception (struct pt_regs *regs, struct exception_fixup fixup);
 
+#ifdef GAS_HAS_LOCAL_TAGS
+#define SEARCH_EXCEPTION_TABLE(regs) search_exception_table(regs->cr_iip + ia64_psr(regs)->ri);
+#else
+#define SEARCH_EXCEPTION_TABLE(regs) search_exception_table(regs->cr_iip);
+#endif
+static inline int HANDLE_EXCEPTION(struct pt_regs *regs)
+{
+	struct exception_fixup fix;
+	fix = SEARCH_EXCEPTION_TABLE(regs);
+	if (fix.cont) {
+		handle_exception(regs, fix);
+		return(1);
+	}
+	return(0);
+}
+
+
 #endif /* _ASM_IA64_UACCESS_H */

Index: 18.5/arch/ia64/mm/fault.c

arch/ia64/mm/fault.c Thu, 14 Mar 2002 15:30:35 +1100 kaos (linux-2.4/r/c/10_fault.c 1.3.1.2 644) renamed from arch/ia64/mm/fault.c Wed, 27 Feb 2002 12:38:35 +1100 kaos (linux-2.4/r/c/10_fault.c 1.3.1.2 644) +1 -9
@@ -49,7 +49,6 @@ ia64_do_page_fault (unsigned long addres
 	int signal = SIGSEGV, code = SEGV_MAPERR;
 	struct vm_area_struct *vma, *prev_vma;
 	struct mm_struct *mm = current->mm;
-	struct exception_fixup fix;
 	struct siginfo si;
 	unsigned long mask;
 
@@ -167,15 +166,8 @@ ia64_do_page_fault (unsigned long addres
 		return;
 	}
 
-#ifdef GAS_HAS_LOCAL_TAGS
-	fix = search_exception_table(regs->cr_iip + ia64_psr(regs)->ri);
-#else
-	fix = search_exception_table(regs->cr_iip);
-#endif
-	if (fix.cont) {
-		handle_exception(regs, fix);
+	if (HANDLE_EXCEPTION(regs))
 		return;
-	}
 
 	/*
 	 * Oops. The kernel tried to access some bad page. We'll have to terminate things

Index: 18.5/arch/ia64/kernel/unaligned.c

arch/ia64/kernel/unaligned.c Thu, 14 Mar 2002 15:30:59 +1100 kaos (linux-2.4/r/c/40_unaligned. 1.1.3.1.3.1.1.2 644) renamed from arch/ia64/kernel/unaligned.c Wed, 27 Feb 2002 12:38:35 +1100 kaos (linux-2.4/r/c/40_unaligned. 1.1.3.1.3.1.1.2 644) +1 -5
@@ -1304,11 +1304,7 @@ ia64_handle_unaligned (unsigned long ifa
 	 * handler into reading an arbitrary kernel addresses...
 	 */
 	if (!user_mode(regs)) {
-#ifdef GAS_HAS_LOCAL_TAGS
-		fix = search_exception_table(regs->cr_iip + ia64_psr(regs)->ri);
-#else
-		fix = search_exception_table(regs->cr_iip);
-#endif
+		fix = SEARCH_EXCEPTION_TABLE(regs);
 	}
 	if (user_mode(regs) || fix.cont) {
 		if ((current->thread.flags & IA64_THREAD_UAC_SIGBUS) != 0)

kdb update to go with above.

Index: 18.5/arch/ia64/kernel/traps.c
--- 18.5/arch/ia64/kernel/traps.c Wed, 27 Feb 2002 12:38:35 +1100 kaos (linux-2.4/r/c/43_traps.c 1.1.4.1.3.1.1.2 644) +++ 18.5(w)/arch/ia64/kernel/traps.c Thu, 14 Mar 2002 15:31:31 +1100 kaos (linux-2.4/r/c/43_traps.c 1.1.4.1.3.1.1.2 644) @@ -591,6 +591,10 @@ ia64_fault (unsigned long vector, unsign

		  sprintf(buf, "Fault %lu", vector);
		  break;
	  }
  +#ifdef	CONFIG_KDB
  +	if (KDB_IS_RUNNING() && HANDLE_EXCEPTION(regs))
  +		return;
  +#endif	/* CONFIG_KDB */
	  die_if_kernel(buf, regs, error);
	  force_sig(SIGILL, current);

}

#2 lore raw
In reply to David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Keith Owens

Keith> On Wed, 13 Mar 2002 19:13:44 -0800,

Quoted 3 lines · Keith> David Mosberger <[email protected]> wrote:
Quoted 3 lines

I'm OK with the first macro (rename it to SEARCH_EXCEPTION_TABLE, though), but the HANDLE_EXCEPTION() macro is ugly: it looks like a statement, when in fact it's a conditional return.

Keith> Take 2.

I applied the attached patch, which is the same as yours except for renaming HANDLE_EXCEPTION() to done_with_exception(). I hope this works for you.

	--david

=== arch/ia64/kernel/unaligned.c 1.5 vs edited ==--- 1.5/arch/ia64/kernel/unaligned.c Fri Mar 8 18:11:40 2002
+++ edited/arch/ia64/kernel/unaligned.c Wed Mar 13 22:37:11 2002
@@ -1305,11 +1305,7 @@
* handler into reading an arbitrary kernel addresses... */
if (!user_mode(regs)) {
-#ifdef GAS_HAS_LOCAL_TAGS
- fix = search_exception_table(regs->cr_iip + ia64_psr(regs)->ri);
-#else
- fix = search_exception_table(regs->cr_iip);
-#endif
+ fix = SEARCH_EXCEPTION_TABLE(regs);
}
if (user_mode(regs) || fix.cont) {
if ((current->thread.flags & IA64_THREAD_UAC_SIGBUS) != 0)
=== arch/ia64/mm/fault.c 1.5 vs edited ==--- 1.5/arch/ia64/mm/fault.c Fri Mar 8 18:11:40 2002
+++ edited/arch/ia64/mm/fault.c Wed Mar 13 22:43:00 2002
@@ -49,7 +49,6 @@
int signal = SIGSEGV, code = SEGV_MAPERR;
struct vm_area_struct *vma, *prev_vma;
struct mm_struct *mm = current->mm;
- struct exception_fixup fix;
struct siginfo si;
unsigned long mask;

@@ -167,15 +166,8 @@
return;
}

-#ifdef GAS_HAS_LOCAL_TAGS
- fix = search_exception_table(regs->cr_iip + ia64_psr(regs)->ri);
-#else
- fix = search_exception_table(regs->cr_iip);
-#endif
- if (fix.cont) {
- handle_exception(regs, fix);
+ if (done_with_exception(regs))
return;
- }

/*
* Oops. The kernel tried to access some bad page. We'll have to terminate things
=== include/asm-ia64/uaccess.h 1.3 vs edited ==--- 1.3/include/asm-ia64/uaccess.h Fri Mar 8 18:11:40 2002
+++ edited/include/asm-ia64/uaccess.h Wed Mar 13 22:43:05 2002
@@ -320,4 +320,22 @@
extern struct exception_fixup search_exception_table (unsigned long addr); extern void handle_exception (struct pt_regs *regs, struct exception_fixup fixup);

+#ifdef GAS_HAS_LOCAL_TAGS
+#define SEARCH_EXCEPTION_TABLE(regs) search_exception_table(regs->cr_iip + ia64_psr(regs)->ri); +#else
+#define SEARCH_EXCEPTION_TABLE(regs) search_exception_table(regs->cr_iip); +#endif
+
+static inline int
+done_with_exception (struct pt_regs *regs)
+{
+ struct exception_fixup fix;
+ fix = SEARCH_EXCEPTION_TABLE(regs);
+ if (fix.cont) {
+ handle_exception(regs, fix);
+ return 1;
+ }
+ return 0;
+}
+
#endif /* _ASM_IA64_UACCESS_H */