arch/arc/kernel/unwind.c
Source file repositories/reference/linux-study-clean/arch/arc/kernel/unwind.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arc/kernel/unwind.c- Extension
.c- Size
- 32936 bytes
- Lines
- 1307
- Domain
- Architecture Layer
- Bucket
- arch/arc
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sched.hlinux/module.hlinux/memblock.hlinux/sort.hlinux/slab.hlinux/stop_machine.hlinux/uaccess.hlinux/ptrace.hasm/sections.hlinux/unaligned.hasm/unwind.h
Detected Declarations
struct unwind_itemstruct unwind_statestruct cfastruct eh_frame_hdr_table_entrystruct unlink_table_infoenum item_locationfunction allocfunction init_unwind_tablefunction arc_unwind_initfunction cmp_eh_frame_hdr_table_entriesfunction init_unwind_hdrfunction unlink_tablefunction unwind_remove_tablefunction get_uleb128function get_sleb128function read_pointerfunction fde_pointer_typefunction advance_locfunction set_rulefunction processCFIfunction arc_unwindexport arc_unwind
Annotated Snippet
struct unwind_item {
enum item_location {
Nowhere,
Memory,
Register,
Value
} where;
uleb128_t value;
};
struct unwind_state {
uleb128_t loc, org;
const u8 *cieStart, *cieEnd;
uleb128_t codeAlign;
sleb128_t dataAlign;
struct cfa {
uleb128_t reg, offs;
} cfa;
struct unwind_item regs[ARRAY_SIZE(reg_info)];
unsigned stackDepth:8;
unsigned version:8;
const u8 *label;
const u8 *stack[MAX_STACK_DEPTH];
};
static const struct cfa badCFA = { ARRAY_SIZE(reg_info), 1 };
static struct unwind_table *find_table(unsigned long pc)
{
struct unwind_table *table;
for (table = &root_table; table; table = table->link)
if ((pc >= table->core.pc
&& pc < table->core.pc + table->core.range)
|| (pc >= table->init.pc
&& pc < table->init.pc + table->init.range))
break;
return table;
}
static unsigned long read_pointer(const u8 **pLoc,
const void *end, signed ptrType);
static void init_unwind_hdr(struct unwind_table *table,
void *(*alloc) (unsigned long));
/*
* wrappers for header alloc (vs. calling one vs. other at call site)
* to elide section mismatches warnings
*/
static void *__init unw_hdr_alloc_early(unsigned long sz)
{
return memblock_alloc_from(sz, sizeof(unsigned int), MAX_DMA_ADDRESS);
}
static void init_unwind_table(struct unwind_table *table, const char *name,
const void *core_start, unsigned long core_size,
const void *init_start, unsigned long init_size,
const void *table_start, unsigned long table_size,
const u8 *header_start, unsigned long header_size)
{
table->core.pc = (unsigned long)core_start;
table->core.range = core_size;
table->init.pc = (unsigned long)init_start;
table->init.range = init_size;
table->address = table_start;
table->size = table_size;
/* To avoid the pointer addition with NULL pointer.*/
if (header_start != NULL) {
const u8 *ptr = header_start + 4;
const u8 *end = header_start + header_size;
/* See if the linker provided table looks valid. */
if (header_size <= 4
|| header_start[0] != 1
|| (void *)read_pointer(&ptr, end, header_start[1])
!= table_start
|| header_start[2] == DW_EH_PE_omit
|| read_pointer(&ptr, end, header_start[2]) <= 0
|| header_start[3] == DW_EH_PE_omit)
header_start = NULL;
}
table->hdrsz = header_size;
smp_wmb();
table->header = header_start;
table->link = NULL;
table->name = name;
}
void __init arc_unwind_init(void)
{
Annotation
- Immediate include surface: `linux/sched.h`, `linux/module.h`, `linux/memblock.h`, `linux/sort.h`, `linux/slab.h`, `linux/stop_machine.h`, `linux/uaccess.h`, `linux/ptrace.h`.
- Detected declarations: `struct unwind_item`, `struct unwind_state`, `struct cfa`, `struct eh_frame_hdr_table_entry`, `struct unlink_table_info`, `enum item_location`, `function alloc`, `function init_unwind_table`, `function arc_unwind_init`, `function cmp_eh_frame_hdr_table_entries`.
- Atlas domain: Architecture Layer / arch/arc.
- Implementation status: integration 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.