uaccess.h (762f99f4f3cb41a775b5157dd761217beba65873) | uaccess.h (12700c17fc286149324f92d6d380bc48e43f253d) |
---|---|
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) 4 * 5 * vineetg: June 2010 6 * -__clear_user( ) called multiple times during elf load was byte loop 7 * converted to do as much word clear as possible. 8 * --- 9 unchanged lines hidden (view full) --- 18 * Amit Bhor, Sameer Dhavale: Codito Technologies 2004 19 */ 20 21#ifndef _ASM_ARC_UACCESS_H 22#define _ASM_ARC_UACCESS_H 23 24#include <linux/string.h> /* for generic string functions */ 25 | 1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) 4 * 5 * vineetg: June 2010 6 * -__clear_user( ) called multiple times during elf load was byte loop 7 * converted to do as much word clear as possible. 8 * --- 9 unchanged lines hidden (view full) --- 18 * Amit Bhor, Sameer Dhavale: Codito Technologies 2004 19 */ 20 21#ifndef _ASM_ARC_UACCESS_H 22#define _ASM_ARC_UACCESS_H 23 24#include <linux/string.h> /* for generic string functions */ 25 |
26 27#define __kernel_ok (uaccess_kernel()) 28 29/* 30 * Algorithmically, for __user_ok() we want do: 31 * (start < TASK_SIZE) && (start+len < TASK_SIZE) 32 * where TASK_SIZE could either be retrieved from thread_info->addr_limit or 33 * emitted directly in code. 34 * 35 * This can however be rewritten as follows: 36 * (len <= TASK_SIZE) && (start+len < TASK_SIZE) 37 * 38 * Because it essentially checks if buffer end is within limit and @len is 39 * non-ngeative, which implies that buffer start will be within limit too. 40 * 41 * The reason for rewriting being, for majority of cases, @len is generally 42 * compile time constant, causing first sub-expression to be compile time 43 * subsumed. 44 * 45 * The second part would generate weird large LIMMs e.g. (0x6000_0000 - 0x10), 46 * so we check for TASK_SIZE using get_fs() since the addr_limit load from mem 47 * would already have been done at this call site for __kernel_ok() 48 * 49 */ 50#define __user_ok(addr, sz) (((sz) <= TASK_SIZE) && \ 51 ((addr) <= (get_fs() - (sz)))) 52#define __access_ok(addr, sz) (unlikely(__kernel_ok) || \ 53 likely(__user_ok((addr), (sz)))) 54 | |
55/*********** Single byte/hword/word copies ******************/ 56 57#define __get_user_fn(sz, u, k) \ 58({ \ 59 long __ret = 0; /* success by default */ \ 60 switch (sz) { \ 61 case 1: __arc_get_user_one(*(k), u, "ldb", __ret); break; \ 62 case 2: __arc_get_user_one(*(k), u, "ldw", __ret); break; \ --- 611 unchanged lines hidden --- | 26/*********** Single byte/hword/word copies ******************/ 27 28#define __get_user_fn(sz, u, k) \ 29({ \ 30 long __ret = 0; /* success by default */ \ 31 switch (sz) { \ 32 case 1: __arc_get_user_one(*(k), u, "ldb", __ret); break; \ 33 case 2: __arc_get_user_one(*(k), u, "ldw", __ret); break; \ --- 611 unchanged lines hidden --- |