From 72510e704e3240f5fd1a3b258fcba2e30fa37d22 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Wed, 4 Nov 2026 19:57:26 +0100 Subject: [PATCH] Emulate aarch64 as a Neoverse N1 cpu in imgutil MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default 'max' cpu of qemu-user emulates SVE and pointer authentication, which aarch64 binaries use and which is expensive to emulate. Default QEMU_CPU to neoverse-n1 for aarch64 builds and exec, unless it is already set. neoverse-n1 needs qemu 7.1 or later, the documentation says how to choose another cpu. Building an EL10 image with mlnx-ofa_kernel-dkms and doca-ofed-userspace on an EL10 x86_64 host with qemu 10.2: DOCA build Total aarch64, master 3270 s (54.5 min) aarch64, branch 2399 s (40 min), −27% x86_64, native 251 s (4 min) Older qemu-user-static, such as qemu 8.2 of Ubuntu 24.04, emulates pointer authentication much more slowly, so builds there can get up to ten times faster. --- confluent_client/doc/man/imgutil.ronn | 5 ++++- imgutil/imgutil | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/confluent_client/doc/man/imgutil.ronn b/confluent_client/doc/man/imgutil.ronn index c2578ce2..2705cefc 100644 --- a/confluent_client/doc/man/imgutil.ronn +++ b/confluent_client/doc/man/imgutil.ronn @@ -54,7 +54,10 @@ with the F (fix-binary) flag; on Ubuntu this is provided by the qemu-user-static package (qemu-user-binfmt as of Ubuntu 26.04). For EL, the architecture is also detected automatically when building from a `-s` - source tree. + source tree. An aarch64 image is emulated as a Neoverse N1 cpu, which needs + qemu 7.1 or later and is much faster to emulate than the default cpu of + qemu. To emulate another cpu, set `QEMU_CPU`, for example + `QEMU_CPU=cortex-a72` for older qemu. The same applies to `imgutil exec`. * `-y`, `--non-interactive`: Avoid prompting for confirmation. diff --git a/imgutil/imgutil b/imgutil/imgutil index f7a19ce3..f66c929e 100644 --- a/imgutil/imgutil +++ b/imgutil/imgutil @@ -1212,7 +1212,7 @@ def main(): buildp.add_argument('-a', '--addpackagelist', action='append', default=[], help='A list of additional packages to include, may be specified multiple times') buildp.add_argument('-s', '--source', help='Directory to pull installation from, typically a subdirectory of /var/lib/confluent/distributions. By default, the repositories for the build system are used. For Ubuntu, this is not supported, the build system repositories are always used.') - buildp.add_argument('--arch', default=None, help='Target architecture to build for (e.g. aarch64). When it differs from the build host architecture, statically linked qemu-user emulator registered in binfmt_misc with the F flag is required') + buildp.add_argument('--arch', default=None, help='Target architecture to build for (e.g. aarch64). When it differs from the build host architecture, statically linked qemu-user emulator registered in binfmt_misc with the F flag is required. aarch64 is emulated as a Neoverse N1 cpu (qemu 7.1 or later), set QEMU_CPU to choose another') buildp.add_argument('-y', '--non-interactive', help='Avoid prompting for confirmation', action='store_true') buildp.add_argument('--selinux', action='store_true', help='Install the targeted SELinux policy and leave SELinux enforcing ' @@ -1271,6 +1271,7 @@ def exec_root(args): pass if imgarch and imgarch != os.uname().machine: check_binfmt(imgarch, args) + set_qemu_cpu(imgarch) exitcode = run_constrained(exec_root_backend, args) if exitcode: sys.exit(exitcode) @@ -1404,6 +1405,13 @@ qemu_arch_map = { } +def set_qemu_cpu(targetarch): + # The default 'max' cpu of qemu-user emulates SVE and pointer + # authentication, which slows down the image build considerably + if targetarch == 'aarch64' and 'QEMU_CPU' not in os.environ: + os.environ['QEMU_CPU'] = 'neoverse-n1' + + def check_binfmt(targetarch, args): qname = qemu_arch_map.get(targetarch, 'qemu-' + targetarch) binfmtdir = '/proc/sys/fs/binfmt_misc' @@ -1682,6 +1690,7 @@ def build_root(args): oshandler.arch, hostarch)) sys.exit(1) check_binfmt(oshandler.arch, args) + set_qemu_cpu(oshandler.arch) if args.selinux and not oshandler.selinuxsupport: sys.stderr.write('--selinux is not supported for {0} images\n'.format(oshandler.oscategory)) sys.exit(1)