From: Oliver Upton <oliver.upton@linux.dev>
To: Anish Moorthy <amoorthy@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Marc Zyngier <maz@kernel.org>,
Sean Christopherson <seanjc@google.com>,
James Houghton <jthoughton@google.com>,
Ben Gardon <bgardon@google.com>,
David Matlack <dmatlack@google.com>,
Ricardo Koller <ricarkol@google.com>,
Chao Peng <chao.p.peng@linux.intel.com>,
Axel Rasmussen <axelrasmussen@google.com>,
kvm@vger.kernel.org, kvmarm@lists.linux.dev
Subject: Re: [PATCH 5/8] kvm: Add cap/kvm_run field for memory fault exits
Date: Wed, 15 Feb 2023 08:59:19 +0000 [thread overview]
Message-ID: <Y+ye5yV2/ifCkxYJ@linux.dev> (raw)
In-Reply-To: <20230215011614.725983-6-amoorthy@google.com>
On Wed, Feb 15, 2023 at 01:16:11AM +0000, Anish Moorthy wrote:
> This new KVM exit allows userspace to handle missing memory. It
> indicates that the pages in the range [gpa, gpa + size) must be mapped.
>
> The "flags" field actually goes unused in this series: it's included for
> forward compatibility with [1], should this series happen to go in
> first.
>
> [1] https://lore.kernel.org/all/CA+EHjTyzZ2n8kQxH_Qx72aRq1k+dETJXTsoOM3tggPZAZkYbCA@mail.gmail.com/
>
> Signed-off-by: Anish Moorthy <amoorthy@google.com>
> Acked-by: James Houghton <jthoughton@google.com>
> ---
> Documentation/virt/kvm/api.rst | 42 ++++++++++++++++++++++++++++++++++
> include/linux/kvm_host.h | 13 +++++++++++
> include/uapi/linux/kvm.h | 13 ++++++++++-
> tools/include/uapi/linux/kvm.h | 7 ++++++
> virt/kvm/kvm_main.c | 26 +++++++++++++++++++++
> 5 files changed, 100 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
> index 9807b05a1b571..4b06e60668686 100644
> --- a/Documentation/virt/kvm/api.rst
> +++ b/Documentation/virt/kvm/api.rst
> @@ -5937,6 +5937,18 @@ delivery must be provided via the "reg_aen" struct.
> The "pad" and "reserved" fields may be used for future extensions and should be
> set to 0s by userspace.
>
> +4.137 KVM_SET_MEM_FAULT_NOWAIT
> +------------------------------
> +
> +:Capability: KVM_CAP_MEM_FAULT_NOWAIT
> +:Architectures: x86, arm64
> +:Type: vm ioctl
> +:Parameters: bool state (in)
> +:Returns: 0 on success, or -1 if KVM_CAP_MEM_FAULT_NOWAIT is not present.
> +
> +Enables (state=true) or disables (state=false) waitless memory faults. For more
> +information, see the documentation of KVM_CAP_MEM_FAULT_NOWAIT.
Why not use KVM_ENABLE_CAP instead for this? Its a preexisting UAPI for
toggling KVM behaviors.
> 5. The kvm_run structure
> ========================
>
> @@ -6544,6 +6556,21 @@ array field represents return values. The userspace should update the return
> values of SBI call before resuming the VCPU. For more details on RISC-V SBI
> spec refer, https://github.com/riscv/riscv-sbi-doc.
>
> +::
> +
> + /* KVM_EXIT_MEMORY_FAULT */
> + struct {
> + __u64 gpa;
> + __u64 size;
> + } memory_fault;
> +
> +If exit reason is KVM_EXIT_MEMORY_FAULT then it indicates that the VCPU has
> +encountered a memory error which is not handled by KVM kernel module and
> +which userspace may choose to handle.
> +
> +'gpa' and 'size' indicate the memory range the error occurs at. Userspace
> +may handle the error and return to KVM to retry the previous memory access.
How is userspace expected to differentiate the gup_fast() failed exit
from the guest-private memory exit? I don't think flags are a good idea
for this, as it comes with the illusion that both events can happen on a
single exit. In reality, these are mutually exclusive.
A fault type/code would be better here, with the option to add flags at
a later date that could be used to further describe the exit (if
needed).
--
Thanks,
Oliver
next prev parent reply other threads:[~2023-02-15 8:59 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 1:16 [PATCH 0/8] Add memory fault exits to avoid slow GUP Anish Moorthy
2023-02-15 1:16 ` [PATCH 1/8] selftests/kvm: Fix bug in how demand_paging_test calculates paging rate Anish Moorthy
2023-02-15 7:27 ` Oliver Upton
2023-02-15 16:44 ` Sean Christopherson
2023-02-15 18:05 ` Anish Moorthy
2023-02-15 1:16 ` [PATCH 2/8] selftests/kvm: Allow many vcpus per UFFD in demand paging test Anish Moorthy
2023-02-15 1:16 ` [PATCH 3/8] selftests/kvm: Switch demand paging uffd readers to epoll Anish Moorthy
2023-02-15 1:16 ` [PATCH 4/8] kvm: Allow hva_pfn_fast to resolve read-only faults Anish Moorthy
2023-02-15 9:01 ` Oliver Upton
2023-02-15 17:03 ` Sean Christopherson
2023-02-15 18:19 ` Anish Moorthy
2023-02-15 1:16 ` [PATCH 5/8] kvm: Add cap/kvm_run field for memory fault exits Anish Moorthy
2023-02-15 8:41 ` Marc Zyngier
2023-02-15 17:07 ` Sean Christopherson
2023-02-16 18:53 ` Anish Moorthy
2023-02-16 21:38 ` Sean Christopherson
2023-02-17 19:14 ` Anish Moorthy
2023-02-17 20:33 ` Sean Christopherson
2023-02-23 1:16 ` Anish Moorthy
2023-02-23 20:55 ` Sean Christopherson
2023-02-23 23:03 ` Anish Moorthy
2023-02-24 0:01 ` Sean Christopherson
2023-02-17 20:47 ` Sean Christopherson
2023-02-15 8:59 ` Oliver Upton [this message]
2023-02-15 1:16 ` [PATCH 6/8] kvm/x86: Add mem fault exit on EPT violations Anish Moorthy
2023-02-15 17:23 ` Sean Christopherson
2023-02-16 22:55 ` Peter Xu
2023-02-23 0:35 ` Anish Moorthy
2023-02-23 20:11 ` Sean Christopherson
2023-02-15 1:16 ` [PATCH 7/8] kvm/arm64: Implement KVM_CAP_MEM_FAULT_NOWAIT for arm64 Anish Moorthy
2023-02-15 18:24 ` Oliver Upton
2023-02-15 23:28 ` Anish Moorthy
2023-02-15 23:37 ` Oliver Upton
2023-02-15 1:16 ` [PATCH 8/8] selftests/kvm: Handle mem fault exits in demand paging test Anish Moorthy
2023-02-15 1:46 ` [PATCH 0/8] Add memory fault exits to avoid slow GUP James Houghton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y+ye5yV2/ifCkxYJ@linux.dev \
--to=oliver.upton@linux.dev \
--cc=amoorthy@google.com \
--cc=axelrasmussen@google.com \
--cc=bgardon@google.com \
--cc=chao.p.peng@linux.intel.com \
--cc=dmatlack@google.com \
--cc=jthoughton@google.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=pbonzini@redhat.com \
--cc=ricarkol@google.com \
--cc=seanjc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).