Re: [PATCH 15/34] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory

2023-11-12 Thread Xiaoyao Li
On 11/11/2023 2:22 AM, Sean Christopherson wrote: On Fri, Nov 10, 2023, Xiaoyao Li wrote: On 11/6/2023 12:30 AM, Paolo Bonzini wrote: diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 68a144cb7dbc..a6de526c0426 100644 --- a/include/linux/kvm_host.h +++ b/include/linux

Re: [PATCH 16/34] KVM: x86: "Reset" vcpu->run->exit_reason early in KVM_RUN

2023-11-10 Thread Xiaoyao Li
d-by: Paolo Bonzini Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba Message-Id: <20231027182217.3615211-19-sea...@google.com> Signed-off-by: Paolo Bonzini Reviewed-by: Xiaoyao Li --- arch/x86/kvm/x86.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c inde

Re: [PATCH 15/34] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory

2023-11-09 Thread Xiaoyao Li
On 11/6/2023 12:30 AM, Paolo Bonzini wrote: From: Sean Christopherson Introduce an ioctl(), KVM_CREATE_GUEST_MEMFD, to allow creating file-based memory that is tied to a specific KVM virtual machine and whose primary purpose is to serve guest memory. A guest-first memory subsystem allows for o

Re: [PATCH 09/34] KVM: Add KVM_EXIT_MEMORY_FAULT exit to report faults to userspace

2023-11-08 Thread Xiaoyao Li
Signed-off-by: Yu Zhang Signed-off-by: Chao Peng Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson Reviewed-by: Paolo Bonzini Message-Id: <20231027182217.3615211-10-sea...@google.com> Signed-off-by: Paolo Bonzini Reviewed-by: Xiaoyao Li --- Documentation/vir

Re: [PATCH v13 09/35] KVM: Add KVM_EXIT_MEMORY_FAULT exit to report faults to userspace

2023-11-01 Thread Xiaoyao Li
On 11/2/2023 1:36 AM, Sean Christopherson wrote: KVM_CAP_MEMORY_FAULT_INFO is x86 only, is it better to put this function to ? I'd prefer to keep it in generic code, as it's highly likely to end up there sooner than later. There's a known use case for ARM (exit to userspace on missing userspac

Re: [PATCH v13 17/35] KVM: Add transparent hugepage support for dedicated guest memory

2023-11-01 Thread Xiaoyao Li
On 10/31/2023 10:16 PM, Sean Christopherson wrote: On Tue, Oct 31, 2023, Xiaoyao Li wrote: On 10/28/2023 2:21 AM, Sean Christopherson wrote: Extended guest_memfd to allow backing guest memory with transparent hugepages. Require userspace to opt-in via a flag even though there's no

Re: [PATCH v13 17/35] KVM: Add transparent hugepage support for dedicated guest memory

2023-10-31 Thread Xiaoyao Li
On 10/28/2023 2:21 AM, Sean Christopherson wrote: Extended guest_memfd to allow backing guest memory with transparent hugepages. Require userspace to opt-in via a flag even though there's no known/anticipated use case for forcing small pages as THP is optional, i.e. to avoid ending up in a situ

Re: [PATCH v13 16/35] KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory

2023-10-30 Thread Xiaoyao Li
On 10/28/2023 2:21 AM, Sean Christopherson wrote: ... +KVM_SET_USER_MEMORY_REGION2 is an extension to KVM_SET_USER_MEMORY_REGION that +allows mapping guest_memfd memory into a guest. All fields shared with +KVM_SET_USER_MEMORY_REGION identically. Userspace can set KVM_MEM_PRIVATE in +flags to h

Re: [PATCH v13 08/35] KVM: Introduce KVM_SET_USER_MEMORY_REGION2

2023-10-30 Thread Xiaoyao Li
a new ioctl() makes detection of bad flags a bit more robust, e.g. if the new fd field is guarded only by a flag and not a new ioctl(), then a userspace bug (setting a "bad" flag) would generate out-of-bounds access instead of an -EINVAL error. Cc: Jarkko Sakkinen Reviewed-by: Paolo Bo

Re: [RFC PATCH v12 07/33] KVM: Add KVM_EXIT_MEMORY_FAULT exit to report faults to userspace

2023-09-21 Thread Xiaoyao Li
On 9/14/2023 9:55 AM, Sean Christopherson wrote: From: Chao Peng Add a new KVM exit type to allow userspace to handle memory faults that KVM cannot resolve, but that userspace *may* be able to handle (without terminating the guest). KVM will initially use KVM_EXIT_MEMORY_FAULT to report implic

Re: [RFC PATCH v12 06/33] KVM: Introduce KVM_SET_USER_MEMORY_REGION2

2023-09-15 Thread Xiaoyao Li
a new ioctl() makes detection of bad flags a bit more robust, e.g. if the new fd field is guarded only by a flag and not a new ioctl(), then a userspace bug (setting a "bad" flag) would generate out-of-bounds access instead of an -EINVAL error. Cc: Jarkko Sakkinen > Reviewed-by: Paolo

Re: [RFC PATCH v12 01/33] KVM: Tweak kvm_hva_range and hva_handler_t to allow reusing for gfn ranges

2023-09-14 Thread Xiaoyao Li
struct kvm, mmu_notifier); } -typedef bool (*hva_handler_t)(struct kvm *kvm, struct kvm_gfn_range *range); +typedef bool (*gfn_handler_t)(struct kvm *kvm, struct kvm_gfn_range *range); Is it worth mentioning the rename of it as well in changelog? Anyway, Reviewed-by: Xiaoyao Li

Re: [RFC PATCH v11 08/29] KVM: Introduce per-page memory attributes

2023-07-21 Thread Xiaoyao Li
On 7/19/2023 7:44 AM, Sean Christopherson wrote: +4.140 KVM_SET_MEMORY_ATTRIBUTES +- + +:Capability: KVM_CAP_MEMORY_ATTRIBUTES +:Architectures: x86 +:Type: vm ioctl +:Parameters: struct kvm_memory_attributes(in/out) +:Returns: 0 on success, <0 on error + +S

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

2023-07-21 Thread Xiaoyao Li
On 7/21/2023 11:05 PM, Xiaoyao Li wrote: On 7/19/2023 7:44 AM, Sean Christopherson wrote: @@ -6255,12 +6298,17 @@ int kvm_init(unsigned vcpu_size, unsigned vcpu_align, struct module *module)   if (r)   goto err_async_pf; +    r = kvm_gmem_init(); +    if (r) +    goto err_gmem

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

2023-07-21 Thread Xiaoyao Li
On 7/19/2023 7:44 AM, Sean Christopherson wrote: @@ -6255,12 +6298,17 @@ int kvm_init(unsigned vcpu_size, unsigned vcpu_align, struct module *module) if (r) goto err_async_pf; + r = kvm_gmem_init(); + if (r) + goto err_gmem; + kvm_chardev_o

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

2023-07-20 Thread Xiaoyao Li
On 7/19/2023 7:44 AM, Sean Christopherson wrote: @@ -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_gu

Re: [PATCH] KVM: X86: Fix compile error in svm/sev.c

2020-04-19 Thread Xiaoyao Li
On 4/19/2020 3:30 PM, Tianjia Zhang wrote: The compiler reported the following compilation errors: arch/x86/kvm/svm/sev.c: In function ‘sev_pin_memory’: arch/x86/kvm/svm/sev.c:361:3: error: implicit declaration of function ‘release_pages’ [-Werror=implicit-function-declaration] release_pages