Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1720428rwb; Thu, 8 Dec 2022 14:30:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf7V+HN/1dtHcliWxhQ88qQZzKCuGQCf7/V8EcxrjiY2UpB7KQ7TVXkmmXfBdw3t/cFKXD9y X-Received: by 2002:a17:906:7193:b0:7c1:39e:db7e with SMTP id h19-20020a170906719300b007c1039edb7emr3945573ejk.59.1670538658347; Thu, 08 Dec 2022 14:30:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670538658; cv=none; d=google.com; s=arc-20160816; b=q+sA6lcyDtntrxXUqVoj+puwU+4PqzzVausT5fQufT56pshocgLL/bXi2P21v4bkBy V5k6ql8MdikIt2twN0JE2h23mpRIJKp8B5jAaANz7oSlfy8cJvvJjjsmaeDSIjlEPqif qcj512M1ZNUW9eWDNJHtBFnuORczKMRFp1q6Ijp1enDZOmOYnFIQpma8gvUuIK2BehjJ PujfFE/F9koTev3JE0kvewf7o7HKSGG/RHfJKuWx1mTRSdNcngPdfixxkqPS3uJY+NRR 0ou5afGGZ4b1lXTysEnUKk4yc5kGZCJN8avbGLmPyNTSJGlg8He5F0yazDZ7i09hUSwx y1Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=GcfCs1furkqjeJ9JsMjH5B9zmyb9nXl02haRXvdO0Rs=; b=B99Tp0+6LETVqc3yDMrLnEIBW2IUsbtgbA+XNNlg4ggC5v+0M898vq5HvhgKZ0cwmL kBDHWAv+x5PlQlIzKrssDesRNKTHBoKQkisJhLXbPMrs2HeuTyswEy/r1b2Sq8ZizwwZ GteK+t1X1aQYMyjC2IFnL/i7tbzgE59WMND201c7nMuyjZjSCpAZ9e0pp3Qr4rnl3dzm 5igVrlNFTpWneV3vgpud3Y/TTZgZbNi2PTE9x8S/TOqdMCn+eq0J/GaIg+4/xU7EbCwb xvpBDN7hJRyu5oTFmQL+raiI11aFlVovSC2gN62AAYroY5J6tNhS9+5Two8/bO7QLQ+V 1Ddw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm3 header.b=nmQjB3rz; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=nLChVJvn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hg2-20020a1709072cc200b007c0d4287966si13633905ejc.423.2022.12.08.14.30.34; Thu, 08 Dec 2022 14:30:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm3 header.b=nmQjB3rz; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=nLChVJvn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229967AbiLHWNG (ORCPT + 73 others); Thu, 8 Dec 2022 17:13:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229905AbiLHWMx (ORCPT ); Thu, 8 Dec 2022 17:12:53 -0500 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C811EBF0 for ; Thu, 8 Dec 2022 14:12:51 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 3D5035C00FF; Thu, 8 Dec 2022 17:12:51 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 08 Dec 2022 17:12:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1670537571; x=1670623971; bh=Gc fCs1furkqjeJ9JsMjH5B9zmyb9nXl02haRXvdO0Rs=; b=nmQjB3rzsudjZsJNsX KKvXkmJe3NKCsowJNyE5E/SXKuVrZ6KDZEZIC+tdcWT0wmBJ9mdEpXiSTsgir8oP ySfAChOsxcJx+Nidk/q4fvO4Z3NkoMXqF6cqvWcPW1ViBrjZ+CMD5PJFDZTiJhPS 1Ce4V9DO/WchgWgYV/P3UYfyhn2WHXMlmG2Pj7PNPwNCvj+aUUt5ZgX5JPfRVRyM I7VP+mjHbVerhk9CPtp7PKGSlDG+iv4/qM7agOm4sk8GJEROXDqYPI7GN1O1+WAJ F+f3HeiPI27FFid9UyN1ukQCfgTVYfMOGcbsPnGIeml8A85fjWKeigRoxJSYo+um gqUg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1670537571; x=1670623971; bh=GcfCs1furkqjeJ9JsMjH5B9zmyb9 nXl02haRXvdO0Rs=; b=nLChVJvnkQKdG60uB2lg435tQIefvrwpLcNvfuJnmhEC d+yu3uKbWMyvVjsMVBodTX/u5KjyoS4pYG0WB7QNLqRQN0hdbfcPQw2riE9tIdrJ I6aR0Slh+IrjFebyfJ/pV8DhIqHSnTbDkduiIRqQF6M/dB+FW+ofSfSlXJt1jgJ3 BuquafkfHP6Sk/LbXjGCfL09Vcrp3pZ0jmX8ynofgIgj62A7uKqmCjLYbgEHZKHd ZllFV27BgykyhnW4bOHfnAMK6L34IFjDKJibtIz2ah1WFECncnIBaPN08ZsRu6Mi SSa+2DNVDBq7h24gdlzLR/X/YM6hPbxerO0h26jlYA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvddtgdduiedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdttddttddtvdenucfhrhhomhepfdfmihhr ihhllhcutedrucfuhhhuthgvmhhovhdfuceokhhirhhilhhlsehshhhuthgvmhhovhdrnh grmhgvqeenucggtffrrghtthgvrhhnpefhieeghfdtfeehtdeftdehgfehuddtvdeuheet tddtheejueekjeegueeivdektdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehkihhrihhllhesshhhuhhtvghmohhvrdhnrghmvg X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 8 Dec 2022 17:12:50 -0500 (EST) Received: by box.shutemov.name (Postfix, from userid 1000) id CEF48109CB7; Fri, 9 Dec 2022 01:12:48 +0300 (+03) Date: Fri, 9 Dec 2022 01:12:48 +0300 From: "Kirill A. Shutemov" To: Tom Lendacky Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Michael Roth , Joerg Roedel , Andy Lutomirski , Peter Zijlstra Subject: Re: [PATCH v6 5/5] x86/sev: Add SNP-specific unaccepted memory support Message-ID: <20221208221248.slltzm5ehnbltdee@box.shutemov.name> References: <20221207014933.8435-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 08, 2022 at 09:29:13AM -0600, Tom Lendacky wrote: > Add SNP-specific hooks to the unaccepted memory support in the boot > path (__accept_memory()) and the core kernel (accept_memory()) in order > to support booting SNP guests when unaccepted memory is present. Without > this support, SNP guests will fail to boot and/or panic() when unaccepted > memory is present in the EFI memory map. > > The process of accepting memory under SNP involves invoking the hypervisor > to perform a page state change for the page to private memory and then > issuing a PVALIDATE instruction to accept the page. > > Since the boot path and the core kernel paths perform similar operations, > move the pvalidate_pages() and vmgexit_psc() functions into sev-shared.c > to avoid code duplication. > > Create the new header file arch/x86/boot/compressed/sev.h because adding > the function declaration to any of the existing SEV related header files > pulls in too many other header files, causing the build to fail. > > Signed-off-by: Tom Lendacky > --- > arch/x86/Kconfig | 1 + > arch/x86/boot/compressed/mem.c | 3 + > arch/x86/boot/compressed/sev.c | 54 ++++++++++++++- > arch/x86/boot/compressed/sev.h | 23 +++++++ > arch/x86/include/asm/sev.h | 3 + > arch/x86/kernel/sev-shared.c | 103 +++++++++++++++++++++++++++++ > arch/x86/kernel/sev.c | 112 ++++---------------------------- > arch/x86/mm/unaccepted_memory.c | 4 ++ > 8 files changed, 204 insertions(+), 99 deletions(-) > create mode 100644 arch/x86/boot/compressed/sev.h > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index d88f61940aa7..0704d4795919 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -1549,6 +1549,7 @@ config AMD_MEM_ENCRYPT > select INSTRUCTION_DECODER > select ARCH_HAS_CC_PLATFORM > select X86_MEM_ENCRYPT > + select UNACCEPTED_MEMORY > help > Say yes to enable support for the encryption of system memory. > This requires an AMD processor that supports Secure Memory I think it misses "depends on EFI_STUB". The code I've submitted contains "select EFI_STUB", but it causes build issues for some configurations. I've changed it to "depends on" in git. -- Kiryl Shutsemau / Kirill A. Shutemov