arch/arm/include/asm/uaccess.h
Source file repositories/reference/linux-study-clean/arch/arm/include/asm/uaccess.h
File Facts
- System
- Linux kernel
- Corpus path
arch/arm/include/asm/uaccess.h- Extension
.h- Size
- 18046 bytes
- Lines
- 634
- Domain
- Architecture Layer
- Bucket
- arch/arm
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
Dependency Surface
linux/kernel.hlinux/string.hasm/page.hasm/domain.hlinux/unaligned.hasm/unified.hasm/pgtable.hasm/proc-fns.hasm/compiler.hasm/extable.hasm-generic/access_ok.h
Detected Declarations
function accessesfunction uaccess_restorefunction uaccess_save_and_enablefunction uaccess_restorefunction uaccess_save_and_enablefunction uaccess_restorefunction raw_copy_from_userfunction raw_copy_to_userfunction __clear_userfunction raw_copy_from_userfunction raw_copy_to_userfunction clear_user
Annotated Snippet
switch (sizeof(*(__p))) { \
case 1: \
if (sizeof((x)) >= 8) \
__get_user_x_64t(__r2, __p, __e, __l, 1); \
else \
__get_user_x(__r2, __p, __e, __l, 1); \
break; \
case 2: \
if (sizeof((x)) >= 8) \
__get_user_x_64t(__r2, __p, __e, __l, 2); \
else \
__get_user_x(__r2, __p, __e, __l, 2); \
break; \
case 4: \
if (sizeof((x)) >= 8) \
__get_user_x_64t(__r2, __p, __e, __l, 4); \
else \
__get_user_x(__r2, __p, __e, __l, 4); \
break; \
case 8: \
if (sizeof((x)) < 8) \
__get_user_x_32t(__r2, __p, __e, __l, 4); \
else \
__get_user_x(__r2, __p, __e, __l, 8); \
break; \
default: __e = __get_user_bad(); break; \
} \
__tmp_e = __e; \
uaccess_restore(__ua_flags); \
x = (typeof(*(p))) __r2; \
__tmp_e; \
})
#define get_user(x, p) \
({ \
might_fault(); \
__get_user_check(x, p); \
})
extern int __put_user_1(void *, unsigned int);
extern int __put_user_2(void *, unsigned int);
extern int __put_user_4(void *, unsigned int);
extern int __put_user_8(void *, unsigned long long);
#define __put_user_check(__pu_val, __ptr, __err, __s) \
({ \
unsigned long __limit = TASK_SIZE - 1; \
register typeof(__pu_val) __r2 asm("r2") = __pu_val; \
register const void __user *__p asm("r0") = __ptr; \
register unsigned long __l asm("r1") = __limit; \
register int __e asm("r0"); \
__asm__ __volatile__ ( \
__asmeq("%0", "r0") __asmeq("%2", "r2") \
__asmeq("%3", "r1") \
"bl __put_user_" #__s \
: "=&r" (__e) \
: "0" (__p), "r" (__r2), "r" (__l) \
: "ip", "lr", "cc"); \
__err = __e; \
})
#else /* CONFIG_MMU */
#define get_user(x, p) __get_user(x, p)
#define __put_user_check __put_user_nocheck
#endif /* CONFIG_MMU */
#include <asm-generic/access_ok.h>
#ifdef CONFIG_CPU_SPECTRE
/*
* When mitigating Spectre variant 1, it is not worth fixing the non-
* verifying accessors, because we need to add verification of the
* address space there. Force these to use the standard get_user()
* version instead.
*/
#define __get_user(x, ptr) get_user(x, ptr)
#else
/*
* The "__xxx" versions of the user access functions do not verify the
* address space - it must have been done previously with a separate
* "access_ok()" call.
*
* The "xxx_error" versions set the third argument to EFAULT if an
* error occurs, and leave it unchanged on success. Note that these
* versions are void (ie, don't return a value as such).
*/
#define __get_user(x, ptr) \
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/string.h`, `asm/page.h`, `asm/domain.h`, `linux/unaligned.h`, `asm/unified.h`, `asm/pgtable.h`, `asm/proc-fns.h`.
- Detected declarations: `function accesses`, `function uaccess_restore`, `function uaccess_save_and_enable`, `function uaccess_restore`, `function uaccess_save_and_enable`, `function uaccess_restore`, `function raw_copy_from_user`, `function raw_copy_to_user`, `function __clear_user`, `function raw_copy_from_user`.
- Atlas domain: Architecture Layer / arch/arm.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.