Skip to content

Add arm64(AArch64) support - #429

Open
dzianisbely wants to merge 5 commits into
datto:mainfrom
dzianisbely:support-arm-aarch64
Open

Add arm64(AArch64) support#429
dzianisbely wants to merge 5 commits into
datto:mainfrom
dzianisbely:support-arm-aarch64

Conversation

@dzianisbely

@dzianisbely dzianisbely commented Jun 21, 2026

Copy link
Copy Markdown

Add arm64 (AArch64) support

Summary

Adds arm64(armv8) support for the modern (5.9+) ftrace-based build. dattobd's x86-dependence turned out to be narrow. Changes isolated behind arch/capability conditionals, and leaves the x86 path untouched.

Supported kernels

arm64(AArch64): kernel 5.10+

ftrace_regs_set_instruction_pointer() exists only from 6.2 (renamed from ftrace_instruction_pointer_set; 6.2 is also where arm64 switched ftrace to WITH_ARGS). Hardcoding it would fail to build on ≤ 6.1 (implicit declaration). Detecting it and falling back to the WITH_REGS ->pc path lowers the arm64 floor to ~5.10.

Runtime-verified: 5.10 (Debian 11), 5.15 (Ubuntu 22.04), 6.8 (emulated), 6.17 (real HW). 5.9 is plausible (submit_bio path is 5.9+, ftrace_regs is 5.11+) but not tested.

P.S For building on 6.17+ kernels, I used ccflags-y := -g -Werror -I$(src)/../.. in /src/configure-tests/feature-tests/Makefile
Does not attempt legacy make_request_fn / syscall-table / armv7.

What changed and why

  1. CR0 write-protect toggling is x86-only and is dead code on 5.9+ (called from nowhere). Wrapped the x86 body in #ifdef CONFIG_X86. no-op stubs otherwise. Closes X86 specific code failes building on ARM #248 (arm64 build break).
  2. mount/umount hooks:
    • IP redirect moved to the dattobd_ftrace_set_ip() macro (the 3 cases above), gated on the HAVE_FTRACE_REGS_SET_INSTRUCTION_POINTER feature-test plus arch — not on the arch alone.
    • FTRACE_OPS_FL_SAVE_REGS requested only when CONFIG_DYNAMIC_FTRACE_WITH_REGS is present (x86 and arm64 ≤ 6.1 have it. arm64 6.2+ has only WITH_ARGS, where requesting SAVE_REGS makes register_ftrace_function() fail) — gated on the capability, not arch.
    • compile-probe configure-tests/feature-tests/ftrace_regs_set_instruction_pointer.c.
  3. FENTRY_CALL_INSTR_BYTES value added. Its only for dattobd_submit_bio_real has no callers (dead code), so the value only needs to compile.
  4. A REQ_OP_WRITE_ZEROES bio has no data pages. Tracer special-cases this, but the guard used the wrong macro, so on kernels ≥ 6.0 it compiled out. The page-less bio hit the per-segment loop, called page_get_inode() on a NULL page, and crashed kernel.
    Fix: key the guards off HAVE_ENUM_REQ_OP_WRITE_ZEROES, which checks the actual constant used and is true on 4.10+ for any arch. No change on < 6.0.
    Note: not arm64-specific, affects every 6.x kernel on all arches, including x86_64. Found on the arm64 port (ext4 lazyinit), reproduced on x86_64/7.0 with scsi_debug.

Evidence

Environments:

===== ENVIRONMENT (arm64, real 5.10 distro) =====
Sun Jun 21 17:39:32 UTC 2026
Linux arm64test 5.10.0-44-cloud-arm64 #1 SMP Debian 5.10.257-1 (2026-05-27) aarch64 GNU/Linux
PAGE_SIZE=4096
Debian GNU/Linux 11 (bullseye)
gcc (Debian 10.2.1-6) 10.2.1 20210110
/tmp/dall.sh: line 13: modinfo: command not found
--- feature-test (expect absent on 5.10 -> arm64 ->pc) ---
HAVE_FTRACE_REGS_SET_INSTRUCTION_POINTER not defined => arm64 ->pc fallback active
===== ENVIRONMENT (arm64, real 5.15 distro) =====
Sun Jun 21 17:04:59 UTC 2026
Linux arm64test 5.15.0-181-generic #191-Ubuntu SMP Fri May 22 19:27:05 UTC 2026 aarch64 aarch64 aarch64 GNU/Linux
PAGE_SIZE=4096
Ubuntu 22.04.5 LTS
gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0
version:        0.12.2
srcversion:     6AD47597211153C5E1728FB
vermagic:       5.15.0-181-generic SMP mod_unload modversions aarch64
--- feature-test result (expect absent on 5.15 -> arm64 ->pc branch) ---
HAVE_FTRACE_REGS_SET_INSTRUCTION_POINTER not defined => arm64 ->pc fallback active
===== ENVIRONMENT (arm64, real hardware) =====
Fri Jun 19 22:13:28 UTC 2026
Linux dbelyarm-QEMU-Virtual-Machine 6.17.0-35-generic #35~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 19:14:16 UTC 2 aarch64 aarch64 aarch64 GNU/Linux
PAGE_SIZE=4096
gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
version:        0.12.2
srcversion:     841B21F4FF35C73387A0256
vermagic:       6.17.0-35-generic SMP preempt mod_unload modversions aarch64
#define HAVE_BDEV_FILE_OPEN_BY_PATH
#define HAVE_ENUM_REQ_OP_WRITE_ZEROES
===== ENVIRONMENT (arm64, emulated, 64K pages) =====
Sat Jun 20 08:41:11 UTC 2026
Linux arm64test 6.8.0-124-generic-64k #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:54:55 UTC 2026 aarch64 aarch64 aarch64 GNU/Linux
PAGE_SIZE=65536
gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
version:        0.12.2
srcversion:     FD08148BF1FD432415BF50E
vermagic:       6.8.0-124-generic SMP preempt mod_unload modversions aarch64
--- module after build ---
srcversion:     A58570CFA61090438956EFF
vermagic:       6.8.0-124-generic-64k SMP preempt mod_unload modversions aarch64
version:        0.12.2
srcversion:     3A57035502391B4076B7EC9
vermagic:       6.8.0-124-generic-64k SMP preempt mod_unload modversions aarch64
#define HAVE_ENUM_REQ_OP_WRITE_ZEROES

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

X86 specific code failes building on ARM

1 participant