Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3679153ybt; Tue, 30 Jun 2020 08:46:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOjN97yDf2tE9k4iVao9POG8b6hNhK49TotgtJ6leOcJ46gx72fyqvqekqXeuZC7I5bMI6 X-Received: by 2002:a05:6402:796:: with SMTP id d22mr24944232edy.78.1593531980433; Tue, 30 Jun 2020 08:46:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593531980; cv=none; d=google.com; s=arc-20160816; b=D5ovT6mge4fQxHJvlYKvnP6L6VqXyd0wCHyQ0Rzgj+F0djvIg6t6bE6yCjn8axtLdV cNxdM27ULzp1lefmu8QXpWd2l8aSz/n4fD3tjenb7fGfmEVP7oMiaRD3olDupaFz1xL5 b+w4s+Rs7il1I0CiffvV9Q5AnRWg1ii9FUag77NX+6PUYX65P7kkHJQLOmauNXqtrhA7 O+X8CDT3huwnbv5owgsgIJOuKzEO0C9KIW8zJLQQNdVJ1QYcaeVwW//y7j4J6IKuAvVJ T0mToYhd3YIPQu/f+p4goI8Nh6e26W5S6RDThMCGF14w/iIwmo7FpB7ytPP1rmKz3H5U /H0w== 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=g+7JZMmEMWPm9TcnXCXFzCXeXPgv7LEiZobSQGLUt4c=; b=hsihZKGdmYMNsSlvHVJyt9HV1RkJqtHfwP0DQLZdHMeNjktvsFgkeGD5dfPxNxoaMn vU3GBd/VM2p9z88iUjoiXRLqi2M0YjFPR1iy/Ii8uCtAOAWkd1OUAr+kk2Ml7wFjECnc X7R8W/8Ifq8zuIhTjWXvE39vnjaFvthBaQUkc1QT+djq+/YPzKoQbIQ0/Vp7ra2cSgU4 Sq1ALgp6/ydYhnUVvT5sf7PzcqpsnjXLCfFUly0mQA6JDNLg3xNn+rWnjfkvdsgtLrID 0mkAb54LJQLA4Hv60BgLtuVfWvDqSIrO6VBk+Swcij4NgKoxnmiDNSJsjS5gsobbGX71 tZZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IfwJae+M; 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 u6si1928468ejf.218.2020.06.30.08.45.56; Tue, 30 Jun 2020 08:46:20 -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=IfwJae+M; 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 S2389703AbgF3PoO (ORCPT + 99 others); Tue, 30 Jun 2020 11:44:14 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:29820 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389617AbgF3PoN (ORCPT ); Tue, 30 Jun 2020 11:44:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593531851; 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=g+7JZMmEMWPm9TcnXCXFzCXeXPgv7LEiZobSQGLUt4c=; b=IfwJae+M2aGa3GlnEIb2oQas55fDDGCS0TQiF685YKehOUQrTyFUXUCbsRLUifaPC8YC3s YoeXQGn28QSNmSFnuHFOjoC9GA6C9FsqUOM3e5bnxxiFdRzcla4gKuVira131VQw0ft7ot uDMqfUhNE6GAGHpxTB17Sem0Sceep+U= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-42-SRPiOL1MPj2l3OTDwGLi4Q-1; Tue, 30 Jun 2020 11:43:58 -0400 X-MC-Unique: SRPiOL1MPj2l3OTDwGLi4Q-1 Received: by mail-ej1-f72.google.com with SMTP id f11so2844062ejb.0 for ; Tue, 30 Jun 2020 08:43: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=g+7JZMmEMWPm9TcnXCXFzCXeXPgv7LEiZobSQGLUt4c=; b=Nh6nLhkTGbqKwbZqEgKnZb0cf7A/qAfn9HwkSqShDNXtw+RZMU8H7H9VrhxBpxFskw CquLOobZtukFcdxvnVhAlgT4AEEkgxLDk4JHR0hCRmuy0foUnTou46HOUm7AxZajoBfq a0sRqf76dMGPlGcNNYEQaF/ujGenizMF58A7MuenjmzViTgAcN9a4vdzJknLG0MnmStn k5q6kg0zHtP1eykAS+1WL73Obn6MM/sRktqYkJ3rnE2XEoQnPN7NCNs73Wz2xS2lRVtA SoWEZwly2S3TASbF6AluvwTbifazbkLUE9b8kOv7allLaqy/KohV83gqOpMpyamxzJYj qbmQ== X-Gm-Message-State: AOAM532TQFl9Ae6XGLOwAqicuxr7+Tlgnzruo8b6LAXFlqfE02bzGYhD Ya4ucPjNN9Z8CefjPcK0YODR302+TRGYdiEjYRphkDnysB/VX291FtuFkqytXyS0P/MZcQvj5HD hFtmdOi4pdiM12sr4lfeo9v/h X-Received: by 2002:a17:906:6a14:: with SMTP id o20mr19371694ejr.128.1593531836505; Tue, 30 Jun 2020 08:43:56 -0700 (PDT) X-Received: by 2002:a17:906:6a14:: with SMTP id o20mr19371673ejr.128.1593531836311; Tue, 30 Jun 2020 08:43: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 w18sm2247913ejc.62.2020.06.30.08.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 08:43:55 -0700 (PDT) From: Vitaly Kuznetsov To: Vivek Goyal Cc: kvm@vger.kernel.org, virtio-fs@redhat.com, pbonzini@redhat.com, sean.j.christopherson@intel.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: <20200630152529.GC322149@redhat.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> Date: Tue, 30 Jun 2020 17:43:54 +0200 Message-ID: <87k0zobltx.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 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? -- Vitaly