arch/xtensa/include/asm/uaccess.h
Source file repositories/reference/linux-study-clean/arch/xtensa/include/asm/uaccess.h
File Facts
- System
- Linux kernel
- Corpus path
arch/xtensa/include/asm/uaccess.h- Extension
.h- Size
- 8499 bytes
- Lines
- 295
- Domain
- Architecture Layer
- Bucket
- arch/xtensa
- 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/prefetch.hasm/types.hasm/extable.hasm-generic/access_ok.h
Detected Declarations
function raw_copy_from_userfunction raw_copy_to_userfunction __xtensa_clear_userfunction clear_userfunction strncpy_from_userfunction strnlen_user
Annotated Snippet
if (unlikely(__copy_from_user(&__x, ptr, 8))) { \
retval = -EFAULT; \
(x) = (__typeof__(*(ptr)))0; \
} else { \
(x) = *(__force __typeof__(*(ptr)) *)&__x; \
} \
break; \
} \
default: \
(x) = (__typeof__(*(ptr)))0; \
__get_user_bad(); \
} \
} while (0)
/*
* WARNING: If you modify this macro at all, verify that the
* __check_align_* macros still work.
*/
#define __get_user_asm(x_, addr_, err_, align, insn, cb) \
do { \
u32 __x = 0; \
__asm__ __volatile__( \
__check_align_##align \
"1: "insn" %[x], %[mem] \n" \
"2: \n" \
" .section .fixup,\"ax\" \n" \
" .align 4 \n" \
" .literal_position \n" \
"5: \n" \
" movi %[tmp], 2b \n" \
" movi %[err], %[efault] \n" \
" jx %[tmp] \n" \
" .previous \n" \
" .section __ex_table,\"a\" \n" \
" .long 1b, 5b \n" \
" .previous" \
:[err] "+r"(err_), [tmp] "=r"(cb), [x] "+r"(__x) \
:[mem] "m"(*(addr_)), [efault] "i"(-EFAULT)); \
(x_) = (__force __typeof__(*(addr_)))__x; \
} while (0)
/*
* Copy to/from user space
*/
extern unsigned __xtensa_copy_user(void *to, const void *from, unsigned n);
static inline unsigned long
raw_copy_from_user(void *to, const void __user *from, unsigned long n)
{
prefetchw(to);
return __xtensa_copy_user(to, (__force const void *)from, n);
}
static inline unsigned long
raw_copy_to_user(void __user *to, const void *from, unsigned long n)
{
prefetch(from);
return __xtensa_copy_user((__force void *)to, from, n);
}
#define INLINE_COPY_USER
/*
* We need to return the number of bytes not cleared. Our memset()
* returns zero if a problem occurs while accessing user-space memory.
* In that event, return no memory cleared. Otherwise, zero for
* success.
*/
static inline unsigned long
__xtensa_clear_user(void __user *addr, unsigned long size)
{
if (!__memset((void __force *)addr, 0, size))
return size;
return 0;
}
static inline unsigned long
clear_user(void __user *addr, unsigned long size)
{
if (access_ok(addr, size))
return __xtensa_clear_user(addr, size);
return size ? -EFAULT : 0;
}
#define __clear_user __xtensa_clear_user
#ifdef CONFIG_ARCH_HAS_STRNCPY_FROM_USER
Annotation
- Immediate include surface: `linux/prefetch.h`, `asm/types.h`, `asm/extable.h`, `asm-generic/access_ok.h`.
- Detected declarations: `function raw_copy_from_user`, `function raw_copy_to_user`, `function __xtensa_clear_user`, `function clear_user`, `function strncpy_from_user`, `function strnlen_user`.
- Atlas domain: Architecture Layer / arch/xtensa.
- 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.