hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/arch/x86/mm/init.c
....@@ -7,8 +7,10 @@
77 #include <linux/swapops.h>
88 #include <linux/kmemleak.h>
99 #include <linux/sched/task.h>
10
+#include <linux/sched/mm.h>
1011
1112 #include <asm/set_memory.h>
13
+#include <asm/cpu_device_id.h>
1214 #include <asm/e820/api.h>
1315 #include <asm/init.h>
1416 #include <asm/page.h>
....@@ -26,6 +28,7 @@
2628 #include <asm/pti.h>
2729 #include <asm/text-patching.h>
2830 #include <asm/memtype.h>
31
+#include <asm/paravirt.h>
2932
3033 /*
3134 * We need to define the tracepoints somewhere, and tlb.c
....@@ -260,6 +263,24 @@
260263 }
261264 }
262265
266
+#define INTEL_MATCH(_model) { .vendor = X86_VENDOR_INTEL, \
267
+ .family = 6, \
268
+ .model = _model, \
269
+ }
270
+/*
271
+ * INVLPG may not properly flush Global entries
272
+ * on these CPUs when PCIDs are enabled.
273
+ */
274
+static const struct x86_cpu_id invlpg_miss_ids[] = {
275
+ INTEL_MATCH(INTEL_FAM6_ALDERLAKE ),
276
+ INTEL_MATCH(INTEL_FAM6_ALDERLAKE_L ),
277
+ INTEL_MATCH(INTEL_FAM6_ALDERLAKE_N ),
278
+ INTEL_MATCH(INTEL_FAM6_RAPTORLAKE ),
279
+ INTEL_MATCH(INTEL_FAM6_RAPTORLAKE_P),
280
+ INTEL_MATCH(INTEL_FAM6_RAPTORLAKE_S),
281
+ {}
282
+};
283
+
263284 static void setup_pcid(void)
264285 {
265286 if (!IS_ENABLED(CONFIG_X86_64))
....@@ -267,6 +288,12 @@
267288
268289 if (!boot_cpu_has(X86_FEATURE_PCID))
269290 return;
291
+
292
+ if (x86_match_cpu(invlpg_miss_ids)) {
293
+ pr_info("Incomplete global flushes, disabling PCID");
294
+ setup_clear_cpu_cap(X86_FEATURE_PCID);
295
+ return;
296
+ }
270297
271298 if (boot_cpu_has(X86_FEATURE_PGE)) {
272299 /*
....@@ -785,9 +812,12 @@
785812 spinlock_t *ptl;
786813 pte_t *ptep;
787814
788
- poking_mm = copy_init_mm();
815
+ poking_mm = mm_alloc();
789816 BUG_ON(!poking_mm);
790817
818
+ /* Xen PV guests need the PGD to be pinned. */
819
+ paravirt_arch_dup_mmap(NULL, poking_mm);
820
+
791821 /*
792822 * Randomize the poking address, but make sure that the following page
793823 * will be mapped at the same PMD. We need 2 pages, so find space for 3,