uaccess.h (05909cd9a0c8811731b38697af13075e8954314f) | uaccess.h (05cdf457477d6603b207d91873f0a3d4c7f8c1cd) |
---|---|
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu> 4 * Copyright (C) 2008-2009 PetaLogix 5 * Copyright (C) 2006 Atmark Techno, Inc. 6 */ 7 8#ifndef _ASM_MICROBLAZE_UACCESS_H --- 16 unchanged lines hidden (view full) --- 25 * get_fs() == KERNEL_DS, checking is bypassed. 26 * 27 * For historical reasons, these macros are grossly misnamed. 28 * 29 * For non-MMU arch like Microblaze, KERNEL_DS and USER_DS is equal. 30 */ 31# define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) 32 | 1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu> 4 * Copyright (C) 2008-2009 PetaLogix 5 * Copyright (C) 2006 Atmark Techno, Inc. 6 */ 7 8#ifndef _ASM_MICROBLAZE_UACCESS_H --- 16 unchanged lines hidden (view full) --- 25 * get_fs() == KERNEL_DS, checking is bypassed. 26 * 27 * For historical reasons, these macros are grossly misnamed. 28 * 29 * For non-MMU arch like Microblaze, KERNEL_DS and USER_DS is equal. 30 */ 31# define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) 32 |
33# ifndef CONFIG_MMU 34# define KERNEL_DS MAKE_MM_SEG(0) 35# define USER_DS KERNEL_DS 36# else | |
37# define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF) 38# define USER_DS MAKE_MM_SEG(TASK_SIZE - 1) | 33# define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFF) 34# define USER_DS MAKE_MM_SEG(TASK_SIZE - 1) |
39# endif | |
40 41# define get_fs() (current_thread_info()->addr_limit) 42# define set_fs(val) (current_thread_info()->addr_limit = (val)) 43 44# define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg) 45 | 35 36# define get_fs() (current_thread_info()->addr_limit) 37# define set_fs(val) (current_thread_info()->addr_limit = (val)) 38 39# define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg) 40 |
46#ifndef CONFIG_MMU 47 48/* Check against bounds of physical memory */ 49static inline int ___range_ok(unsigned long addr, unsigned long size) 50{ 51 return ((addr < memory_start) || 52 ((addr + size - 1) > (memory_start + memory_size - 1))); 53} 54 55#define __range_ok(addr, size) \ 56 ___range_ok((unsigned long)(addr), (unsigned long)(size)) 57 58#define access_ok(addr, size) (__range_ok((addr), (size)) == 0) 59 60#else 61 | |
62static inline int access_ok(const void __user *addr, unsigned long size) 63{ 64 if (!size) 65 goto ok; 66 67 if ((get_fs().seg < ((unsigned long)addr)) || 68 (get_fs().seg < ((unsigned long)addr + size - 1))) { 69 pr_devel("ACCESS fail at 0x%08x (size 0x%x), seg 0x%08x\n", 70 (__force u32)addr, (u32)size, 71 (u32)get_fs().seg); 72 return 0; 73 } 74ok: 75 pr_devel("ACCESS OK at 0x%08x (size 0x%x), seg 0x%08x\n", 76 (__force u32)addr, (u32)size, 77 (u32)get_fs().seg); 78 return 1; 79} | 41static inline int access_ok(const void __user *addr, unsigned long size) 42{ 43 if (!size) 44 goto ok; 45 46 if ((get_fs().seg < ((unsigned long)addr)) || 47 (get_fs().seg < ((unsigned long)addr + size - 1))) { 48 pr_devel("ACCESS fail at 0x%08x (size 0x%x), seg 0x%08x\n", 49 (__force u32)addr, (u32)size, 50 (u32)get_fs().seg); 51 return 0; 52 } 53ok: 54 pr_devel("ACCESS OK at 0x%08x (size 0x%x), seg 0x%08x\n", 55 (__force u32)addr, (u32)size, 56 (u32)get_fs().seg); 57 return 1; 58} |
80#endif | |
81 | 59 |
82#ifdef CONFIG_MMU | |
83# define __FIXUP_SECTION ".section .fixup,\"ax\"\n" 84# define __EX_TABLE_SECTION ".section __ex_table,\"a\"\n" | 60# define __FIXUP_SECTION ".section .fixup,\"ax\"\n" 61# define __EX_TABLE_SECTION ".section __ex_table,\"a\"\n" |
85#else 86# define __FIXUP_SECTION ".section .discard,\"ax\"\n" 87# define __EX_TABLE_SECTION ".section .discard,\"ax\"\n" 88#endif | |
89 90extern unsigned long __copy_tofrom_user(void __user *to, 91 const void __user *from, unsigned long size); 92 93/* Return: number of not copied bytes, i.e. 0 if OK or non-zero if fail. */ 94static inline unsigned long __must_check __clear_user(void __user *to, 95 unsigned long n) 96{ --- 254 unchanged lines hidden --- | 62 63extern unsigned long __copy_tofrom_user(void __user *to, 64 const void __user *from, unsigned long size); 65 66/* Return: number of not copied bytes, i.e. 0 if OK or non-zero if fail. */ 67static inline unsigned long __must_check __clear_user(void __user *to, 68 unsigned long n) 69{ --- 254 unchanged lines hidden --- |