History

[PATCH] x86_64: Implement is_compat_task the right way

By setting a flag during a 32bit system call only

Andi Kleen committed 20 years ago

Commit bf2fcc61 parent 29663876 files · +16 −1Browse files

Unified · Split

6 files
  1. arch/x86_64/ia32/ia32entry.S +5 −0
  2. arch/x86_64/kernel/asm-offsets.c +1 −0
  3. arch/x86_64/kernel/entry.S +1 −0
  4. drivers/input/evdev.c +3 −1
  5. include/asm-x86_64/compat.h +5 −0
  6. include/asm-x86_64/thread_info.h +1 −0
arch/x86_64/ia32/ia32entry.S+5−0
@@ -104,6 +104,7 @@ ENTRY(ia32_sysenter_target) · 103 unmodified lines
104 .quad 1b,ia32_badarg104 .quad 1b,ia32_badarg
105 .previous 105 .previous
106 GET_THREAD_INFO(%r10)106 GET_THREAD_INFO(%r10)
107 orl $TS_COMPAT,threadinfo_status(%r10)
107 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)108 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
108 CFI_REMEMBER_STATE109 CFI_REMEMBER_STATE
109 jnz sysenter_tracesys110 jnz sysenter_tracesys
@@ -117,6 +118,7 @@ sysenter_do_call: · 7 unmodified lines
117 cli118 cli
118 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)119 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
119 jnz int_ret_from_sys_call120 jnz int_ret_from_sys_call
121 andl $~TS_COMPAT,threadinfo_status(%r10)
120 /* clear IF, that popfq doesn't enable interrupts early */122 /* clear IF, that popfq doesn't enable interrupts early */
121 andl $~0x200,EFLAGS-R11(%rsp) 123 andl $~0x200,EFLAGS-R11(%rsp)
122 RESTORE_ARGS 1,24,1,1,1,1124 RESTORE_ARGS 1,24,1,1,1,1
@@ -203,6 +205,7 @@ ENTRY(ia32_cstar_target) · 80 unmodified lines
203 .quad 1b,ia32_badarg205 .quad 1b,ia32_badarg
204 .previous 206 .previous
205 GET_THREAD_INFO(%r10)207 GET_THREAD_INFO(%r10)
208 orl $TS_COMPAT,threadinfo_status(%r10)
206 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)209 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
207 CFI_REMEMBER_STATE210 CFI_REMEMBER_STATE
208 jnz cstar_tracesys211 jnz cstar_tracesys
@@ -216,6 +219,7 @@ cstar_do_call: · 7 unmodified lines
216 cli219 cli
217 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)220 testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
218 jnz int_ret_from_sys_call221 jnz int_ret_from_sys_call
222 andl $~TS_COMPAT,threadinfo_status(%r10)
219 RESTORE_ARGS 1,-ARG_SKIP,1,1,1223 RESTORE_ARGS 1,-ARG_SKIP,1,1,1
220 movl RIP-ARGOFFSET(%rsp),%ecx224 movl RIP-ARGOFFSET(%rsp),%ecx
221 CFI_REGISTER rip,rcx225 CFI_REGISTER rip,rcx
@@ -288,6 +292,7 @@ ENTRY(ia32_syscall) · 66 unmodified lines
288 this could be a problem. */292 this could be a problem. */
289 SAVE_ARGS 0,0,1293 SAVE_ARGS 0,0,1
290 GET_THREAD_INFO(%r10)294 GET_THREAD_INFO(%r10)
295 orl $TS_COMPAT,threadinfo_status(%r10)
291 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)296 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%r10)
292 jnz ia32_tracesys297 jnz ia32_tracesys
293ia32_do_syscall: 298ia32_do_syscall:
arch/x86_64/kernel/asm-offsets.c+1−0
@@ -33,6 +33,7 @@ int main(void) · 32 unmodified lines
33 ENTRY(flags);33 ENTRY(flags);
34 ENTRY(addr_limit);34 ENTRY(addr_limit);
35 ENTRY(preempt_count);35 ENTRY(preempt_count);
36 ENTRY(status);
36 BLANK();37 BLANK();
37#undef ENTRY38#undef ENTRY
38#define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry))39#define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry))
arch/x86_64/kernel/entry.S+1−0
@@ -313,6 +313,7 @@ int_with_check: · 312 unmodified lines
313 movl threadinfo_flags(%rcx),%edx313 movl threadinfo_flags(%rcx),%edx
314 andl %edi,%edx314 andl %edi,%edx
315 jnz int_careful315 jnz int_careful
316 andl $~TS_COMPAT,threadinfo_status(%rcx)
316 jmp retint_swapgs317 jmp retint_swapgs
317 318
318 /* Either reschedule or signal or syscall exit tracking needed. */319 /* Either reschedule or signal or syscall exit tracking needed. */
drivers/input/evdev.c+3−1
@@ -154,8 +154,10 @@ struct input_event_compat { · 153 unmodified lines
154 __s32 value;154 __s32 value;
155};155};
156 156
157/* Note to the author of this code: did it ever occur to
158 you why the ifdefs are needed? Think about it again. -AK */
157#ifdef CONFIG_X86_64159#ifdef CONFIG_X86_64
158# define COMPAT_TEST test_thread_flag(TIF_IA32)160# define COMPAT_TEST is_compat_task()
159#elif defined(CONFIG_IA64)161#elif defined(CONFIG_IA64)
160# define COMPAT_TEST IS_IA32_PROCESS(ia64_task_regs(current))162# define COMPAT_TEST IS_IA32_PROCESS(ia64_task_regs(current))
161#elif defined(CONFIG_S390)163#elif defined(CONFIG_S390)
include/asm-x86_64/compat.h+5−0
@@ -202,4 +202,9 @@ static __inline__ void __user *compat_alloc_user_space(long len) · 201 unmodified lines
202 return (void __user *)regs->rsp - len; 202 return (void __user *)regs->rsp - len;
203}203}
204 204
205static inline int is_compat_task(void)
206{
207 return current_thread_info()->status & TS_COMPAT;
208}
209
205#endif /* _ASM_X86_64_COMPAT_H */210#endif /* _ASM_X86_64_COMPAT_H */
include/asm-x86_64/thread_info.h+1−0
@@ -138,6 +138,7 @@ static inline struct thread_info *stack_thread_info(void) · 137 unmodified lines
138 * have to worry about atomic accesses.138 * have to worry about atomic accesses.
139 */139 */
140#define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */140#define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */
141#define TS_COMPAT 0x0002 /* 32bit syscall active */
141 142
142#endif /* __KERNEL__ */143#endif /* __KERNEL__ */
143 144

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t