arch/arm64/mm/extable.c
Source file repositories/reference/linux-study-clean/arch/arm64/mm/extable.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/mm/extable.c- Extension
.c- Size
- 2661 bytes
- Lines
- 117
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/extable.hlinux/uaccess.hasm/asm-extable.hasm/esr.hasm/ptrace.h
Detected Declarations
function cpy_faulted_on_uaccessfunction insn_may_access_userfunction get_ex_fixupfunction ex_handler_uaccess_err_zerofunction ex_handler_uaccess_cpyfunction ex_handler_load_unaligned_zeropadfunction fixup_exception
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Based on arch/arm/mm/extable.c
*/
#include <linux/bitfield.h>
#include <linux/extable.h>
#include <linux/uaccess.h>
#include <asm/asm-extable.h>
#include <asm/esr.h>
#include <asm/ptrace.h>
static bool cpy_faulted_on_uaccess(const struct exception_table_entry *ex,
unsigned long esr)
{
bool uaccess_is_write = FIELD_GET(EX_DATA_UACCESS_WRITE, ex->data);
bool fault_on_write = esr & ESR_ELx_WNR;
return uaccess_is_write == fault_on_write;
}
bool insn_may_access_user(unsigned long addr, unsigned long esr)
{
const struct exception_table_entry *ex = search_exception_tables(addr);
if (!ex)
return false;
switch (ex->type) {
case EX_TYPE_UACCESS_CPY:
return cpy_faulted_on_uaccess(ex, esr);
default:
return true;
}
}
static inline unsigned long
get_ex_fixup(const struct exception_table_entry *ex)
{
return ((unsigned long)&ex->fixup + ex->fixup);
}
static bool ex_handler_uaccess_err_zero(const struct exception_table_entry *ex,
struct pt_regs *regs)
{
int reg_err = FIELD_GET(EX_DATA_REG_ERR, ex->data);
int reg_zero = FIELD_GET(EX_DATA_REG_ZERO, ex->data);
pt_regs_write_reg(regs, reg_err, -EFAULT);
pt_regs_write_reg(regs, reg_zero, 0);
regs->pc = get_ex_fixup(ex);
return true;
}
static bool ex_handler_uaccess_cpy(const struct exception_table_entry *ex,
struct pt_regs *regs, unsigned long esr)
{
/* Do not fix up faults on kernel memory accesses */
if (!cpy_faulted_on_uaccess(ex, esr))
return false;
regs->pc = get_ex_fixup(ex);
return true;
}
static bool
ex_handler_load_unaligned_zeropad(const struct exception_table_entry *ex,
struct pt_regs *regs)
{
int reg_data = FIELD_GET(EX_DATA_REG_DATA, ex->data);
int reg_addr = FIELD_GET(EX_DATA_REG_ADDR, ex->data);
unsigned long data, addr, offset;
addr = pt_regs_read_reg(regs, reg_addr);
offset = addr & 0x7UL;
addr &= ~0x7UL;
data = *(unsigned long*)addr;
#ifndef __AARCH64EB__
data >>= 8 * offset;
#else
data <<= 8 * offset;
#endif
pt_regs_write_reg(regs, reg_data, data);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/extable.h`, `linux/uaccess.h`, `asm/asm-extable.h`, `asm/esr.h`, `asm/ptrace.h`.
- Detected declarations: `function cpy_faulted_on_uaccess`, `function insn_may_access_user`, `function get_ex_fixup`, `function ex_handler_uaccess_err_zero`, `function ex_handler_uaccess_cpy`, `function ex_handler_load_unaligned_zeropad`, `function fixup_exception`.
- Atlas domain: Architecture Layer / arch/arm64.
- Implementation status: source implementation candidate.
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.