Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp206904ybb; Thu, 19 Mar 2020 14:29:58 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvM7oPl4lnPwcMFn0f+6f1DsXiyTaBEmuHoH9AONSZ67JYIvB9+xdYy3cIKiam/1N/K3n3p X-Received: by 2002:aca:cc81:: with SMTP id c123mr3907814oig.74.1584653398045; Thu, 19 Mar 2020 14:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584653398; cv=none; d=google.com; s=arc-20160816; b=g40blFsV7rZ4R7ul28MenW+Y6/fKtwXjP27tBbUHJ0io6ouePRzdb1BRP1iWtXetwB j1m3eyTFlqw63/Me7JC1iqrY1STxtkQDPphC/BV+lgcZp+Ap5Ljcl92VWrd1uOnzvh9a 8Z22j8b/XKwyiPHHiMbyinEXr0Igxx6nuJGPXAjv1H3udM5D++jY7Um3HEQlUWFTXLkq x8rQvPNrQ4EbT/ZFmNFspAuJcVh6XgQcP8jSKPtEvKYpOXVgp/HdCpU1cU0Ek3RXWO+M DckOfbzGDYtAanvmkVvu3bPz1b7zqxeOmOPeeTWGhdnyOg9RFbQRWdw6LS3n0HYMpG+i bYcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=k+WjdSohZ3G9367cqN0h1x05OSV7F//ShQtSY9I+ZDo=; b=cuXWctzYT+gzIx9N3iqJ34hC/mNlWfJoJlJI5/d8tyocf6Gw5CXHX//HNZKUElOLOu 3OM5giilZec2T7d/m7J5+ZKn1rUW4YvyJE9QHEkywOtBEnb4l2oxYjUcqAwOzfGQ9Xh4 Lm+qvh6np4Cga8ATQnUxn/BohH+RloM8OWe2nTfIFkigb22sVaKL4lMW4p5PsAAs59GQ AkQQ7rwsvN8YKJWKe3tHvNsLvCZegzOQ70aMCfGXgzi6MOnz1NlgCdqUM7/6oQhGBAAa jqt3nPrjLiI2H9uJ/kvIpTrFQWNDR7RdKpcKCHbIXoaztHWiFCJ0LnqiUvjI470XahCr 99Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C1zjTJmh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a19si1442187oic.227.2020.03.19.14.29.45; Thu, 19 Mar 2020 14:29:58 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=C1zjTJmh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727032AbgCSV2F (ORCPT + 99 others); Thu, 19 Mar 2020 17:28:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:33844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbgCSV2E (ORCPT ); Thu, 19 Mar 2020 17:28:04 -0400 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4774A20772 for ; Thu, 19 Mar 2020 21:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584653283; bh=wDHKIdt3Y3vhWUMG3wIbeCs2/G5gOP3qUw5RVSybfDM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=C1zjTJmhscb/kf6Gr/fLaWAmP4m/XMANCnSraK8P22tZ6JgeDtk3jsSDi3+5i3oM3 3WJXtWqGhmvVH1YYl8ntlKGNCat6JnlIwaR+8D+lFJ2u+MNgBOIBFv3BGQfc+CFBNG E/Trc2xBeKw4sqF1qJ75dnXSuaEg/zoAPhUQVf+g= Received: by mail-wm1-f54.google.com with SMTP id g62so4154103wme.1 for ; Thu, 19 Mar 2020 14:28:03 -0700 (PDT) X-Gm-Message-State: ANhLgQ0YZPG56Nzx3Pbv2olobcO0GNlam7vUtOolx0ck0sSfD93CiG6A XUVvFoDAU9y7B9VDO1PcsiQqlftYv3Sdqis+hpgWnw== X-Received: by 2002:a1c:b0c3:: with SMTP id z186mr5806142wme.36.1584653281734; Thu, 19 Mar 2020 14:28:01 -0700 (PDT) MIME-Version: 1.0 References: <20200319091407.1481-1-joro@8bytes.org> <20200319091407.1481-71-joro@8bytes.org> <20200319160749.GC5122@8bytes.org> <20200319192654.GD611@suse.de> In-Reply-To: <20200319192654.GD611@suse.de> From: Andy Lutomirski Date: Thu, 19 Mar 2020 14:27:49 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 70/70] x86/sev-es: Add NMI state tracking To: Joerg Roedel Cc: Andy Lutomirski , Joerg Roedel , X86 ML , "H. Peter Anvin" , Dave Hansen , Peter Zijlstra , Thomas Hellstrom , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , LKML , kvm list , Linux Virtualization Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 19, 2020 at 12:26 PM Joerg Roedel wrote: > > On Thu, Mar 19, 2020 at 11:40:39AM -0700, Andy Lutomirski wrote: > > > Nope. A nested NMI will reset the interrupted NMI's return frame to > > cause it to run again when it's done. I don't think this will have > > any real interaction with #VC. There's no longjmp() here. > > Ahh, so I misunderstood that part, in this case your proposal of sending > the NMI-complete message right at the beginning of do_nmi() should work > just fine. I will test this and see how it works out. > > > I certainly *like* preventing nesting, but I don't think we really > > want a whole alternate NMI path just for a couple of messed-up AMD > > generations. And the TF trick is not so pretty either. > > Indeed, if it could be avoided, it should. > > > > > > > This causes us to pop the NMI frame off the stack. Assuming the NMI > > > > restart logic is invoked (which is maybe impossible?), we get #DB, > > > > which presumably is actually delivered. And we end up on the #DB > > > > stack, which might already have been in use, so we have a potential > > > > increase in nesting. Also, #DB may be called from an unexpected > > > > context. > > > > > > An SEV-ES hypervisor is required to intercept #DB, which means that the > > > #DB exception actually ends up being a #VC exception. So it will not end > > > up on the #DB stack. > > > > With your patch set, #DB doesn't seem to end up on the #DB stack either. > > Right, it does not use the #DB stack or shift-ist stuff. Maybe it > should, is this needed for anything else than making entry code > debugable by kgdb? AIUI the shift-ist stuff is because we aren't very good about the way that we handle tracing right now, and that can cause a limited degree of recursion. #DB uses IST for historical reasons that don't necessarily make sense. Right now, we need it for only one reason: the MOV SS issue. IIRC this isn't actually triggerable without debugging enabled -- MOV SS with no breakpoint but TF on doesn't seem to malfunction quite as badly. --Andy > > Regards, > > Joerg