Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2667262rwb; Fri, 11 Nov 2022 12:50:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf7rIQWrxG7h3egh5Ff/AYUPlNGYZcCgV9cw9Z9Bo3e1DBEfztZnqmv6zJsrd5J3kuzuKdFx X-Received: by 2002:a17:906:a986:b0:78c:c893:1965 with SMTP id jr6-20020a170906a98600b0078cc8931965mr3233004ejb.247.1668199835755; Fri, 11 Nov 2022 12:50:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668199835; cv=none; d=google.com; s=arc-20160816; b=O8Tfm1YWP86zQwpW+XarNv8D9VjucCt50ckdJmJahSbzq1coWzGs4Ei/SrjcjYLn9i H8jl4jB+Ovg2PrJYUchJT9gqeXax8ecPbf0uMrGuq3Jh0N8XfIn4ufGuMIpyi3/Hhucx iGa0aCAP6LVyRkexogeK4UAbJuFnOmwFB1h39RQKcbrTSPlujuHEaxG3cOhRWkuNQXC0 KfEJ6xmwZNeKUyNXgKruauWAXrQmSrpM80PNy14/Owi0u4OzQzZ13fMeX1nhJre9BqSq fbwTlNU0wcIrENHLW1MdqpX2Iefx+kmn7P1zl/W+C11Mn+U51MwpendsvqNzbrUWl22z D+Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=re1xEC6k7MwZnaDsgXlcM1FC9AzckvHp8TB1sTA3mF0=; b=o4/mO0DHPTV4yHtBvn5d+32+axV/1JRSJUaBylyZRME3oNcESZjFBra5PQw+cNYvZx J6lLSlwKikfxUaTkhQ3dLeNMkuW/fP5ZodxFZU4QonX9IU9Mphq9rx97KOwQ8wVI7Xbu qGf7DTKXgIfXsib3TkatMG5tTlM9FNtpSIw24KH18IY0nI27ZrgF3QySMCyzvFU5h3jW X/4DXx78961idDqMYVDNEqVRAJhgDQUmGE+APgkVFiOnXZSoRsNZtZlGEkGbcr5N6ZdC dQFYbX01J0pHz0xy2mGc4tkNlC9h5ryghH2tLRdDQoC8uWCpHuVy+DVGYCuBqlGfMkIh rUZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=bGucnxcM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hg7-20020a1709072cc700b007a6ec6fb027si3168657ejc.538.2022.11.11.12.50.12; Fri, 11 Nov 2022 12:50:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=bGucnxcM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233967AbiKKTeJ (ORCPT + 90 others); Fri, 11 Nov 2022 14:34:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233898AbiKKTeH (ORCPT ); Fri, 11 Nov 2022 14:34:07 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2CB567124; Fri, 11 Nov 2022 11:34:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=re1xEC6k7MwZnaDsgXlcM1FC9AzckvHp8TB1sTA3mF0=; b=bGucnxcMeuxE0K1iwsx2lvLt1Y HP2vOL+Yga26V3XNxf4TJCY37B8AfzAMswhmZMkIkldaaDpibqEl8eLfQEixZzlycR5MGNGYSJjgc 00E1jNkYEHB50Ujye1TJQCCD7vbLL+r1xW+CCID6omjbHdLhZDFc8fayjqqMKpNEXkRXmCOfzn45T UkhsD6CrT3UcF/pYx5f5pwMv7JmNThTlqjtzPhXHMvGsowsMy01sFC1NM+nZX8fb7Y9m1FzJ6DVfq iMP9aI2YPhS/DVopa+r49H1Cg9RvcOKfd8t0kxKHe/hMgI2xo1S1fMbFuxHSavxZwY6mPreIJlxFZ RjVqdPog==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1otZma-00DItQ-JG; Fri, 11 Nov 2022 19:33:47 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id A810D300137; Fri, 11 Nov 2022 20:33:36 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 9154B209EDD10; Fri, 11 Nov 2022 20:33:36 +0100 (CET) Date: Fri, 11 Nov 2022 20:33:36 +0100 From: Peter Zijlstra To: "Li, Xin3" Cc: Paolo Bonzini , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "kvm@vger.kernel.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "hpa@zytor.com" , "Christopherson,, Sean" , "Tian, Kevin" Subject: Re: [RESEND PATCH 5/6] KVM: x86/VMX: add kvm_vmx_reinject_nmi_irq() for NMI/IRQ reinjection Message-ID: References: <20221110061545.1531-1-xin3.li@intel.com> <20221110061545.1531-6-xin3.li@intel.com> <6097036e-063f-5175-72b2-8935b12af853@redhat.com> <6fd26a70-3774-6ae7-73ea-4653aee106f0@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 11, 2022 at 06:06:12PM +0000, Li, Xin3 wrote: > > On Fri, Nov 11, 2022 at 01:48:26PM +0100, Paolo Bonzini wrote: > > > On 11/11/22 13:19, Peter Zijlstra wrote: > > > > On Fri, Nov 11, 2022 at 01:04:27PM +0100, Paolo Bonzini wrote: > > > > > On Intel you can optionally make it hold onto IRQs, but NMIs are > > > > > always eaten by the VMEXIT and have to be reinjected manually. > > > > > > > > That 'optionally' thing worries me -- as in, KVM is currently > > > > opting-out? > > > > > > Yes, because "If the “process posted interrupts” VM-execution control > > > is 1, the “acknowledge interrupt on exit” VM-exit control is 1" (SDM > > > 26.2.1.1, checks on VM-Execution Control Fields). Ipse dixit. Posted > > > interrupts are available and used on all processors since I think Ivy Bridge. > > > > (imagine the non-coc compliant reaction here) > > > > So instead of fixing it, they made it worse :-( > > > > And now FRED is arguably making it worse again, and people wonder why I > > hate virt... > > Maybe I take it wrong, but FRED doesn't make anything worse. Fred entry > code will call external_interrupt() immediately for IRQs. But what about NMIs, afaict this is all horribly broken for NMIs. So the whole VMX thing latches the NMI (which stops NMI recursion), right? But then you drop out of noinstr code, which means any random exception can happen (kprobes #BP, hw_breakpoint #DB, or even #PF due to random nonsense like *SAN). This exception will do IRET and clear the NMI latch, all before you get to run any of the NMI code. Note how the normal NMI code is very careful to clear DR7 and both kprobes and hw_breakpoint know not to accept noinstr code as targets. You threw all that out the window. Also, NMI is IST, and with FRED it will run on a different stack as well, directly calling external_interrupt() doesn't honour that either. > You really really don't like the context how VMX dispatches NMI/IRQs (which has > been there for a long time), right? I really really hate this with a passion. The fact that it's been this way is no justification for keeping it. Crap is crap. Intel should have taken an example of SVM in this regard, and not doubled down and extended this NMI hole to regular IRQs. These are exactly the kind of exception delivery trainwrecks FRED is supposed to fix, except in this case it appears it doesn't :/