Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3700865ybt; Tue, 30 Jun 2020 09:15:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycR+ewhewHeToQWUmfK/LrmHF4C9jmWBDwelgek2NFjvO7pSaeDI2GuFINFmr5F+TP3q3e X-Received: by 2002:a05:6402:1c10:: with SMTP id ck16mr6702174edb.72.1593533708760; Tue, 30 Jun 2020 09:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593533708; cv=none; d=google.com; s=arc-20160816; b=xNkjIfeU9fGUcBGzhR7V19DcqRY336XYYbn0YPmMCsJ0bkWLvYn0TF9eWnXajxJQ8M WF5S7/v2RrnXst7yk7oBLHMpDLuUIUf3kMOVf+rwfu9XFMiOFCdP8lpbNCapvUrpukaC PfYWF7Jkyv5t1AVNzVt7xB7QQ8RHJESxxOXll6NsmzpZG4ORcQqt3PuBCNXSH9g0HyeM LGU/1bmEPhqp/nC3jyeCaUUOiKahj1pp9cH7lnqooTPj8EHVUrgGRBd6qIOMvUX+zQPN Kj/Sm9BSZOK4/p/U/D7iQ26TTwvhDupAMuakF3fFm0NwKJkGJMj/9467mahga9UjnkA5 hD6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=u1woKrpm36qH+9CniD7td2Wx/FFa6jfnW3kyhHa0B0Q=; b=j1W7IsW7iTHny6dEGWm/l/M6wAEz0JKw+msTTmcS2hrSSiw4w6uEul1bgL/4H2ajgl GStFmgYBaP38PU8cZjqhgStNH94qf5bHhPxzlT23CZdtv5aZzQaA0eonnSIZAc9PZlgo 5b8o/lU83MPs4ij2tuTybftywgbcomJNThMHotif983j7XrWU/ZS0CLmozGU6b0Sbuqh fefodAtkoz+msmUu5RCRCXI6sSCFUdCufCA0V1HxuXxdFTyGbvNsniCrQf4NdlYlvGux GgxRTgiGkCVBTO0V9rtUvzziRvoEwPHnIL6AnvzRYGET2DCM+TfaN8leJ5ul5bQsNbXs OVGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QjFDxWJF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n6si2010457ejs.278.2020.06.30.09.14.45; Tue, 30 Jun 2020 09:15:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QjFDxWJF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731554AbgF3QM6 (ORCPT + 99 others); Tue, 30 Jun 2020 12:12:58 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:48058 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726117AbgF3QM5 (ORCPT ); Tue, 30 Jun 2020 12:12:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593533575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=u1woKrpm36qH+9CniD7td2Wx/FFa6jfnW3kyhHa0B0Q=; b=QjFDxWJFsfITSYU6Zi/Nu9CVcGycqask2/d7EzIbQxqCqyLultGws6dbd3o+OXs+h3mfPG /h1LmMJLKUFdFUvsBa8oZi91G0zl7i3j1ViNUrksY3soSW/AeO10UggiSKYziK1hy3fdXI S8EKIN21z2/aNZc7BIKMlp8LNGaBE50= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-106-ITcJyhPKP1ONxpoKLPpe5Q-1; Tue, 30 Jun 2020 12:12:52 -0400 X-MC-Unique: ITcJyhPKP1ONxpoKLPpe5Q-1 Received: by mail-ed1-f71.google.com with SMTP id m12so16196457edv.3 for ; Tue, 30 Jun 2020 09:12:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=u1woKrpm36qH+9CniD7td2Wx/FFa6jfnW3kyhHa0B0Q=; b=sv3QKHhsYQMeQWXoVjMQPS+DZo3HmUEhot4JOsNQbGdrFuQTpCEdIrpQiX9hVIZT6b Brrh3kt4/gPcFMnZ2chJHpsshRWgOjhyOPrhRL2P9SFOKaMCDtjXnQT3GYWSJymH30WN K8ZzGAazycT1muzu+7nQbhQ4muGoUgC7Kj3w7sA134rzEoD69xOJPKJreBRcfF5PctmS P8n9JNuHxHqjggHTN+bPysqMESNdclYiCoqKnBixWgi5Oi0HZt+EgrJXYwbO1lZDhzRO eItSUSPLqdghonnel7gwHpsV1a+OMNTT2LVv6LN4tzjzGXLU5zGRU7oupFLBqJ9KIVBP kCCA== X-Gm-Message-State: AOAM530kIMESm/QVxwvn0vAOvm4jjPDETz1KUP+IA2f1XbRTtkE8s0iD WLBSAuMWZnLU7iyK8m7enSLxhkHfdLQnv5INy/fvvHxKf/6XbE9btllxg6igSLIWuN+DOnAGFyS QUZvbcKFFm4ACWXYWRduv3Qag X-Received: by 2002:a17:907:4003:: with SMTP id nj3mr17335439ejb.278.1593533571145; Tue, 30 Jun 2020 09:12:51 -0700 (PDT) X-Received: by 2002:a17:907:4003:: with SMTP id nj3mr17335420ejb.278.1593533570875; Tue, 30 Jun 2020 09:12:50 -0700 (PDT) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id w24sm3311717edt.28.2020.06.30.09.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 09:12:50 -0700 (PDT) From: Vitaly Kuznetsov To: Sean Christopherson Cc: Vivek Goyal , kvm@vger.kernel.org, virtio-fs@redhat.com, pbonzini@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] kvm,x86: Exit to user space in case of page fault error In-Reply-To: <20200630155028.GE7733@linux.intel.com> References: <20200625214701.GA180786@redhat.com> <87lfkach6o.fsf@vitty.brq.redhat.com> <20200626150303.GC195150@redhat.com> <874kqtd212.fsf@vitty.brq.redhat.com> <20200629220353.GC269627@redhat.com> <87sgecbs9w.fsf@vitty.brq.redhat.com> <20200630145303.GB322149@redhat.com> <87mu4kbn7x.fsf@vitty.brq.redhat.com> <20200630152529.GC322149@redhat.com> <87k0zobltx.fsf@vitty.brq.redhat.com> <20200630155028.GE7733@linux.intel.com> Date: Tue, 30 Jun 2020 18:12:49 +0200 Message-ID: <87h7usbkhq.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sean Christopherson writes: > On Tue, Jun 30, 2020 at 05:43:54PM +0200, Vitaly Kuznetsov wrote: >> Vivek Goyal writes: >> >> > On Tue, Jun 30, 2020 at 05:13:54PM +0200, Vitaly Kuznetsov wrote: >> >> >> >> > - If you retry in kernel, we will change the context completely that >> >> > who was trying to access the gfn in question. We want to retain >> >> > the real context and retain information who was trying to access >> >> > gfn in question. >> >> >> >> (Just so I understand the idea better) does the guest context matter to >> >> the host? Or, more specifically, are we going to do anything besides >> >> get_user_pages() which will actually analyze who triggered the access >> >> *in the guest*? >> > >> > When we exit to user space, qemu prints bunch of register state. I am >> > wondering what does that state represent. Does some of that traces >> > back to the process which was trying to access that hva? I don't >> > know. >> >> We can get the full CPU state when the fault happens if we need to but >> generally we are not analyzing it. I can imagine looking at CPL, for >> example, but trying to distinguish guest's 'process A' from 'process B' >> may not be simple. >> >> > >> > I think keeping a cache of error gfns might not be too bad from >> > implemetation point of view. I will give it a try and see how >> > bad does it look. >> >> Right; I'm only worried about the fact that every cache (or hash) has a >> limited size and under certain curcumstances we may overflow it. When an >> overflow happens, we will follow the APF path again and this can go over >> and over. Maybe we can punch a hole in EPT/NPT making the PFN reserved/ >> not-present so when the guest tries to access it again we trap the >> access in KVM and, if the error persists, don't follow the APF path? > > Just to make sure I'm somewhat keeping track, is the problem we're trying to > solve that the guest may not immediately retry the "bad" GPA and so KVM may > not detect that the async #PF already came back as -EFAULT or whatever? Yes. In Vivek's patch there's a single 'error_gfn' per vCPU which serves as an indicator whether to follow APF path or not. -- Vitaly