From nobody Thu Apr 2 20:42:04 2026 Received: from mail-06.mail-europe.com (mail-06.mail-europe.com [85.9.210.45]) (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 E0646221F11 for ; Thu, 12 Feb 2026 15:34:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=85.9.210.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770910501; cv=none; b=J1Yt8Verhu2fmuD1Wr+Hf0cSSpSk/gbtAHKqHgqF69lg4K9Ir1TnZ7H10cA+1kvKt/a4fmuOpfxkiY0jr4+BtnLXw+z/v9zMHQ/IWaXLu4ikDgbvBYm5pQz8OEBsufVV9e8/qrUqs+ujNn1zGfNg/atOqxESTGzTsa9DiIfkmLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770910501; c=relaxed/simple; bh=GKU97sFrDJU9ubg2pcOiS88y9fxPx469uJTR7aE6ieM=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VSNfTBrgMidNhxQcKi8GiOvc0b2YPqAc5p+2Bzs1WcRJj5r3XrIlIsuAwZhK6eMfc0sy+wdii97N6DbVLf8AQJw9Og4sXAZsIZlwALccPVFPkOazdmoDQGbHCNbqc1EVpSUlVu1K3nw0CpDvfOLp3SNAl7CzmaHMGUU7+mYDObk= 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=LkvNi11u; arc=none smtp.client-ip=85.9.210.45 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="LkvNi11u" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1770910483; x=1771169683; bh=4M+Owbd0HeHgku23Jntag7YvEbhLlJDH/9jpPFuXA6I=; 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=LkvNi11ucnkDX/2xnpTUxpj/bCdwE7jsGSoECQXV5bYHUB2FR14P/tWdKaT0/+meO lS5AQ1VDp2eUI7fH5wPoAcuBLQ1SErjdxA8Hy01o0Pp2PWovt1lEQHPKJE9YSn0pRO SdNKYKVcLZTFfTi1lSTFBdfWqUPxtc9nT9PP1m2lDjdmC93oX28oqI7uupScMmA04G tFut9ZKv7RCz3pygvKsgF++U8hUJLrmjzjjEWLJcP2TNgQMuph7PVUe8InR648u3Uc W63m/yOzKfq7cB59BVAzVtBKJol9RSHf+dkxQpiHDrTcngubAuEuCxjSYwGjZqUEI+ EJSjcEOGM87eg== Date: Thu, 12 Feb 2026 15:34:38 +0000 To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" From: Maciej Wieczor-Retman Cc: m.wieczorretman@pm.me, pawel.chmielewski@linux.intel.com, Farrah Chen , Maciej Wieczor-Retman , stable@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/3] x86/cpu: Clear feature bits disabled at compile-time Message-ID: <32fbbfc16974cfed11e7d2651bce836ba9ceaccc.1770908783.git.m.wieczorretman@pm.me> In-Reply-To: References: Feedback-ID: 164464600:user:proton X-Pm-Message-ID: 13dc42a1ba63ab0ef2e91884790de5ad50f75227 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. Through the cpufeaturemasks.awk script add a DISABLED_MASK_INITIALIZER macro that creates an initializer list filled with DISABLED_MASKx bitmasks. At the same time add a REQUIRED_MASK_INITIALIZER that can be used for a sanity check of whether all the required feature bits are set at the end of cpu identification. Initialize the cpu_caps_cleared array 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. Reported-by: Farrah Chen Closes: https://bugzilla.kernel.org/show_bug.cgi?id=3D220348 Signed-off-by: Maciej Wieczor-Retman Cc: # 6.18.x --- 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 e7ab22fce3b5..8d12c5722245 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -732,7 +732,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_INITIALIZER; __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..b7f4e775a365 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_INITIALIZER\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