Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3660968pxy; Mon, 26 Apr 2021 07:00:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDHRLnyxQKddppAYatGjKshYmtEFC3peSvNyoxcEnNlQ/XaNi9xssbM3/ADtAKOreqJcLb X-Received: by 2002:a65:5b8e:: with SMTP id i14mr6235192pgr.324.1619445643147; Mon, 26 Apr 2021 07:00:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619445643; cv=none; d=google.com; s=arc-20160816; b=DsPeZhc8cWJfkWwRIMNKfz3nUIey48lFOrswX5CQM9Dq85vqe4ReGmbTFjfyFUcK7I dDYAbezReunfJtyfhl5p0wvPQsGPQ6LK8mZz6TVmrg3ZAkaHCXbfrgntXj70CLa/54pr 8PRi/fT/LADn46PflBOy8vIzZpI+dY6sgb89hP9vMgtC3KNKMzeX5f+mPkJJPlFhZI7+ Ker1RZlL0OQ980gDE2PEKc+38YW1xAsV4CDBLeHklYLxz0NT00XLAmCPa96ozcxwZ5zA 4SL2UERvpn4Ku0LN42EPoRpiAhiGjl1hdYac0x07yX7rN0LDOU0ZxJvBnKx7hcqWKV/5 fiTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=WlW8SbZQUeQNthdo3nOdGnmHPB1C2XjsxA8oKrhA37c=; b=MM7HjCjmEVHZ9SmFnV0+vuDtj08ptFdezHib5QikY3ckDtILOvAJqbQjErM2svH0F9 CXYcCy3nWWmdjaydF3BBHQ2Q8n8zHrMbBONu7dGwRDVpm3NV3ePTMHfYdr9yuIQNqRf4 wLRbH4jUHUl1DZJEq9BGRJbQwGd7vHe/H4sj6F48xKGpqv3CuChisYDt91eViDzWbzcC WjzO54tReUYyGNfyYsXECzC2kAsvMp0ob2FndvkcEF+EzkMrMQuZihTHos1grgFxMvvi PQJ8BTzWhFh6/gkPOtW8L4a/AGshI7zDYZDp6+hlxeqCV6GY/U1/dpbOVo00/YabsWI/ JbEw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m14si17582196pfc.148.2021.04.26.07.00.27; Mon, 26 Apr 2021 07:00:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233506AbhDZN7x (ORCPT + 99 others); Mon, 26 Apr 2021 09:59:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:44642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231862AbhDZN7w (ORCPT ); Mon, 26 Apr 2021 09:59:52 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6C11C601FC; Mon, 26 Apr 2021 13:59:09 +0000 (UTC) Date: Mon, 26 Apr 2021 09:59:07 -0400 From: Steven Rostedt To: Maxim Levitsky Cc: Paolo Bonzini , Lai Jiangshan , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, LKML , Josh Poimboeuf , Uros Bizjak , Andi Kleen , Andy Lutomirski Subject: Re: [PATCH v2 2/2] KVM: VMX: Invoke NMI handler via indirect call instead of INTn Message-ID: <20210426095907.698ec524@gandalf.local.home> In-Reply-To: References: <20200915191505.10355-1-sean.j.christopherson@intel.com> <20200915191505.10355-3-sean.j.christopherson@intel.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 26 Apr 2021 14:44:49 +0300 Maxim Levitsky wrote: > On Mon, 2021-04-26 at 12:40 +0200, Paolo Bonzini wrote: > > On 26/04/21 11:33, Lai Jiangshan wrote: > > > When handle_interrupt_nmi_irqoff() is called, we may lose the > > > CPU-hidden-NMI-masked state due to IRET of #DB, #BP or other traps > > > between VMEXIT and handle_interrupt_nmi_irqoff(). > > > > > > But the NMI handler in the Linux kernel*expects* the CPU-hidden-NMI-masked > > > state is still set in the CPU for no nested NMI intruding into the beginning > > > of the handler. This is incorrect. The Linux kernel has for some time handled the case of nested NMIs. It had to, to implement the ftrace break point updates, as it would trigger an int3 in an NMI which would "unmask" the NMIs. It has also been a long time bug where a page fault could do the same (the reason you could never do a dump all tasks from NMI without triple faulting!). But that's been fixed a long time ago, and I even wrote an LWN article about it ;-) https://lwn.net/Articles/484932/ The NMI handler can handle the case of nested NMIs, and implements a software "latch" to remember that another NMI is to be executed, if there is a nested one. And it does so after the first one has finished. -- Steve