Message ID | 20231122170106.270266-3-jpiotrowski@linux.microsoft.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1467355vqb; Wed, 22 Nov 2023 09:02:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHESI1dJ6BBixNpFfRafBJ3CByhRECVPrjRy+ia4tvhsEOBMFnbJKgoHysDGnXAs7fZyGrR X-Received: by 2002:a05:6808:1aa9:b0:3b2:e07e:5062 with SMTP id bm41-20020a0568081aa900b003b2e07e5062mr2635557oib.52.1700672543273; Wed, 22 Nov 2023 09:02:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700672543; cv=none; d=google.com; s=arc-20160816; b=WK1CTP+1hKOlf8H9Hc+g629uEYZr6WXZziHqsUh2KnWZvT5j+Dzh7h3RBqcEUEAuKh s1Ymgr7OXasez47nf8LIEFoXSYLwT31qpFNKfCtVuf5GgjNWlvS5lRdbisX+pytdcy2X +bdtRGPwyQwPokXlL2oGYvBdoIWkfCsWI1gNVOWYzqfRpX4+6dO7eCP51ZNIZfhFNi1M 7Si6LCqzUTIThOSF25tSERQV4bE6Jpm9nGJOQnJsPblwJbjAV+nkSl2kYrEgCrGFS2is bUVkvmmb817aAKJKOhJYgbGMOrZIb1L9PIYNpZ6Dk1ypvSRlGHrbVA2Lnl6lUPhVSD9i Je2Q== 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:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=9wgjWP/62NvaWRr+CGCSQIegQce2mbkL4aNWuVLLmPI=; fh=E8ULNJBgdDg9an7hIBnyD2FCRjgTqVL5oPJZZj2SaL0=; b=rA3YdYhCYLUxV4sHaQYWQvd4rfQsGkNbH3OZKeRCoudX91Qy5gHrncFemIgby71lag xteaefFh/4BnfRIzWijI+EzmLvc8tDAcdHKVNud9rgpMIJqWEpvb6rGvTMN9xQx/3F7t R7HMFAojb5SnZt28AsZPMNpFjxay63dOTmNGg77JGgRfc4i05sit8tYpk7KlP1l62eWY KdsXxGXPsWv1P2vgxNAK5TV7yP3dZnvwK8ZloxoHPiwawddrc/vL9oc5jHDiiWWgEIJG VBvpyElBBRD7eMErMp/pz5BEcG6VUMrmNEebSHbsTNb0Zv1Q6hv1rDaL++vm3CfOQsy7 PiIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=cQ5qDyv2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id ep7-20020a056808444700b003b2e7937184si4928294oib.114.2023.11.22.09.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 09:02:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=cQ5qDyv2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 83E5D8236247; Wed, 22 Nov 2023 09:02:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343876AbjKVRBw (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Wed, 22 Nov 2023 12:01:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232906AbjKVRBu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 22 Nov 2023 12:01:50 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9ABB29F; Wed, 22 Nov 2023 09:01:46 -0800 (PST) Received: from localhost.localdomain (77-166-152-30.fixed.kpn.net [77.166.152.30]) by linux.microsoft.com (Postfix) with ESMTPSA id 3567820B74C2; Wed, 22 Nov 2023 09:01:42 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3567820B74C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1700672506; bh=9wgjWP/62NvaWRr+CGCSQIegQce2mbkL4aNWuVLLmPI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cQ5qDyv2Rah3MoXsEFMlU8EIn49kbZ5NPUGql50qiS7Za5mSWv8lv9Vss99FM6i+h BvCUBCqrAoBSX8/lWTVA/wcDN6HGodpQUlCgVH79GAT+bnyrcQhs4ZjDiLXbodRKlb FItHxXC4nnexkyPpElSU/phmqHSIgFxyBu6LjFRg= From: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com> To: linux-kernel@vger.kernel.org, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, "H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, Michael Kelley <mhkelley58@gmail.com>, Nikolay Borisov <nik.borisov@suse.com>, Peter Zijlstra <peterz@infradead.org>, Thomas Gleixner <tglx@linutronix.de>, Tom Lendacky <thomas.lendacky@amd.com>, x86@kernel.org, Dexuan Cui <decui@microsoft.com> Cc: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com>, linux-hyperv@vger.kernel.org, stefan.bader@canonical.com, tim.gardner@canonical.com, roxana.nicolescu@canonical.com, cascardo@canonical.com, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, sashal@kernel.org, stable@vger.kernel.org Subject: [PATCH v1 3/3] x86/tdx: Provide stub tdx_accept_memory() for non-TDX configs Date: Wed, 22 Nov 2023 18:01:06 +0100 Message-Id: <20231122170106.270266-3-jpiotrowski@linux.microsoft.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231122170106.270266-1-jpiotrowski@linux.microsoft.com> References: <20231122170106.270266-1-jpiotrowski@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 22 Nov 2023 09:02:17 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783284413167567273 X-GMAIL-MSGID: 1783284413167567273 |
Series |
[v1,1/3] x86/tdx: Check for TDX partitioning during early TDX init
|
|
Commit Message
Jeremi Piotrowski
Nov. 22, 2023, 5:01 p.m. UTC
When CONFIG_INTEL_TDX_GUEST is not defined but CONFIG_UNACCEPTED_MEMORY=y is,
the kernel fails to link with an undefined reference to tdx_accept_memory from
arch_accept_memory. Provide a stub for tdx_accept_memory to fix the build for
that configuration.
CONFIG_UNACCEPTED_MEMORY is also selected by CONFIG_AMD_MEM_ENCRYPT, and there
are stubs for snp_accept_memory for when it is not defined. Previously this did
not result in an error when CONFIG_INTEL_TDX_GUEST was not defined because the
branch that references tdx_accept_memory() was being discarded due to
DISABLE_TDX_GUEST being set.
Cc: <stable@vger.kernel.org> # v6.5+
Fixes: 75d090fd167a ("x86/tdx: Add unaccepted memory support")
Signed-off-by: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com>
---
arch/x86/include/asm/shared/tdx.h | 4 ++++
1 file changed, 4 insertions(+)
Comments
On Wed, Nov 22, 2023 at 06:01:06PM +0100, Jeremi Piotrowski wrote: > When CONFIG_INTEL_TDX_GUEST is not defined but CONFIG_UNACCEPTED_MEMORY=y is, > the kernel fails to link with an undefined reference to tdx_accept_memory from > arch_accept_memory. Provide a stub for tdx_accept_memory to fix the build for > that configuration. > > CONFIG_UNACCEPTED_MEMORY is also selected by CONFIG_AMD_MEM_ENCRYPT, and there > are stubs for snp_accept_memory for when it is not defined. Previously this did > not result in an error when CONFIG_INTEL_TDX_GUEST was not defined because the > branch that references tdx_accept_memory() was being discarded due to > DISABLE_TDX_GUEST being set. And who unsets it now?
On 23/11/2023 15:11, Kirill A. Shutemov wrote: > On Wed, Nov 22, 2023 at 06:01:06PM +0100, Jeremi Piotrowski wrote: >> When CONFIG_INTEL_TDX_GUEST is not defined but CONFIG_UNACCEPTED_MEMORY=y is, >> the kernel fails to link with an undefined reference to tdx_accept_memory from >> arch_accept_memory. Provide a stub for tdx_accept_memory to fix the build for >> that configuration. >> >> CONFIG_UNACCEPTED_MEMORY is also selected by CONFIG_AMD_MEM_ENCRYPT, and there >> are stubs for snp_accept_memory for when it is not defined. Previously this did >> not result in an error when CONFIG_INTEL_TDX_GUEST was not defined because the >> branch that references tdx_accept_memory() was being discarded due to >> DISABLE_TDX_GUEST being set. > > And who unsets it now? > Who unsets what now? DISABLE_TDX_GUEST still works the same as before, but patch 2 changed the check in arch_accept_memory() to be more specific (cc_platform_has(CC_ATTR_TDX_MODULE_CALLS)). The stub should have been there all along for CONFIG_AMD_MEM_ENCRPYT=y && CONFIG_INTEL_TDX_GUEST=n configs, but it happened to work without it.
diff --git a/arch/x86/include/asm/shared/tdx.h b/arch/x86/include/asm/shared/tdx.h index 7513b3bb69b7..58cdbaac3d5b 100644 --- a/arch/x86/include/asm/shared/tdx.h +++ b/arch/x86/include/asm/shared/tdx.h @@ -91,7 +91,11 @@ struct tdx_module_output { u64 __tdx_module_call(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9, struct tdx_module_output *out); +#ifdef CONFIG_INTEL_TDX_GUEST bool tdx_accept_memory(phys_addr_t start, phys_addr_t end); +#else +static inline bool tdx_accept_memory(phys_addr_t start, phys_addr_t end) { return false; } +#endif /* * The TDG.VP.VMCALL-Instruction-execution sub-functions are defined