From nobody Mon Feb 9 18:43:37 2026 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65BDD37BE98 for ; Fri, 30 Jan 2026 12:33:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769776437; cv=none; b=MqgWLHFEPPlh6HVsYchjP3+kCSkcvv0bQXtdNoJeS2TElrOTsmKBLWRemblkWfnDBnYi2OTadNNjshfwSxyPgrygM1Q/TZlI0KnwQ3sC0ZAQBpDphI8mGywwJHzC2L4fqxe4IQ8wcXs7h49NpI+4Mwjh/js4fbn6aQCNIg7AynE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769776437; c=relaxed/simple; bh=qzcr3R98xZsCAh0/k7UKmpdghOqp7uYjUaX2fIcYTHs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xey0WAUpAaoW6Dn2ylB/9qh6vdOu7qPBxM08CM/HmiTWCLg4NuJMxX+ppDkcntgm86VRnRu0YQzTStPL53+ecoYBboTewg3FnbQN0JHW3T2w4lCb07krwG6HA+L/BPUACqLnw0hTCpZBJcLS84eEh2chsmnPBSIiET0No5ZCcCw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cfg.kr; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cfg.kr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f194.google.com with SMTP id d2e1a72fcca58-81f4e36512aso1982764b3a.3 for ; Fri, 30 Jan 2026 04:33:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769776435; x=1770381235; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=xE4ytC+T4x6cBliZdTyIHBTCqD8XM6E6UxBUmSlpbzw=; b=QS1huOuH29RRJ4K3OCD9q30FmKkrzJ9nwbgdKcYDP+Xuht507IIZXD+vTV7YhKawug XZgnCAGexDFKFyLOIERsUk44x7FdxVZ8HnQpohqlExNDWbdc4DtXBCSl/uWQgNSRjTY2 ZHtO0Eew51EE5xZ30lfGAfSFiWJsQtLB/6VOjO6wJ7+3OgcTLwoqPQ38ZW9fmW0PbKNg 7hQJ5mQeImzdkcf83hxmOuVJgXyur8SZ8p5qpECZCvqX6I10H3QYGx2W0PKa/u29QqTo F1T0ciFD5zqsaynlj6aSLqS9w+51AludQWhtimLwGXM7B+/a6fD8VPlvAIbA7f8MLL3n gCLw== X-Forwarded-Encrypted: i=1; AJvYcCXVbrJuCHj4B188+nvs19FGJMXN8iqyHjbxJUky8kcCHEDBKwr/AzJyPfoLo2OWWvTswHoHD2gGoveLxaY=@vger.kernel.org X-Gm-Message-State: AOJu0YzXnBKewwF24kjPc5N0VTV9RbGemZ1spOpenzWLE3YyHQhkQ2eq /QZ2H28LqmrNghErNktgpTh/Faow+gvZt7RSlJv2M1UIHeuGjqfxE5vc X-Gm-Gg: AZuq6aI4MbfWHN1FXYKuELfOU8y68LB5HWHO0VuZ8cKVSGUbUyPJqzBcP3k4dPGKBNh ZXZb59SxRgqMrcyl/Ih8ks3Zwii7wHh0+bkYOyVALtuaBk9Ahgs3OsVAGZQGFOzTIeOh7fTsCg6 9Q1nnzxivUfUkGnL5/WEp064vbTCTFs7TqHZpSi7zJ7mZMNozdQrcISC5XI+F2Jo2XsqMkkSO4I zlAY39gUuhg3cnw4tww1nQhzqJ/Ur9iGP8bw/ZPDJ0K9uQsrSY+Yb5snb17rH2CI0z8brWkevNf tBYhXMoiSmllUHDC956807Yqjmx8nqkKbEQXyZAgfxZcol1ZAK0eFK3PCG7e7zAEe1A2QLfp3ww rqXYvL0auGltyTjCjaLts2dzTwhHMpJaIErYJuPEIzU7JGC0MWwXeURGUQaRrynNjujZSOLTJxs M= X-Received: by 2002:a05:6a21:32a3:b0:364:37d:cc63 with SMTP id adf61e73a8af0-392e0148311mr2553367637.56.1769776435586; Fri, 30 Jan 2026 04:33:55 -0800 (PST) Received: from cfg.kr ([211.244.25.5]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-c642b0b4c07sm7554342a12.36.2026.01.30.04.33.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jan 2026 04:33:55 -0800 (PST) From: Joongsun Moon-Lee To: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen Cc: "H . Peter Anvin" , Peter Zijlstra , Pawan Gupta , Josh Poimboeuf , linux-kernel@vger.kernel.org, Joongsun Moon-Lee Subject: [PATCH v2 1/2] x86/cpu: Refactor RFDS mitigation to use X86_FEATURE_RFDS_CLEAR Date: Fri, 30 Jan 2026 21:33:39 +0900 Message-ID: <20260130123340.1544-2-moontorise@cfg.kr> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260130123340.1544-1-moontorise@cfg.kr> References: <20260129154342.3867-1-moontorise@cfg.kr> <20260130123340.1544-1-moontorise@cfg.kr> 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" The current RFDS mitigation logic relies on verw_clears_cpu_reg_file(), which directly checks the RFDS_CLEAR bit in the IA32_ARCH_CAPABILITIES MSR. To support quirks for CPUs that mitigate RFDS but do not enumerate it, transition to using the synthetic feature flag X86_FEATURE_RFDS_CLEAR. Replace the MSR-bit-based check with boot_cpu_has(X86_FEATURE_RFDS_CLEAR) and synthesize this feature bit in rfds_select_mitigation() if the architectural RFDS_CLEAR bit is present. Suggested-by: Dave Hansen Link: https://lore.kernel.org/all/20260129154342.3867-1-moontorise@cfg.kr/ Signed-off-by: Joongsun Moon-Lee --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/bugs.c | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpuf= eatures.h index 63b0f9aa9b3e..3480d9ddc046 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -513,6 +513,7 @@ * and purposes if CLEAR_CPU_BUF_VM is set). */ #define X86_FEATURE_X2AVIC_EXT (21*32+20) /* AMD SVM x2AVIC support for 4= k vCPUs */ +#define X86_FEATURE_RFDS_CLEAR (21*32+21) /* Clear register file via VERW= */ =20 /* * BUG word(s) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 83f51cab0b1e..479702bc9c00 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -648,11 +648,6 @@ static const char * const rfds_strings[] =3D { [RFDS_MITIGATION_UCODE_NEEDED] =3D "Vulnerable: No microcode", }; =20 -static inline bool __init verw_clears_cpu_reg_file(void) -{ - return (x86_arch_cap_msr & ARCH_CAP_RFDS_CLEAR); -} - static void __init rfds_select_mitigation(void) { if (!boot_cpu_has_bug(X86_BUG_RFDS)) { @@ -670,7 +665,10 @@ static void __init rfds_select_mitigation(void) if (rfds_mitigation =3D=3D RFDS_MITIGATION_OFF) return; =20 - if (verw_clears_cpu_reg_file()) + if (x86_arch_cap_msr & ARCH_CAP_RFDS_CLEAR) + setup_force_cpu_cap(X86_FEATURE_RFDS_CLEAR); + + if (boot_cpu_has(X86_FEATURE_RFDS_CLEAR)) verw_clear_cpu_buf_mitigation_selected =3D true; } =20 @@ -683,7 +681,7 @@ static void __init rfds_update_mitigation(void) rfds_mitigation =3D RFDS_MITIGATION_VERW; =20 if (rfds_mitigation =3D=3D RFDS_MITIGATION_VERW) { - if (!verw_clears_cpu_reg_file()) + if (!boot_cpu_has(X86_FEATURE_RFDS_CLEAR)) rfds_mitigation =3D RFDS_MITIGATION_UCODE_NEEDED; } =20 --=20 2.52.0