Skip to content

Commit 68799c0

Browse files
yyu-intel-commdroth
authored andcommitted
x86/mm: Change cpa_flush() to call flush_kernel_range() directly
The function cpa_flush() calls __flush_tlb_one_kernel() and flush_tlb_all(). Replacing that with a call to flush_tlb_kernel_range() allows cpa_flush() to make use of INVLPGB or RAR without any additional changes. Initialize invlpgb_count_max to 1, since flush_tlb_kernel_range() can now be called before invlpgb_count_max has been initialized to the value read from CPUID. [riel: remove now unused __cpa_flush_tlb] Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com> Signed-off-by: Rik van Riel <riel@surriel.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Acked-by: Dave Hansen <dave.hansen@linux.intel.com> Link: https://lore.kernel.org/all/20250606171112.4013261-4-riel%40surriel.com (cherry picked from commit 86e6815) Signed-off-by: Michael Roth <michael.roth@amd.com>
1 parent 4ccd326 commit 68799c0

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

arch/x86/mm/pat/set_memory.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -399,15 +399,6 @@ static void cpa_flush_all(unsigned long cache)
399399
on_each_cpu(__cpa_flush_all, (void *) cache, 1);
400400
}
401401

402-
static void __cpa_flush_tlb(void *data)
403-
{
404-
struct cpa_data *cpa = data;
405-
unsigned int i;
406-
407-
for (i = 0; i < cpa->numpages; i++)
408-
flush_tlb_one_kernel(fix_addr(__cpa_addr(cpa, i)));
409-
}
410-
411402
static int collapse_large_pages(unsigned long addr, struct list_head *pgtables);
412403

413404
static void cpa_collapse_large_pages(struct cpa_data *cpa)
@@ -444,6 +435,7 @@ static void cpa_collapse_large_pages(struct cpa_data *cpa)
444435

445436
static void cpa_flush(struct cpa_data *cpa, int cache)
446437
{
438+
unsigned long start, end;
447439
unsigned int i;
448440

449441
BUG_ON(irqs_disabled() && !early_boot_irqs_disabled);
@@ -453,10 +445,12 @@ static void cpa_flush(struct cpa_data *cpa, int cache)
453445
goto collapse_large_pages;
454446
}
455447

456-
if (cpa->force_flush_all || cpa->numpages > tlb_single_page_flush_ceiling)
457-
flush_tlb_all();
458-
else
459-
on_each_cpu(__cpa_flush_tlb, cpa, 1);
448+
start = fix_addr(__cpa_addr(cpa, 0));
449+
end = fix_addr(__cpa_addr(cpa, cpa->numpages));
450+
if (cpa->force_flush_all)
451+
end = TLB_FLUSH_ALL;
452+
453+
flush_tlb_kernel_range(start, end);
460454

461455
if (!cache)
462456
goto collapse_large_pages;

0 commit comments

Comments
 (0)