From nobody Thu Apr 2 20:28:29 2026 Received: from mail-10629.protonmail.ch (mail-10629.protonmail.ch [79.135.106.29]) (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 123DA261573 for ; Thu, 12 Feb 2026 15:35:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.135.106.29 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770910521; cv=none; b=tKaUdxwmGcMcDkr7avo6iGWOSR7RI0Qh1aPhepkMjGn5dcg+KRger+OCl9TO3ol9Cb71nh5LpyQufj0FinSpA7w4eqlUXp04Jh6/zQX6+gODA9sy+cskiFimvLOG7laclMdSxG2MVThSN4LiRkSu46w/61JsuOH9qdCNzMCTFQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770910521; c=relaxed/simple; bh=qPHU/iqPGo4QUaiikvj4I9zMeEeqhvSOaSIOtXjU5v8=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lEZV33LK6RqaKA5XZav0+8W49jv9igunx9wwdTjENJoMH6/uhM57xOWYfhyhHj9uE6vI85ZaFyevGw8dD7q8YtRYIfommfYtwnPP3fP529bDpI1HVV3Rlt8zhji4unc9zXW9/5we/9JDQodLNRqOn47KUH4OORdFvaV45XcTFpc= 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=qnhhDvoU; arc=none smtp.client-ip=79.135.106.29 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="qnhhDvoU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1770910518; x=1771169718; bh=+2td+hWXdeO7n5KKSpxBOjQhidpQ+z25dP3GgRIDo6g=; 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=qnhhDvoUWiPMhbG7w2WC+ymZqOQMxAZELNfsXosBWeOBuulyJO9x+h3rvlhHZQ9aD nXJXy+tiw680CF5joRpfNLwMAp7TKoyuEIx0hbVIeTOJI66Cd/pLEe/tTnLDNngLp3 mdobS2O65UBHwZmr3NR+0baJvEmhl8SHgl/zHpXpRpUzLo2uK+NIZU0fPG5DxmS0e2 qo7Hzqe+2wV0ZlyG0DJlqBdiSB0ZUw8vQKdreNB/Fn3PsWIACzo4tZlDw6IscqQ3iX yzH00aqfPBZ5pCTxP553XT9fN/8x8SZGOpyQVUl7+uI/P3+lF75y11tsry2uwLgwFg snmE8F1izV7ZQ== Date: Thu, 12 Feb 2026 15:35:13 +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, Maciej Wieczor-Retman , linux-kernel@vger.kernel.org Subject: [PATCH v5 3/3] x86/cpu: Required feature bits sanity check Message-ID: <1bfbcdf7d2d7d5a1180e0de92d14cd6c246d5ea5.1770908783.git.m.wieczorretman@pm.me> In-Reply-To: References: Feedback-ID: 164464600:user:proton X-Pm-Message-ID: 685c61b2aeb6325055334ac04c07df5cf77b35eb 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 identification concludes, do a sanity check by comparing the final x86_capability bitmask with the pre-defined required feature bits. Signed-off-by: Maciej Wieczor-Retman Acked-by: H. Peter Anvin (Intel) --- arch/x86/kernel/cpu/common.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 7aede0760ebc..5cf4f7174be8 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1987,6 +1987,36 @@ const char *x86_cap_name(unsigned int bit) return undef_buf; } =20 +/* + * As a sanity check compare the final x86_capability bitmask with the ini= tial + * predefined required feature bits. In case of a mismatch emit a warning = with + * the faulty bitmask value. + */ +static void verify_required_features(const struct cpuinfo_x86 *c) +{ + u32 missing[NCAPINTS] =3D REQUIRED_MASK_INITIALIZER; + u32 error =3D 0; + unsigned int i; + + for (i =3D 0; i < NCAPINTS; i++) { + missing[i] &=3D ~c->x86_capability[i]; + error |=3D missing[i]; + } + + if (!error) + return; /* All good */ + + /* + * At least one required feature is missing. Print a warning, + * and taint the kernel. + */ + pr_warn("cpu %d: missing required feature(s):", c->cpu_index); + for_each_set_bit(i, (void *)missing, NCAPINTS << 5) + pr_cont(" %s", x86_cap_name(i)); + pr_cont("\n"); + add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK); +} + /* * This does the hard work of actually picking apart the CPU stuff... */ @@ -2116,6 +2146,8 @@ static void identify_cpu(struct cpuinfo_x86 *c) mcheck_cpu_init(c); =20 numa_add_cpu(smp_processor_id()); + + verify_required_features(c); } =20 /* --=20 2.53.0