[PATCH v19 16/20] KVM: arm64: CCA: Don't expose unsupported capabilities for realm guests
Jonathan Cameron
jonathan.cameron at oss.qualcomm.com
Tue Sep 22 15:53:38 PDT 2026
On Sun, 20 Sep 2026 22:28:41 +0100
Suzuki K Poulose <suzuki.poulose at arm.com> wrote:
> Limit the capabilities that are allowed for Realm VMs. Similarly block
> the vm_ioctls backed by the capabilities.
>
> Repurpose the kvm_pkvm_ioctl_allowed() to support both pKVM and Realm
> ioctls. Rename the helper to kvm_vm_ioctl_allowed() and move it
> into arch/arm64/kvm/arm.c. Also add a generic kvm_vm_ext_allowed()
> to handle pKVM and Realm capability filtering and route them accordingly.
>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose at arm.com>
One trivial - otherwise seems fine to me.
> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> index 86e705330d7bd..eab8543a4194d 100644
> --- a/arch/arm64/kvm/arm.c
> +++ b/arch/arm64/kvm/arm.c
> +/*
> + * Check whether the KVM VM IOCTL is allowed. For pKVM and Realm VMs, certain
> + * ioctls are not allowed. Further, certain features are allowed only for
> + * non-protected VMs in pKVM.
> + */
> +static inline bool kvm_vm_ioctl_allowed(struct kvm *kvm, unsigned int ioctl)
> +{
> + long ext;
> + int r;
> +
> + /*
> + * We are guaranteed to be called with a valid kvm instance, as the
> + * only caller is kvm_arch_vm_ioctl(). Catch any deviations, as we
> + * rely on the kvm instance below.
> + */
> + if (WARN_ON_ONCE(!kvm))
> + return false;
> +
> + /* Cover both pKVM host and Realm VMs */
Comment is a little confusing. This is the path that covers everything
other than those two. Maybe 'Rest of function covers both...'
> + if (!kvm_vm_hyp_is_distrusting(kvm))
> + return true;
> +
> + r = kvm_get_cap_for_kvm_ioctl(ioctl, &ext);
> + if (WARN_ON_ONCE(r < 0))
> + return false;
> +
> + return kvm_vm_ext_allowed(kvm, ext);
> +}
More information about the linux-arm-kernel
mailing list