arch/arm64/include/asm/uaccess.h
Source file repositories/reference/linux-study-clean/arch/arm64/include/asm/uaccess.h
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/include/asm/uaccess.h- Extension
.h- Size
- 13979 bytes
- Lines
- 503
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- 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
asm/alternative.hasm/kernel-pgtable.hasm/sysreg.hlinux/bitops.hlinux/kasan-checks.hlinux/string.hasm/asm-extable.hasm/cpufeature.hasm/mmu.hasm/mte.hasm/ptrace.hasm/memory.hasm/extable.hasm-generic/access_ok.h
Detected Declarations
function access_okfunction __uaccess_ttbr0_disablefunction __uaccess_ttbr0_enablefunction uaccess_ttbr0_disablefunction uaccess_ttbr0_enablefunction uaccess_ttbr0_disablefunction uaccess_ttbr0_enablefunction __uaccess_disable_hw_panfunction __uaccess_enable_hw_panfunction uaccess_disable_privilegedfunction uaccess_enable_privilegedfunction rangefunction user_access_beginfunction user_access_savefunction user_access_restorefunction __clear_userfunction copy_from_user_flushcachefunction probe_subpage_writeable
Annotated Snippet
static inline unsigned long user_access_save(void) { return 0; }
static inline void user_access_restore(unsigned long enabled) { }
/*
* We want the unsafe accessors to always be inlined and use
* the error labels - thus the macro games.
*/
#define unsafe_copy_loop(dst, src, len, type, label) \
while (len >= sizeof(type)) { \
unsafe_put_user(*(type *)(src),(type __user *)(dst),label); \
dst += sizeof(type); \
src += sizeof(type); \
len -= sizeof(type); \
}
#define unsafe_copy_to_user(_dst,_src,_len,label) \
do { \
char __user *__ucu_dst = (_dst); \
const char *__ucu_src = (_src); \
size_t __ucu_len = (_len); \
unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u64, label); \
unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u32, label); \
unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u16, label); \
unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u8, label); \
} while (0)
#define INLINE_COPY_USER
extern unsigned long __must_check __arch_clear_user(void __user *to, unsigned long n);
static inline unsigned long __must_check __clear_user(void __user *to, unsigned long n)
{
if (access_ok(to, n)) {
uaccess_ttbr0_enable();
n = __arch_clear_user(__uaccess_mask_ptr(to), n);
uaccess_ttbr0_disable();
}
return n;
}
#define clear_user __clear_user
extern long strncpy_from_user(char *dest, const char __user *src, long count);
extern __must_check long strnlen_user(const char __user *str, long n);
#ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE
extern unsigned long __must_check __copy_user_flushcache(void *to, const void __user *from, unsigned long n);
static inline size_t copy_from_user_flushcache(void *dst, const void __user *src, size_t size)
{
kasan_check_write(dst, size);
return __copy_user_flushcache(dst, __uaccess_mask_ptr(src), size);
}
#endif
#ifdef CONFIG_ARCH_HAS_SUBPAGE_FAULTS
/*
* Return 0 on success, the number of bytes not probed otherwise.
*/
static inline size_t probe_subpage_writeable(const char __user *uaddr,
size_t size)
{
if (!system_supports_mte())
return 0;
return mte_probe_user_range(uaddr, size);
}
#endif /* CONFIG_ARCH_HAS_SUBPAGE_FAULTS */
#endif /* __ASM_UACCESS_H */
Annotation
- Immediate include surface: `asm/alternative.h`, `asm/kernel-pgtable.h`, `asm/sysreg.h`, `linux/bitops.h`, `linux/kasan-checks.h`, `linux/string.h`, `asm/asm-extable.h`, `asm/cpufeature.h`.
- Detected declarations: `function access_ok`, `function __uaccess_ttbr0_disable`, `function __uaccess_ttbr0_enable`, `function uaccess_ttbr0_disable`, `function uaccess_ttbr0_enable`, `function uaccess_ttbr0_disable`, `function uaccess_ttbr0_enable`, `function __uaccess_disable_hw_pan`, `function __uaccess_enable_hw_pan`, `function uaccess_disable_privileged`.
- Atlas domain: Architecture Layer / arch/arm64.
- 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.