diff options
author | Peter Zijlstra <peterz@infradead.org> | 2018-09-19 04:50:22 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2018-09-27 14:39:42 -0400 |
commit | fce2ce9544e9f098ba828442221ce99c2a5ecb0f (patch) | |
tree | fedc1986407d0a35a6312b0b237135f2b2c6e273 | |
parent | 5f464b33b17219a233af1267c621632225bc7acc (diff) |
x86/mm/cpa: Move CLFLUSH test into cpa_flush_array()
Rather than guarding cpa_flush_array() users with a CLFLUSH test, put
it inside.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Dave Hansen <dave.hansen@intel.com>
Cc: Bin Yang <bin.yang@intel.com>
Cc: Mark Gross <mark.gross@intel.com>
Link: https://lkml.kernel.org/r/20180919085948.087848187@infradead.org
-rw-r--r-- | arch/x86/mm/pageattr.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 3cc4a2ae4dbb..33d89d505f93 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c | |||
@@ -328,6 +328,11 @@ static void cpa_flush_array(unsigned long baddr, unsigned long *start, | |||
328 | 328 | ||
329 | BUG_ON(irqs_disabled() && !early_boot_irqs_disabled); | 329 | BUG_ON(irqs_disabled() && !early_boot_irqs_disabled); |
330 | 330 | ||
331 | if (!static_cpu_has(X86_FEATURE_CLFLUSH)) { | ||
332 | cpa_flush_all(cache); | ||
333 | return; | ||
334 | } | ||
335 | |||
331 | flush_tlb_kernel_range(baddr, baddr + PAGE_SIZE * numpages); | 336 | flush_tlb_kernel_range(baddr, baddr + PAGE_SIZE * numpages); |
332 | 337 | ||
333 | if (!cache) | 338 | if (!cache) |
@@ -1756,19 +1761,19 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages, | |||
1756 | cache = !!pgprot2cachemode(mask_set); | 1761 | cache = !!pgprot2cachemode(mask_set); |
1757 | 1762 | ||
1758 | /* | 1763 | /* |
1759 | * On success we use CLFLUSH, when the CPU supports it to | 1764 | * On error; flush everything to be sure. |
1760 | * avoid the WBINVD. If the CPU does not support it and in the | ||
1761 | * error case we fall back to cpa_flush_all (which uses | ||
1762 | * WBINVD): | ||
1763 | */ | 1765 | */ |
1764 | if (!ret && boot_cpu_has(X86_FEATURE_CLFLUSH)) { | 1766 | if (ret) { |
1765 | if (cpa.flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) { | ||
1766 | cpa_flush_array(baddr, addr, numpages, cache, | ||
1767 | cpa.flags, pages); | ||
1768 | } else | ||
1769 | cpa_flush_range(baddr, numpages, cache); | ||
1770 | } else | ||
1771 | cpa_flush_all(cache); | 1767 | cpa_flush_all(cache); |
1768 | goto out; | ||
1769 | } | ||
1770 | |||
1771 | if (cpa.flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) { | ||
1772 | cpa_flush_array(baddr, addr, numpages, cache, | ||
1773 | cpa.flags, pages); | ||
1774 | } else { | ||
1775 | cpa_flush_range(baddr, numpages, cache); | ||
1776 | } | ||
1772 | 1777 | ||
1773 | out: | 1778 | out: |
1774 | return ret; | 1779 | return ret; |