arch/nios2/include/asm/uaccess.h
Source file repositories/reference/linux-study-clean/arch/nios2/include/asm/uaccess.h
File Facts
- System
- Linux kernel
- Corpus path
arch/nios2/include/asm/uaccess.h- Extension
.h- Size
- 4863 bytes
- Lines
- 189
- Domain
- Architecture Layer
- Bucket
- arch/nios2
- 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/string.hasm/page.hasm/extable.hasm-generic/access_ok.h
Detected Declarations
function Copyrightfunction clear_user
Annotated Snippet
#ifndef _ASM_NIOS2_UACCESS_H
#define _ASM_NIOS2_UACCESS_H
#include <linux/string.h>
#include <asm/page.h>
#include <asm/extable.h>
#include <asm-generic/access_ok.h>
# define __EX_TABLE_SECTION ".section __ex_table,\"a\"\n"
/*
* Zero Userspace
*/
static inline unsigned long __must_check __clear_user(void __user *to,
unsigned long n)
{
__asm__ __volatile__ (
"1: stb zero, 0(%1)\n"
" addi %0, %0, -1\n"
" addi %1, %1, 1\n"
" bne %0, zero, 1b\n"
"2:\n"
__EX_TABLE_SECTION
".word 1b, 2b\n"
".previous\n"
: "=r" (n), "=r" (to)
: "0" (n), "1" (to)
);
return n;
}
static inline unsigned long __must_check clear_user(void __user *to,
unsigned long n)
{
if (!access_ok(to, n))
return n;
return __clear_user(to, n);
}
extern unsigned long
raw_copy_from_user(void *to, const void __user *from, unsigned long n);
extern unsigned long
raw_copy_to_user(void __user *to, const void *from, unsigned long n);
#define INLINE_COPY_USER
extern long strncpy_from_user(char *__to, const char __user *__from,
long __len);
extern __must_check long strnlen_user(const char __user *s, long n);
/* Optimized macros */
#define __get_user_asm(val, insn, addr, err) \
{ \
unsigned long __gu_val; \
__asm__ __volatile__( \
" movi %0, %3\n" \
"1: " insn " %1, 0(%2)\n" \
" movi %0, 0\n" \
"2:\n" \
" .section __ex_table,\"a\"\n" \
" .word 1b, 2b\n" \
" .previous" \
: "=&r" (err), "=r" (__gu_val) \
: "r" (addr), "i" (-EFAULT)); \
val = (__force __typeof__(*(addr)))__gu_val; \
}
extern void __get_user_unknown(void);
#define __get_user_8(val, ptr, err) do { \
u64 __val = 0; \
err = 0; \
if (raw_copy_from_user(&(__val), ptr, sizeof(val))) { \
err = -EFAULT; \
} else { \
val = (typeof(val))(typeof((val) - (val)))__val; \
} \
} while (0)
#define __get_user_common(val, size, ptr, err) \
do { \
switch (size) { \
case 1: \
__get_user_asm(val, "ldbu", ptr, err); \
break; \
case 2: \
__get_user_asm(val, "ldhu", ptr, err); \
Annotation
- Immediate include surface: `linux/string.h`, `asm/page.h`, `asm/extable.h`, `asm-generic/access_ok.h`.
- Detected declarations: `function Copyright`, `function clear_user`.
- Atlas domain: Architecture Layer / arch/nios2.
- 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.