qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] hw/arm/virt: KVM: Enable PAuth when supported by the host


From: Richard Henderson
Subject: Re: [PATCH v2] hw/arm/virt: KVM: Enable PAuth when supported by the host
Date: Thu, 6 Jan 2022 10:26:29 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0

On 1/6/22 9:29 AM, Marc Zyngier wrote:
On Thu, 06 Jan 2022 17:20:33 +0000,
Richard Henderson <richard.henderson@linaro.org> wrote:

On 1/6/22 1:16 AM, Marc Zyngier wrote:
+static 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));
+}

Do we really need to have them both set to play the game?  Given that
the only thing that happens is that we disable whatever host support
exists, can we have "pauth enabled" mean whatever subset the host has?

The host will always expose either both features or none, and that's
part of the ABI. From the bit of kernel documentation located in
Documentation/virt/kvm/api.rst:

<quote>
4.82 KVM_ARM_VCPU_INIT
----------------------
[...]
          - KVM_ARM_VCPU_PTRAUTH_ADDRESS: Enables Address Pointer authentication
            for arm64 only.
            Depends on KVM_CAP_ARM_PTRAUTH_ADDRESS.
            If KVM_CAP_ARM_PTRAUTH_ADDRESS and KVM_CAP_ARM_PTRAUTH_GENERIC are
            both present, then both KVM_ARM_VCPU_PTRAUTH_ADDRESS and
            KVM_ARM_VCPU_PTRAUTH_GENERIC must be requested or neither must be
            requested.

          - KVM_ARM_VCPU_PTRAUTH_GENERIC: Enables Generic Pointer authentication
            for arm64 only.
            Depends on KVM_CAP_ARM_PTRAUTH_GENERIC.
            If KVM_CAP_ARM_PTRAUTH_ADDRESS and KVM_CAP_ARM_PTRAUTH_GENERIC are
            both present, then both KVM_ARM_VCPU_PTRAUTH_ADDRESS and
            KVM_ARM_VCPU_PTRAUTH_GENERIC must be requested or neither must be
            requested.
</quote>

KVM will reject the initialisation if only one of the features is
requested, so checking and enabling both makes sense to me.

Well, no, that's not what that says.  It says that *if* both host
flags are set, then both guest flags must be set or both unset.

Indeed. But KVM never returns just one flag. It only exposes both or
none.

Mm. It does beg the question of why KVM exposes multiple bits. If they must be tied, then it only serves to make the interface more complicated than necessary. We would be better served to have a single bit to control all of PAuth.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]