From nobody Thu Apr 2 20:20:50 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 27CBC346A02 for ; Fri, 27 Mar 2026 02:18:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774577908; cv=none; b=jnXhbgaxva27yxPfKBrlfI8qNo7aRECa7X3InY+9Ta1izC8E/SvEtmE/UmB+Q/Zlbi7hCfc51QR64KuBcHC/8mx5qK8hg8mfYgd47owxpS4JANHZMyvZrftIEsly7919ztD5WrE7jIhBCoTnYwBjz7eaGWvbSzfvKbVz5RrbvLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774577908; c=relaxed/simple; bh=2M0077shx+cp5E/0UitoS25jemq15VlJuQh2C/Iu43A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T2l7KQgaLIGYqtNOu65N15+AZT/pqzP+WFelXPy5d2AJgA/ae8GgfeAhTS3gCe8L+/ORy5YwEztMAOGiH3fE8tsziRKbHgQmQ95OnNfJU1t+5b46/of/TSuFV5rAzQoE/4U75F+DzFDto/yvYzzCo0s/D/X4rzyuWND35p+pfLs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=F4uQx+XK; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ATFG84Jf; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="F4uQx+XK"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ATFG84Jf" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774577904; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ySK0vbw5fQQ1k3iTzALbXciUAXQFVLXE+FR8sQuweNg=; b=F4uQx+XKLCCY7oRL3+Zn7m7BNw6lpIo2cmYfhnUWqjfWIizsy5ILbsrwHKgIfjavd3WoMd VI/8HcybDifI6bfSFzthj5CPOLnI6DJB+aCDKIIHG4RD/F8YM2PjYJvwXRNFGXLKrBM1bk hgYo8uuIdiWrI8p6nYO10STGRvupd8B5czwbr3jR13LLa+2x1N07U50m1YWULXlsSb2NAf nk9aLSnApt1mkfDly3fzInaMemOwCenoLf/nPLwZP9uvtdeh8sUlXcE3+mvgpETQ9Eh+pG XVMpQigj2IfB3I5lMLqYeNddGzUQbn/Yw5bwV33Fh9ZHmPEy4KkC+pK9nm2X0Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774577904; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ySK0vbw5fQQ1k3iTzALbXciUAXQFVLXE+FR8sQuweNg=; b=ATFG84Jf4/5hYS1q/bjLm2kqTx20p15lQxDC5sc2tASPccXO48qLXTN1EPBiJ//LrnU5/I S+3Ot5v9AccmAsCQ== To: Borislav Petkov , Dave Hansen , Ingo Molnar Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Sean Christopherson , David Woodhouse , Peter Zijlstra , Christian Ludloff , Sohil Mehta , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v6 18/90] x86/cpu: Use parsed CPUID(0x80000000) Date: Fri, 27 Mar 2026 03:15:32 +0100 Message-ID: <20260327021645.555257-19-darwi@linutronix.de> In-Reply-To: <20260327021645.555257-1-darwi@linutronix.de> References: <20260327021645.555257-1-darwi@linutronix.de> 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" At early boot code, use parsed CPUID(0x80000000) instead of invoking a direct CPUID query. The original code has the check: extended_cpuid_level =3D ((eax & 0xffff0000) =3D=3D 0x80000000) ? eax := 0; to protect against Intel 32-bit machines without an extended range, where a CPUID(0x80000000) query will repeat the output of the max-valid standard CPUID leaf output. A similar check is already done at the CPUID parser's own CPUID(0x80000000) read function: if (CPUID_RANGE(el0->max_ext_leaf) !=3D CPUID_EXT_START) { // Handle error } Thus, for the call-site, the parsed CPUID NULL check below: el0 =3D cpuid_leaf(c, 0x80000000); extended_cpuid_level =3D el0 ? el0->max_ext_leaf : 0; is sufficient. Signed-off-by: Ahmed S. Darwish --- arch/x86/kernel/cpu/common.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index f31746c216c9..204c1f65f265 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1017,6 +1017,7 @@ static void init_speculation_control(struct cpuinfo_x= 86 *c) =20 void get_cpu_cap(struct cpuinfo_x86 *c) { + const struct leaf_0x80000000_0 *el0 =3D cpuid_leaf(c, 0x80000000); u32 eax, ebx, ecx, edx; =20 /* Intel-defined flags: level 0x00000001 */ @@ -1052,12 +1053,7 @@ void get_cpu_cap(struct cpuinfo_x86 *c) c->x86_capability[CPUID_D_1_EAX] =3D eax; } =20 - /* - * Check if extended CPUID leaves are implemented: Max extended - * CPUID leaf must be in the 0x80000001-0x8000ffff range. - */ - eax =3D cpuid_eax(0x80000000); - c->extended_cpuid_level =3D ((eax & 0xffff0000) =3D=3D 0x80000000) ? eax = : 0; + c->extended_cpuid_level =3D el0 ? el0->max_ext_leaf : 0; =20 if (c->extended_cpuid_level >=3D 0x80000001) { cpuid(0x80000001, &eax, &ebx, &ecx, &edx); --=20 2.53.0