Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[S390] implement is_compat_task

Implement is_compat_task and use it all over the place.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Heiko Carstens and committed by
Martin Schwidefsky
7757591a d90cbd46

+36 -19
+18 -1
arch/s390/include/asm/compat.h
··· 5 5 */ 6 6 #include <linux/types.h> 7 7 #include <linux/sched.h> 8 + #include <linux/thread_info.h> 8 9 9 10 #define PSW32_MASK_PER 0x40000000UL 10 11 #define PSW32_MASK_DAT 0x04000000UL ··· 164 163 return (u32)(unsigned long)uptr; 165 164 } 166 165 166 + #ifdef CONFIG_COMPAT 167 + 168 + static inline int is_compat_task(void) 169 + { 170 + return test_thread_flag(TIF_31BIT); 171 + } 172 + 173 + #else 174 + 175 + static inline int is_compat_task(void) 176 + { 177 + return 0; 178 + } 179 + 180 + #endif 181 + 167 182 static inline void __user *compat_alloc_user_space(long len) 168 183 { 169 184 unsigned long stack; 170 185 171 186 stack = KSTK_ESP(current); 172 - if (test_thread_flag(TIF_31BIT)) 187 + if (is_compat_task()) 173 188 stack &= 0x7fffffffUL; 174 189 return (void __user *) (stack - len); 175 190 }
+2 -1
arch/s390/kernel/process.c
··· 32 32 #include <linux/elfcore.h> 33 33 #include <linux/kernel_stat.h> 34 34 #include <linux/syscalls.h> 35 + #include <asm/compat.h> 35 36 #include <asm/uaccess.h> 36 37 #include <asm/pgtable.h> 37 38 #include <asm/system.h> ··· 205 204 save_fp_regs(&p->thread.fp_regs); 206 205 /* Set a new TLS ? */ 207 206 if (clone_flags & CLONE_SETTLS) { 208 - if (test_thread_flag(TIF_31BIT)) { 207 + if (is_compat_task()) { 209 208 p->thread.acrs[0] = (unsigned int) regs->gprs[6]; 210 209 } else { 211 210 p->thread.acrs[0] = (unsigned int)(regs->gprs[6] >> 32);
+5 -7
arch/s390/kernel/ptrace.c
··· 36 36 #include <linux/elf.h> 37 37 #include <linux/regset.h> 38 38 #include <linux/tracehook.h> 39 - 39 + #include <linux/compat.h> 40 40 #include <asm/segment.h> 41 41 #include <asm/page.h> 42 42 #include <asm/pgtable.h> ··· 69 69 if (per_info->single_step) { 70 70 per_info->control_regs.bits.starting_addr = 0; 71 71 #ifdef CONFIG_COMPAT 72 - if (test_thread_flag(TIF_31BIT)) 72 + if (is_compat_task()) 73 73 per_info->control_regs.bits.ending_addr = 0x7fffffffUL; 74 74 else 75 75 #endif ··· 482 482 { 483 483 __u32 tmp; 484 484 485 - if (!test_thread_flag(TIF_31BIT) || 486 - (addr & 3) || addr > sizeof(struct user) - 3) 485 + if (!is_compat_task() || (addr & 3) || addr > sizeof(struct user) - 3) 487 486 return -EIO; 488 487 489 488 tmp = __peek_user_compat(child, addr); ··· 583 584 static int poke_user_compat(struct task_struct *child, 584 585 addr_t addr, addr_t data) 585 586 { 586 - if (!test_thread_flag(TIF_31BIT) || 587 - (addr & 3) || addr > sizeof(struct user32) - 3) 587 + if (!is_compat_task() || (addr & 3) || addr > sizeof(struct user32) - 3) 588 588 return -EIO; 589 589 590 590 return __poke_user_compat(child, addr, data); ··· 658 660 } 659 661 660 662 if (unlikely(current->audit_context)) 661 - audit_syscall_entry(test_thread_flag(TIF_31BIT) ? 663 + audit_syscall_entry(is_compat_task() ? 662 664 AUDIT_ARCH_S390 : AUDIT_ARCH_S390X, 663 665 regs->gprs[2], regs->orig_gpr2, 664 666 regs->gprs[3], regs->gprs[4],
+2 -1
arch/s390/kernel/signal.c
··· 26 26 #include <linux/binfmts.h> 27 27 #include <linux/tracehook.h> 28 28 #include <linux/syscalls.h> 29 + #include <linux/compat.h> 29 30 #include <asm/ucontext.h> 30 31 #include <asm/uaccess.h> 31 32 #include <asm/lowcore.h> ··· 483 482 /* Whee! Actually deliver the signal. */ 484 483 int ret; 485 484 #ifdef CONFIG_COMPAT 486 - if (test_thread_flag(TIF_31BIT)) { 485 + if (is_compat_task()) { 487 486 ret = handle_signal32(signr, &ka, &info, oldset, regs); 488 487 } 489 488 else
+2 -2
arch/s390/kernel/vdso.c
··· 22 22 #include <linux/elf.h> 23 23 #include <linux/security.h> 24 24 #include <linux/bootmem.h> 25 - 25 + #include <linux/compat.h> 26 26 #include <asm/pgtable.h> 27 27 #include <asm/system.h> 28 28 #include <asm/processor.h> ··· 214 214 vdso_pagelist = vdso64_pagelist; 215 215 vdso_pages = vdso64_pages; 216 216 #ifdef CONFIG_COMPAT 217 - if (test_thread_flag(TIF_31BIT)) { 217 + if (is_compat_task()) { 218 218 vdso_pagelist = vdso32_pagelist; 219 219 vdso_pages = vdso32_pages; 220 220 }
+2 -1
arch/s390/mm/fault.c
··· 19 19 #include <linux/ptrace.h> 20 20 #include <linux/mman.h> 21 21 #include <linux/mm.h> 22 + #include <linux/compat.h> 22 23 #include <linux/smp.h> 23 24 #include <linux/kdebug.h> 24 25 #include <linux/smp_lock.h> ··· 240 239 up_read(&mm->mmap_sem); 241 240 clear_tsk_thread_flag(current, TIF_SINGLE_STEP); 242 241 #ifdef CONFIG_COMPAT 243 - compat = test_tsk_thread_flag(current, TIF_31BIT); 242 + compat = is_compat_task(); 244 243 if (compat && instruction == 0x0a77) 245 244 sys32_sigreturn(); 246 245 else if (compat && instruction == 0x0aad)
+5 -6
arch/s390/mm/mmap.c
··· 28 28 #include <linux/mm.h> 29 29 #include <linux/module.h> 30 30 #include <asm/pgalloc.h> 31 + #include <asm/compat.h> 31 32 32 33 /* 33 34 * Top of mmap area (just below the process stack). ··· 56 55 /* 57 56 * Force standard allocation for 64 bit programs. 58 57 */ 59 - if (!test_thread_flag(TIF_31BIT)) 58 + if (!is_compat_task()) 60 59 return 1; 61 60 #endif 62 61 return sysctl_legacy_va_layout || ··· 92 91 93 92 int s390_mmap_check(unsigned long addr, unsigned long len) 94 93 { 95 - if (!test_thread_flag(TIF_31BIT) && 94 + if (!is_compat_task() && 96 95 len >= TASK_SIZE && TASK_SIZE < (1UL << 53)) 97 96 return crst_table_upgrade(current->mm, 1UL << 53); 98 97 return 0; ··· 109 108 area = arch_get_unmapped_area(filp, addr, len, pgoff, flags); 110 109 if (!(area & ~PAGE_MASK)) 111 110 return area; 112 - if (area == -ENOMEM && 113 - !test_thread_flag(TIF_31BIT) && TASK_SIZE < (1UL << 53)) { 111 + if (area == -ENOMEM && !is_compat_task() && TASK_SIZE < (1UL << 53)) { 114 112 /* Upgrade the page table to 4 levels and retry. */ 115 113 rc = crst_table_upgrade(mm, 1UL << 53); 116 114 if (rc) ··· 131 131 area = arch_get_unmapped_area_topdown(filp, addr, len, pgoff, flags); 132 132 if (!(area & ~PAGE_MASK)) 133 133 return area; 134 - if (area == -ENOMEM && 135 - !test_thread_flag(TIF_31BIT) && TASK_SIZE < (1UL << 53)) { 134 + if (area == -ENOMEM && !is_compat_task() && TASK_SIZE < (1UL << 53)) { 136 135 /* Upgrade the page table to 4 levels and retry. */ 137 136 rc = crst_table_upgrade(mm, 1UL << 53); 138 137 if (rc)