Skip to content

Commit

Permalink
MIPS: uaccess: Added __get/__put_kernel_nofault
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thomas Bogendoerfer committed Apr 6, 2021
1 parent 9a91dd5 commit 08ee3a0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
24 changes: 24 additions & 0 deletions arch/mips/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,18 @@ do { \
(val) = __gu_tmp.t; \
}

#define HAVE_GET_KERNEL_NOFAULT

#define __get_kernel_nofault(dst, src, type, err_label) \
do { \
int __gu_err; \
\
__get_kernel_common(*((type *)(dst)), sizeof(type), \
(__force type *)(src)); \
if (unlikely(__gu_err)) \
goto err_label; \
} while (0)

#ifndef CONFIG_EVA
#define __put_kernel_common(ptr, size) __put_user_common(ptr, size)
#else
Expand Down Expand Up @@ -483,6 +495,18 @@ do { \

extern void __put_user_unknown(void);

#define __put_kernel_nofault(dst, src, type, err_label) \
do { \
type __pu_val; \
int __pu_err = 0; \
\
__pu_val = *(__force type *)(src); \
__put_kernel_common(((type *)(dst)), sizeof(type)); \
if (unlikely(__pu_err)) \
goto err_label; \
} while (0)


/*
* We're generating jump to subroutines which will be outside the range of
* jump instructions
Expand Down
4 changes: 4 additions & 0 deletions arch/mips/mm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ else
obj-y += uasm-mips.o
endif

ifndef CONFIG_EVA
obj-y += maccess.o
endif

obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o
obj-$(CONFIG_64BIT) += ioremap64.o pgtable-64.o
obj-$(CONFIG_HIGHMEM) += highmem.o
Expand Down
10 changes: 10 additions & 0 deletions arch/mips/mm/maccess.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: GPL-2.0-only

#include <linux/uaccess.h>
#include <linux/kernel.h>

bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
{
/* highest bit set means kernel space */
return (unsigned long)unsafe_src >> (BITS_PER_LONG - 1);
}

0 comments on commit 08ee3a0

Please sign in to comment.