Skip to content

Commit cb0698a

Browse files
committed
boot-qemu.sh: Use implementation defined pointer authentication algorithm
By default, QEMU's TCG uses the architected QARMA algorithm for pointer authentication, which is better cryptographically but extremely slow to emulate. As of QEMU 6.0.0, there is an "Implementation Defined" algorithm available, which is not cryptographic but significantly faster to run. ARCH=arm64 defconfig: Benchmark 1: QARMA Time (mean ± σ): 10.381 s ± 0.048 s [User: 8.469 s, System: 0.142 s] Range (min … max): 10.317 s … 10.478 s 50 runs Benchmark 2: Implementation Defined Time (mean ± σ): 7.051 s ± 0.015 s [User: 5.125 s, System: 0.130 s] Range (min … max): 7.014 s … 7.083 s 50 runs Summary 'Implementation Defined' ran 1.47 ± 0.01 times faster than 'QARMA' ARCH=arm64 defconfig + KASAN_SW_TAGS + the KUnit tests: Benchmark 1: QARMA Time (mean ± σ): 185.997 s ± 2.778 s [User: 184.043 s, System: 0.593 s] Range (min … max): 182.816 s … 190.463 s 10 runs Benchmark 2: Implementation Defined Time (mean ± σ): 29.618 s ± 0.301 s [User: 26.951 s, System: 0.500 s] Range (min … max): 29.185 s … 30.103 s 10 runs Summary 'Implementation Defined' ran 6.28 ± 0.11 times faster than 'QARMA' This should help avoid weird timeouts in CI, as the VMs can be quite slow. Aside from the benchmarks above, this change is visible in dmesg: [ 0.000000] CPU features: detected: Address authentication (architected QARMA5 algorithm) vs. [ 0.000000] CPU features: detected: Address authentication (IMP DEF algorithm) Link: https://lore.kernel.org/YlgVa+AP0g4IYvzN@lakrids/ Link: https://gitlab.com/qemu-project/qemu/-/blob/v7.0.0/docs/system/arm/cpu-features.rst Signed-off-by: Nathan Chancellor <[email protected]>
1 parent c2d25a4 commit cb0698a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

boot-qemu.sh

+10-4
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,23 @@ function setup_qemu_args() {
232232
KIMAGE=Image.gz
233233
QEMU=(qemu-system-aarch64)
234234
get_full_kernel_path
235-
if [[ $(get_qemu_ver_code) -ge 602050 ]]; then
235+
QEMU_VER_CODE=$(get_qemu_ver_code)
236+
if [[ ${QEMU_VER_CODE} -ge 602050 ]]; then
236237
LNX_VER_CODE=$(get_lnx_ver_code gzip -c -d "${KERNEL}")
237238
# https://gitlab.com/qemu-project/qemu/-/issues/964
238239
if [[ ${LNX_VER_CODE} -lt 416000 ]]; then
239240
CPU=cortex-a72
240-
# https://gitlab.com/qemu-project/qemu/-/commit/69b2265d5fe8e0f401d75e175e0a243a7d505e53
241+
# lpa2=off: https://gitlab.com/qemu-project/qemu/-/commit/69b2265d5fe8e0f401d75e175e0a243a7d505e53
242+
# pauth-impdef=true: https://lore.kernel.org/YlgVa+AP0g4IYvzN@lakrids/
241243
elif [[ ${LNX_VER_CODE} -lt 512000 ]]; then
242-
CPU=max,lpa2=off
244+
CPU=max,lpa2=off,pauth-impdef=true
243245
fi
244246
fi
245-
[[ -z ${CPU} ]] && CPU=max
247+
if [[ -z ${CPU} ]]; then
248+
CPU=max
249+
# https://lore.kernel.org/YlgVa+AP0g4IYvzN@lakrids/
250+
[[ ${QEMU_VER_CODE} -ge 600000 ]] && CPU=${CPU},pauth-impdef=true
251+
fi
246252
APPEND_STRING+="console=ttyAMA0 earlycon "
247253
QEMU_ARCH_ARGS=(
248254
-cpu "${CPU}"

0 commit comments

Comments
 (0)