arch/powerpc/include/asm/uaccess.h
Source file repositories/reference/linux-study-clean/arch/powerpc/include/asm/uaccess.h
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/include/asm/uaccess.h- Extension
.h- Size
- 18399 bytes
- Lines
- 626
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
Dependency Surface
linux/sizes.hasm/processor.hasm/page.hasm/extable.hasm/kup.hasm/asm-compat.hasm-generic/access_ok.h
Detected Declarations
function __access_okfunction will_use_vmxfunction raw_copy_tofrom_userfunction raw_copy_in_userfunction raw_copy_from_userfunction raw_copy_to_userfunction __clear_userfunction clear_userfunction copy_mc_to_kernelfunction copy_mc_to_userfunction __user_access_begin
Annotated Snippet
if (unlikely(ret)) {
allow_user_access(to, dir);
ret = __copy_tofrom_user_base(to, from, n);
prevent_user_access(dir);
}
return ret;
}
allow_user_access(to, dir);
ret = __copy_tofrom_user(to, from, n);
prevent_user_access(dir);
return ret;
}
#ifdef CONFIG_PPC64
static inline unsigned long
raw_copy_in_user(void __user *to, const void __user *from, unsigned long n)
{
barrier_nospec();
return raw_copy_tofrom_user(to, from, n, KUAP_READ_WRITE);
}
#endif /* CONFIG_PPC64 */
static inline unsigned long raw_copy_from_user(void *to, const void __user *from, unsigned long n)
{
return raw_copy_tofrom_user((__force void __user *)to, from, n, KUAP_READ);
}
static inline unsigned long
raw_copy_to_user(void __user *to, const void *from, unsigned long n)
{
return raw_copy_tofrom_user(to, (__force const void __user *)from, n, KUAP_WRITE);
}
unsigned long __arch_clear_user(void __user *addr, unsigned long size);
static inline unsigned long __clear_user(void __user *addr, unsigned long size)
{
unsigned long ret;
might_fault();
allow_user_access(addr, KUAP_WRITE);
ret = __arch_clear_user(addr, size);
prevent_user_access(KUAP_WRITE);
return ret;
}
static inline unsigned long clear_user(void __user *addr, unsigned long size)
{
return likely(access_ok(addr, size)) ? __clear_user(addr, size) : size;
}
extern long strncpy_from_user(char *dst, const char __user *src, long count);
extern __must_check long strnlen_user(const char __user *str, long n);
#ifdef CONFIG_ARCH_HAS_COPY_MC
unsigned long __must_check
copy_mc_generic(void *to, const void *from, unsigned long size);
static inline unsigned long __must_check
copy_mc_to_kernel(void *to, const void *from, unsigned long size)
{
return copy_mc_generic(to, from, size);
}
#define copy_mc_to_kernel copy_mc_to_kernel
static inline unsigned long __must_check
copy_mc_to_user(void __user *to, const void *from, unsigned long n)
{
if (check_copy_size(from, n, true)) {
if (access_ok(to, n)) {
allow_user_access(to, KUAP_WRITE);
n = copy_mc_generic((void __force *)to, from, n);
prevent_user_access(KUAP_WRITE);
}
}
return n;
}
#endif
extern size_t copy_from_user_flushcache(void *dst, const void __user *src, size_t size);
static __must_check __always_inline bool __user_access_begin(const void __user *ptr, size_t len,
unsigned long dir)
{
if (unlikely(!access_ok(ptr, len)))
return false;
might_fault();
Annotation
- Immediate include surface: `linux/sizes.h`, `asm/processor.h`, `asm/page.h`, `asm/extable.h`, `asm/kup.h`, `asm/asm-compat.h`, `asm-generic/access_ok.h`.
- Detected declarations: `function __access_ok`, `function will_use_vmx`, `function raw_copy_tofrom_user`, `function raw_copy_in_user`, `function raw_copy_from_user`, `function raw_copy_to_user`, `function __clear_user`, `function clear_user`, `function copy_mc_to_kernel`, `function copy_mc_to_user`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.