Skip to contentSkip to conversation

x86/mm: Allow clflush_cache_range() to flush large ranges

PATCH In review Yang Wencheng 2 participants 2 messages Nov 30

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mm: Allow clflush_cache_range() to flush large ranges

clflush_cache_range() accepts an unsigned int size even though several callers naturally pass size_t values. Ranges larger than UINT_MAX are therefore truncated and only partially flushed.

Use size_t for the public interface and its internal helper so the complete range is preserved.

Fixes d7c8f21a8cad ("x86: cpa: move flush to cpa")
---
 arch/x86/include/asm/cacheflush.h | 2 +-
 arch/x86/mm/pat/set_memory.c      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/include/asm/cacheflush.h +1 -1
index b192d917a6d0..b3a2b5f1bef1 100644
@@ -8,6 +8,6 @@
 #include <asm-generic/cacheflush.h>
 #include <asm/special_insns.h>
 
-void clflush_cache_range(void *addr, unsigned int size);
+void clflush_cache_range(void *addr, size_t size);
 
 #endif /* _ASM_X86_CACHEFLUSH_H */
arch/x86/mm/pat/set_memory.c +2 -2
index b1d5c5a0ffb4..d115a9afef47 100644
@@ -325,7 +325,7 @@ static unsigned long __cpa_addr(struct cpa_data *cpa, unsigned long idx)
  * Flushing functions
  */
 
-static void clflush_cache_range_opt(void *vaddr, unsigned int size)
+static void clflush_cache_range_opt(void *vaddr, size_t size)
 {
 	const unsigned long clflush_size = boot_cpu_data.x86_clflush_size;
 	void *p = (void *)((unsigned long)vaddr & ~(clflush_size - 1));
@@ -346,7 +346,7 @@ static void clflush_cache_range_opt(void *vaddr, unsigned int size)
  * CLFLUSHOPT is an unordered instruction which needs fencing with MFENCE or
  * SFENCE to avoid ordering issues.
  */
-void clflush_cache_range(void *vaddr, unsigned int size)
+void clflush_cache_range(void *vaddr, size_t size)
 {
 	mb();
 	clflush_cache_range_opt(vaddr, size);

base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244

Signature · 1 line
2.43.0
#1 lore raw
Quoted 6 lines · Yang Wencheng

clflush_cache_range() accepts an unsigned int size even though several callers naturally pass size_t values. Ranges larger than UINT_MAX are therefore truncated and only partially flushed.

Use size_t for the public interface and its internal helper so the complete range is preserved.

Does this cause any practical problems?