[PATCH] x86/mm: Don't disable INVLPG if "incomplete Global INVLPG flushes" is fixed by microcode

From: Xi Ruoyao
Date: Sun Mar 24 2024 - 13:11:58 EST


Per the "Processor Specification Update" documentations referred by the
intel-microcode-20240312 release note, this microcode release has fixed
the issue for all affected models.

So don't disable INVLPG if the microcode is new enough.

Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Link: https://lore.kernel.org/all/168436059559.404.13934972543631851306.tip-bot2@tip-bot2/
Link: https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files/releases/tag/microcode-20240312
Link: https://cdrdv2.intel.com/v1/dl/getContent/740518 # RPL042, rev. 13
Link: https://cdrdv2.intel.com/v1/dl/getContent/682436 # ADL063, rev. 24
Signed-off-by: Xi Ruoyao <xry111@xxxxxxxxxxx>
---
arch/x86/mm/init.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 679893ea5e68..a6a2f38c3999 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -279,6 +279,25 @@ static const struct x86_cpu_id invlpg_miss_ids[] = {
{}
};

+/*
+ * INVLPG issue is fixed with intel-microcode-20240312 for all
+ * affected models. This table is taken from the release note
+ * of this microcode release.
+ */
+static const struct x86_cpu_desc invlpg_miss_fixed_ucode[] = {
+ INTEL_CPU_DESC(INTEL_FAM6_ALDERLAKE, 2, 0x34),
+ INTEL_CPU_DESC(INTEL_FAM6_ALDERLAKE, 5, 0x34),
+ INTEL_CPU_DESC(INTEL_FAM6_ALDERLAKE_L, 3, 0x432),
+ INTEL_CPU_DESC(INTEL_FAM6_ALDERLAKE_L, 4, 0x432),
+ INTEL_CPU_DESC(INTEL_FAM6_ATOM_GRACEMONT, 0, 0x15),
+ INTEL_CPU_DESC(INTEL_FAM6_RAPTORLAKE, 1, 0x122),
+ INTEL_CPU_DESC(INTEL_FAM6_RAPTORLAKE_P, 2, 0x4121),
+ INTEL_CPU_DESC(INTEL_FAM6_RAPTORLAKE_P, 3, 0x4121),
+ INTEL_CPU_DESC(INTEL_FAM6_RAPTORLAKE_S, 2, 0x34),
+ INTEL_CPU_DESC(INTEL_FAM6_RAPTORLAKE_S, 5, 0x34),
+ {}
+};
+
static void setup_pcid(void)
{
if (!IS_ENABLED(CONFIG_X86_64))
@@ -287,7 +306,8 @@ static void setup_pcid(void)
if (!boot_cpu_has(X86_FEATURE_PCID))
return;

- if (x86_match_cpu(invlpg_miss_ids)) {
+ if (x86_match_cpu(invlpg_miss_ids) &&
+ !x86_cpu_has_min_microcode_rev(invlpg_miss_fixed_ucode)) {
pr_info("Incomplete global flushes, disabling PCID");
setup_clear_cpu_cap(X86_FEATURE_PCID);
return;
--
2.44.0