Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp814190ybh; Sat, 7 Mar 2020 11:02:19 -0800 (PST) X-Google-Smtp-Source: ADFU+vvi00KsqE9eIFTjVy7/83v8lqpvjRB34b4OmmERnMH1rh5pWlV94qvyJzLgV+sIcz8Q6fKo X-Received: by 2002:aca:ed58:: with SMTP id l85mr6394267oih.70.1583607739063; Sat, 07 Mar 2020 11:02:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583607739; cv=none; d=google.com; s=arc-20160816; b=PhsfNzUocN0mIQNT6H/vtpovb7hivE83LXWvFbDP0qpgpU96nvKEFDSMvN27RXCNMM /club/df/yrElAQ2GCAx2RAUGMaiel5gTZEy1AhHKMTHaIivYVuY9AFlGARiFTxlnf47 YTyQr/TO/uDJwiSkYoYtWFlgBvQrhrJOX3h9fhTdMitOmhyj+wQVhSYAKBemvCF7e6kk Uoc1kEJVuBxLWPC8T5R87Xe8SPgq7d0YMY8dhQB/gYmavGtFQKUMYnmr+OyP/halw2dJ vhW/hHlI1I2nuvoU3CM7eKIqmsgy2NVlikquhYBGe7tTsYrV49r+UaD/1nB2cnIp5axf 4KsA== 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=qwtNdYArzVhvmk2tU6j5KEAtHNRQ0PfSUJotoXl67gc=; b=aEQZyhymt66Y/xIwQdKGPAEkSwv2cAatpsUflIJtaTCTQymrF/UTbDeQgbxEDF+qV6 ENitakza8KxPVjgFpuHZLIqcrvv8kKZXs7CxXTj72DQECzci9l/SozkgAZiNOEE/9Ju0 KpgCYB+LA1Jn/yJW6YMGtgOPuFbOj+aqN//LNPLREmqNKC7v2aEMiIWgrYULidUAYjEL jV4fJ/jAfqe+88SCbZ1INlK30doidTAJ69Fbxw6xYxI1YFkkOwqxP9LePGyillSSZFg8 p/ZD7PNRsMkairTHFQUbj++ynU1RvagJAyjKt2Dm5aaypDErwRURnwzgzFnBSfBZs4OP ry8A== 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 l23si1549902oii.20.2020.03.07.11.01.54; Sat, 07 Mar 2020 11:02:19 -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 S1726307AbgCGTBK (ORCPT + 99 others); Sat, 7 Mar 2020 14:01:10 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:55794 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726114AbgCGTBJ (ORCPT ); Sat, 7 Mar 2020 14:01:09 -0500 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 1jAeh7-0007da-F2; Sat, 07 Mar 2020 20:01:05 +0100 Received: by nanos.tec.linutronix.de (Postfix, from userid 1000) id 81EDA104088; Sat, 7 Mar 2020 20:01:04 +0100 (CET) From: Thomas Gleixner To: Andy Lutomirski Cc: Andy Lutomirski , LKML , X86 ML , kvm list , Paolo Bonzini , stable Subject: Re: [PATCH v2] x86/kvm: Disable KVM_ASYNC_PF_SEND_ALWAYS In-Reply-To: References: <87ftek9ngq.fsf@nanos.tec.linutronix.de> Date: Sat, 07 Mar 2020 20:01:04 +0100 Message-ID: <87a74s9ehb.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 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. Thanks, tglx