Commit 428e2976 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

uaccess: remove segment_eq

segment_eq is only used to implement uaccess_kernel.  Just open code
uaccess_kernel in the arch uaccess headers and remove one layer of
indirection.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Acked-by: default avatarGreentime Hu <green.hu@gmail.com>
Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Cc: Nick Hu <nickhu@andestech.com>
Cc: Vincent Chen <deanbo422@gmail.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Link: http://lkml.kernel.org/r/20200710135706.537715-5-hch@lst.deSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent efbfc62e
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#define get_fs() (current_thread_info()->addr_limit) #define get_fs() (current_thread_info()->addr_limit)
#define set_fs(x) (current_thread_info()->addr_limit = (x)) #define set_fs(x) (current_thread_info()->addr_limit = (x))
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
/* /*
* Is a address valid? This does a straightforward calculation rather * Is a address valid? This does a straightforward calculation rather
......
...@@ -14,8 +14,7 @@ typedef unsigned long mm_segment_t; ...@@ -14,8 +14,7 @@ typedef unsigned long mm_segment_t;
#define KERNEL_DS MAKE_MM_SEG(0) #define KERNEL_DS MAKE_MM_SEG(0)
#define USER_DS MAKE_MM_SEG(TASK_SIZE) #define USER_DS MAKE_MM_SEG(TASK_SIZE)
#define uaccess_kernel() (get_fs() == KERNEL_DS)
#define segment_eq(a, b) ((a) == (b))
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#endif /* __ASMARC_SEGMENT_H */ #endif /* __ASMARC_SEGMENT_H */
...@@ -76,7 +76,7 @@ static inline void set_fs(mm_segment_t fs) ...@@ -76,7 +76,7 @@ static inline void set_fs(mm_segment_t fs)
modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER); modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
} }
#define segment_eq(a, b) ((a) == (b)) #define uaccess_kernel() (get_fs() == KERNEL_DS)
/* /*
* We use 33-bit arithmetic here. Success returns zero, failure returns * We use 33-bit arithmetic here. Success returns zero, failure returns
...@@ -267,7 +267,7 @@ extern int __put_user_8(void *, unsigned long long); ...@@ -267,7 +267,7 @@ extern int __put_user_8(void *, unsigned long long);
*/ */
#define USER_DS KERNEL_DS #define USER_DS KERNEL_DS
#define segment_eq(a, b) (1) #define uaccess_kernel() (true)
#define __addr_ok(addr) ((void)(addr), 1) #define __addr_ok(addr) ((void)(addr), 1)
#define __range_ok(addr, size) ((void)(addr), 0) #define __range_ok(addr, size) ((void)(addr), 0)
#define get_fs() (KERNEL_DS) #define get_fs() (KERNEL_DS)
......
...@@ -50,7 +50,7 @@ static inline void set_fs(mm_segment_t fs) ...@@ -50,7 +50,7 @@ static inline void set_fs(mm_segment_t fs)
CONFIG_ARM64_UAO)); CONFIG_ARM64_UAO));
} }
#define segment_eq(a, b) ((a) == (b)) #define uaccess_kernel() (get_fs() == KERNEL_DS)
/* /*
* Test whether a block of memory is a valid user space address. * Test whether a block of memory is a valid user space address.
......
...@@ -13,6 +13,6 @@ typedef struct { ...@@ -13,6 +13,6 @@ typedef struct {
#define USER_DS ((mm_segment_t) { 0x80000000UL }) #define USER_DS ((mm_segment_t) { 0x80000000UL })
#define get_fs() (current_thread_info()->addr_limit) #define get_fs() (current_thread_info()->addr_limit)
#define set_fs(x) (current_thread_info()->addr_limit = (x)) #define set_fs(x) (current_thread_info()->addr_limit = (x))
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
#endif /* __ASM_CSKY_SEGMENT_H */ #endif /* __ASM_CSKY_SEGMENT_H */
...@@ -33,7 +33,7 @@ static inline mm_segment_t get_fs(void) ...@@ -33,7 +33,7 @@ static inline mm_segment_t get_fs(void)
return USER_DS; return USER_DS;
} }
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#define get_fs() (current_thread_info()->addr_limit) #define get_fs() (current_thread_info()->addr_limit)
#define set_fs(x) (current_thread_info()->addr_limit = (x)) #define set_fs(x) (current_thread_info()->addr_limit = (x))
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
/* /*
* When accessing user memory, we need to make sure the entire area really is in * When accessing user memory, we need to make sure the entire area really is in
......
...@@ -52,7 +52,7 @@ static inline void set_fs(mm_segment_t val) ...@@ -52,7 +52,7 @@ static inline void set_fs(mm_segment_t val)
#define set_fs(x) (current_thread_info()->addr_limit = (x)) #define set_fs(x) (current_thread_info()->addr_limit = (x))
#endif #endif
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
# define get_fs() (current_thread_info()->addr_limit) # define get_fs() (current_thread_info()->addr_limit)
# define set_fs(val) (current_thread_info()->addr_limit = (val)) # define set_fs(val) (current_thread_info()->addr_limit = (val))
# define segment_eq(a, b) ((a).seg == (b).seg) # define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
#ifndef CONFIG_MMU #ifndef CONFIG_MMU
......
...@@ -72,7 +72,7 @@ extern u64 __ua_limit; ...@@ -72,7 +72,7 @@ extern u64 __ua_limit;
#define get_fs() (current_thread_info()->addr_limit) #define get_fs() (current_thread_info()->addr_limit)
#define set_fs(x) (current_thread_info()->addr_limit = (x)) #define set_fs(x) (current_thread_info()->addr_limit = (x))
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
/* /*
* eva_kernel_access() - determine whether kernel memory access on an EVA system * eva_kernel_access() - determine whether kernel memory access on an EVA system
......
...@@ -44,7 +44,7 @@ static inline void set_fs(mm_segment_t fs) ...@@ -44,7 +44,7 @@ static inline void set_fs(mm_segment_t fs)
current_thread_info()->addr_limit = fs; current_thread_info()->addr_limit = fs;
} }
#define segment_eq(a, b) ((a) == (b)) #define uaccess_kernel() (get_fs() == KERNEL_DS)
#define __range_ok(addr, size) (size <= get_fs() && addr <= (get_fs() -size)) #define __range_ok(addr, size) (size <= get_fs() && addr <= (get_fs() -size))
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#define get_fs() (current_thread_info()->addr_limit) #define get_fs() (current_thread_info()->addr_limit)
#define set_fs(seg) (current_thread_info()->addr_limit = (seg)) #define set_fs(seg) (current_thread_info()->addr_limit = (seg))
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
#define __access_ok(addr, len) \ #define __access_ok(addr, len) \
(((signed long)(((long)get_fs().seg) & \ (((signed long)(((long)get_fs().seg) & \
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#define get_fs() (current_thread_info()->addr_limit) #define get_fs() (current_thread_info()->addr_limit)
#define set_fs(x) (current_thread_info()->addr_limit = (x)) #define set_fs(x) (current_thread_info()->addr_limit = (x))
#define segment_eq(a, b) ((a) == (b)) #define uaccess_kernel() (get_fs() == KERNEL_DS)
/* Ensure that the range from addr to addr+size is all within the process' /* Ensure that the range from addr to addr+size is all within the process'
* address space * address space
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#define KERNEL_DS ((mm_segment_t){0}) #define KERNEL_DS ((mm_segment_t){0})
#define USER_DS ((mm_segment_t){1}) #define USER_DS ((mm_segment_t){1})
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
#define get_fs() (current_thread_info()->addr_limit) #define get_fs() (current_thread_info()->addr_limit)
#define set_fs(x) (current_thread_info()->addr_limit = (x)) #define set_fs(x) (current_thread_info()->addr_limit = (x))
......
...@@ -38,8 +38,7 @@ static inline void set_fs(mm_segment_t fs) ...@@ -38,8 +38,7 @@ static inline void set_fs(mm_segment_t fs)
set_thread_flag(TIF_FSCHECK); set_thread_flag(TIF_FSCHECK);
} }
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
#define user_addr_max() (get_fs().seg) #define user_addr_max() (get_fs().seg)
#ifdef __powerpc64__ #ifdef __powerpc64__
......
...@@ -64,11 +64,9 @@ static inline void set_fs(mm_segment_t fs) ...@@ -64,11 +64,9 @@ static inline void set_fs(mm_segment_t fs)
current_thread_info()->addr_limit = fs; current_thread_info()->addr_limit = fs;
} }
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
#define user_addr_max() (get_fs().seg) #define user_addr_max() (get_fs().seg)
/** /**
* access_ok: - Checks if a user space pointer is valid * access_ok: - Checks if a user space pointer is valid
* @addr: User space pointer to start of block to check * @addr: User space pointer to start of block to check
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#define USER_DS_SACF (3) #define USER_DS_SACF (3)
#define get_fs() (current->thread.mm_segment) #define get_fs() (current->thread.mm_segment)
#define segment_eq(a,b) (((a) & 2) == ((b) & 2)) #define uaccess_kernel() ((get_fs() & 2) == KERNEL_DS)
void set_fs(mm_segment_t fs); void set_fs(mm_segment_t fs);
......
...@@ -24,8 +24,7 @@ typedef struct { ...@@ -24,8 +24,7 @@ typedef struct {
#define USER_DS KERNEL_DS #define USER_DS KERNEL_DS
#endif #endif
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
#define get_fs() (current_thread_info()->addr_limit) #define get_fs() (current_thread_info()->addr_limit)
#define set_fs(x) (current_thread_info()->addr_limit = (x)) #define set_fs(x) (current_thread_info()->addr_limit = (x))
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#define get_fs() (current->thread.current_ds) #define get_fs() (current->thread.current_ds)
#define set_fs(val) ((current->thread.current_ds) = (val)) #define set_fs(val) ((current->thread.current_ds) = (val))
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
/* We have there a nice not-mapped page at PAGE_OFFSET - PAGE_SIZE, so that this test /* We have there a nice not-mapped page at PAGE_OFFSET - PAGE_SIZE, so that this test
* can be fairly lightweight. * can be fairly lightweight.
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#define get_fs() ((mm_segment_t){(current_thread_info()->current_ds)}) #define get_fs() ((mm_segment_t){(current_thread_info()->current_ds)})
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
#define set_fs(val) \ #define set_fs(val) \
do { \ do { \
......
...@@ -33,7 +33,7 @@ static inline void set_fs(mm_segment_t fs) ...@@ -33,7 +33,7 @@ static inline void set_fs(mm_segment_t fs)
set_thread_flag(TIF_FSCHECK); set_thread_flag(TIF_FSCHECK);
} }
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
#define user_addr_max() (current->thread.addr_limit.seg) #define user_addr_max() (current->thread.addr_limit.seg)
/* /*
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#define get_fs() (current->thread.current_ds) #define get_fs() (current->thread.current_ds)
#define set_fs(val) (current->thread.current_ds = (val)) #define set_fs(val) (current->thread.current_ds = (val))
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
#define __kernel_ok (uaccess_kernel()) #define __kernel_ok (uaccess_kernel())
#define __user_ok(addr, size) \ #define __user_ok(addr, size) \
......
...@@ -86,8 +86,8 @@ static inline void set_fs(mm_segment_t fs) ...@@ -86,8 +86,8 @@ static inline void set_fs(mm_segment_t fs)
} }
#endif #endif
#ifndef segment_eq #ifndef uaccess_kernel
#define segment_eq(a, b) ((a).seg == (b).seg) #define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
#endif #endif
#define access_ok(addr, size) __access_ok((unsigned long)(addr),(size)) #define access_ok(addr, size) __access_ok((unsigned long)(addr),(size))
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/thread_info.h> #include <linux/thread_info.h>
#define uaccess_kernel() segment_eq(get_fs(), KERNEL_DS)
#include <asm/uaccess.h> #include <asm/uaccess.h>
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment