[PATCH v11 4/4] x86/cpu: Clear feature bits whose dependencies were cleared
From: Maciej Wieczor-Retman
Date: Fri Mar 20 2026 - 08:53:36 EST
From: Maciej Wieczor-Retman <maciej.wieczor-retman@xxxxxxxxx>
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.
Running setup_clear_cpu_cap() on such cases inside
check_cpufeature_deps() should guarantee that the cleanup of the
leftover bits has to run only once. Afterwards apply_forced_caps()
clears the leftover bits from x86_capability[] and the warning inside
check_cpufeature_deps() doesn't trigger anymore.
Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@xxxxxxxxx>
---
Changelog v11:
- Add this patch to the series.
arch/x86/kernel/cpu/cpuid-deps.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c
index 5002f496d095..b0f5d3fe6655 100644
--- a/arch/x86/kernel/cpu/cpuid-deps.c
+++ b/arch/x86/kernel/cpu/cpuid-deps.c
@@ -163,6 +163,16 @@ void check_cpufeature_deps(struct cpuinfo_x86 *c)
for (d = cpuid_deps; d->feature; d++) {
if (cpu_has(c, d->feature) && !cpu_has(c, d->depends)) {
+ /*
+ * If the dependency was cleared through the disabled
+ * bitmasks while the feature wasn't it also needs to be
+ * cleared.
+ */
+ if (!DISABLED_MASK_BIT_SET(d->feature) && DISABLED_MASK_BIT_SET(d->depends)) {
+ setup_clear_cpu_cap(d->feature);
+ continue;
+ }
+
/*
* Only warn about the first unmet dependency on the
* first CPU where it is encountered to avoid spamming
--
2.53.0