Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-06 Thread Sean Christopherson
On Tue, Oct 06, 2020 at 01:35:27PM -0400, Vivek Goyal wrote: > On Tue, Oct 06, 2020 at 10:17:04AM -0700, Sean Christopherson wrote: > > [..] > > > > Note, TDX doesn't allow injection exceptions, so reflecting a #PF back > > > > into the guest is not an option. > > > > > > Not even #MC? So sad

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-06 Thread Vivek Goyal
On Tue, Oct 06, 2020 at 10:17:04AM -0700, Sean Christopherson wrote: [..] > > > Note, TDX doesn't allow injection exceptions, so reflecting a #PF back > > > into the guest is not an option. > > > > Not even #MC? So sad :-) > > Heh, #MC isn't allowed either, yet... If #MC is not allowd, logic

Re: [Virtio-fs] [PATCH v4] kvm, x86: Exit to user space in case page fault error

2020-10-06 Thread Vivek Goyal
On Tue, Oct 06, 2020 at 06:21:48PM +0100, Dr. David Alan Gilbert wrote: > * Sean Christopherson (sean.j.christopher...@intel.com) wrote: > > On Tue, Oct 06, 2020 at 06:39:56PM +0200, Vitaly Kuznetsov wrote: > > > Sean Christopherson writes: > > > > > > > On Tue, Oct 06, 2020 at 05:24:54PM +0200,

Re: [Virtio-fs] [PATCH v4] kvm, x86: Exit to user space in case page fault error

2020-10-06 Thread Dr. David Alan Gilbert
* Sean Christopherson (sean.j.christopher...@intel.com) wrote: > On Tue, Oct 06, 2020 at 06:39:56PM +0200, Vitaly Kuznetsov wrote: > > Sean Christopherson writes: > > > > > On Tue, Oct 06, 2020 at 05:24:54PM +0200, Vitaly Kuznetsov wrote: > > >> Vivek Goyal writes: > > >> > So you will have to

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-06 Thread Sean Christopherson
On Tue, Oct 06, 2020 at 06:39:56PM +0200, Vitaly Kuznetsov wrote: > Sean Christopherson writes: > > > On Tue, Oct 06, 2020 at 05:24:54PM +0200, Vitaly Kuznetsov wrote: > >> Vivek Goyal writes: > >> > So you will have to report token (along with -EFAULT) to user space. So > >> > this > >> > is

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-06 Thread Vitaly Kuznetsov
Sean Christopherson writes: > On Tue, Oct 06, 2020 at 05:24:54PM +0200, Vitaly Kuznetsov wrote: >> Vivek Goyal writes: >> > So you will have to report token (along with -EFAULT) to user space. So >> > this >> > is basically the 3rd proposal which is extension of kvm API and will >> > report

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-06 Thread Vivek Goyal
On Tue, Oct 06, 2020 at 09:12:00AM -0700, Sean Christopherson wrote: > On Tue, Oct 06, 2020 at 05:24:54PM +0200, Vitaly Kuznetsov wrote: > > Vivek Goyal writes: > > > So you will have to report token (along with -EFAULT) to user space. So > > > this > > > is basically the 3rd proposal which is

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-06 Thread Sean Christopherson
On Tue, Oct 06, 2020 at 05:24:54PM +0200, Vitaly Kuznetsov wrote: > Vivek Goyal writes: > > So you will have to report token (along with -EFAULT) to user space. So this > > is basically the 3rd proposal which is extension of kvm API and will > > report say HVA/GFN also to user space along with

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-06 Thread Vitaly Kuznetsov
Vivek Goyal writes: > On Tue, Oct 06, 2020 at 04:50:44PM +0200, Vitaly Kuznetsov wrote: >> Vivek Goyal writes: >> >> > On Tue, Oct 06, 2020 at 04:05:16PM +0200, Vitaly Kuznetsov wrote: >> >> Vivek Goyal writes: >> >> >> >> > A. Just exit to user space with -EFAULT (using kvm request) and

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-06 Thread Vivek Goyal
On Tue, Oct 06, 2020 at 04:50:44PM +0200, Vitaly Kuznetsov wrote: > Vivek Goyal writes: > > > On Tue, Oct 06, 2020 at 04:05:16PM +0200, Vitaly Kuznetsov wrote: > >> Vivek Goyal writes: > >> > >> > A. Just exit to user space with -EFAULT (using kvm request) and don't > >> >wait for the

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-06 Thread Vitaly Kuznetsov
Vivek Goyal writes: > On Tue, Oct 06, 2020 at 04:05:16PM +0200, Vitaly Kuznetsov wrote: >> Vivek Goyal writes: >> >> > A. Just exit to user space with -EFAULT (using kvm request) and don't >> >wait for the accessing task to run on vcpu again. >> >> What if we also save the required

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-06 Thread Vivek Goyal
On Tue, Oct 06, 2020 at 04:05:16PM +0200, Vitaly Kuznetsov wrote: > Vivek Goyal writes: > > > A. Just exit to user space with -EFAULT (using kvm request) and don't > >wait for the accessing task to run on vcpu again. > > What if we also save the required information (RIP, GFN, ...) in the

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-06 Thread Vitaly Kuznetsov
Vivek Goyal writes: > A. Just exit to user space with -EFAULT (using kvm request) and don't >wait for the accessing task to run on vcpu again. What if we also save the required information (RIP, GFN, ...) in the guest along with the APF token so in case of -EFAULT we can just 'crash' the

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-06 Thread Vivek Goyal
On Mon, Oct 05, 2020 at 09:16:20AM -0700, Sean Christopherson wrote: > On Mon, Oct 05, 2020 at 11:33:18AM -0400, Vivek Goyal wrote: > > On Fri, Oct 02, 2020 at 02:13:14PM -0700, Sean Christopherson wrote: > > Now I have few questions. > > > > - If we exit to user space asynchronously (using kvm

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-05 Thread Sean Christopherson
On Mon, Oct 05, 2020 at 11:33:18AM -0400, Vivek Goyal wrote: > On Fri, Oct 02, 2020 at 02:13:14PM -0700, Sean Christopherson wrote: > Now I have few questions. > > - If we exit to user space asynchronously (using kvm request), what debug > information is in there which tells user which address

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-05 Thread Vivek Goyal
On Fri, Oct 02, 2020 at 02:13:14PM -0700, Sean Christopherson wrote: > On Fri, Oct 02, 2020 at 04:02:14PM -0400, Vivek Goyal wrote: > > On Fri, Oct 02, 2020 at 12:45:18PM -0700, Sean Christopherson wrote: > > > On Fri, Oct 02, 2020 at 03:27:34PM -0400, Vivek Goyal wrote: > > > > On Fri, Oct 02,

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-02 Thread Sean Christopherson
On Fri, Oct 02, 2020 at 04:02:14PM -0400, Vivek Goyal wrote: > On Fri, Oct 02, 2020 at 12:45:18PM -0700, Sean Christopherson wrote: > > On Fri, Oct 02, 2020 at 03:27:34PM -0400, Vivek Goyal wrote: > > > On Fri, Oct 02, 2020 at 11:30:37AM -0700, Sean Christopherson wrote: > > > > On Fri, Oct 02,

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-02 Thread Vivek Goyal
On Fri, Oct 02, 2020 at 12:45:18PM -0700, Sean Christopherson wrote: > On Fri, Oct 02, 2020 at 03:27:34PM -0400, Vivek Goyal wrote: > > On Fri, Oct 02, 2020 at 11:30:37AM -0700, Sean Christopherson wrote: > > > On Fri, Oct 02, 2020 at 11:38:54AM -0400, Vivek Goyal wrote: > > > > On Thu, Oct 01,

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-02 Thread Sean Christopherson
On Fri, Oct 02, 2020 at 03:27:34PM -0400, Vivek Goyal wrote: > On Fri, Oct 02, 2020 at 11:30:37AM -0700, Sean Christopherson wrote: > > On Fri, Oct 02, 2020 at 11:38:54AM -0400, Vivek Goyal wrote: > > > On Thu, Oct 01, 2020 at 03:33:20PM -0700, Sean Christopherson wrote: > > > > Alternatively,

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-02 Thread Vivek Goyal
On Fri, Oct 02, 2020 at 11:30:37AM -0700, Sean Christopherson wrote: > On Fri, Oct 02, 2020 at 11:38:54AM -0400, Vivek Goyal wrote: > > On Thu, Oct 01, 2020 at 03:33:20PM -0700, Sean Christopherson wrote: > > > Alternatively, what about adding a new KVM request type to handle this? > > > E.g. when

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-02 Thread Sean Christopherson
On Fri, Oct 02, 2020 at 11:38:54AM -0400, Vivek Goyal wrote: > On Thu, Oct 01, 2020 at 03:33:20PM -0700, Sean Christopherson wrote: > > Alternatively, what about adding a new KVM request type to handle this? > > E.g. when the APF comes back with -EFAULT, snapshot the GFN and make a > > request.

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-02 Thread Vivek Goyal
On Thu, Oct 01, 2020 at 03:33:20PM -0700, Sean Christopherson wrote: > On Thu, Oct 01, 2020 at 05:55:08PM -0400, Vivek Goyal wrote: > > On Mon, Sep 28, 2020 at 09:37:00PM -0700, Sean Christopherson wrote: > > > On Mon, Jul 20, 2020 at 05:13:59PM -0400, Vivek Goyal wrote: > > > > @@ -10369,6

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-01 Thread Sean Christopherson
On Thu, Oct 01, 2020 at 05:55:08PM -0400, Vivek Goyal wrote: > On Mon, Sep 28, 2020 at 09:37:00PM -0700, Sean Christopherson wrote: > > On Mon, Jul 20, 2020 at 05:13:59PM -0400, Vivek Goyal wrote: > > > @@ -10369,6 +10378,36 @@ void kvm_set_rflags(struct kvm_vcpu *vcpu, > > > unsigned long

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-10-01 Thread Vivek Goyal
On Mon, Sep 28, 2020 at 09:37:00PM -0700, Sean Christopherson wrote: > On Mon, Jul 20, 2020 at 05:13:59PM -0400, Vivek Goyal wrote: > > --- > > arch/x86/include/asm/kvm_host.h | 2 ++ > > arch/x86/kvm/mmu.h | 2 +- > > arch/x86/kvm/mmu/mmu.c | 2 +- > > arch/x86/kvm/x86.c

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-09-28 Thread Sean Christopherson
On Mon, Jul 20, 2020 at 05:13:59PM -0400, Vivek Goyal wrote: > --- > arch/x86/include/asm/kvm_host.h | 2 ++ > arch/x86/kvm/mmu.h | 2 +- > arch/x86/kvm/mmu/mmu.c | 2 +- > arch/x86/kvm/x86.c | 54 +++-- > include/linux/kvm_types.h

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-08-07 Thread Vivek Goyal
On Mon, Jul 20, 2020 at 05:13:59PM -0400, Vivek Goyal wrote: > Page fault error handling behavior in kvm seems little inconsistent when > page fault reports error. If we are doing fault synchronously > then we capture error (-EFAULT) returned by __gfn_to_pfn_memslot() and > exit to user space and

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-07-29 Thread Pankaj Gupta
> Page fault error handling behavior in kvm seems little inconsistent when > page fault reports error. If we are doing fault synchronously > then we capture error (-EFAULT) returned by __gfn_to_pfn_memslot() and > exit to user space and qemu reports error, "error: kvm run failed Bad > address". >

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-07-27 Thread Vivek Goyal
On Mon, Jul 27, 2020 at 06:09:32PM +0200, Vitaly Kuznetsov wrote: > Vivek Goyal writes: > > > On Mon, Jul 20, 2020 at 05:13:59PM -0400, Vivek Goyal wrote: > >> Page fault error handling behavior in kvm seems little inconsistent when > >> page fault reports error. If we are doing fault

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-07-27 Thread Vitaly Kuznetsov
Vivek Goyal writes: > On Mon, Jul 20, 2020 at 05:13:59PM -0400, Vivek Goyal wrote: >> Page fault error handling behavior in kvm seems little inconsistent when >> page fault reports error. If we are doing fault synchronously >> then we capture error (-EFAULT) returned by __gfn_to_pfn_memslot()

Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-07-27 Thread Vivek Goyal
On Mon, Jul 20, 2020 at 05:13:59PM -0400, Vivek Goyal wrote: > Page fault error handling behavior in kvm seems little inconsistent when > page fault reports error. If we are doing fault synchronously > then we capture error (-EFAULT) returned by __gfn_to_pfn_memslot() and > exit to user space and

[PATCH v4] kvm,x86: Exit to user space in case page fault error

2020-07-20 Thread Vivek Goyal
Page fault error handling behavior in kvm seems little inconsistent when page fault reports error. If we are doing fault synchronously then we capture error (-EFAULT) returned by __gfn_to_pfn_memslot() and exit to user space and qemu reports error, "error: kvm run failed Bad address". But if we