From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 599F8235C01 for ; Sat, 4 Jul 2026 00:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783124484; cv=none; b=L1Jm7OjwCfTmsaef3lidk2IUyspAcmH8+Sl5VqX/kc3CInXpu+c+ADfK0+W4l3MEYczb0bxvC0J69tS/Un04GkOcIoFTfrAY5UkLiE6ad3uUctdyzdMLaFsZN2C2acUx6ffnLqYe7A9Lhp+5hh+KpX64voZZNRcySMyj+ekfD4w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783124484; c=relaxed/simple; bh=d8esytshOxqR5lriWzZNvvJdyiVdj64hLQoV316XJ8o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qj2tQt9w4FqJ+YUjPsX5NHA5tQ96+r5jCNXhs/SiQzFrJ/OSXg128bqZMH3LVHPjYaIBjP2K7b1pmmSjNv9PK1NpY07wgMK4iqVBbC0QxmiETWpOhbY3JuIQDjs37CtxkBX9aEjUVp6JvxlLTBDNB5FDr9xGDR+xzl4PbYxCRoA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Bx+/rbkl; arc=none smtp.client-ip=91.218.175.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Bx+/rbkl" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783124481; 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=zdrYYHrpsx+P80tgVW4Fs8Ygiy8h4jkJ/VS0hdKA83I=; b=Bx+/rbkl966Cw6MlCohyWVIf/IZfvZXlYuLgbVti/XOaa63KVOYwAeXbsakWLkU6TPJAnw o8CJHR9qB2tnnMBib/8skqUH2E0qx5EJaqeG/bmskJEAG7jhXdmD8PrptegdNX2sNxLAvJ x3oAR44UV31IQ7IxL9QOpHshhgPFnv4= From: Ihor Solodrai To: Borislav Petkov , Dave Hansen , Ingo Molnar , Thomas Gleixner Cc: Alexei Starovoitov , Andrii Nakryiko , Andrey Ryabinin , Andrew Morton , "H . Peter Anvin" , Andrey Konovalov , bpf@vger.kernel.org, kernel-team@meta.com, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 4/5] x86/cpu: Set X86_BUG_ESPFIX in identify_cpu_32() Date: Fri, 3 Jul 2026 17:20:45 -0700 Message-ID: <20260704002046.3859585-5-ihor.solodrai@linux.dev> In-Reply-To: <20260704002046.3859585-1-ihor.solodrai@linux.dev> References: <20260704002046.3859585-1-ihor.solodrai@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X86_BUG_ESPFIX is 32-bit-only. Move setting it into identify_cpu_32(), next to the other 32-bit-only setup. Signed-off-by: Ihor Solodrai --- arch/x86/kernel/cpu/common.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 519e495c4a14..8f093c6c7ccc 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -2005,23 +2005,6 @@ static void identify_cpu(struct cpuinfo_x86 *c) get_model_name(c); /* Default name */ - /* - * ESPFIX is a strange bug. All real CPUs have it. Paravirt - * systems that run Linux at CPL > 0 may or may not have the - * issue, but, even if they have the issue, there's absolutely - * nothing we can do about it because we can't use the real IRET - * instruction. - * - * NB: For the time being, only 32-bit kernels support - * X86_BUG_ESPFIX as such. 64-bit kernels directly choose - * whether to apply espfix using paravirt hooks. If any - * non-paravirt system ever shows up that does *not* have the - * ESPFIX issue, we can change this. - */ -#ifdef CONFIG_X86_32 - set_cpu_bug(c, X86_BUG_ESPFIX); -#endif - no_cpuid: cpu_parse_topology(c); @@ -2151,6 +2134,23 @@ static void identify_cpu_32(struct cpuinfo_x86 *c) if (!IS_ENABLED(CONFIG_X86_32)) return; + /* + * ESPFIX is a strange bug. All real CPUs have it. Paravirt + * systems that run Linux at CPL > 0 may or may not have the + * issue, but, even if they have the issue, there's absolutely + * nothing we can do about it because we can't use the real IRET + * instruction. + * + * NB: For the time being, only 32-bit kernels support + * X86_BUG_ESPFIX as such. 64-bit kernels directly choose + * whether to apply espfix using paravirt hooks. If any + * non-paravirt system ever shows up that does *not* have the + * ESPFIX issue, we can change this. + */ +#ifdef CONFIG_X86_32 + set_cpu_bug(c, X86_BUG_ESPFIX); +#endif + enable_sep_cpu(); } -- 2.54.0