Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp375678pxu; Tue, 6 Oct 2020 08:28:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynIv8O4la3y7Nt4XA0YcfxZUOWqJDFKlJVmBk7haol24SAQOiWxJ8CQDHLndrMkkFSjwl0 X-Received: by 2002:a17:906:649a:: with SMTP id e26mr5992923ejm.415.1601998112926; Tue, 06 Oct 2020 08:28:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601998112; cv=none; d=google.com; s=arc-20160816; b=kspZ2/mJIpeSrxqtk5o/cxhUsgSaJ27WGmHPxjMyOWLDce4gBlOs0XkD7G5NbROElO wdXuvb0KCYTEaCZ0r1ncnrmW7cQ9RSbUbt0eemwmthRVHZK0ZNjL9slKkLmjA+d+Lv2h H7sarFH+g8HqUK0XYSe+G0HLWzN8Jxd4Qk9Tr28Q+spLyl7oKYgD8PNMqeCqSjdVgWha L+2qwtDGEiUemfiixVSwuqHyqUpMtrTPM2+Yze8deVv8Jvc7AJxvkDv6BJxngLpFfTVU 5Op5S/JU8+70/Kuij/YJRZMrjPw1a+20tU+k30r2b6zRY/lOLDarWMEseioRdQXf1jhR WRtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=wZL08bNRgmcXboDsDLfB4r/vwPMC+a0Y4m0HSS5QKZQ=; b=uL5tJWzPbDChQh9PI7hLIFonDM2utU82d9j5f6XvN6+SFR6U8IG1iDj0lIrYO3CyJ3 z4koXsK9zMvtCRVvzPB2xkjnO36IJqTqHYQz6B0YRgB2+odCxDI3KVjEZ7ZHjJhJ2aia nPB6wJZHwVgYppjhodpj/j6/1LMC4rSJoj3kZwEW3GPh+Setb2vl5HQ3N29UtK1TTib9 tzlJbAvWLYgMZH93LC6ryIgWU3TnlHaZ6Rx5zsk650eHWSN/WFgzqkkP8Zrd3IUeuYky 2qPc5DRWCPbP+4NnqVC8bTiNInnv+Z/e8wu8B8Qo229FmWaMLIS2chulnJBzbcYs042d SfFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gWMrjvI4; 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 e3si2158760ejt.37.2020.10.06.08.28.09; Tue, 06 Oct 2020 08:28:32 -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=gWMrjvI4; 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 S1725995AbgJFPZC (ORCPT + 99 others); Tue, 6 Oct 2020 11:25:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45497 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbgJFPZA (ORCPT ); Tue, 6 Oct 2020 11:25:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601997899; 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=wZL08bNRgmcXboDsDLfB4r/vwPMC+a0Y4m0HSS5QKZQ=; b=gWMrjvI4eLiOTvsgGf6wkjjKzg/NPKamGE+plnkp4pTm52HmEKObUK9PKIjfBnQ4xLX+Sx abFnnZFBPiKxmiuN5z0zWR8Cl4szjlGiTdFZ/iE3iBMdUlvgJiEZJV3Jbaf3IGDKoMBbxf xSruizhXKYC69laNrnYn8P4McIu8J4g= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-540-65K7jFFcP3CX18NtkLIRTA-1; Tue, 06 Oct 2020 11:24:57 -0400 X-MC-Unique: 65K7jFFcP3CX18NtkLIRTA-1 Received: by mail-wr1-f71.google.com with SMTP id l15so5491234wro.10 for ; Tue, 06 Oct 2020 08:24:57 -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=wZL08bNRgmcXboDsDLfB4r/vwPMC+a0Y4m0HSS5QKZQ=; b=QZSYkYl6ldCKiUKHkksMXLiv9eH1ySwz/bvVL3ACU1heWkUwUZoqsM719tZw526JYK fydWZE5PETGKUEizaehD10blkHmtIMpJDCQUTwwgA6d+atOrksTuQCXlYhl3VARnMtTF ba2rMJZrYXRNGqae1zIaJzgyFV3Yszatf3sxPkEzCzj44BCka43J2mz48jQrPJmDbw/8 eEw/tzuIbs/7tBZVj3gv8mGDw9W7dOHEn0muZ7PjhG7XS2vf6gpp0AkfIEISXCjIOhCV 7EH7UHwHTj9phBXMbG0vUeAHRYdCkBGrwSYZA1Yk01BGTRxwoDUC5+oS/k7sl5CefOhX cvCg== X-Gm-Message-State: AOAM532bn8M9EdUE3frjdcfzL4qpmAfcKb1NsPoynm3I30BW0jA2biB0 NyMk1C0NgaUxzF+4sJd3y6nn0+y+HUj4QNvYrP4D/SON3XQVVBcA7nQOVDIwLSThMAXJsz+ljjq dUs7i4ZrXvp2L1Y6/IUNOJaxA X-Received: by 2002:adf:e952:: with SMTP id m18mr5504914wrn.171.1601997896533; Tue, 06 Oct 2020 08:24:56 -0700 (PDT) X-Received: by 2002:adf:e952:: with SMTP id m18mr5504887wrn.171.1601997896255; Tue, 06 Oct 2020 08:24:56 -0700 (PDT) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id l5sm2459791wrq.14.2020.10.06.08.24.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2020 08:24:55 -0700 (PDT) From: Vitaly Kuznetsov To: Vivek Goyal Cc: Sean Christopherson , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, virtio-fs-list , pbonzini@redhat.com Subject: Re: [PATCH v4] kvm,x86: Exit to user space in case page fault error In-Reply-To: <20201006150817.GD5306@redhat.com> References: <20201002192734.GD3119@redhat.com> <20201002194517.GD24460@linux.intel.com> <20201002200214.GB10232@redhat.com> <20201002211314.GE24460@linux.intel.com> <20201005153318.GA4302@redhat.com> <20201005161620.GC11938@linux.intel.com> <20201006134629.GB5306@redhat.com> <877ds38n6r.fsf@vitty.brq.redhat.com> <20201006141501.GC5306@redhat.com> <874kn78l2z.fsf@vitty.brq.redhat.com> <20201006150817.GD5306@redhat.com> Date: Tue, 06 Oct 2020 17:24:54 +0200 Message-ID: <871rib8ji1.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 >> > >> > Can you elaborate a bit more on this. You mean save GFN on stack before >> > it starts waiting for PAGE_READY event? >> >> When PAGE_NOT_PRESENT event is injected as #PF (for now) in the guest >> kernel gets all the registers of the userspace process (except for CR2 >> which is replaced with a token). In case it is not trivial to extract >> accessed GFN from this data we can extend the shared APF structure and >> add it there, KVM has it when it queues APF. >> >> > >> >> so in case of -EFAULT we can just 'crash' >> >> the guest and the required information can easily be obtained from >> >> kdump? This will solve the debugging problem even for TDX/SEV-ES (if >> >> kdump is possible there). >> > >> > Just saving additional info in guest will not help because there might >> > be many tasks waiting and you don't know which GFN is problematic one. >> >> But KVM knows which token caused the -EFAULT when we exit to userspace >> (and we can pass this information to it) so to debug the situation you >> take this token and then explore the kdump searching for what's >> associated with this exact token. > > 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 -EFAULT. > Right, I meant to say that guest kernel has full register state of the userspace process which caused APF to get queued and instead of trying to extract it in KVM and pass to userspace in case of a (later) failure we limit KVM api change to contain token or GFN only and somehow keep the rest in the guest. This should help with TDX/SEV-ES. -- Vitaly