[PATCH 4/6] uaccess: remove segment_eq
Linus Torvalds
torvalds at linux-foundation.org
Tue Jul 14 11:27:14 EDT 2020
Ack, just with a note:
On Tue, Jul 14, 2020 at 4:06 AM Christoph Hellwig <hch at lst.de> wrote:
>
> --- a/arch/x86/include/asm/uaccess.h
> +++ b/arch/x86/include/asm/uaccess.h
> @@ -33,7 +33,7 @@ static inline void set_fs(mm_segment_t fs)
> 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)
This "uaccess_kernel()" interface is a better model anyway, because at
least on x86 (and from a quick glance at others), we might avoid the
exact equality comparison, and instead do simpler/better things.
On x86-64, for example, checking whether the limit has the high bit
set is not only more flexible and correct, it's much cheaper too.
Of course, trying to get rid of all this means that it doesn't matter
so much, but it would probably have been good to do this part years
ago regardless.
Linus
More information about the linux-riscv
mailing list