pmb.parse.arch: use qemu for running armhf on aarch64 (MR 2285)

This works around an issue where some armhf apps are compiled with
instructions that are not compatible with aarch64, for example apk uses
MCR, and that does not exist on aarch64 causing apk to fail in a chroot
with SIGILL. It's impossible to build armhf images on aarch64 hosts, and
this also fixes a crash when running `pmbootstrap zap -a`, since pmb zap
will init an armhf chroot and blow up with apk generates a SIGILL.

For reference, here's how I arrived at the conclusion that apk (and gdb,
and probably others...) are executing invalid instructions on aarch64
when not using binfmt+qemu emulation:

$ uname -m
aarch64

$ file sbin/apk.static
sbin/apk.static: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, BuildID[sha1]=997a8ef97b17cb4951a6220b7807a66fed67bc10, stripped

$ gdb sbin/apk.static
(gdb) r
Starting program: /run/user/10000/foo/sbin/apk.static
Program received signal SIGILL, Illegal instruction.
0x0012843c in ?? ()
(gdb) x /1i $pc
=> 0x12843c:    mcr     15, 0, r0, cr7, cr10, {5}
This commit is contained in:
Clayton Craft 2024-03-29 13:44:05 -07:00 committed by Oliver Smith
parent ce08cb6803
commit 3ff178eb32
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
1 changed files with 1 additions and 1 deletions

View File

@ -103,7 +103,7 @@ def cpu_emulation_required(arch):
not_required = {
"x86_64": ["x86"],
"armv7": ["armel", "armhf"],
"aarch64": ["armel", "armhf", "armv7"],
"aarch64": ["armv7"],
}
if pmb.config.arch_native in not_required:
if arch in not_required[pmb.config.arch_native]: