Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5081124ybv; Tue, 11 Feb 2020 08:50:19 -0800 (PST) X-Google-Smtp-Source: APXvYqwGtwNbbYKF8yqYwUk7Pe81jSoaeksL8F+asIV9By+70lFUjOtzKPmBmxlZVE1lSDjiucgm X-Received: by 2002:a05:6830:1385:: with SMTP id d5mr6155820otq.61.1581439819123; Tue, 11 Feb 2020 08:50:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581439819; cv=none; d=google.com; s=arc-20160816; b=Bkjd80Lzb330+il+MYUNt4X0DXT8IHoVnI1Tn6cbCNEK/HHRzCz7Q9vzECri6VnqMi bc/M8/1PbWMhss7QHVYo8cibCsKE5oFI4oXnER8VynH8ID0wggs2QTXR3hlBviXvIO/R 2amF3kYC6bv7GZPI+NY+JAm2vcbZiHAMrBFM1w4HQCiAYFN2CTqv33NYdPIOyK6acMgH v5ZUm3CzkYfRsOMUmtuLou0Rf3gs4u0MnUWQhd8omvbwY9V+HYRRzY/Aw2Sa+IkHztW+ z7mTlLHj0dy17QdKfGgmBJWGipI7H7K06BEa30mNDtEtXRnrC7IRLUafBgjKgGkHM51A iwkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qWnHe7FrDz9eGFNLgL+pqzJ1ZkJDW34fv36AbfxXMr8=; b=zIyYFoOl4if9qG11hvVTFGWoIvdqAYRXC57Ei+8ZDLE0J+seQbNDkGHPJC67qltG9L NIf4xvmq1yqVL3yJ8loKZAV220+rnhcEv7rpY0/bo2WIOrgXJpICxA99u+cByL46Y2X+ LoMElCw2ucN4+E3gzNAzJVgACm9l+7YbeK8lYc+nFX/e73Vs7MWTbg7BQzJem+C7DljA Dx2uKhe0pWSGkNYGs8fvjWVeo1U7I8ixOZ6BzzTtIXcLAS9xvl0LSl7d9ZVcNBpdTBtm 4wDTrd0ugERPmEaTiw60j7fTy+wmufUUqod5NlGtunDZWhDMo3A1PtJmLvodReOI5EQA 0Lqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=cY+vxpu+; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si2005929otq.217.2020.02.11.08.50.06; Tue, 11 Feb 2020 08:50:19 -0800 (PST) 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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=cY+vxpu+; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730281AbgBKOua (ORCPT + 99 others); Tue, 11 Feb 2020 09:50:30 -0500 Received: from merlin.infradead.org ([205.233.59.134]:42424 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728047AbgBKOua (ORCPT ); Tue, 11 Feb 2020 09:50:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=qWnHe7FrDz9eGFNLgL+pqzJ1ZkJDW34fv36AbfxXMr8=; b=cY+vxpu+iRqOion51hgN8KX8MM 1ztoOSVH+loxUd+9cbzHUqhSuxSF3LOfJv8duUXhxKH2Z1IHwKMBH/at+c/Cr80ky3sxlR8qCQGvU aVr63GLxbE7ign3Eo81P5zChu8DcE0DuXWqtrdUZzLUQ6fsI5sw8gFrovEGfgeXMmH96vtXSW4wfO u3TY0WQCVUDMYijkbo0rt/loz5YVkvXyit/W4w49yjooJCHdaGaBY+7tkvMXitWtLnxCLfJi5reXz /knDm8dNgLTOgNnS5d+atTm7sAaC7tWVOA+UV4/lKoCh28QH0WVTf2P1CeSseDiFdoJg0jFZcRFC0 XIvV5OOg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1Wra-00065I-Nz; Tue, 11 Feb 2020 14:50:10 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id EE03C300446; Tue, 11 Feb 2020 15:48:19 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id B1B3D2B8BECD3; Tue, 11 Feb 2020 15:50:08 +0100 (CET) Date: Tue, 11 Feb 2020 15:50:08 +0100 From: Peter Zijlstra To: Joerg Roedel Cc: x86@kernel.org, hpa@zytor.com, Andy Lutomirski , Dave Hansen , Thomas Hellstrom , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, Joerg Roedel Subject: Re: [RFC PATCH 00/62] Linux as SEV-ES Guest Support Message-ID: <20200211145008.GT14914@hirez.programming.kicks-ass.net> References: <20200211135256.24617-1-joro@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200211135256.24617-1-joro@8bytes.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 11, 2020 at 02:51:54PM +0100, Joerg Roedel wrote: > NMI Special Handling > -------------------- > > The last thing that needs special handling with SEV-ES are NMIs. > Hypervisors usually start to intercept IRET instructions when an NMI got > injected to find out when the NMI window is re-opened. But handling IRET > intercepts requires the hypervisor to access guest register state and is > not possible with SEV-ES. The specification under [1] solves this > problem with an NMI_COMPLETE message sent my the guest to the > hypervisor, upon which the hypervisor re-opens the NMI window for the > guest. > > This patch-set sends the NMI_COMPLETE message before the actual IRET, > while the kernel is still on a valid stack and kernel cr3. This opens > the NMI-window a few instructions early, but this is fine as under > x86-64 Linux NMI-nesting is safe. The alternative would be to > single-step over the IRET, but that requires more intrusive changes to > the entry code because it does not handle entries from kernel-mode while > on the entry stack. > > Besides the special handling above the patch-set contains the handlers > for the #VC exception and all the exit-codes specified in [1]. Oh gawd; so instead of improving the whole NMI situation, AMD went and made it worse still ?!?