Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1330597rdb; Tue, 30 Jan 2024 15:36:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFkuu6Uk6JDgyI8vyivpAQtPL981LcVxVccrUwt1FJ3cLcEJ5I78S9+uU+6fevP02CIY0za X-Received: by 2002:a05:6512:15a3:b0:510:16b8:7a55 with SMTP id bp35-20020a05651215a300b0051016b87a55mr93252lfb.62.1706657797846; Tue, 30 Jan 2024 15:36:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706657797; cv=pass; d=google.com; s=arc-20160816; b=muZlWULlmHnub6LaIlj5dchZ1iReoNE6lIS/UxX0jvswiqaLphH6dnr3LcQbebFhxN 9LiHyy4udPDwwcAtIdsTaXS1UhYcLs1cKeEQmTQDlSl8EZaTdFogfUUiGuo87c9YKjPp OTRD3KUsu0yO7epOfajeL98viaJ2GYQ7v0dYV7lf6Ya09FTzeRyz04aLWAv7ii6nN+0Z DqPmm83OlyhUotOaRlBFUtJ+rDN2W460rvvkFNCk8CiBBmWpAT4rSyD0HwhlhGYoPf7o a5UKcCZnqCGcNfdjsVEZr81lSckFR9d5N7ZaaBM3qoEHL/vBijXMA2rappzlihYsZ5e1 nVGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=axcbRM2llP/14TobXwOGMEBDoZYGUZAoPtXlyDA8878=; fh=+bYgbVoLWBp55M2uhBAaakGZpp9VHheO9xksoS6vmhY=; b=CqiwZ/a2mMnHjqHVZgZd0YTLib2fKwZOJIjVW9fn/ni/9XjpkhzT+FeAlO+yOqPUuN 5M3uQXlQUwo1RH7DPNdFBHw0uHJ7/gXMlmSVz3jgeoq4M8m3Gj/LlrHIXrQOs1pFk1pz rUXO4zumSSvMrHTB4h8n/ciLV3WJ9trdhiyz71UOYfLsw5eGwTAs+LA3tkKS22+hOU3y 0O3acTOvaR5oXOZCadyu6+XeaSZgnepxtKHtm327n/YLke1et9OWSbCK5jrGrcFDbuUl +Ag4AqnGp/f2KNlE22VqHvst54wgYrDKBy4MkWPZv6M13DTWXzQAARw0+Uiz9jSQho0j 2e1Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UQBTpCVV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-45486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45486-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q25-20020a1709060e5900b00a2dd05df9d5si5014525eji.437.2024.01.30.15.36.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 15:36:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UQBTpCVV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-45486-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45486-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6C8851F23007 for ; Tue, 30 Jan 2024 23:36:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEC9A79957; Tue, 30 Jan 2024 23:36:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UQBTpCVV" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 109917EF06; Tue, 30 Jan 2024 23:36:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706657789; cv=none; b=loG3Dug4XWSRgyHbWkhBYloH/yBi0vxnIqgIptQeX8wN3/JnUDkTpprx0B38IpKqBAPXfsVqX/dTPdYb8/6c0rfDXEjUb717a6IFbgu8Iurr2v2YP6X992k6QdBFo0ItxvScCmjbmEuewFsPtVvRISNS8MxCCEcn/hQ5n6jKYAo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706657789; c=relaxed/simple; bh=sLwv6+dGl8oHWbDEHeRaajMfbIGR/+C6zSrAA66CSOU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=uB2CsMFNPH6ffMcz2UFQD7e27Wg1VgO62KH9V2zi3btCYZcHifBnBGOq+VCe/bAKPhW1VeDxX7MWSt9shEE+YHteUMgvsNfIsDK8lCJhMmx9sOjQfkjMj4dJbpCLOtF6FsVxLBz6Yj1rspqcJi51gFhh8EbKSk1EtT3X5BXEVMU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UQBTpCVV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92910C433F1; Tue, 30 Jan 2024 23:36:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706657788; bh=sLwv6+dGl8oHWbDEHeRaajMfbIGR/+C6zSrAA66CSOU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=UQBTpCVVO1vP7QYDHfbZW4bRc3cwWDKU9QY6qudNNcBhelR5M3FDpXwKpx2p+S9h2 R5PSM+p/KMJjDpolr/N2wZG0m302QXEUeAlETB6f49O1lqpNgUMUAx36MxbyjShXB6 90bnJK3XhGdoeoja2Mzm0VWicbiCumPsaFTO5anj6JPfv6KoGyPMdgKRgScy6RohUZ y+CSu9X5Edg1U+iKEx9OAOwnwzttaj/Nn0Q1fsYrSwZESPL3prHmOwL2wsxIgc08Tz CcqbtUl0lPdZq1x7fuoKPJ58jBXpMyqEjlUHn1Pr8qjixTmi+Bmc1Zrs66KgUEG3Rs 5prOaj2i12DNA== Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-51124d43943so184294e87.2; Tue, 30 Jan 2024 15:36:28 -0800 (PST) X-Gm-Message-State: AOJu0YzxlnvN65/GGEdoyuwEKIiW9Ul6e7rRu5DyG05lxf+fw5jrUwyE KIcrKPx/nUarj4W1A/CQVUiiNMySI6Szwl0Se9CFy5L4cf6OUC0vWUV1j4ADY8q4monVbR61E9K QutmpnvIna2nChLYPO6EFG39p7Uc= X-Received: by 2002:a19:6518:0:b0:511:18f5:9480 with SMTP id z24-20020a196518000000b0051118f59480mr75132lfb.60.1706657786812; Tue, 30 Jan 2024 15:36:26 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240129180502.4069817-21-ardb+git@google.com> <20240129180502.4069817-35-ardb+git@google.com> In-Reply-To: From: Ard Biesheuvel Date: Wed, 31 Jan 2024 00:36:15 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 14/19] x86/coco: Make cc_set_mask() static inline To: Kevin Loughlin Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Tom Lendacky , Dionna Glaze , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Andy Lutomirski , Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Justin Stitt , Kees Cook , Brian Gerst , linux-arch@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 31 Jan 2024 at 00:16, Kevin Loughlin wro= te: > > On Mon, Jan 29, 2024 at 10:06=E2=80=AFAM Ard Biesheuvel wrote: > > > > From: Ard Biesheuvel > > > > Setting the cc_mask global variable may be done early in the boot while > > running fromm a 1:1 translation. This code is built with -fPIC in order > > to support this. > > > > Make cc_set_mask() static inline so it can execute safely in this > > context as well. > > > > Signed-off-by: Ard Biesheuvel > > --- > > arch/x86/coco/core.c | 7 +------ > > arch/x86/include/asm/coco.h | 8 +++++++- > > 2 files changed, 8 insertions(+), 7 deletions(-) > > > > diff --git a/arch/x86/coco/core.c b/arch/x86/coco/core.c > > index eeec9986570e..d07be9d05cd0 100644 > > --- a/arch/x86/coco/core.c > > +++ b/arch/x86/coco/core.c > > @@ -14,7 +14,7 @@ > > #include > > > > enum cc_vendor cc_vendor __ro_after_init =3D CC_VENDOR_NONE; > > -static u64 cc_mask __ro_after_init; > > +u64 cc_mask __ro_after_init; > > > > static bool noinstr intel_cc_platform_has(enum cc_attr attr) > > { > > @@ -148,8 +148,3 @@ u64 cc_mkdec(u64 val) > > } > > } > > EXPORT_SYMBOL_GPL(cc_mkdec); > > - > > -__init void cc_set_mask(u64 mask) > > -{ > > - cc_mask =3D mask; > > -} > > diff --git a/arch/x86/include/asm/coco.h b/arch/x86/include/asm/coco.h > > index 6ae2d16a7613..ecc29d6136ad 100644 > > --- a/arch/x86/include/asm/coco.h > > +++ b/arch/x86/include/asm/coco.h > > @@ -13,7 +13,13 @@ enum cc_vendor { > > extern enum cc_vendor cc_vendor; > > > > #ifdef CONFIG_ARCH_HAS_CC_PLATFORM > > -void cc_set_mask(u64 mask); > > +static inline void cc_set_mask(u64 mask) > > In the inline functions I changed/added to core.c in [0], I saw an > objtool warning on clang builds when using inline instead of > __always_inline; I did not see the same warning for gcc . Should we > similarly use __always_inline to strictly-enforce here? > > [0] https://lore.kernel.org/lkml/20240130220845.1978329-2-kevinloughlin@g= oogle.com/#Z31arch:x86:coco:core.c This assembles to a single instruction movq %rsi, cc_mask(%rip) and the definition is in a header file, so I'm not convinced it makes a different. And looking at your series, I think there is no need to modify coco.c at all if you just take this patch instead: the other code in that file should not be called early at all (unless our downstream has substantial changes there)