Commit 136ef0e
fix: gate UFFD write-protection on x86_64 for ARM64 compatibility
Commit 8fc760f ("feat: enable write-protection on guest memory") added
UFFD write-protection support unconditionally. ARM64 Linux kernels do not
implement UFFD write protection — they lack UFFD_FEATURE_WP_ASYNC,
UFFDIO_REGISTER_MODE_WP, the UFFDIO_WRITEPROTECT ioctl, and
UFFDIO_COPY_MODE_WP. This causes snapshot restore to fail on ARM64
(Apple Silicon / AWS Graviton) with ioctl errors from the kernel.
Gate the three write-protection code paths in guest_memory_from_uffd()
behind #[cfg(target_arch = "x86_64")]:
1. UFFD features: request WP_ASYNC only on x86_64. On other
architectures, request only EVENT_REMOVE | MISSING_HUGETLBFS.
2. Register mode: include WRITE_PROTECT in the register mode only on
x86_64. On other architectures, register with MISSING only.
3. write_protect ioctl: gate the hugetlbfs write-protection call behind
cfg(target_arch = "x86_64") so it is never emitted on ARM64.
The core UFFD snapshot restore functionality (page fault handling via
MISSING mode) works identically on both architectures and is unaffected.
Also update scripts/build.sh to auto-detect the target architecture and
select the correct Rust target triple (aarch64-unknown-linux-musl) so the
build script works on ARM64 hosts.
Tested: built for aarch64-unknown-linux-musl, deployed to ARM64 VM,
verified sandbox creation via UFFD snapshot restore succeeds with no
write-protection errors.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent a41d3fb commit 136ef0e
2 files changed
Lines changed: 29 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
5 | 20 | | |
6 | 21 | | |
7 | 22 | | |
8 | 23 | | |
9 | 24 | | |
10 | 25 | | |
| 26 | + | |
11 | 27 | | |
12 | 28 | | |
13 | 29 | | |
14 | 30 | | |
15 | 31 | | |
16 | | - | |
| 32 | + | |
17 | 33 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
496 | | - | |
497 | | - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
498 | 501 | | |
499 | 502 | | |
500 | 503 | | |
| |||
504 | 507 | | |
505 | 508 | | |
506 | 509 | | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
507 | 514 | | |
508 | 515 | | |
509 | 516 | | |
510 | | - | |
| 517 | + | |
511 | 518 | | |
512 | 519 | | |
513 | 520 | | |
| |||
516 | 523 | | |
517 | 524 | | |
518 | 525 | | |
| 526 | + | |
519 | 527 | | |
520 | 528 | | |
521 | 529 | | |
| |||
0 commit comments