lkml.org 
[lkml]   [2020]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2] x86/kvm: Disable KVM_ASYNC_PF_SEND_ALWAYS
On Fri, Mar 6, 2020 at 6:26 PM Andy Lutomirski <luto@kernel.org> wrote:
>
> The ABI is broken and we cannot support it properly. Turn it off.
>
> If this causes a meaningful performance regression for someone, KVM
> can introduce an improved ABI that is supportable.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
> arch/x86/kernel/kvm.c | 21 ++++++++++++++++++---
> 1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index 93ab0cbd304e..e6f2aefa298b 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -318,11 +318,26 @@ static void kvm_guest_cpu_init(void)
>
> pa = slow_virt_to_phys(this_cpu_ptr(&apf_reason));
>
> -#ifdef CONFIG_PREEMPTION
> - pa |= KVM_ASYNC_PF_SEND_ALWAYS;
> -#endif
> pa |= KVM_ASYNC_PF_ENABLED;
>
> + /*
> + * We do not set KVM_ASYNC_PF_SEND_ALWAYS. With the current
> + * KVM paravirt ABI, the following scenario is possible:
> + *
> + * #PF: async page fault (KVM_PV_REASON_PAGE_NOT_PRESENT)
> + * NMI before CR2 or KVM_PF_REASON_PAGE_NOT_PRESENT
> + * NMI accesses user memory, e.g. due to perf
> + * #PF: normal page fault
> + * #PF reads CR2 and apf_reason -- apf_reason should be 0
> + *
> + * outer #PF reads CR2 and apf_reason -- apf_reason should be
> + * KVM_PV_REASON_PAGE_NOT_PRESENT
> + *
> + * There is no possible way that both reads of CR2 and
> + * apf_reason get the correct values. Fixing this would
> + * require paravirt ABI changes.
> + */
> +

Upon re-reading my own comment, I think the problem is real, but I
don't think my patch fixes it. The outer #PF could just as easily
have come from user mode. We may actually need the NMI code (and
perhaps MCE and maybe #DB too) to save, clear, and restore apf_reason.
If we do this, then maybe CPL0 async PFs are actually okay, but the
semantics are so poorly defined that I'm not very confident about
that.

\
 
 \ /
  Last update: 2020-03-07 16:04    [W:0.062 / U:0.976 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site