From: Hirokazu Takata <takata@linux-m32r.org>

[PATCH 2.6.10-rc3-mm1] m32r: Don't encode ACE_INSTRUCTION in address (2/3)
- To be more comprehensive, keep ACE_INSTRUCTION (access exception 
  on instruction execution) information in thread_info->flags,
  instead of encoding it into address parameter.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
---

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/m32r/mm/fault.c           |    7 ++++---
 25-akpm/include/asm-m32r/thread_info.h |   16 ++++++++++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)

diff -puN arch/m32r/mm/fault.c~m32r-dont-encode-ace_instruction-in arch/m32r/mm/fault.c
--- 25/arch/m32r/mm/fault.c~m32r-dont-encode-ace_instruction-in	Thu Dec 16 15:40:14 2004
+++ 25-akpm/arch/m32r/mm/fault.c	Thu Dec 16 15:40:14 2004
@@ -222,7 +222,8 @@ survive:
 	 * make sure we exit gracefully rather than endlessly redo
 	 * the fault.
 	 */
-	addr = (address & PAGE_MASK) | (error_code & ACE_INSTRUCTION);
+	addr = (address & PAGE_MASK);
+	set_thread_fault_code(error_code);
 	switch (handle_mm_fault(mm, vma, addr, write)) {
 		case VM_FAULT_MINOR:
 			tsk->min_flt++;
@@ -237,7 +238,7 @@ survive:
 		default:
 			BUG();
 	}
-
+	set_thread_fault_code(0);
 	up_read(&mm->mmap_sem);
 	return;
 
@@ -381,7 +382,7 @@ void update_mmu_cache(struct vm_area_str
 	unsigned long *entry1, *entry2;
 	unsigned long pte_data, flags;
 	unsigned int *entry_dat;
-	int inst = vaddr & 8;
+	int inst = get_thread_fault_code() & ACE_INSTRUCTION;
 	int i;
 
 	/* Ptrace may call this routine. */
diff -puN include/asm-m32r/thread_info.h~m32r-dont-encode-ace_instruction-in include/asm-m32r/thread_info.h
--- 25/include/asm-m32r/thread_info.h~m32r-dont-encode-ace_instruction-in	Thu Dec 16 15:40:14 2004
+++ 25-akpm/include/asm-m32r/thread_info.h	Thu Dec 16 15:40:14 2004
@@ -99,6 +99,21 @@ static inline struct thread_info *curren
 #define get_thread_info(ti) get_task_struct((ti)->task)
 #define put_thread_info(ti) put_task_struct((ti)->task)
 
+#define TI_FLAG_FAULT_CODE_SHIFT	28
+
+static inline void set_thread_fault_code(unsigned int val)
+{
+	struct thread_info *ti = current_thread_info();
+	ti->flags = (ti->flags & (~0 >> (32 - TI_FLAG_FAULT_CODE_SHIFT)))
+		| (val << TI_FLAG_FAULT_CODE_SHIFT);
+}
+
+static inline unsigned int get_thread_fault_code(void)
+{
+	struct thread_info *ti = current_thread_info();
+	return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT;
+}
+
 #else /* !__ASSEMBLY__ */
 
 /* how to get the thread information struct from ASM */
@@ -123,6 +138,7 @@ static inline struct thread_info *curren
 #define TIF_SINGLESTEP		4	/* restore singlestep on return to user mode */
 #define TIF_IRET		5	/* return with iret */
 #define TIF_POLLING_NRFLAG	16	/* true if poll_idle() is polling TIF_NEED_RESCHED */
+					/* 31..28 fault code */
 
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
_