Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4087806pxy; Mon, 26 Apr 2021 18:01:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyg1+MasNrjos7Brd+Xb7oTvPYvaoRWH+jwn2Q+4qVv4bGKDMiJSQj9Lq+bxI6ZOF/tNe0a X-Received: by 2002:a17:907:8319:: with SMTP id mq25mr5337425ejc.441.1619485309695; Mon, 26 Apr 2021 18:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619485309; cv=none; d=google.com; s=arc-20160816; b=rRyLMI7v/BXWbl9OANtwfsg2ZWw8ke9om4wBZb5MebQPparRZKOX+eJbVdZuf1spip rwAxZigbcvnNmdtvna5bu7s8vpRK5gxma0JJMqBvBtKzG7ud7FkB4NiFYCGk6Eq0JKCJ myFGkLYtMamIoYbo4IVImCfaxOISAtZ66S3atghyD41sw6mkMV+Ri//qqPvUfkTI1Tbu qHEG2V4wxGmID2P4Lw7hGlOIEjTYCCkP8HnO5Xc9LcqxWnUytTFoIYDl5VqrqDpjoK/E VX6pdWZUfliaIdc4/PFtCAzl3v8tuG3EAP0tR8Kv8UoZ7rgI3A0RylPGdDBOwS2A3qEI ARVA== 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=opD7QXLEbLKj4Lfyty040VJAwD6XXRL/GIqJOzSy0rA=; b=UTQ9mHKV86EI/l4clCzwRjTYiO2pg3E2aUqaXD1kC1C3APl3suXcsFBEioCKV6MSq7 Q3ea/ECJmUFDM3KGUQG7DliJ0+j6OjJr+OP9tptpx+i8ODQKUrYTcCLIhSoiOd/dyHbA YkT0HtB7Ie/C8K1GBO+VCReU9wcb6jHfcIUPP9LSGSXMW7Z3s67ao+fRHocQDExuLc1I ztV14tsXGiG+q2PnuLOA+sKlNei0A+0E5oWQHcsPHKqjWYFeEeANQ3MVeVsjcSkHC5Gr qV1HQ+06IIsj1Zpe8fR/Ti5XyGJgANBzTv1WSQN9nYJ+Cio6cj8u+L2AhAngQvHhjJOm GjrQ== 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 p5si1228063edt.42.2021.04.26.18.01.25; Mon, 26 Apr 2021 18:01:49 -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 S235290AbhD0BBH (ORCPT + 99 others); Mon, 26 Apr 2021 21:01:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:50050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232022AbhD0BBF (ORCPT ); Mon, 26 Apr 2021 21:01:05 -0400 Received: from oasis.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 30CAF60BBB; Tue, 27 Apr 2021 01:00:22 +0000 (UTC) Date: Mon, 26 Apr 2021 21:00:20 -0400 From: Steven Rostedt To: Lai Jiangshan Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, LKML , Josh Poimboeuf , Uros Bizjak , Andi Kleen , Andy Lutomirski , Sean Christopherson , Maxim Levitsky Subject: Re: [PATCH v2 2/2] KVM: VMX: Invoke NMI handler via indirect call instead of INTn Message-ID: <20210426210020.417e3cfc@oasis.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.3 (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 Tue, 27 Apr 2021 08:54:37 +0800 Lai Jiangshan wrote: > > However, I'm not sure which of the two situations is better: entering > > the NMI handler on the IST without setting the hidden NMI-blocked flag > > could be a recipe for bad things as well. > > The change makes the ASM NMI entry called on the kernel stack. But the > ASM NMI entry expects it on the IST stack and it plays with "NMI executing" > variable on the IST stack. In this change, the stranded ASM NMI entry > will use the wrong/garbage "NMI executing" variable on the kernel stack > and may do some very wrong thing. I missed this detail. > > Sorry, in my reply, "the NMI handler" meant to be the ASM entry installed > on the IDT table which really expects to be NMI-masked at the beginning. > > The C NMI handler can handle the case of nested NMIs, which is useful > here. I think we should change it to call the C NMI handler directly > here as Andy Lutomirski suggested: Yes, because that's the way x86_32 works. > > On Mon, Apr 26, 2021 at 11:09 PM Andy Lutomirski wrote: > > The C NMI code has its own reentrancy protection and has for years. > > It should work fine for this use case. > > I think this is the right way. Agreed. -- Steve