diff options
author | Paul Mundt <lethal@linux-sh.org> | 2012-05-14 01:57:28 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2012-05-14 01:57:28 -0400 |
commit | 5a1dc78a38bfb04159a08cd493e5b3d844939e6c (patch) | |
tree | 860420d3d52e2666449d1e688c399876a5c16bd3 /arch/sh/include/asm/thread_info.h | |
parent | f007688a50cf5724049a4a5f17023fcdb0966b54 (diff) |
sh: Support thread fault code encoding.
This provides a simple interface modelled after sparc64/m32r to encode
the error code in the upper byte of thread_info for finer-grained
handling in the page fault path.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/include/asm/thread_info.h')
-rw-r--r-- | arch/sh/include/asm/thread_info.h | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/arch/sh/include/asm/thread_info.h b/arch/sh/include/asm/thread_info.h index 20ee40af16e9..25a13e534ffe 100644 --- a/arch/sh/include/asm/thread_info.h +++ b/arch/sh/include/asm/thread_info.h | |||
@@ -10,8 +10,18 @@ | |||
10 | * - Incorporating suggestions made by Linus Torvalds and Dave Miller | 10 | * - Incorporating suggestions made by Linus Torvalds and Dave Miller |
11 | */ | 11 | */ |
12 | #ifdef __KERNEL__ | 12 | #ifdef __KERNEL__ |
13 | |||
13 | #include <asm/page.h> | 14 | #include <asm/page.h> |
14 | 15 | ||
16 | /* | ||
17 | * Page fault error code bits | ||
18 | */ | ||
19 | #define FAULT_CODE_WRITE (1 << 0) /* write access */ | ||
20 | #define FAULT_CODE_INITIAL (1 << 1) /* initial page write */ | ||
21 | #define FAULT_CODE_ITLB (1 << 2) /* ITLB miss */ | ||
22 | #define FAULT_CODE_PROT (1 << 3) /* protection fault */ | ||
23 | #define FAULT_CODE_USER (1 << 4) /* user-mode access */ | ||
24 | |||
15 | #ifndef __ASSEMBLY__ | 25 | #ifndef __ASSEMBLY__ |
16 | #include <asm/processor.h> | 26 | #include <asm/processor.h> |
17 | 27 | ||
@@ -107,10 +117,13 @@ extern void init_thread_xstate(void); | |||
107 | #endif /* __ASSEMBLY__ */ | 117 | #endif /* __ASSEMBLY__ */ |
108 | 118 | ||
109 | /* | 119 | /* |
110 | * thread information flags | 120 | * Thread information flags |
111 | * - these are process state flags that various assembly files may need to access | 121 | * |
112 | * - pending work-to-be-done flags are in LSW | 122 | * - Limited to 24 bits, upper byte used for fault code encoding. |
113 | * - other flags in MSW | 123 | * |
124 | * - _TIF_ALLWORK_MASK and _TIF_WORK_MASK need to fit within 2 bytes, or | ||
125 | * we blow the tst immediate size constraints and need to fix up | ||
126 | * arch/sh/kernel/entry-common.S. | ||
114 | */ | 127 | */ |
115 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ | 128 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ |
116 | #define TIF_SIGPENDING 1 /* signal pending */ | 129 | #define TIF_SIGPENDING 1 /* signal pending */ |
@@ -133,12 +146,6 @@ extern void init_thread_xstate(void); | |||
133 | #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) | 146 | #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) |
134 | #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) | 147 | #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) |
135 | 148 | ||
136 | /* | ||
137 | * _TIF_ALLWORK_MASK and _TIF_WORK_MASK need to fit within 2 bytes, or we | ||
138 | * blow the tst immediate size constraints and need to fix up | ||
139 | * arch/sh/kernel/entry-common.S. | ||
140 | */ | ||
141 | |||
142 | /* work to do in syscall trace */ | 149 | /* work to do in syscall trace */ |
143 | #define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \ | 150 | #define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \ |
144 | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \ | 151 | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \ |
@@ -165,6 +172,7 @@ extern void init_thread_xstate(void); | |||
165 | #define TS_USEDFPU 0x0002 /* FPU used by this task this quantum */ | 172 | #define TS_USEDFPU 0x0002 /* FPU used by this task this quantum */ |
166 | 173 | ||
167 | #ifndef __ASSEMBLY__ | 174 | #ifndef __ASSEMBLY__ |
175 | |||
168 | #define HAVE_SET_RESTORE_SIGMASK 1 | 176 | #define HAVE_SET_RESTORE_SIGMASK 1 |
169 | static inline void set_restore_sigmask(void) | 177 | static inline void set_restore_sigmask(void) |
170 | { | 178 | { |
@@ -172,6 +180,24 @@ static inline void set_restore_sigmask(void) | |||
172 | ti->status |= TS_RESTORE_SIGMASK; | 180 | ti->status |= TS_RESTORE_SIGMASK; |
173 | set_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags); | 181 | set_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags); |
174 | } | 182 | } |
183 | |||
184 | #define TI_FLAG_FAULT_CODE_SHIFT 24 | ||
185 | |||
186 | /* | ||
187 | * Additional thread flag encoding | ||
188 | */ | ||
189 | static inline void set_thread_fault_code(unsigned int val) | ||
190 | { | ||
191 | struct thread_info *ti = current_thread_info(); | ||
192 | ti->flags = (ti->flags & (~0 >> (32 - TI_FLAG_FAULT_CODE_SHIFT))) | ||
193 | | (val << TI_FLAG_FAULT_CODE_SHIFT); | ||
194 | } | ||
195 | |||
196 | static inline unsigned int get_thread_fault_code(void) | ||
197 | { | ||
198 | struct thread_info *ti = current_thread_info(); | ||
199 | return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT; | ||
200 | } | ||
175 | #endif /* !__ASSEMBLY__ */ | 201 | #endif /* !__ASSEMBLY__ */ |
176 | 202 | ||
177 | #endif /* __KERNEL__ */ | 203 | #endif /* __KERNEL__ */ |