Message ID | 20250122152738.1173160-4-tabba@google.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | KVM: Mapping of guest_memfd at the host and a software protected VM type | expand |
On 22.01.25 16:27, Fuad Tabba wrote: > Add the KVM capability KVM_CAP_GUEST_MEMFD_MAPPABLE, which is > true if mapping guest memory is supported by the host. > > Signed-off-by: Fuad Tabba <tabba@google.com> > --- > include/uapi/linux/kvm.h | 1 + > virt/kvm/kvm_main.c | 4 ++++ > 2 files changed, 5 insertions(+) > > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h > index 502ea63b5d2e..021f8ef9979b 100644 > --- a/include/uapi/linux/kvm.h > +++ b/include/uapi/linux/kvm.h > @@ -933,6 +933,7 @@ struct kvm_enable_cap { > #define KVM_CAP_PRE_FAULT_MEMORY 236 > #define KVM_CAP_X86_APIC_BUS_CYCLES_NS 237 > #define KVM_CAP_X86_GUEST_MODE 238 > +#define KVM_CAP_GUEST_MEMFD_MAPPABLE 239 Maybe similarly consider calling this something like KVM_CAP_GUEST_MEMFD_SHARED_MEM No strong opinion on this one, though.
On Thu, 23 Jan 2025 at 11:42, David Hildenbrand <david@redhat.com> wrote: > > On 22.01.25 16:27, Fuad Tabba wrote: > > Add the KVM capability KVM_CAP_GUEST_MEMFD_MAPPABLE, which is > > true if mapping guest memory is supported by the host. > > > > Signed-off-by: Fuad Tabba <tabba@google.com> > > --- > > include/uapi/linux/kvm.h | 1 + > > virt/kvm/kvm_main.c | 4 ++++ > > 2 files changed, 5 insertions(+) > > > > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h > > index 502ea63b5d2e..021f8ef9979b 100644 > > --- a/include/uapi/linux/kvm.h > > +++ b/include/uapi/linux/kvm.h > > @@ -933,6 +933,7 @@ struct kvm_enable_cap { > > #define KVM_CAP_PRE_FAULT_MEMORY 236 > > #define KVM_CAP_X86_APIC_BUS_CYCLES_NS 237 > > #define KVM_CAP_X86_GUEST_MODE 238 > > +#define KVM_CAP_GUEST_MEMFD_MAPPABLE 239 > > Maybe similarly consider calling this something like > > KVM_CAP_GUEST_MEMFD_SHARED_MEM > > No strong opinion on this one, though. Ack. That would make the naming consistent. /fuad > -- > Cheers, > > David / dhildenb >
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 502ea63b5d2e..021f8ef9979b 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -933,6 +933,7 @@ struct kvm_enable_cap { #define KVM_CAP_PRE_FAULT_MEMORY 236 #define KVM_CAP_X86_APIC_BUS_CYCLES_NS 237 #define KVM_CAP_X86_GUEST_MODE 238 +#define KVM_CAP_GUEST_MEMFD_MAPPABLE 239 struct kvm_irq_routing_irqchip { __u32 irqchip; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index ad9802012a3f..9cd6690b7955 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -4872,6 +4872,10 @@ static int kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) #ifdef CONFIG_KVM_PRIVATE_MEM case KVM_CAP_GUEST_MEMFD: return !kvm || kvm_arch_has_private_mem(kvm); +#endif +#ifdef CONFIG_KVM_GMEM_MAPPABLE + case KVM_CAP_GUEST_MEMFD_MAPPABLE: + return !kvm || kvm_arch_private_mem_inplace(kvm); #endif default: break;
Add the KVM capability KVM_CAP_GUEST_MEMFD_MAPPABLE, which is true if mapping guest memory is supported by the host. Signed-off-by: Fuad Tabba <tabba@google.com> --- include/uapi/linux/kvm.h | 1 + virt/kvm/kvm_main.c | 4 ++++ 2 files changed, 5 insertions(+)