[PATCH v2 01/20] KVM: arm64: Only allow ptrauth for a pVM on a system with full ptrauth

Vincent Donnefort vdonnefort at google.com
Thu Dec 3 03:47:26 PST 2026


On Wed, Nov 25, 2026 at 03:38:52PM +0000, Fuad Tabba wrote:
> EL2 allows a protected VM both ptrauth features whatever the system
> supports. An id_aa64isar1 override can leave a system with generic but
> not address auth. EL2 then doesn't trap the guest's key accesses, but
> it doesn't switch the keys either, since the switch is gated on
> ARM64_HAS_ADDRESS_AUTH. The host can read and write the guest's
> APGAKey.
> 
> Only allow the ptrauth features when the system has full ptrauth, as
> the host does.
> 
> Fixes: b56680de9c648 ("KVM: arm64: Initialize trap register values in hyp in pKVM")
> Signed-off-by: Fuad Tabba <fuad.tabba at linux.dev>
> ---
>  arch/arm64/include/asm/kvm_pkvm.h | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/kvm_pkvm.h b/arch/arm64/include/asm/kvm_pkvm.h
> index fd042d2b54624..155ac35069245 100644
> --- a/arch/arm64/include/asm/kvm_pkvm.h
> +++ b/arch/arm64/include/asm/kvm_pkvm.h
> @@ -76,11 +76,14 @@ static inline void kvm_pkvm_vcpu_allowed_features(struct kvm *kvm,
>  	if (kvm_pkvm_ext_allowed(kvm, KVM_CAP_ARM_PMU_V3))
>  		set_bit(KVM_ARM_VCPU_PMU_V3, allowed);
>  
> -	if (kvm_pkvm_ext_allowed(kvm, KVM_CAP_ARM_PTRAUTH_ADDRESS))
> -		set_bit(KVM_ARM_VCPU_PTRAUTH_ADDRESS, allowed);
> +	/* Without address auth, EL2 doesn't switch the guest's keys. */
> +	if (system_has_full_ptr_auth()) {
> +		if (kvm_pkvm_ext_allowed(kvm, KVM_CAP_ARM_PTRAUTH_ADDRESS))
> +			set_bit(KVM_ARM_VCPU_PTRAUTH_ADDRESS, allowed);
>  
> -	if (kvm_pkvm_ext_allowed(kvm, KVM_CAP_ARM_PTRAUTH_GENERIC))
> -		set_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, allowed);
> +		if (kvm_pkvm_ext_allowed(kvm, KVM_CAP_ARM_PTRAUTH_GENERIC))
> +			set_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, allowed);
> +	}
>  
>  	if (kvm_pkvm_ext_allowed(kvm, KVM_CAP_ARM_SVE))
>  		set_bit(KVM_ARM_VCPU_SVE, allowed);
> -- 
> 2.47.3
> 

If we mandate both GENERIC and ADDRESS on the host, do we need to also update
vm_has_ptrauth() to

  system_has_full_ptr_auth() && (kvm_vcpu_has_feature(kvm, KVM_ARM_VCPU_PTRAUTH_ADDRESS) ||
                                 kvm_vcpu_has_feature(kvm, KVM_ARM_VCPU_PTRAUTH_GENERIC)

and pvmid_aa64isar1 to

  MAX_FEAT_FUNC(GPA, IMP, vm_has_ptrauth),
  MAX_FEAT_FUNC(GPI, IMP, vm_has_ptrauth),
                                 

-- 
Vincent



More information about the linux-arm-kernel mailing list