Skip to content

Commit aff7cce

Browse files
author
Marc Zyngier
committed
KVM: arm64: Allow PtrAuth to be enabled from userspace on non-VHE systems
Now that the scene is set for enabling PtrAuth on non-VHE, drop the restrictions preventing userspace from enabling it. Acked-by: Andrew Scull <[email protected]> Acked-by: Mark Rutland <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent dfb0589 commit aff7cce

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

arch/arm64/kvm/reset.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ static u32 kvm_ipa_limit;
4242
#define VCPU_RESET_PSTATE_SVC (PSR_AA32_MODE_SVC | PSR_AA32_A_BIT | \
4343
PSR_AA32_I_BIT | PSR_AA32_F_BIT)
4444

45+
static bool system_has_full_ptr_auth(void)
46+
{
47+
return system_supports_address_auth() && system_supports_generic_auth();
48+
}
49+
4550
/**
4651
* kvm_arch_vm_ioctl_check_extension
4752
*
@@ -80,8 +85,7 @@ int kvm_arch_vm_ioctl_check_extension(struct kvm *kvm, long ext)
8085
break;
8186
case KVM_CAP_ARM_PTRAUTH_ADDRESS:
8287
case KVM_CAP_ARM_PTRAUTH_GENERIC:
83-
r = has_vhe() && system_supports_address_auth() &&
84-
system_supports_generic_auth();
88+
r = system_has_full_ptr_auth();
8589
break;
8690
default:
8791
r = 0;
@@ -205,19 +209,14 @@ static void kvm_vcpu_reset_sve(struct kvm_vcpu *vcpu)
205209

206210
static int kvm_vcpu_enable_ptrauth(struct kvm_vcpu *vcpu)
207211
{
208-
/* Support ptrauth only if the system supports these capabilities. */
209-
if (!has_vhe())
210-
return -EINVAL;
211-
212-
if (!system_supports_address_auth() ||
213-
!system_supports_generic_auth())
214-
return -EINVAL;
215212
/*
216213
* For now make sure that both address/generic pointer authentication
217-
* features are requested by the userspace together.
214+
* features are requested by the userspace together and the system
215+
* supports these capabilities.
218216
*/
219217
if (!test_bit(KVM_ARM_VCPU_PTRAUTH_ADDRESS, vcpu->arch.features) ||
220-
!test_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, vcpu->arch.features))
218+
!test_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, vcpu->arch.features) ||
219+
!system_has_full_ptr_auth())
221220
return -EINVAL;
222221

223222
vcpu->arch.flags |= KVM_ARM64_GUEST_HAS_PTRAUTH;

0 commit comments

Comments
 (0)