Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1267715ybh; Sat, 7 Mar 2020 23:23:53 -0800 (PST) X-Google-Smtp-Source: ADFU+vt0i0C3iluBTn8sTAL1hI+dOUxgTqTCnlmHvK7G4y8WNuOcB7n+BhDjreDgeOA3HCxcA+/K X-Received: by 2002:a05:6830:18ce:: with SMTP id v14mr9285103ote.4.1583652233785; Sat, 07 Mar 2020 23:23:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583652233; cv=none; d=google.com; s=arc-20160816; b=dgajYmQyRgRUVDcFEHeu2mEgheO5hZe+SCkGrpA3FaJPI0uEHb4/j+JEZMxin8SJZ9 1GHsuPk56j1hMEDWxuWBhqwTK7CIubczhohwjyqyr49q6kdgY3rGEgsAWAIcu9fuwMTA 9E2KpwVQbaGYCFG7OelfcCIOunlEnLxxfK+fRNonCfHof6S1PjKnmnc96A/vvufi73vp 2J7f6+o+gig3L5mdZ8QF1bCn72dZQO8dcMMDnJ8cW8NM4GT32sh5xMrNFvMO3b21GdvP 4Rb/A8kYTcFXOHdwsEdjF1d+XA34O3ZD3JNvBveZiFju2ZIKk+h7U4OFritZwSWTB/1e mftQ== 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; bh=s9xDah/gtvXYkxP4SWEafrkYQlUmaBMGtVBF5bE9V58=; b=Do+cLyWC2DMhMc66Y2WYkaGR05UEEepFxu/mexxEuDoA+KpUGMTemYtdz3divZe7S3 UMxqEDgmZ3quJ+5jYl594NgWvjcdNlhgu9sXjCJx1H9b0RcjMgMoXxT3x5jJqzUWMx5d SOUujhNdt4OaTrxBBqNFDyED9Fqx9hGB4hnupj9OuTVA8EoXL6QjX2K2zGiCtxkkZ8+w +IXPGZFCSsrdSbhQfASI6zDCBnOdlsQviVljHYaM7nC9KyxyRqAPrpfBrcbro2MyzwY1 i5RfuZIk9kqrkTRGLv7ybMdd/avLb4rWZZJnIFeCJBVyive8/KfbYwGujI8yM1hUSak8 BQBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i7si532817otp.96.2020.03.07.23.23.41; Sat, 07 Mar 2020 23:23:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726156AbgCHHXO (ORCPT + 99 others); Sun, 8 Mar 2020 03:23:14 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:56289 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725904AbgCHHXO (ORCPT ); Sun, 8 Mar 2020 03:23:14 -0400 Received: from p5de0bf0b.dip0.t-ipconnect.de ([93.224.191.11] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jAqHF-0003H3-MR; Sun, 08 Mar 2020 08:23:09 +0100 Received: by nanos.tec.linutronix.de (Postfix, from userid 1000) id 97952104096; Sun, 8 Mar 2020 08:23:08 +0100 (CET) From: Thomas Gleixner To: Andy Lutomirski Cc: LKML , X86 ML , kvm list , Paolo Bonzini , stable Subject: Re: [PATCH v2] x86/kvm: Disable KVM_ASYNC_PF_SEND_ALWAYS In-Reply-To: <87a74s9ehb.fsf@nanos.tec.linutronix.de> References: <87ftek9ngq.fsf@nanos.tec.linutronix.de> <87a74s9ehb.fsf@nanos.tec.linutronix.de> Date: Sun, 08 Mar 2020 08:23:08 +0100 Message-ID: <87wo7v8g4j.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thomas Gleixner writes: > Andy Lutomirski writes: >> On Sat, Mar 7, 2020 at 7:47 AM Thomas Gleixner wrote: >>> The host knows exactly when it injects a async PF and it can store CR2 >>> and reason of that async PF in flight. >>> >>> On the next VMEXIT it checks whether apf_reason is 0. If apf_reason is 0 >>> then it knows that the guest has read CR2 and apf_reason. All good >>> nothing to worry about. >>> >>> If not it needs to be careful. >>> >>> As long as the apf_reason of the last async #PF is not cleared by the >>> guest no new async #PF can be injected. That's already correct because >>> in that case IF==0 which prevents a nested async #PF. >>> >>> If MCE, NMI trigger a real pagefault then the #PF injection needs to >>> clear apf_reason and set the correct CR2. When that #PF returns then the >>> old CR2 and apf_reason need to be restored. >> >> How is the host supposed to know when the #PF returns? Intercepting >> IRET sounds like a bad idea and, in any case, is not actually a >> reliable indication that #PF returned. > > The host does not care about the IRET. It solely has to check whether > apf_reason is 0 or not. That way it knows that the guest has read CR2 > and apf_reason. Bah. I'm a moron. Of course it needs to trap the IRET of the #PF in order to restore CR2 and apf_reason. Alternatively it could trap the CR2 read of #PF, but yes that's all nasty. Thanks, tglx