From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>,
virtio-fs@redhat.com, miklos@szeredi.hu, stefanha@redhat.com,
dgilbert@redhat.com, pbonzini@redhat.com, wanpengli@tencent.com,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] kvm: Add capability to be able to report async pf error to guest
Date: Wed, 17 Jun 2020 11:32:24 -0700 [thread overview]
Message-ID: <20200617183224.GK26818@linux.intel.com> (raw)
In-Reply-To: <87lfklhm58.fsf@vitty.brq.redhat.com>
On Wed, Jun 17, 2020 at 03:12:03PM +0200, Vitaly Kuznetsov wrote:
> Vivek Goyal <vgoyal@redhat.com> writes:
>
> > As of now asynchronous page fault mecahanism assumes host will always be
> > successful in resolving page fault. So there are only two states, that
> > is page is not present and page is ready.
> >
> > If a page is backed by a file and that file has been truncated (as
> > can be the case with virtio-fs), then page fault handler on host returns
> > -EFAULT.
> >
> > As of now async page fault logic does not look at error code (-EFAULT)
> > returned by get_user_pages_remote() and returns PAGE_READY to guest.
> > Guest tries to access page and page fault happnes again. And this
> > gets kvm into an infinite loop. (Killing host process gets kvm out of
> > this loop though).
Isn't this already fixed by patch 1/3 "kvm,x86: Force sync fault if previous
attempts failed"? If it isn't, it should be, i.e. we should fix KVM before
adding what are effectively optimizations on top. And, it's not clear that
the optimizations are necessary, e.g. I assume the virtio-fs truncation
scenario is relatively uncommon, i.e. not performance sensitive?
> >
> > This patch adds another state to async page fault logic which allows
> > host to return error to guest. Once guest knows that async page fault
> > can't be resolved, it can send SIGBUS to host process (if user space
I assume this is supposed to be "it can send SIGBUS to guest process"?
Otherwise none of this makes sense (to me).
> > was accessing the page in question).
Allowing the guest to opt-in to intercepting host page allocation failures
feels wrong, and fragile. KVM can't possibly know whether an allocation
failure is something that should be forwarded to the guest, as KVM doesn't
know the physical backing for any given hva/gfn, e.g. the error could be
due to a physical device failure or a configuration issue. Relying on the
async #PF mechanism to prevent allocation failures from crashing the guest
is fragile because there is no guarantee that a #PF can be async.
IMO, the virtio-fs truncation use case should first be addressed in a way
that requires explicit userspace intervention, e.g. by enhancing
kvm_handle_bad_page() to provide the necessary information to userspace so
that userspace can reflect select errors into the guest. The reflection
could piggyback whatever vector is used by async page faults (#PF or #VE),
but would not be an async page fault per se. If an async #PF happens to
encounter an allocation failure, it would naturally fall back to the
synchronous path (provided by patch 1/3) and the synchronous path would
automagically handle the error as above.
In other words, I think the guest should be able to enable "error handling"
support without first enabling async #PF. From a functional perspective it
probably won't change a whole lot, but it would hopefully force us to
concoct an overall "paravirt page fault" design as opposed to simply async
#PF v2.
next prev parent reply other threads:[~2020-06-17 18:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-16 21:48 [RFC PATCH 0/3] kvm,x86: Improve kvm page fault error handling Vivek Goyal
2020-06-16 21:48 ` [PATCH 1/3] kvm,x86: Force sync fault if previous attempts failed Vivek Goyal
2020-06-17 13:02 ` Vitaly Kuznetsov
2020-06-17 19:58 ` Vivek Goyal
2020-06-16 21:48 ` [PATCH 2/3] kvm: Add capability to be able to report async pf error to guest Vivek Goyal
2020-06-17 13:12 ` Vitaly Kuznetsov
2020-06-17 18:32 ` Sean Christopherson [this message]
2020-06-17 21:51 ` Vivek Goyal
2020-06-17 23:00 ` Sean Christopherson
2020-06-17 23:05 ` Sean Christopherson
2020-06-18 12:47 ` Vivek Goyal
2020-06-17 20:33 ` Vivek Goyal
2020-06-16 21:48 ` [PATCH 3/3] kvm, async_pf: Use FOLL_WRITE only for write faults Vivek Goyal
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=20200617183224.GK26818@linux.intel.com \
--to=sean.j.christopherson@intel.com \
--cc=dgilbert@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=pbonzini@redhat.com \
--cc=stefanha@redhat.com \
--cc=vgoyal@redhat.com \
--cc=virtio-fs@redhat.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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).