From nobody Thu Apr 2 17:19:10 2026 Received: from mail-244122.protonmail.ch (mail-244122.protonmail.ch [109.224.244.122]) (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 4D5A12C11D7 for ; Fri, 27 Mar 2026 15:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.224.244.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774624276; cv=none; b=nn9DFn0FDGkLVS+vz3xZkfAw/5wk9tU36F6Otl1UyqDsDXVFayPLDEUeG7Ul2bxMzNKUgKCqTObKdxBY/sGz8KieMzyV59OcR7apj6GfNxT9y4yEHlMKPR2WBXdRb6Ps3mbYInrw2r4SpNp+OHUOngZoKpC5DBkVcvawx41xqf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774624276; c=relaxed/simple; bh=wzzalzPxVVKQxnGvWEyChxXh3eeSSgsRnM1yqXEoC80=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Wb6zccXmWUB/nEy86R7pWrW5UjGqxe34VkoG1vCIeKpo3tekOiEfom+7l1fUwj7eip2wNpKM9rrBflW0nOrcNe7oQnOuAJURiTDovECCdEYGUmypZQpYXdCB2o2S4/xO8KRTVc2vM1tEp5+te8ctiaqza8Iaf/V1/fEmTuZZ+08= 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=SePzEZNS; arc=none smtp.client-ip=109.224.244.122 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="SePzEZNS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1774624267; x=1774883467; bh=2t+mCAaBPvVGyZJ5jJNkh3hsQUUyOl8CVa+3ml4O2pQ=; 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=SePzEZNSkyYdG7ew2kyv4jApMZU2qrWHjlmrnmUcK31eie4tj6G7+FdD5PgRjQV7g 2Pm9MflVTCKspCrwjkSiQ9YFdHgtDc+u8eK2M/umOMboEcF2q20U30KEp4iblyGASg +1wajy2417xXlLyLoh+dq7yd0BBIUiwlGzCVeiJqH6s1Bt8olipHJf5wTjTn218ul7 35cdeuiiZ33G0+4ZumHUFKpAwzCSuuYtO78YkF1r6/NPJEotjbcvW2cfdwGjL/VOsN 2nZ7SK/DhqhYfMsBXXP95Kvzh2lt0MtDZtBhAVblwDstfe4gn1GVhsW/1qH7RkvubH af9oLrLsNMagQ== Date: Fri, 27 Mar 2026 15:11:04 +0000 To: bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, xin@zytor.com, chang.seok.bae@intel.com, mingo@redhat.com, elena.reshetova@intel.com, maciej.wieczor-retman@intel.com, babu.moger@amd.com, sohil.mehta@intel.com, pawan.kumar.gupta@linux.intel.com, pmladek@suse.com, nik.borisov@suse.com, ptesarik@suse.com, darwi@linutronix.de, tglx@kernel.org, peterz@infradead.org, jpoimboe@kernel.org, ak@linux.intel.com From: Maciej Wieczor-Retman Cc: linux-kernel@vger.kernel.org, x86@kernel.org, m.wieczorretman@pm.me Subject: [PATCH v12 4/4] x86/cpu: Clear feature bits whose dependencies were cleared Message-ID: <48fda57397205a062b752e37e63948fa668946f7.1774623092.git.m.wieczorretman@pm.me> In-Reply-To: References: Feedback-ID: 164464600:user:proton X-Pm-Message-ID: 57334ec51a1159fa048a1d7fcdf191d174633637 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 After cpu_caps_cleared[] is initialized with DISABLED_MASK_INIT, features present in disabled bitmasks are cleared from x86_capability[]. However features that depend on them and are not part of any disabled mask are not cleared by anything. They can trigger the warning in check_cpufeature_deps(), as before both features would show up as enabled even though they weren't. The uncleared features can also still falsely show up in /proc/cpuinfo. Take such cases into account before applying the cpu_caps_cleared[] array. Signed-off-by: Maciej Wieczor-Retman --- Changelog v12: - Move the check from check_cpufeature_deps() to apply_forced_caps(). Redo last paragraph of the patch message. Changelog v11: - Add this patch to the series. arch/x86/include/asm/cpufeature.h | 1 + arch/x86/kernel/cpu/common.c | 2 ++ arch/x86/kernel/cpu/cpuid-deps.c | 14 ++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufe= ature.h index 3ddc1d33399b..e7a62990a9c2 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -77,6 +77,7 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; =20 extern void setup_clear_cpu_cap(unsigned int bit); extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit); +void clear_feature_disabled_deps(struct cpuinfo_x86 *c); void check_cpufeature_deps(struct cpuinfo_x86 *c); =20 #define setup_force_cpu_cap(bit) do { \ diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 8ad0da7012dd..2e24bdb3acaa 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -955,6 +955,8 @@ static void apply_forced_caps(struct cpuinfo_x86 *c) { int i; =20 + clear_feature_disabled_deps(c); + for (i =3D 0; i < NCAPINTS + NBUGINTS; i++) { c->x86_capability[i] &=3D ~cpu_caps_cleared[i]; c->x86_capability[i] |=3D cpu_caps_set[i]; diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-d= eps.c index 4354c0dd6d66..83060c0013c1 100644 --- a/arch/x86/kernel/cpu/cpuid-deps.c +++ b/arch/x86/kernel/cpu/cpuid-deps.c @@ -158,6 +158,20 @@ void setup_clear_cpu_cap(unsigned int feature) do_clear_cpu_cap(NULL, feature); } =20 +/* + * If the dependency was cleared through the disabled bitmasks while the + * feature wasn't it also needs to be cleared. + */ +void clear_feature_disabled_deps(struct cpuinfo_x86 *c) +{ + const struct cpuid_dep *d; + + for (d =3D cpuid_deps; d->feature; d++) { + if (!DISABLED_MASK_BIT_SET(d->feature) && DISABLED_MASK_BIT_SET(d->depen= ds)) + set_bit(d->feature, (unsigned long *)cpu_caps_cleared); + } +} + void check_cpufeature_deps(struct cpuinfo_x86 *c) { char feature_buf[X86_NAMELESS_FEAT_BUFLEN], depends_buf[X86_NAMELESS_FEAT= _BUFLEN]; --=20 2.53.0