From nobody Wed Apr 8 04:49:10 2026 Received: from mail-10630.protonmail.ch (mail-10630.protonmail.ch [79.135.106.30]) (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 76DEF292B2E for ; Tue, 10 Mar 2026 18:03:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.135.106.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773165811; cv=none; b=FxyxEQSNNM/OSzjgfJQn5sWwHoudbvaiDlv2B7MfzxcbVJ0Ju0NM2YMYcbkETpROu8yG2G83i1Cx2XpkN8fw7WiBr447k4D0EslyKK3mw0BI6Y0TZ+7tBVQxJ3UVaDjwgpf1lQ9NITnsg/L5w5ndsJst7suyWyl7bA4PHIVXHZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773165811; c=relaxed/simple; bh=OYrF3nOmXvR+249DPVEEvTLFqKlha5+fX4BJ3zKY6Zk=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ft/nsqUJmGwX7m5YlAwZqf1MPF5cn1MnMa/QvWFVroVsyIxtWU7G587PnP55VZHQe5bYyyxgm5U6T8MbKotxRD6fjVhwTJeIxfxHkdQi+b4DdGuNui6Oig/v1SHuTO2x8H+9j0VuB9JnIXN1EbNslXM0QTuDisZVB0rwml1dXfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me; spf=pass smtp.mailfrom=pm.me; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b=EqNgJieB; arc=none smtp.client-ip=79.135.106.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pm.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="EqNgJieB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1773165801; x=1773425001; bh=Haf9VXVnh7S6OwY0cy4yYJkcrMnRbD6Px2IMPMj/Z+0=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=EqNgJieBSDQ9I3eFYcxjE+bIUbz4OP3j47WcBSFdX3BaXHzDD+A/2e4aDDnOwBZoc 9XlGmzHpYb1rsksA5xa8e2Y7ZYlfi0K4mclMQWdQZs53CUgvF+PDQ7pY/bdml40x91 ZlIn1NJytf2wwnhdBqICk0UNHpv8Noj78CJgxD0TfubDPM91BseflNhZX3ghvZmHyt DmUOGPMJUQ+GzGF6PZ/8SepHxOnYK2fBXm1S4bqRWsWE69LnbW9OiSsgl9t625Z3Qc 1aotL1w3Q2hfTqMA3FdKKh/SxvIyfqvNZBXBG0JSzeKpf8T9DVsfto0jDM0YR0Zqg2 hSsCu7QtLZx5Q== Date: Tue, 10 Mar 2026 18:03:16 +0000 To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" From: Maciej Wieczor-Retman Cc: sohil.mehta@intel.com, m.wieczorretman@pm.me, Farrah Chen , Maciej Wieczor-Retman , linux-kernel@vger.kernel.org Subject: [PATCH v9 1/3] x86/cpu: Clear feature bits disabled at compile-time Message-ID: In-Reply-To: References: Feedback-ID: 164464600:user:proton X-Pm-Message-ID: 53b839685494ecd2e6df67227c4296d6686e879a 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: Maciej Wieczor-Retman If some config options are disabled during compile time, they still are enumerated in macros that use the x86_capability bitmask - cpu_has() or this_cpu_has(). The features are also visible in /proc/cpuinfo even though they are not enabled - which is contrary to what the documentation states about the file. Examples of such feature flags are lam, fred, sgx, ibrs_enhanced, split_lock_detect, user_shstk, avx_vnni and enqcmd. Once the cpu_caps_cleared[] is initialized with the autogenerated disabled bitmask apply_forced_caps() will clear the corresponding bits in boot_cpu_data.x86_capability[] and other secondary CPUs' cpu_data.x86_capability[]. Thus features disabled at compile time won't show up in /proc/cpuinfo. No BUGS are defined to be cleared at compile time, therefore only the NCAPINTS part of cpu_caps_cleared[] is initialized. The NBUGINTS part is set initialized to zero. Reported-by: Farrah Chen Closes: https://bugzilla.kernel.org/show_bug.cgi?id=3D220348 Signed-off-by: Maciej Wieczor-Retman Reviewed-by: Sohil Mehta --- Changelog v9: - *_MASK_INITIALIZER -> *_MASK_INIT - Remove Cc stable. - Note that the BUGS part of cpu_caps_cleared[] is zeroed. Changelog v6: - Remove patch message portions that are not just describing the diff. arch/x86/kernel/cpu/common.c | 3 ++- arch/x86/tools/cpufeaturemasks.awk | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index a8ff4376c286..76339e988304 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -735,7 +735,8 @@ static const char *table_lookup_model(struct cpuinfo_x8= 6 *c) } =20 /* Aligned to unsigned long to avoid split lock in atomic bitmap ops */ -__u32 cpu_caps_cleared[NCAPINTS + NBUGINTS] __aligned(sizeof(unsigned long= )); +__u32 cpu_caps_cleared[NCAPINTS + NBUGINTS] __aligned(sizeof(unsigned long= )) =3D + DISABLED_MASK_INIT; __u32 cpu_caps_set[NCAPINTS + NBUGINTS] __aligned(sizeof(unsigned long)); =20 #ifdef CONFIG_X86_32 diff --git a/arch/x86/tools/cpufeaturemasks.awk b/arch/x86/tools/cpufeature= masks.awk index 173d5bf2d999..9382bd15279a 100755 --- a/arch/x86/tools/cpufeaturemasks.awk +++ b/arch/x86/tools/cpufeaturemasks.awk @@ -82,6 +82,12 @@ END { } printf " 0\t\\\n"; printf "\t) & (1U << ((x) & 31)))\n\n"; + + printf "\n#define %s_MASK_INIT\t\t\t\\", s; + printf "\n\t{\t\t\t\t\t\t\\"; + for (i =3D 0; i < ncapints; i++) + printf "\n\t\t%s_MASK%d,\t\t\t\\", s, i; + printf "\n\t}\n\n"; } =20 printf "#endif /* _ASM_X86_CPUFEATUREMASKS_H */\n"; --=20 2.53.0