uaccess.h (34737e26980341519d00e84711fe619f9f47e79c) | uaccess.h (12700c17fc286149324f92d6d380bc48e43f253d) |
---|---|
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Copyright (C) 2012 Regents of the University of California 4 * 5 * This file was copied from include/asm-generic/uaccess.h 6 */ 7 8#ifndef _ASM_RISCV_UACCESS_H --- 7 unchanged lines hidden (view full) --- 16 */ 17#ifdef CONFIG_MMU 18#include <linux/errno.h> 19#include <linux/compiler.h> 20#include <linux/thread_info.h> 21#include <asm/byteorder.h> 22#include <asm/extable.h> 23#include <asm/asm.h> | 1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Copyright (C) 2012 Regents of the University of California 4 * 5 * This file was copied from include/asm-generic/uaccess.h 6 */ 7 8#ifndef _ASM_RISCV_UACCESS_H --- 7 unchanged lines hidden (view full) --- 16 */ 17#ifdef CONFIG_MMU 18#include <linux/errno.h> 19#include <linux/compiler.h> 20#include <linux/thread_info.h> 21#include <asm/byteorder.h> 22#include <asm/extable.h> 23#include <asm/asm.h> |
24#include <asm-generic/access_ok.h> |
|
24 25#define __enable_user_access() \ 26 __asm__ __volatile__ ("csrs sstatus, %0" : : "r" (SR_SUM) : "memory") 27#define __disable_user_access() \ 28 __asm__ __volatile__ ("csrc sstatus, %0" : : "r" (SR_SUM) : "memory") 29 | 25 26#define __enable_user_access() \ 27 __asm__ __volatile__ ("csrs sstatus, %0" : : "r" (SR_SUM) : "memory") 28#define __disable_user_access() \ 29 __asm__ __volatile__ ("csrc sstatus, %0" : : "r" (SR_SUM) : "memory") 30 |
30/** 31 * access_ok: - Checks if a user space pointer is valid 32 * @addr: User space pointer to start of block to check 33 * @size: Size of block to check 34 * 35 * Context: User context only. This function may sleep. 36 * 37 * Checks if a pointer to a block of memory in user space is valid. 38 * 39 * Returns true (nonzero) if the memory block may be valid, false (zero) 40 * if it is definitely invalid. 41 * 42 * Note that, depending on architecture, this function probably just 43 * checks that the pointer is in the user space range - after calling 44 * this function, memory access functions may still return -EFAULT. 45 */ 46#define access_ok(addr, size) ({ \ 47 __chk_user_ptr(addr); \ 48 likely(__access_ok((unsigned long __force)(addr), (size))); \ 49}) 50 | |
51/* | 31/* |
52 * Ensure that the range [addr, addr+size) is within the process's 53 * address space 54 */ 55static inline int __access_ok(unsigned long addr, unsigned long size) 56{ 57 return size <= TASK_SIZE && addr <= TASK_SIZE - size; 58} 59 60/* | |
61 * The exception table consists of pairs of addresses: the first is the 62 * address of an instruction that is allowed to fault, and the second is 63 * the address at which the program should continue. No registers are 64 * modified, so it is entirely up to the continuation code to figure out 65 * what to do. 66 * 67 * All the routines below use bits of fixup code that are out of line 68 * with the main instruction path. This means when everything is well, --- 302 unchanged lines hidden --- | 32 * The exception table consists of pairs of addresses: the first is the 33 * address of an instruction that is allowed to fault, and the second is 34 * the address at which the program should continue. No registers are 35 * modified, so it is entirely up to the continuation code to figure out 36 * what to do. 37 * 38 * All the routines below use bits of fixup code that are out of line 39 * with the main instruction path. This means when everything is well, --- 302 unchanged lines hidden --- |