functions Reply-To: Add checks to ensure that only page-aligned addresses are provided. Signed-off-by: Helge Deller <deller@xxxxxx> 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