Skip to content

Commit 132f8ec

Browse files
pbo-linaropm215
authored andcommitted
target/arm: change default pauth algorithm to impdef
Pointer authentication on aarch64 is pretty expensive (up to 50% of execution time) when running a virtual machine with tcg and -cpu max (which enables pauth=on). The advice is always: use pauth-impdef=on. Our documentation even mentions it "by default" in docs/system/introduction.rst. Thus, we change the default to use impdef by default. This does not affect kvm or hvf acceleration, since pauth algorithm used is the one from host cpu. This change is retro compatible, in terms of cli, with previous versions, as the semantic of using -cpu max,pauth-impdef=on, and -cpu max,pauth-qarma3=on is preserved. The new option introduced in previous patch and matching old default is -cpu max,pauth-qarma5=on. It is retro compatible with migration as well, by defining a backcompat property, that will use qarma5 by default for virt machine <= 9.2. Tested by saving and restoring a vm from qemu 9.2.0 into qemu-master (10.0) for cpus neoverse-n2 and max. Signed-off-by: Pierrick Bouvier <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-id: [email protected] Signed-off-by: Peter Maydell <[email protected]>
1 parent 39d7001 commit 132f8ec

File tree

6 files changed

+26
-9
lines changed

6 files changed

+26
-9
lines changed

docs/system/arm/cpu-features.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ Below is the list of TCG VCPU features and their descriptions.
223223
When ``pauth`` is enabled, select the architected QARMA5 algorithm.
224224

225225
Without ``pauth-impdef``, ``pauth-qarma3`` or ``pauth-qarma5`` enabled,
226-
the architected QARMA5 algorithm is used. The architected QARMA5
226+
the QEMU impdef algorithm is used. The architected QARMA5
227227
and QARMA3 algorithms have good cryptographic properties, but can
228228
be quite slow to emulate. The impdef algorithm used by QEMU is
229229
non-cryptographic but significantly faster.

docs/system/introduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ would default to it anyway.
169169

170170
.. code::
171171
172-
-cpu max,pauth-impdef=on \
172+
-cpu max \
173173
-smp 4 \
174174
-accel tcg \
175175

hw/core/machine.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
#include "hw/virtio/virtio-iommu.h"
3737
#include "audio/audio.h"
3838

39-
GlobalProperty hw_compat_9_2[] = {};
39+
GlobalProperty hw_compat_9_2[] = {
40+
{"arm-cpu", "backcompat-pauth-default-use-qarma5", "true"},
41+
};
4042
const size_t hw_compat_9_2_len = G_N_ELEMENTS(hw_compat_9_2);
4143

4244
GlobalProperty hw_compat_9_1[] = {

target/arm/cpu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,6 +2653,8 @@ static const Property arm_cpu_properties[] = {
26532653
DEFINE_PROP_INT32("core-count", ARMCPU, core_count, -1),
26542654
/* True to default to the backward-compat old CNTFRQ rather than 1Ghz */
26552655
DEFINE_PROP_BOOL("backcompat-cntfrq", ARMCPU, backcompat_cntfrq, false),
2656+
DEFINE_PROP_BOOL("backcompat-pauth-default-use-qarma5", ARMCPU,
2657+
backcompat_pauth_default_use_qarma5, false),
26562658
};
26572659

26582660
static const gchar *arm_gdb_arch_name(CPUState *cs)

target/arm/cpu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,9 @@ struct ArchCPU {
972972
/* QOM property to indicate we should use the back-compat CNTFRQ default */
973973
bool backcompat_cntfrq;
974974

975+
/* QOM property to indicate we should use the back-compat QARMA5 default */
976+
bool backcompat_pauth_default_use_qarma5;
977+
975978
/* Specify the number of cores in this CPU cluster. Used for the L2CTLR
976979
* register.
977980
*/

target/arm/cpu64.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,15 +529,25 @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
529529
return;
530530
}
531531

532-
if (cpu->prop_pauth_impdef) {
533-
isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, API, features);
534-
isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, GPI, 1);
532+
bool use_default = !cpu->prop_pauth_qarma5 &&
533+
!cpu->prop_pauth_qarma3 &&
534+
!cpu->prop_pauth_impdef;
535+
536+
if (cpu->prop_pauth_qarma5 ||
537+
(use_default &&
538+
cpu->backcompat_pauth_default_use_qarma5)) {
539+
isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, APA, features);
540+
isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, GPA, 1);
535541
} else if (cpu->prop_pauth_qarma3) {
536542
isar2 = FIELD_DP64(isar2, ID_AA64ISAR2, APA3, features);
537543
isar2 = FIELD_DP64(isar2, ID_AA64ISAR2, GPA3, 1);
538-
} else { /* default is pauth-qarma5 */
539-
isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, APA, features);
540-
isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, GPA, 1);
544+
} else if (cpu->prop_pauth_impdef ||
545+
(use_default &&
546+
!cpu->backcompat_pauth_default_use_qarma5)) {
547+
isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, API, features);
548+
isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, GPI, 1);
549+
} else {
550+
g_assert_not_reached();
541551
}
542552
} else if (cpu->prop_pauth_impdef ||
543553
cpu->prop_pauth_qarma3 ||

0 commit comments

Comments
 (0)