From nobody Sat Feb 7 18:15:14 2026 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 0A13E22CBF5 for ; Mon, 10 Mar 2025 13:11:32 +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=1741612293; cv=none; b=lCNpsawEPE3extke+cGP/93bShwn5FN2Do7X9Uac48ZnQkGh9H4772B+PXa5afXXF3Y0rwOsSK/wzECQbwUEF2utzjP7z22/yKk0PYgbrk8GwvT3cvOK8HT+/5y9XrRxldQPdTxL6zx+eYLic1HS2rBjnOOwyhO0r/pR6d4NYq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741612293; c=relaxed/simple; bh=1sPXlOrJgc2EhQcV6hft1tTfyoeXcFPRPvUKeNq3yfc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=heam2Moy7az7O+9cL9jIjujSbybkLkvy7kTl9qF90fS8ov8l0o4gK/r1y7motjFKg0F5j+5EqITREIohdsRduzN2p/zCGEYk919eYyp8gamoiGn5IWreolv0n/D9q3UogMaeJJ5To1Q5WkZOWsGex0VxmXSAJhr781j1yZwpYKs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dPZ1YSnU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dPZ1YSnU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D68FC4CEE5; Mon, 10 Mar 2025 13:11:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741612292; bh=1sPXlOrJgc2EhQcV6hft1tTfyoeXcFPRPvUKeNq3yfc=; h=From:To:Cc:Subject:Date:From; b=dPZ1YSnU9FAWDhgF5MpWC2QUKcwHi8O/O44pcdb6Y4xZMroJUgsrfUYBNqZrmR6pX PBLqx1N2G3o6b8OnKK75BK4mwy+TUwr0a/gqmah5J8OPlav60yad9do9sXSMoB0PGD xsI408VzkRITOmrxSIPGJPk6KXE4tVsL0I5L1V8KMHC0Nb+xLpFLRdA8qE3ycd+GJ/ je8x7THwni+aqlXIyVCQKHqWJ0M3SeOsDzo9uVdSPVjX+Ui4fd8wMflQx/ciMCCQla 38aUdhYQqvTkx+p4hckgf09D9TJ02ZpM6rIN5eKbBepSGuRPWk43g/eMDQaYWomk9X sswaWhlWhbsiA== From: Arnd Bergmann To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Tom Lendacky , "Kirill A. Shutemov" , Rick Edgecombe , Kuppuswamy Sathyanarayanan Cc: Arnd Bergmann , "H. Peter Anvin" , Elena Reshetova , "Jason A. Donenfeld" , Yue Haibing , Juergen Gross , David Woodhouse , linux-kernel@vger.kernel.org Subject: [PATCH] [v2] x86: coco: replace static const cc_mask with a function Date: Mon, 10 Mar 2025 14:10:59 +0100 Message-Id: <20250310131114.2635497-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann When extra warnings are enabled, the cc_mask definition in asm/coco.h causes a build failure with gcc: arch/x86/include/asm/coco.h:28:18: error: 'cc_mask' defined but not used [-= Werror=3Dunused-const-variable=3D] 28 | static const u64 cc_mask =3D 0; Add a cc_get_mask() function mirroring cc_set_mask() for the one user of the variable outside of the coco implementation. Fixes: a0a8d15a798b ("x86/tdx: Preserve shared bit on mprotect()") Signed-off-by: Arnd Bergmann -- v2: use an inline helper instead of a __maybe_unused annotaiton. Reviewed-by: Kirill A. Shutemov Reviewed-by: Kuppuswamy Sathyanarayanan=20 --- arch/x86/include/asm/coco.h | 10 +++++++++- arch/x86/include/asm/pgtable_types.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/coco.h b/arch/x86/include/asm/coco.h index aa6c8f8ca958..e7225452963f 100644 --- a/arch/x86/include/asm/coco.h +++ b/arch/x86/include/asm/coco.h @@ -15,6 +15,11 @@ enum cc_vendor { extern enum cc_vendor cc_vendor; extern u64 cc_mask; =20 +static inline u64 cc_get_mask(void) +{ + return cc_mask; +} + static inline void cc_set_mask(u64 mask) { RIP_REL_REF(cc_mask) =3D mask; @@ -25,7 +30,10 @@ u64 cc_mkdec(u64 val); void cc_random_init(void); #else #define cc_vendor (CC_VENDOR_NONE) -static const u64 cc_mask =3D 0; +static inline u64 cc_get_mask(void) +{ + return 0; +} =20 static inline u64 cc_mkenc(u64 val) { diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pg= table_types.h index c90e9c51edb7..74d461cc8e20 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h @@ -179,7 +179,7 @@ enum page_cache_mode { }; #endif =20 -#define _PAGE_CC (_AT(pteval_t, cc_mask)) +#define _PAGE_CC (_AT(pteval_t, cc_get_mask())) #define _PAGE_ENC (_AT(pteval_t, sme_me_mask)) =20 #define _PAGE_CACHE_MASK (_PAGE_PWT | _PAGE_PCD | _PAGE_PAT) --=20 2.39.5