torvalds/linux
Architecture support
Purpose
arch/ contains all CPU-architecture-specific code: the boot stub, exception/interrupt entry, system-call entry, atomics and locking primitives, page-table types, MMU and TLB management, low-level context-switch, vDSO, kvm host backend, perf event counters, and per-platform peripherals where they don't have a driver subsystem of their own.
22 architectures live here. Anything portable between them lives elsewhere in the tree (include/asm-generic/, lib/, kernel/).
Architectures
| Directory | Architecture | Status |
|---|---|---|
alpha/ |
DEC Alpha | Maintenance only |
arc/ |
Synopsys ARC | Active |
arm/ |
32-bit ARM | Active (legacy hardware) |
arm64/ |
64-bit ARM (AArch64) | First-tier; very active |
csky/ |
C-SKY | Maintenance |
hexagon/ |
Qualcomm Hexagon | Maintenance |
loongarch/ |
LoongArch | Active (newer arch) |
m68k/ |
Motorola 68000 | Maintenance, hobbyist |
microblaze/ |
Xilinx MicroBlaze | Active (FPGA SoCs) |
mips/ |
MIPS | Active |
nios2/ |
Altera Nios II | Maintenance |
openrisc/ |
OpenRISC | Active (FPGA, academic) |
parisc/ |
HP PA-RISC | Maintenance |
powerpc/ |
POWER / PowerPC | First-tier |
riscv/ |
RISC-V | First-tier; very active |
s390/ |
IBM Z (System/390 / z/Architecture) | First-tier |
sh/ |
Renesas SuperH | Maintenance |
sparc/ |
SPARC | Maintenance |
um/ |
User-Mode Linux | Active (test/dev) |
x86/ |
x86 / x86_64 | First-tier; the most active |
xtensa/ |
Tensilica Xtensa | Active |
The first-tier architectures (x86, arm64, riscv, powerpc, s390) get most of the new feature work. Others receive maintenance and review.
Per-arch directory shape
Each arch/<arch>/ typically contains:
arch/<arch>/
├── Kconfig # Architecture's configuration menu
├── Makefile # Compilation flags, default cflags
├── boot/ # Bootloader interface, decompressors
├── kernel/ # Trap entry, syscall entry, smp, time, traps, signal, vdso glue, perf
├── mm/ # Page tables, TLB, fault handler, hugetlb
├── lib/ # Hand-written or arch-tuned helpers (memcpy, atomics, crypto)
├── include/asm/ # asm/*.h — primitives consumed by the rest of the kernel
├── crypto/ # Hardware crypto primitives (e.g. AES-NI on x86)
├── kvm/ # Architecture-specific KVM host code
├── platforms/, mach-*/ # Per-board / per-SoC code (mostly arm)
├── configs/ # defconfigs
├── tools/ # arch-specific tools (e.g. relocs)
└── vdso/ # virtual DSO mapped into user spaceConcrete examples: arch/x86/, arch/arm64/, arch/riscv/.
What lives in arch and what doesn't
Generic abstractions live in include/asm-generic/. Architectures override only what they need. A short, partial list of what's almost always arch-specific:
- Boot path before the C entry. Decompression, MMU enable, page-table setup, jump to
start_kernel. - Trap and IRQ entry/exit (
arch/<arch>/kernel/entry*.Sor generic helpers inkernel/entry/). - System-call dispatch table (varies by arch).
- Atomic operations (
arch/<arch>/include/asm/atomic.hand friends). - Memory barriers and the memory model (
arch/<arch>/include/asm/barrier.h). - Page-table walking and TLB invalidation.
- Context switch (
switch_to,__switch_to). - Per-CPU implementation (
arch/<arch>/include/asm/percpu.h). - vDSO (the small ELF mapped into user space for
gettimeofday,clock_gettime,getcpu, etc.). - Architecture-specific KVM (
arch/<arch>/kvm/). - Perf event PMU drivers.
Common subsystems with arch parts
| Subsystem | Arch piece |
|---|---|
| MMU / TLB | arch/<arch>/mm/ |
| Atomics, barriers | arch/<arch>/include/asm/{atomic,barrier}.h |
| Locking fast paths | arch/<arch>/include/asm/spinlock*.h |
| Syscall entry | arch/<arch>/kernel/entry*.S and arch/<arch>/kernel/syscall*.c |
| KVM | arch/<arch>/kvm/ (paired with Virtualization which covers virt/) |
| BPF JIT | arch/<arch>/net/bpf_jit*.c |
| FPU / SIMD save/restore | arch/<arch>/kernel/fpu* |
| ftrace / kprobes | per-arch hooks in arch/<arch>/kernel/ |
How it integrates with the rest of the tree
graph LR
BL[Bootloader] --> ARCH[arch/<arch>/boot]
ARCH --> START["start_kernel() in init/main.c"]
START --> GENERIC[Generic kernel code]
GENERIC -->|asm-generic shims| ASM[arch/<arch>/include/asm/]
GENERIC -->|"function ptrs"| ARCH_OPS["arch_*() callbacks"]
DRV[drivers/] -.-> ARCH_OPS
KVM[virt/kvm + arch/<arch>/kvm/] --> CPUFEAT[CPU feature detection]Most consumers never touch arch directly — they include <asm/foo.h> or <linux/foo.h>, and the build picks the right backing implementation based on CONFIG_<ARCH> and the per-arch include/asm/.
Key source files (per first-tier arch)
| Arch | Bootstrap | Trap entry |
|---|---|---|
| x86 | arch/x86/boot/, arch/x86/kernel/head_64.S |
arch/x86/entry/ |
| arm64 | arch/arm64/kernel/head.S |
arch/arm64/kernel/entry.S |
| riscv | arch/riscv/kernel/head.S |
arch/riscv/kernel/entry.S |
| powerpc | arch/powerpc/kernel/head_64.S |
arch/powerpc/kernel/ |
| s390 | arch/s390/kernel/head64.S |
arch/s390/kernel/ |
Entry points for modification
- Adding a CPU feature flag: each arch has a feature-bits header (
arch/x86/include/asm/cpufeatures.h,arch/arm64/include/asm/cpufeature.h, etc.). Wire it throughcpu_feature_enabled()and the alternatives framework. - Adding a syscall: edit
arch/<arch>/include/asm/syscall_table.h(or equivalent), then the generic UAPI table ininclude/uapi/asm-generic/unistd.h. - New device-tree consumer: handled by
drivers/, but board-specific boot fixups for arm/arm64 may go underarch/arm//arch/arm64/. - New BPF JIT:
arch/<arch>/net/bpf_jit*.c. Examples:arch/x86/net/bpf_jit_comp.c,arch/arm64/net/bpf_jit_comp.c.
Related pages
- Init — what runs after the arch stub.
- Memory management — page-table types and TLB flush.
- Kernel core — per-CPU, locking, RCU.
- Virtualization — KVM has architecture-specific halves.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.