From: Vishal Annapurve Advertise KVM_CAP_GUEST_MEMFD_LINK via KVM_CHECK_EXTENSION so that userspace VMMs and selftests can discover support for linking guest_memfd instances across VMs via KVM_LINK_GUEST_MEMFD. Signed-off-by: Vishal Annapurve Co-developed-by: Tao Gong Signed-off-by: Tao Gong --- Documentation/virt/kvm/api.rst | 8 ++++++++ include/uapi/linux/kvm.h | 1 + virt/kvm/kvm_main.c | 2 ++ 3 files changed, 11 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index 7c527a1e7c487..bc54212e48c32 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -9738,6 +9738,14 @@ take care to differentiate between these cases. The presence of this capability indicates that the nested KVM guest can start in ESA mode. +8.48 KVM_CAP_GUEST_MEMFD_LINK +----------------------------- + +:Architectures: all + +The presence of this capability indicates that KVM supports linking an +existing guest_memfd file to another VM via KVM_LINK_GUEST_MEMFD. + 9. Known KVM API problems ========================= diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 53fe8dce57db2..09926fa85fe6c 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -1000,6 +1000,7 @@ struct kvm_enable_cap { #define KVM_CAP_PPC_COMPAT_CAPS 250 #define KVM_CAP_ARM_PMU_V3_STRICT 251 #define KVM_CAP_GUEST_MEMFD_MEMORY_ATTRIBUTES 252 +#define KVM_CAP_GUEST_MEMFD_LINK 253 struct kvm_irq_routing_irqchip { __u32 irqchip; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 70521371b64ab..135e7bb7609a8 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -5008,6 +5008,8 @@ static int kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) return 0; return KVM_MEMORY_ATTRIBUTE_PRIVATE; + case KVM_CAP_GUEST_MEMFD_LINK: + return 1; #endif default: break; -- 2.56.0.257.gf7497c7d27-goog