kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: virtio-fs@redhat.com, miklos@szeredi.hu, stefanha@redhat.com,
	dgilbert@redhat.com, vgoyal@redhat.com, aarcange@redhat.com,
	dhildenb@redhat.com
Subject: [RFC PATCH 0/4] kvm,x86,async_pf: Add capability to return page fault error
Date: Tue, 31 Mar 2020 15:40:07 -0400	[thread overview]
Message-ID: <20200331194011.24834-1-vgoyal@redhat.com> (raw)

Current page fault logic in kvm seems to assume that host will always
be able to successfully resolve page fault soon or later. There does not
seem to be any mechanism for hypervisor to return an error say -EFAULT
to guest.

We are writing DAX support for virtiofs filesystem. This will allow
directly mapping host page cache page into guest user space process.

This mechanism now needs additional support from kvm where a page
fault error needs to be propagated back into guest. For example, say
guest process mmaped a file (and this did an mmap of portion of file
on host into qemu address space). Now file gets truncated and guest
process tries to access mapped region. It will generate page fault
in host and it will try to map the file page. But page is not there
any more so it will get back -EFAULT. But there is no mechanism to
send this information back to guest and currently host sends PAGE_READY
to guest, guest retries and fault happens again and host tries to
resolve page fault again and this becomes an infinite loop.

This is an RFC patch series which tries to extend async page fault
mechanism to also be able to communicate back that an error occurred
while resolving the page fault. Then guest can send SIGBUS to guest
process accessing the truncated portion of file. Or if access happened
in guest kernel, then it can try to fixup the exception and jump
to error handling portion if there is one.  

This patch series tries to solve it only for x86 architecture on intel
vmx only. Also it does not solve the problem for nested virtualization.

Is extending async page fault mechanism to report error back to
guest is right thing to do? Or there needs to be another way.

Any feedback or comments are welcome. 

Thanks
Vivek

Vivek Goyal (4):
  kvm: Add capability to be able to report async pf error to guest
  kvm: async_pf: Send faulting gva address in case of error
  kvm: Always get async page notifications
  kvm,x86,async_pf: Search exception tables in case of error

 Documentation/virt/kvm/cpuid.rst     |  4 ++
 Documentation/virt/kvm/msr.rst       | 11 +++--
 arch/x86/include/asm/kvm_host.h      | 17 ++++++-
 arch/x86/include/asm/kvm_para.h      | 13 +++---
 arch/x86/include/asm/vmx.h           |  2 +
 arch/x86/include/uapi/asm/kvm_para.h | 12 ++++-
 arch/x86/kernel/kvm.c                | 69 ++++++++++++++++++++++------
 arch/x86/kvm/cpuid.c                 |  3 +-
 arch/x86/kvm/mmu/mmu.c               | 12 +++--
 arch/x86/kvm/vmx/nested.c            |  2 +-
 arch/x86/kvm/vmx/vmx.c               | 11 ++++-
 arch/x86/kvm/x86.c                   | 37 +++++++++++----
 include/linux/kvm_host.h             |  1 +
 virt/kvm/async_pf.c                  |  6 ++-
 14 files changed, 156 insertions(+), 44 deletions(-)

-- 
2.25.1


             reply	other threads:[~2020-03-31 20:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31 19:40 Vivek Goyal [this message]
2020-03-31 19:40 ` [PATCH 1/4] kvm: Add capability to be able to report async pf error to guest Vivek Goyal
2020-03-31 19:40 ` [PATCH 2/4] kvm: async_pf: Send faulting gva address in case of error Vivek Goyal
2020-03-31 19:40 ` [PATCH 3/4] kvm: Always get async page notifications Vivek Goyal
2020-03-31 19:40 ` [PATCH 4/4] kvm,x86,async_pf: Search exception tables in case of error 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=20200331194011.24834-1-vgoyal@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=dhildenb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=stefanha@redhat.com \
    --cc=virtio-fs@redhat.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).