From: Helge Deller <deller@gmx.de>
To: linux-parisc@vger.kernel.org, John David Anglin <dave.anglin@bell.net>
Subject: [PATCH] parisc: Add checks to verify page alignment in cache
Date: Wed, 1 Feb 2023 21:33:28 +0100 [thread overview]
Message-ID: <Y9rMmE5+8Nmp3AxC@p100> (raw)
functions
Reply-To:
Add checks to ensure that only page-aligned addresses are provided.
Signed-off-by: Helge Deller <deller@gmx.de>
diff --git a/arch/parisc/include/asm/cacheflush.h b/arch/parisc/include/asm/cacheflush.h
index 0bdee6724132..ff07c509e04b 100644
--- a/arch/parisc/include/asm/cacheflush.h
+++ b/arch/parisc/include/asm/cacheflush.h
@@ -15,6 +15,9 @@ DECLARE_STATIC_KEY_TRUE(parisc_has_cache);
DECLARE_STATIC_KEY_TRUE(parisc_has_dcache);
DECLARE_STATIC_KEY_TRUE(parisc_has_icache);
+#define PA_CHECK_PAGE_ALIGNED(addr) \
+ WARN_ON_ONCE((unsigned long)addr & ~PAGE_MASK)
+
#define flush_cache_dup_mm(mm) flush_cache_mm(mm)
void flush_user_icache_range_asm(unsigned long, unsigned long);
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
index 1d3b8bc8a623..595968f708c3 100644
--- a/arch/parisc/kernel/cache.c
+++ b/arch/parisc/kernel/cache.c
@@ -317,6 +317,7 @@ __flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr,
{
if (!static_branch_likely(&parisc_has_cache))
return;
+ PA_CHECK_PAGE_ALIGNED(vmaddr);
preempt_disable();
flush_dcache_page_asm(physaddr, vmaddr);
if (vma->vm_flags & VM_EXEC)
@@ -550,6 +551,7 @@ void flush_kernel_dcache_page_addr(const void *addr)
{
unsigned long flags;
+ PA_CHECK_PAGE_ALIGNED(addr);
flush_kernel_dcache_page_asm(addr);
purge_tlb_start(flags);
pdtlb(SR_KERNEL, addr);
@@ -567,8 +569,10 @@ static void flush_cache_page_if_present(struct vm_area_struct *vma,
* a non-access TLB miss. Hopefully, the page has already been
* flushed.
*/
- if (ptep && pte_needs_flush(*ptep))
+ if (ptep && pte_needs_flush(*ptep)) {
+ PA_CHECK_PAGE_ALIGNED(vmaddr);
flush_cache_page(vma, vmaddr, pfn);
+ }
}
void copy_user_highpage(struct page *to, struct page *from,
@@ -712,6 +716,7 @@ void flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned
{
if (WARN_ON(!pfn_valid(pfn)))
return;
+ PA_CHECK_PAGE_ALIGNED(vmaddr);
if (parisc_requires_coherency())
flush_user_cache_page(vma, vmaddr);
else
reply other threads:[~2023-02-01 20:33 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=Y9rMmE5+8Nmp3AxC@p100 \
--to=deller@gmx.de \
--cc=dave.anglin@bell.net \
--cc=linux-parisc@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.