Skip to content

Commit 86a00f2

Browse files
pbo-linaropm215
authored andcommitted
target/arm: add new property to select pauth-qarma5
Before changing default pauth algorithm, we need to make sure current default one (QARMA5) can still be selected. $ qemu-system-aarch64 -cpu max,pauth-qarma5=on ... 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 538b764 commit 86a00f2

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

docs/system/arm/cpu-features.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,10 @@ Below is the list of TCG VCPU features and their descriptions.
219219
``pauth-qarma3``
220220
When ``pauth`` is enabled, select the architected QARMA3 algorithm.
221221

222-
Without either ``pauth-impdef`` or ``pauth-qarma3`` enabled,
222+
``pauth-qarma5``
223+
When ``pauth`` is enabled, select the architected QARMA5 algorithm.
224+
225+
Without ``pauth-impdef``, ``pauth-qarma3`` or ``pauth-qarma5`` enabled,
223226
the architected QARMA5 algorithm is used. The architected QARMA5
224227
and QARMA3 algorithms have good cryptographic properties, but can
225228
be quite slow to emulate. The impdef algorithm used by QEMU is

target/arm/arm-qmp-cmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static const char *cpu_model_advertised_features[] = {
9494
"sve640", "sve768", "sve896", "sve1024", "sve1152", "sve1280",
9595
"sve1408", "sve1536", "sve1664", "sve1792", "sve1920", "sve2048",
9696
"kvm-no-adjvtime", "kvm-steal-time",
97-
"pauth", "pauth-impdef", "pauth-qarma3",
97+
"pauth", "pauth-impdef", "pauth-qarma3", "pauth-qarma5",
9898
NULL
9999
};
100100

target/arm/cpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,7 @@ struct ArchCPU {
10621062
bool prop_pauth;
10631063
bool prop_pauth_impdef;
10641064
bool prop_pauth_qarma3;
1065+
bool prop_pauth_qarma5;
10651066
bool prop_lpa2;
10661067

10671068
/* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */

target/arm/cpu64.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,12 @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
520520
}
521521

522522
if (cpu->prop_pauth) {
523-
if (cpu->prop_pauth_impdef && cpu->prop_pauth_qarma3) {
523+
if ((cpu->prop_pauth_impdef && cpu->prop_pauth_qarma3) ||
524+
(cpu->prop_pauth_impdef && cpu->prop_pauth_qarma5) ||
525+
(cpu->prop_pauth_qarma3 && cpu->prop_pauth_qarma5)) {
524526
error_setg(errp,
525-
"cannot enable both pauth-impdef and pauth-qarma3");
527+
"cannot enable pauth-impdef, pauth-qarma3 and "
528+
"pauth-qarma5 at the same time");
526529
return;
527530
}
528531

@@ -532,13 +535,15 @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
532535
} else if (cpu->prop_pauth_qarma3) {
533536
isar2 = FIELD_DP64(isar2, ID_AA64ISAR2, APA3, features);
534537
isar2 = FIELD_DP64(isar2, ID_AA64ISAR2, GPA3, 1);
535-
} else {
538+
} else { /* default is pauth-qarma5 */
536539
isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, APA, features);
537540
isar1 = FIELD_DP64(isar1, ID_AA64ISAR1, GPA, 1);
538541
}
539-
} else if (cpu->prop_pauth_impdef || cpu->prop_pauth_qarma3) {
540-
error_setg(errp, "cannot enable pauth-impdef or "
541-
"pauth-qarma3 without pauth");
542+
} else if (cpu->prop_pauth_impdef ||
543+
cpu->prop_pauth_qarma3 ||
544+
cpu->prop_pauth_qarma5) {
545+
error_setg(errp, "cannot enable pauth-impdef, pauth-qarma3 or "
546+
"pauth-qarma5 without pauth");
542547
error_append_hint(errp, "Add pauth=on to the CPU property list.\n");
543548
}
544549
}
@@ -553,6 +558,8 @@ static const Property arm_cpu_pauth_impdef_property =
553558
DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false);
554559
static const Property arm_cpu_pauth_qarma3_property =
555560
DEFINE_PROP_BOOL("pauth-qarma3", ARMCPU, prop_pauth_qarma3, false);
561+
static Property arm_cpu_pauth_qarma5_property =
562+
DEFINE_PROP_BOOL("pauth-qarma5", ARMCPU, prop_pauth_qarma5, false);
556563

557564
void aarch64_add_pauth_properties(Object *obj)
558565
{
@@ -573,6 +580,7 @@ void aarch64_add_pauth_properties(Object *obj)
573580
} else {
574581
qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property);
575582
qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_qarma3_property);
583+
qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_qarma5_property);
576584
}
577585
}
578586

tests/qtest/arm-cpu-features.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,21 +419,28 @@ static void pauth_tests_default(QTestState *qts, const char *cpu_type)
419419
assert_has_feature_enabled(qts, cpu_type, "pauth");
420420
assert_has_feature_disabled(qts, cpu_type, "pauth-impdef");
421421
assert_has_feature_disabled(qts, cpu_type, "pauth-qarma3");
422+
assert_has_feature_disabled(qts, cpu_type, "pauth-qarma5");
422423
assert_set_feature(qts, cpu_type, "pauth", false);
423424
assert_set_feature(qts, cpu_type, "pauth", true);
424425
assert_set_feature(qts, cpu_type, "pauth-impdef", true);
425426
assert_set_feature(qts, cpu_type, "pauth-impdef", false);
426427
assert_set_feature(qts, cpu_type, "pauth-qarma3", true);
427428
assert_set_feature(qts, cpu_type, "pauth-qarma3", false);
429+
assert_set_feature(qts, cpu_type, "pauth-qarma5", true);
430+
assert_set_feature(qts, cpu_type, "pauth-qarma5", false);
428431
assert_error(qts, cpu_type,
429-
"cannot enable pauth-impdef or pauth-qarma3 without pauth",
432+
"cannot enable pauth-impdef, pauth-qarma3 or pauth-qarma5 without pauth",
430433
"{ 'pauth': false, 'pauth-impdef': true }");
431434
assert_error(qts, cpu_type,
432-
"cannot enable pauth-impdef or pauth-qarma3 without pauth",
435+
"cannot enable pauth-impdef, pauth-qarma3 or pauth-qarma5 without pauth",
433436
"{ 'pauth': false, 'pauth-qarma3': true }");
434437
assert_error(qts, cpu_type,
435-
"cannot enable both pauth-impdef and pauth-qarma3",
436-
"{ 'pauth': true, 'pauth-impdef': true, 'pauth-qarma3': true }");
438+
"cannot enable pauth-impdef, pauth-qarma3 or pauth-qarma5 without pauth",
439+
"{ 'pauth': false, 'pauth-qarma5': true }");
440+
assert_error(qts, cpu_type,
441+
"cannot enable pauth-impdef, pauth-qarma3 and pauth-qarma5 at the same time",
442+
"{ 'pauth': true, 'pauth-impdef': true, 'pauth-qarma3': true,"
443+
" 'pauth-qarma5': true }");
437444
}
438445

439446
static void test_query_cpu_model_expansion(const void *data)

0 commit comments

Comments
 (0)