Thread (108 messages) 108 messages, 20 authors, 2023-09-06

Re: [RFC PATCH v11 12/29] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory

From: Sean Christopherson <seanjc@google.com>
Date: 2023-07-20 15:15:39
Also in: kvm, kvm-riscv, kvmarm, linux-arm-kernel, linux-fsdevel, linux-mips, linux-mm, linux-riscv, linux-security-module, lkml

On Thu, Jul 20, 2023, Xiaoyao Li wrote:
On 7/19/2023 7:44 AM, Sean Christopherson wrote:
quoted
@@ -5134,6 +5167,16 @@ static long kvm_vm_ioctl(struct file *filp,
  	case KVM_GET_STATS_FD:
  		r = kvm_vm_ioctl_get_stats_fd(kvm);
  		break;
+	case KVM_CREATE_GUEST_MEMFD: {
+		struct kvm_create_guest_memfd guest_memfd;
+
+		r = -EFAULT;
+		if (copy_from_user(&guest_memfd, argp, sizeof(guest_memfd)))
+			goto out;
+
+		r = kvm_gmem_create(kvm, &guest_memfd);
+		break;
+	}
Does it need a new CAP to indicate the support of guest_memfd?
Yeah, I meant to add that to the TODO list and forgot (obviously).
This is patch series introduces 3 new CAPs and it seems any one of them can
serve as the indicator of guest_memfd.

+#define KVM_CAP_USER_MEMORY2 230
+#define KVM_CAP_MEMORY_ATTRIBUTES 231
+#define KVM_CAP_VM_TYPES 232
The number of new caps being added is the main why I didn't just add another one.
On the other hand, we have room for a few billion caps, so one more isn't a big
deal.  So yeah, KVM_CAP_GUEST_MEMFD is probably the way to go.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help