Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp699695ybt; Wed, 17 Jun 2020 11:34:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoupXcFJPiKk7k3HLe0vbWXxRFUhYtyENjpsXbgq2nd5hOtygs1wNwNbjWN2QznVAZgWfY X-Received: by 2002:a50:8e16:: with SMTP id 22mr461163edw.273.1592418895217; Wed, 17 Jun 2020 11:34:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592418895; cv=none; d=google.com; s=arc-20160816; b=Yr73wlKzxtyBnSvrMUmv0wxUnjjk65DHqKUP5hAXauZ0T03IFsqPNMZdRrbPag1B/3 QvhN4FKuezy7ihaDHILx28gz/D/te55KOKZ1tsdKe26uCrdx+V9iAdgbvlXZUcBd9/QP dgaN4ZA3fOKE8g6kekTse3JKGvGGkccU4nIkS2UZBv/mGvrEXSkUA3OLdMK2E1mzEeuF OfxhgwdDSLxf39y40mcAl45nKcw2cUbksDpbIg3r6D0jLMv6IYJyFQuIvq8YqZyV3uny jU/P28vswrTct4YSzNKvc3FucMxkagNHDKkHbzCGMn7Fno6BIilkTAn+8SwYAYrMCLFp h6ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=n1WnV9H7AduDHz2VkW9QCMybeugcFT466tVS29ACumE=; b=gBJk1A16EpY54AYFxGndUgxl58cNy4sAlqTeTLeHYY7EmHITM4x2YDCKICQGM7BLHS PR6q+ppu/E4Ths+xXC6Z7osdo19S/0NF17VxekFqAgb66WXwyYCCY+hJyaY21xDebx/3 zDY1sdleffpDR95qJII3vHFfgU52dMWFSOOX4qaaTV5r08JZGdMPE/GEwP7AtQzdx+EH BH7IIUnxRPvgjJC7ndPMP6NU2/olJXYI0HcVNb+N1xLIAR7HA+2mIJAOCmi4Tfe1Dzz0 tgRevE/9NKiH6c/y5lbOHxFPBxo7ExdGI1KDhzwSK6JRZpzEUNC5YsVnuAy8kp58ew00 57Lw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd24si436672edb.336.2020.06.17.11.34.32; Wed, 17 Jun 2020 11:34:55 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727771AbgFQSc0 (ORCPT + 99 others); Wed, 17 Jun 2020 14:32:26 -0400 Received: from mga09.intel.com ([134.134.136.24]:15632 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726912AbgFQSc0 (ORCPT ); Wed, 17 Jun 2020 14:32:26 -0400 IronPort-SDR: Heq0lZ+rxMLq9CxHv+wzrNZP4U2cdoVMZWPHOWXU5rDq5OHfJfwGpg8VttknL3Y9zhSL8od0O0 eAPZNC9D3khg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2020 11:32:25 -0700 IronPort-SDR: adYkGQfP2UnElRGEJLNSZmQJe7CJIILLyFWQpU15MypxbLdC39GAC5XqxiTXYHKphCK9d65QcH xoqbO0CZBa7w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,523,1583222400"; d="scan'208";a="309568526" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.152]) by fmsmga002.fm.intel.com with ESMTP; 17 Jun 2020 11:32:24 -0700 Date: Wed, 17 Jun 2020 11:32:24 -0700 From: Sean Christopherson To: Vitaly Kuznetsov Cc: Vivek Goyal , 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 Message-ID: <20200617183224.GK26818@linux.intel.com> References: <20200616214847.24482-1-vgoyal@redhat.com> <20200616214847.24482-3-vgoyal@redhat.com> <87lfklhm58.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87lfklhm58.fsf@vitty.brq.redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 17, 2020 at 03:12:03PM +0200, Vitaly Kuznetsov wrote: > Vivek Goyal 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.