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

MIPS: uaccess: Added __get/__put_kernel_nofault

Added __get/__put_kernel_nofault as preparation for removing
get/set_fs.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>

+38
+24
arch/mips/include/asm/uaccess.h
··· 355 355 (val) = __gu_tmp.t; \ 356 356 } 357 357 358 + #define HAVE_GET_KERNEL_NOFAULT 359 + 360 + #define __get_kernel_nofault(dst, src, type, err_label) \ 361 + do { \ 362 + int __gu_err; \ 363 + \ 364 + __get_kernel_common(*((type *)(dst)), sizeof(type), \ 365 + (__force type *)(src)); \ 366 + if (unlikely(__gu_err)) \ 367 + goto err_label; \ 368 + } while (0) 369 + 358 370 #ifndef CONFIG_EVA 359 371 #define __put_kernel_common(ptr, size) __put_user_common(ptr, size) 360 372 #else ··· 494 482 } 495 483 496 484 extern void __put_user_unknown(void); 485 + 486 + #define __put_kernel_nofault(dst, src, type, err_label) \ 487 + do { \ 488 + type __pu_val; \ 489 + int __pu_err = 0; \ 490 + \ 491 + __pu_val = *(__force type *)(src); \ 492 + __put_kernel_common(((type *)(dst)), sizeof(type)); \ 493 + if (unlikely(__pu_err)) \ 494 + goto err_label; \ 495 + } while (0) 496 + 497 497 498 498 /* 499 499 * We're generating jump to subroutines which will be outside the range of
+4
arch/mips/mm/Makefile
··· 22 22 obj-y += uasm-mips.o 23 23 endif 24 24 25 + ifndef CONFIG_EVA 26 + obj-y += maccess.o 27 + endif 28 + 25 29 obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o 26 30 obj-$(CONFIG_64BIT) += ioremap64.o pgtable-64.o 27 31 obj-$(CONFIG_HIGHMEM) += highmem.o
+10
arch/mips/mm/maccess.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + 3 + #include <linux/uaccess.h> 4 + #include <linux/kernel.h> 5 + 6 + bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size) 7 + { 8 + /* highest bit set means kernel space */ 9 + return (unsigned long)unsafe_src >> (BITS_PER_LONG - 1); 10 + }