hw/arm/virt: KVM: Enable PAuth when supported by the host
Marc Zyngier
maintainerPATCH 1/1 hw/arm/virt: KVM: Enable PAuth when supported by the host
Add basic support for Pointer Authentication when running a KVM guest and that the host supports it, loosely based on the SVE support.
Although the feature is enabled by default when the host advertises it, it is possible to disable it by setting the 'pauth=off' CPU property.
Tested on an Apple M1 running 5.16-rc6.
--- docs/system/arm/cpu-features.rst | 5 +++++ target/arm/cpu.c | 1 + target/arm/cpu.h | 1 + target/arm/cpu64.c | 36 ++++++++++++++++++++++++++++++++ target/arm/kvm.c | 13 ++++++++++++ target/arm/kvm64.c | 10 +++++++++ target/arm/kvm_arm.h | 7 +++++++ 7 files changed, 73 insertions(+)
docs/system/arm/cpu-features.rst +5 -0
@@ -211,6 +211,11 @@ the list of KVM VCPU features and their descriptions. influence the guest scheduler behavior and/or be exposed to the guest userspace. + pauth Enable or disable ``FEAT_Pauth``, pointer + authentication. By default, the feature is enabled + with ``-cpu host`` if supported by both the host + kernel and the hardware. + TCG VCPU Features =================
target/arm/cpu.c +1 -0
@@ -2091,6 +2091,7 @@ static void arm_host_initfn(Object *obj)kvm_arm_set_cpu_features_from_host (cpu);if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {aarch64_add_sve_properties (obj); +aarch64_add_pauth_properties (obj); }#else hvf_arm_set_cpu_features_from_host (cpu);
target/arm/cpu.h +1 -0
@@ -1076,6 +1076,7 @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);void aarch64_sve_change_el (CPUARMState *env,int old_el,int new_el,bool el0_a64);void aarch64_add_sve_properties (Object *obj); +void aarch64_add_pauth_properties (Object *obj);/* * SVE registers are encoded in KVM's memory in an endianness-invariant format.
target/arm/cpu64.c +36 -0
@@ -625,6 +625,42 @@ void aarch64_add_sve_properties(Object *obj)#endif } +static bool cpu_arm_get_pauth (Object *obj,Error **errp) +{ +ARMCPU *cpu =ARM_CPU (obj); +return cpu_isar_feature (aa64_pauth, cpu); +} + +static void cpu_arm_set_pauth (Object *obj,bool value,Error **errp) +{ +ARMCPU *cpu =ARM_CPU (obj); +uint64_t t; + +if (value) { +if (!kvm_arm_pauth_supported ()) { +error_setg (errp,"'pauth' feature not supported by KVM on this host" ); + } + +return ; + } + +/* +* If the host supports PAuth, we only end-up here if the user has +* disabled the support, and value is false. +*/ + t = cpu->isar.id_aa64isar1; + t =FIELD_DP64 (t,ID_AA64ISAR1 ,APA , value); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPA , value); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,API , value); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPI , value); + cpu->isar.id_aa64isar1 = t; +} + +void aarch64_add_pauth_properties (Object *obj) +{ +object_property_add_bool (obj,"pauth" , cpu_arm_get_pauth, cpu_arm_set_pauth); +} +void arm_cpu_pauth_finalize (ARMCPU *cpu,Error **errp) {int arch_val =0 , impdef_val =0 ;
target/arm/kvm.c +13 -0
@@ -84,6 +84,7 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,if (vmfd <0 ) { goto err; } + cpufd =ioctl (vmfd,KVM_CREATE_VCPU ,0 );if (cpufd <0 ) { goto err;
@@ -94,6 +95,18 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, goto finish; } +/* +* Ask for Pointer Authentication if supported. We can't play the +* SVE trick of synthetising the ID reg as KVM won't tell us +* whether we have the architected or IMPDEF version of PAuth, so +* we have to use the actual ID regs. +*/ +if (ioctl (vmfd,KVM_CHECK_EXTENSION ,KVM_CAP_ARM_PTRAUTH_ADDRESS ) >0 && +ioctl (vmfd,KVM_CHECK_EXTENSION ,KVM_CAP_ARM_PTRAUTH_GENERIC ) >0 ) { + init->features[0 ] |= (1 <<KVM_ARM_VCPU_PTRAUTH_ADDRESS | +1 <<KVM_ARM_VCPU_PTRAUTH_GENERIC ); + } +if (init->target ==-1 ) {struct kvm_vcpu_init preferred;
target/arm/kvm64.c +10 -0
@@ -725,6 +725,12 @@ bool kvm_arm_sve_supported(void)return kvm_check_extension (kvm_state,KVM_CAP_ARM_SVE ); } +bool kvm_arm_pauth_supported (void ) +{ +return (kvm_check_extension (kvm_state,KVM_CAP_ARM_PTRAUTH_ADDRESS ) && +kvm_check_extension (kvm_state,KVM_CAP_ARM_PTRAUTH_GENERIC )); +} +bool kvm_arm_steal_time_supported (void ) {return kvm_check_extension (kvm_state,KVM_CAP_STEAL_TIME );
@@ -865,6 +871,10 @@ int kvm_arch_init_vcpu(CPUState *cs)assert (kvm_arm_sve_supported ()); cpu->kvm_init_features[0 ] |=1 <<KVM_ARM_VCPU_SVE ; } +if (cpu_isar_feature (aa64_pauth, cpu)) { + cpu->kvm_init_features[0 ] |= (1 <<KVM_ARM_VCPU_PTRAUTH_ADDRESS | +1 <<KVM_ARM_VCPU_PTRAUTH_GENERIC ); + }/* Do KVM_ARM_VCPU_INIT ioctl */ ret =kvm_arm_vcpu_init (cs);
target/arm/kvm_arm.h +7 -0
@@ -306,6 +306,13 @@ bool kvm_arm_pmu_supported(void);*/ bool kvm_arm_sve_supported (void ); +/** +* kvm_arm_pauth_supported: +* +* Returns true if KVM can enable Pointer Authentication and false otherwise. +*/ +bool kvm_arm_pauth_supported (void ); +/** * kvm_arm_get_max_vm_ipa_size: * @ms: Machine state handle
Signature · 1 line
2.30.2
Hi Marc,
Quoted 30 lines · Marc Zyngier
Add basic support for Pointer Authentication when running a KVM guest and that the host supports it, loosely based on the SVE support.
Although the feature is enabled by default when the host advertises it, it is possible to disable it by setting the 'pauth=off' CPU property.
Tested on an Apple M1 running 5.16-rc6.
Cc Eric Auger <[email protected]>Cc Andrew Jones <[email protected]>Cc Richard Henderson <[email protected]>Cc Peter Maydell <[email protected]>Signed-off-by Marc Zyngier <[email protected]>--- docs/system/arm/cpu-features.rst | 5 +++++ target/arm/cpu.c | 1 + target/arm/cpu.h | 1 + target/arm/cpu64.c | 36 ++++++++++++++++++++++++++++++++ target/arm/kvm.c | 13 ++++++++++++ target/arm/kvm64.c | 10 +++++++++ target/arm/kvm_arm.h | 7 +++++++ 7 files changed, 73 insertions(+)docs/system/arm/cpu-features.rst +0
-0
docs/system/arm/cpu-features.rst the list of KVM VCPU features and their descriptions. · line 218
Quoted 8 lines
docs/system/arm/cpu-features.rst +5
-0@@ -211,6 +211,11 @@ the list of KVM VCPU features and their descriptions. influence the guest scheduler behavior and/or be exposed to the guest userspace. + pauth Enable or disable ``FEAT_Pauth``, pointer + authentication. By default, the feature is enabled + with ``-cpu host`` if supported by both the host + kernel and the hardware. +
Thanks for considering a documentation update. In this case, though, I think we should delete the "TCG VCPU Features" pauth paragraph, rather than add a new "KVM VCPU Features" pauth paragraph. We don't need to document each CPU feature. We just document complex ones, like sve*, KVM specific ones (kvm-*), and TCG specific ones (now only pauth-impdef).
Quoted 60 lines
docs/system/arm/cpu-features.rst +0
-0TCG VCPU Features =================target/arm/cpu.c +1
-0@@ -2091,6 +2091,7 @@ static void arm_host_initfn(Object *obj)kvm_arm_set_cpu_features_from_host (cpu);if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {aarch64_add_sve_properties (obj); +aarch64_add_pauth_properties (obj); }#else hvf_arm_set_cpu_features_from_host (cpu);target/arm/cpu.h +1
-0@@ -1076,6 +1076,7 @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);void aarch64_sve_change_el (CPUARMState *env,int old_el,int new_el,bool el0_a64);void aarch64_add_sve_properties (Object *obj); +void aarch64_add_pauth_properties (Object *obj);/* * SVE registers are encoded in KVM's memory in an endianness-invariant format. target/arm/cpu64.c +25
-0@@ -625,6 +625,42 @@ void aarch64_add_sve_properties(Object *obj)#endif } +static bool cpu_arm_get_pauth (Object *obj,Error **errp) +{ +ARMCPU *cpu =ARM_CPU (obj); +return cpu_isar_feature (aa64_pauth, cpu); +} + +static void cpu_arm_set_pauth (Object *obj,bool value,Error **errp) +{ +ARMCPU *cpu =ARM_CPU (obj); +uint64_t t; + +if (value) { +if (!kvm_arm_pauth_supported ()) { +error_setg (errp,"'pauth' feature not supported by KVM on this host" ); + } + +return ; + } + +/* +* If the host supports PAuth, we only end-up here if the user has +* disabled the support, and value is false. +*/ + t = cpu->isar.id_aa64isar1; + t =FIELD_DP64 (t,ID_AA64ISAR1 ,APA , value);
target/arm/cpu64.c void aarch64_add_sve_properties(Object *obj) · line 662
Quoted 10 lines
target/arm/cpu64.c +10
-0+ t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPA , value); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,API , value); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPI , value); + cpu->isar.id_aa64isar1 = t; +} + +void aarch64_add_pauth_properties (Object *obj) +{ +object_property_add_bool (obj,"pauth" , cpu_arm_get_pauth, cpu_arm_set_pauth); +}
I think we should try to merge as much as possible between the TCG and KVM pauth property handling. I think we just need to move the qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property) call into KVM/TCG common code and then modify arm_cpu_pauth_finalize() to handle checking KVM for support when KVM is enabled and also to not look at the impdef property.
Quoted 22 lines
target/arm/cpu64.c +1
-0+void arm_cpu_pauth_finalize (ARMCPU *cpu,Error **errp) {int arch_val =0 , impdef_val =0 ;target/arm/kvm.c +3
-0@@ -84,6 +84,7 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,if (vmfd <0 ) { goto err; } + cpufd =ioctl (vmfd,KVM_CREATE_VCPU ,0 );if (cpufd <0 ) { goto err;@@ -94,6 +95,18 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, goto finish; } +/* +* Ask for Pointer Authentication if supported. We can't play the
target/arm/kvm.c bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, · line 109
Quoted 10 lines
target/arm/kvm.c +10
-0+* SVE trick of synthetising the ID reg as KVM won't tell us +* whether we have the architected or IMPDEF version of PAuth, so +* we have to use the actual ID regs. +*/ +if (ioctl (vmfd,KVM_CHECK_EXTENSION ,KVM_CAP_ARM_PTRAUTH_ADDRESS ) >0 && +ioctl (vmfd,KVM_CHECK_EXTENSION ,KVM_CAP_ARM_PTRAUTH_GENERIC ) >0 ) { + init->features[0 ] |= (1 <<KVM_ARM_VCPU_PTRAUTH_ADDRESS | +1 <<KVM_ARM_VCPU_PTRAUTH_GENERIC ); + } +
I think kvm_init() is called prior to kvm_arm_get_host_cpu_features(), which means we can do this instead
target/arm/kvm64.c +11 -0
@@ -521,6 +521,17 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)*/ struct kvm_vcpu_init init = { .target =-1 , }; +/* +* Ask for Pointer Authentication if supported. We can't play the +* SVE trick of synthetising the ID reg as KVM won't tell us +* whether we have the architected or IMPDEF version of PAuth, so +* we have to use the actual ID regs. +*/ +if (kvm_arm_pauth_supported ()) { + init->features[0 ] |= (1 <<KVM_ARM_VCPU_PTRAUTH_ADDRESS | +1 <<KVM_ARM_VCPU_PTRAUTH_GENERIC ); + } +if (!kvm_arm_create_scratch_host_vcpu (cpus_to_try, fdarray, &init)) {return false; }
Assuming I'm right about the call order, then I think I'd like that more.
Quoted 36 lines
target/arm/kvm.c +0
-0if (init->target ==-1 ) {struct kvm_vcpu_init preferred;target/arm/kvm64.c +10
-0@@ -725,6 +725,12 @@ bool kvm_arm_sve_supported(void)return kvm_check_extension (kvm_state,KVM_CAP_ARM_SVE ); } +bool kvm_arm_pauth_supported (void ) +{ +return (kvm_check_extension (kvm_state,KVM_CAP_ARM_PTRAUTH_ADDRESS ) && +kvm_check_extension (kvm_state,KVM_CAP_ARM_PTRAUTH_GENERIC )); +} +bool kvm_arm_steal_time_supported (void ) {return kvm_check_extension (kvm_state,KVM_CAP_STEAL_TIME );@@ -865,6 +871,10 @@ int kvm_arch_init_vcpu(CPUState *cs)assert (kvm_arm_sve_supported ()); cpu->kvm_init_features[0 ] |=1 <<KVM_ARM_VCPU_SVE ; } +if (cpu_isar_feature (aa64_pauth, cpu)) { + cpu->kvm_init_features[0 ] |= (1 <<KVM_ARM_VCPU_PTRAUTH_ADDRESS | +1 <<KVM_ARM_VCPU_PTRAUTH_GENERIC ); + }/* Do KVM_ARM_VCPU_INIT ioctl */ ret =kvm_arm_vcpu_init (cs);target/arm/kvm_arm.h +0
-0
target/arm/kvm_arm.h bool kvm_arm_pmu_supported(void); · line 315
Quoted 10 lines
target/arm/kvm_arm.h +7
-0@@ -306,6 +306,13 @@ bool kvm_arm_pmu_supported(void);*/ bool kvm_arm_sve_supported (void ); +/** +* kvm_arm_pauth_supported: +* +* Returns true if KVM can enable Pointer Authentication and false otherwise. +*/ +bool kvm_arm_pauth_supported (void ); +
If we merge more of the pauth property handling with the TCG code, then we'll also need a stub in the !CONFIG_KVM section for compiling without kvm support.
Quoted 6 lines
target/arm/kvm_arm.h +0
-0/** * kvm_arm_get_max_vm_ipa_size: * @ms: Machine state handle Signature · 1 line
2.30.2
Thanks,
drew
Marc Zyngier
maintainerHi Andrew,
Quoted 37 lines · Andrew Jones
Hi Marc,
Quoted 33 lines · Marc Zyngier
Add basic support for Pointer Authentication when running a KVM guest and that the host supports it, loosely based on the SVE support.
Although the feature is enabled by default when the host advertises it, it is possible to disable it by setting the 'pauth=off' CPU property.
Tested on an Apple M1 running 5.16-rc6.
Cc Eric Auger <[email protected]>Cc Andrew Jones <[email protected]>Cc Richard Henderson <[email protected]>Cc Peter Maydell <[email protected]>Signed-off-by Marc Zyngier <[email protected]>--- docs/system/arm/cpu-features.rst | 5 +++++ target/arm/cpu.c | 1 + target/arm/cpu.h | 1 + target/arm/cpu64.c | 36 ++++++++++++++++++++++++++++++++ target/arm/kvm.c | 13 ++++++++++++ target/arm/kvm64.c | 10 +++++++++ target/arm/kvm_arm.h | 7 +++++++ 7 files changed, 73 insertions(+)docs/system/arm/cpu-features.rst +0
-0@@ -211,6 +211,11 @@ the list of KVM VCPU features and their descriptions. influence the guest scheduler behavior and/or be exposed to the guest userspace.
Quoted 11 lines
docs/system/arm/cpu-features.rst the list of KVM VCPU features and their descriptions. · line 218
Quoted 5 lines
docs/system/arm/cpu-features.rst +5
-0+ pauth Enable or disable ``FEAT_Pauth``, pointer + authentication. By default, the feature is enabled + with ``-cpu host`` if supported by both the host + kernel and the hardware. +Thanks for considering a documentation update. In this case, though, I think we should delete the "TCG VCPU Features" pauth paragraph, rather than add a new "KVM VCPU Features" pauth paragraph. We don't need to document each CPU feature. We just document complex ones, like sve*, KVM specific ones (kvm-*), and TCG specific ones (now only pauth-impdef).
Sure, works for me. Do we need to keep a trace of the available options? I'm not sure how a user is supposed to find out about those (I always end-up grepping through the code base, and something tells me I'm doing it wrong...). The QMP stuff flies way over my head.
Quoted 69 lines
Quoted 69 lines
docs/system/arm/cpu-features.rst +0
-0TCG VCPU Features =================target/arm/cpu.c +1
-0@@ -2091,6 +2091,7 @@ static void arm_host_initfn(Object *obj)kvm_arm_set_cpu_features_from_host (cpu);if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {aarch64_add_sve_properties (obj); +aarch64_add_pauth_properties (obj); }#else hvf_arm_set_cpu_features_from_host (cpu);target/arm/cpu.h +1
-0@@ -1076,6 +1076,7 @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);void aarch64_sve_change_el (CPUARMState *env,int old_el,int new_el,bool el0_a64);void aarch64_add_sve_properties (Object *obj); +void aarch64_add_pauth_properties (Object *obj);/* * SVE registers are encoded in KVM's memory in an endianness-invariant format. target/arm/cpu64.c +34
-0@@ -625,6 +625,42 @@ void aarch64_add_sve_properties(Object *obj)#endif } +static bool cpu_arm_get_pauth (Object *obj,Error **errp) +{ +ARMCPU *cpu =ARM_CPU (obj); +return cpu_isar_feature (aa64_pauth, cpu); +} + +static void cpu_arm_set_pauth (Object *obj,bool value,Error **errp) +{ +ARMCPU *cpu =ARM_CPU (obj); +uint64_t t; + +if (value) { +if (!kvm_arm_pauth_supported ()) { +error_setg (errp,"'pauth' feature not supported by KVM on this host" ); + } + +return ; + } + +/* +* If the host supports PAuth, we only end-up here if the user has +* disabled the support, and value is false. +*/ + t = cpu->isar.id_aa64isar1; + t =FIELD_DP64 (t,ID_AA64ISAR1 ,APA , value); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPA , value); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,API , value); + t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPI , value); + cpu->isar.id_aa64isar1 = t; +} + +void aarch64_add_pauth_properties (Object *obj) +{ +object_property_add_bool (obj,"pauth" , cpu_arm_get_pauth, cpu_arm_set_pauth);
Quoted 8 lines
target/arm/cpu64.c void aarch64_add_sve_properties(Object *obj) · line 662
Quoted 1 line
target/arm/cpu64.c +1
-0+}I think we should try to merge as much as possible between the TCG and KVM pauth property handling. I think we just need to move the
qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property)call into KVM/TCG common code and then modifyarm_cpu_pauth_finalize()to handle checking KVM for support when KVM is enabled and also to not look at the impdef property.
Happy to merge things more, though using qdev_property_add_static() feels a bit odd here (I have to forcefully replicate the probed state into the cpu->prop_pauth property in order to have a sensible default on KVM).
Anyway, I'll post something with this hack, and we add another coat of paint to the bike shed! ;-)
Quoted 60 lines
Quoted 23 lines
target/arm/cpu64.c +1
-0+void arm_cpu_pauth_finalize (ARMCPU *cpu,Error **errp) {int arch_val =0 , impdef_val =0 ;target/arm/kvm.c +3
-0@@ -84,6 +84,7 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,if (vmfd <0 ) { goto err; } + cpufd =ioctl (vmfd,KVM_CREATE_VCPU ,0 );if (cpufd <0 ) { goto err;@@ -94,6 +95,18 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, goto finish; } +/* +* Ask for Pointer Authentication if supported. We can't play the target/arm/kvm.c bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, · line 109
Quoted 10 lines
target/arm/kvm.c +10
-0+* SVE trick of synthetising the ID reg as KVM won't tell us +* whether we have the architected or IMPDEF version of PAuth, so +* we have to use the actual ID regs. +*/ +if (ioctl (vmfd,KVM_CHECK_EXTENSION ,KVM_CAP_ARM_PTRAUTH_ADDRESS ) >0 && +ioctl (vmfd,KVM_CHECK_EXTENSION ,KVM_CAP_ARM_PTRAUTH_GENERIC ) >0 ) { + init->features[0 ] |= (1 <<KVM_ARM_VCPU_PTRAUTH_ADDRESS | +1 <<KVM_ARM_VCPU_PTRAUTH_GENERIC ); + } +I think
kvm_init()is called prior tokvm_arm_get_host_cpu_features(), which means we can do this insteadtarget/arm/kvm64.c +11
-0@@ -521,6 +521,17 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)*/ struct kvm_vcpu_init init = { .target =-1 , }; +/* +* Ask for Pointer Authentication if supported. We can't play the +* SVE trick of synthetising the ID reg as KVM won't tell us +* whether we have the architected or IMPDEF version of PAuth, so +* we have to use the actual ID regs. +*/ +if (kvm_arm_pauth_supported ()) { + init->features[0 ] |= (1 <<KVM_ARM_VCPU_PTRAUTH_ADDRESS | +1 <<KVM_ARM_VCPU_PTRAUTH_GENERIC ); + } +if (!kvm_arm_create_scratch_host_vcpu (cpus_to_try, fdarray, &init)) {return false; }
Quoted 1 line
Assuming I'm right about the call order, then I think I'd like that more.
Yup, works nicely, and allows for some further cleanups.
Quoted 41 lines
Quoted 41 lines
target/arm/kvm.c +0
-0if (init->target ==-1 ) {struct kvm_vcpu_init preferred;target/arm/kvm64.c +10
-0@@ -725,6 +725,12 @@ bool kvm_arm_sve_supported(void)return kvm_check_extension (kvm_state,KVM_CAP_ARM_SVE ); } +bool kvm_arm_pauth_supported (void ) +{ +return (kvm_check_extension (kvm_state,KVM_CAP_ARM_PTRAUTH_ADDRESS ) && +kvm_check_extension (kvm_state,KVM_CAP_ARM_PTRAUTH_GENERIC )); +} +bool kvm_arm_steal_time_supported (void ) {return kvm_check_extension (kvm_state,KVM_CAP_STEAL_TIME );@@ -865,6 +871,10 @@ int kvm_arch_init_vcpu(CPUState *cs)assert (kvm_arm_sve_supported ()); cpu->kvm_init_features[0 ] |=1 <<KVM_ARM_VCPU_SVE ; } +if (cpu_isar_feature (aa64_pauth, cpu)) { + cpu->kvm_init_features[0 ] |= (1 <<KVM_ARM_VCPU_PTRAUTH_ADDRESS | +1 <<KVM_ARM_VCPU_PTRAUTH_GENERIC ); + }/* Do KVM_ARM_VCPU_INIT ioctl */ ret =kvm_arm_vcpu_init (cs);target/arm/kvm_arm.h +0
-0@@ -306,6 +306,13 @@ bool kvm_arm_pmu_supported(void);*/ bool kvm_arm_sve_supported (void );
Quoted 11 lines
target/arm/kvm_arm.h bool kvm_arm_pmu_supported(void); · line 315
Quoted 7 lines
target/arm/kvm_arm.h +7
-0+/** +* kvm_arm_pauth_supported: +* +* Returns true if KVM can enable Pointer Authentication and false otherwise. +*/ +bool kvm_arm_pauth_supported (void ); +If we merge more of the pauth property handling with the TCG code, then we'll also need a stub in the !CONFIG_KVM section for compiling without kvm support.
Actually, this can go altogether, as it can now be made static in kvm64.c and not be visible outside of the KVM code at all.
Thanks a lot for the review and the guidance!
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Quoted 10 lines · Marc Zyngier
Quoted 6 lines · Andrew Jones
Thanks for considering a documentation update. In this case, though, I think we should delete the "TCG VCPU Features" pauth paragraph, rather than add a new "KVM VCPU Features" pauth paragraph. We don't need to document each CPU feature. We just document complex ones, like sve*, KVM specific ones (kvm-*), and TCG specific ones (now only pauth-impdef).
Sure, works for me. Do we need to keep a trace of the available options?
For arm we need to extend target/arm/helper.c:arm_cpu_list() to output the possible flags like x86 does. On x86 doing this
qemu-system-x86_64 -cpu help
not only gives us a list of cpu types, but also a list of flags we can provide to the cpus (although not all flags will work on all cpus...) On arm doing this
qemu-system-aarch64 -cpu help
only gives us a list of cpu types.
Quoted 4 lines
I'm not sure how a user is supposed to find out about those (I always end-up grepping through the code base, and something tells me I'm doing it wrong...). The QMP stuff flies way over my head.
Indeed, currently grepping is less awkward than probing with QMP. With an extension to target/arm/helper.c:arm_cpu_list() we can avoid grepping too. I've just added this to my TODO [again]. It was there once already, but fell off the bottom...
Thanks,
drew