Message ID | 20250211121128.703390-5-tabba@google.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | KVM: Mapping guest_memfd backed memory at the host for software protected VMs | expand |
On 11.02.25 13:11, Fuad Tabba wrote: > Add the KVM capability KVM_CAP_GMEM_SHARED_MEM, which indicates > that the VM supports shared memory in guest_memfd, or that the > host can create VMs that support shared memory. Supporting shared > memory implies that memory can be mapped when shared with the > host. Was there a good reason to not squash this into the next patch?
On 20.02.25 12:37, David Hildenbrand wrote: > On 11.02.25 13:11, Fuad Tabba wrote: >> Add the KVM capability KVM_CAP_GMEM_SHARED_MEM, which indicates >> that the VM supports shared memory in guest_memfd, or that the >> host can create VMs that support shared memory. Supporting shared >> memory implies that memory can be mapped when shared with the >> host. > > Was there a good reason to not squash this into the next patch? Sorry, I was confused, I meant the previous commit, where we essentially add the mmap option in the first place.
On Thu, 20 Feb 2025 at 11:39, David Hildenbrand <david@redhat.com> wrote: > > On 20.02.25 12:37, David Hildenbrand wrote: > > On 11.02.25 13:11, Fuad Tabba wrote: > >> Add the KVM capability KVM_CAP_GMEM_SHARED_MEM, which indicates > >> that the VM supports shared memory in guest_memfd, or that the > >> host can create VMs that support shared memory. Supporting shared > >> memory implies that memory can be mapped when shared with the > >> host. > > > > Was there a good reason to not squash this into the next patch? > > Sorry, I was confused, I meant the previous commit, where we essentially > add the mmap option in the first place. Will do. Thanks, /fuad > -- > Cheers, > > David / dhildenb >
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 45e6d8fca9b9..117937a895da 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -929,6 +929,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_GMEM_SHARED_MEM 239 struct kvm_irq_routing_irqchip { __u32 irqchip; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index ba0327e2d0d3..38f0f402ea46 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -4830,6 +4830,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_SHARED_MEM + case KVM_CAP_GMEM_SHARED_MEM: + return !kvm || kvm_arch_gmem_supports_shared_mem(kvm); #endif default: break;
Add the KVM capability KVM_CAP_GMEM_SHARED_MEM, which indicates that the VM supports shared memory in guest_memfd, or that the host can create VMs that support shared memory. Supporting shared memory implies that memory can be mapped when shared with 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(+)