From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0473C433ED for ; Mon, 26 Apr 2021 13:59:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8CBFD6103E for ; Mon, 26 Apr 2021 13:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233560AbhDZN7x (ORCPT ); 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: kvm@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