mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yang Wencheng <east.moutain.yang@gmail.com>
To: x86@kernel.org
Cc: Yang Wencheng <east.moutain.yang@gmail.com>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Andy Lutomirski <luto@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	"Mike Rapoport (Microsoft)" <rppt@kernel.org>,
	Vishal Moola <vishal.moola@gmail.com>,
	"Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
	Coiby Xu <coiby.xu@gmail.com>,
	Arjan van de Ven <arjan@linux.intel.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] x86/mm: Allow clflush_cache_range() to flush large ranges
Date: Mon, 30 Nov 2026 14:57:11 +0800	[thread overview]
Message-ID: <20261130065719.174405-1-east.moutain.yang@gmail.com> (raw)

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")
Signed-off-by: Yang Wencheng <east.moutain.yang@gmail.com>
---
 arch/x86/include/asm/cacheflush.h | 2 +-
 arch/x86/mm/pat/set_memory.c      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
index b192d917a6d0..b3a2b5f1bef1 100644
--- a/arch/x86/include/asm/cacheflush.h
+++ b/arch/x86/include/asm/cacheflush.h
@@ -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 */
diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index b1d5c5a0ffb4..d115a9afef47 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -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
-- 
2.43.0


                 reply	other threads:[~2026-11-30  6:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130065719.174405-1-east.moutain.yang@gmail.com \
    --to=east.moutain.yang@gmail.com \
    --cc=arjan@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=coiby.xu@gmail.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rppt@kernel.org \
    --cc=tglx@kernel.org \
    --cc=vishal.moola@gmail.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®