sort out the flush_icache_range mess v2
Subsystems (27)
Hi all,
flush_icache_range is mostly used for kernel address, except for the following cases:
- the nommu brk and mmap implementations,
- the read_code helper that is only used for binfmt_flat, binfmt_elf_fdpic, and binfmt_aout including the broken ia32 compat version
- binfmt_flat itself,
none of which really are used by a typical MMU enabled kernel, as a.out can only be build for alpha and m68k to start with.
But strangely enough commit ae92ef8a4424 ("PATCH] flush icache in correct context") added a "set_fs(KERNEL_DS)" around the flush_icache_range call in the module loader, because apparently m68k assumed user pointers.
This series first cleans up the cacheflush implementations, largely by switching as much as possible to the asm-generic version after a few preparations, then moves the misnamed current flush_icache_user_range to a new name, to finally introduce a real flush_icache_user_range to be used for the above use cases to flush the instruction cache for a userspace address range. The last patch then drops the set_fs in the module code and moves it into the m68k implementation.
A git tree is available here:
git://git.infradead.org/users/hch/misc.git flush_icache_range.2
Gitweb:
http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/flush_icache_range.2
Changes since v1:
- fix pmem.c compilation on some s390 configs
- drop two patches picked up by the arch maintainers
PATCH 1/29 arm: fix the flush_icache_range arguments in set_fiq_handler
The arguments passed look bogus, try to fix them to something that seems to make sense.
--- arch/arm/kernel/fiq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/kernel/fiq.c +2 -2
@@ -98,8 +98,8 @@ void set_fiq_handler(void *start, unsigned int length)memcpy (base + offset, start, length);if (!cache_is_vipt_nonaliasing ()) -flush_icache_range ((unsigned long )base + offset, offset + - length); +flush_icache_range ((unsigned long )base + offset, + (unsigned long )base + offset + length);flush_icache_range (0xffff0000 + offset,0xffff0000 + offset + length); }
Signature · 1 line
2.26.2
PATCH 2/29 nds32: unexport flush_icache_page
In reply to Christoph Hellwigflush_icache_page is only used by mm/memory.c.
--- arch/nds32/mm/cacheflush.c | 1 - 1 file changed, 1 deletion(-)
arch/nds32/mm/cacheflush.c +0 -1
@@ -35,7 +35,6 @@ void flush_icache_page(struct vm_area_struct *vma, struct page *page)kunmap_atomic ((void *)kaddr);local_irq_restore (flags); } -EXPORT_SYMBOL (flush_icache_page);void flush_icache_user_range (struct vm_area_struct *vma,struct page *page,unsigned long addr,int len)
Signature · 1 line
2.26.2
PATCH 3/29 powerpc: unexport flush_icache_user_range
In reply to Christoph Hellwigflush_icache_user_range is only used by copy_to_user_page, which is only used by core VM code.
--- arch/powerpc/mm/mem.c | 1 - 1 file changed, 1 deletion(-)
arch/powerpc/mm/mem.c +0 -1
@@ -587,7 +587,6 @@ void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,flush_icache_range (maddr, maddr + len);kunmap (page); } -EXPORT_SYMBOL (flush_icache_user_range);/* * System memory should not be in /proc/iomem but various tools expect it
Signature · 1 line
2.26.2
PATCH 4/29 unicore32: remove flush_cache_user_range
In reply to Christoph Hellwigflush_cache_user_range is an ARMism not used by any generic or unicore32 specific code.
--- arch/unicore32/include/asm/cacheflush.h | 8 -------- 1 file changed, 8 deletions(-)
arch/unicore32/include/asm/cacheflush.h +0 -8
@@ -132,14 +132,6 @@ extern void flush_cache_page(struct vm_area_struct *vma,#define flush_cache_dup_mm (mm) flush_cache_mm(mm) -/* -* flush_cache_user_range is used when we want to ensure that the -* Harvard caches are synchronised for the user space address range. -* This is used for the UniCore private sys_cacheflush system call. -*/ -#define flush_cache_user_range (vma, start, end) \ - __cpuc_coherent_user_range((start) & PAGE_MASK, PAGE_ALIGN(end)) -/* * Perform necessary cache operations to ensure that data previously * stored within this range of addresses can be executed by the CPU.
Signature · 1 line
2.26.2
PATCH 5/29 asm-generic: fix the inclusion guards for cacheflush.h
In reply to Christoph Hellwigcacheflush.h uses a somewhat to generic include guard name that clashes with various arch files. Use a more specific one.
--- include/asm-generic/cacheflush.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/asm-generic/cacheflush.h +3 -3
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __ASM_CACHEFLUSH_H -#define __ASM_CACHEFLUSH_H +#ifndef _ASM_GENERIC_CACHEFLUSH_H +#define _ASM_GENERIC_CACHEFLUSH_H/* Keep includes the same across arches. */ #include <linux/mm.h>
@@ -109,4 +109,4 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end) memcpy(dst, src, len)#endif -#endif /* __ASM_CACHEFLUSH_H */ +#endif /* _ASM_GENERIC_CACHEFLUSH_H */
Signature · 1 line
2.26.2
PATCH 6/29 asm-generic: don't include <linux/mm.h> in cacheflush.h
In reply to Christoph HellwigThis seems to lead to some crazy include loops when using asm-generic/cacheflush.h on more architectures, so leave it to the arch header for now.
--- arch/um/include/asm/tlb.h | 2 ++ arch/x86/include/asm/cacheflush.h | 2 ++ drivers/nvdimm/pmem.c | 3 ++- include/asm-generic/cacheflush.h | 3 --- 4 files changed, 6 insertions(+), 4 deletions(-)
arch/um/include/asm/tlb.h +2 -0
@@ -2,6 +2,8 @@#ifndef __UM_TLB_H#define __UM_TLB_H +#include <linux/mm.h> +#include <asm/tlbflush.h> #include <asm-generic/cacheflush.h> #include <asm-generic/tlb.h>
arch/x86/include/asm/cacheflush.h +2 -0
@@ -2,6 +2,8 @@#ifndef _ASM_X86_CACHEFLUSH_H#define _ASM_X86_CACHEFLUSH_H +#include <linux/mm.h> +/* Caches aren't brain-dead on the intel. */ #include <asm-generic/cacheflush.h> #include <asm/special_insns.h>
drivers/nvdimm/pmem.c +2 -1
@@ -7,7 +7,6 @@* Copyright (c) 2015, Boaz Harrosh <[email protected]>. */ -#include <asm/cacheflush.h> #include <linux/blkdev.h> #include <linux/hdreg.h> #include <linux/init.h>
@@ -25,6 +24,8 @@#include <linux/dax.h> #include <linux/nd.h> #include <linux/backing-dev.h> +#include <linux/mm.h> +#include <asm/cacheflush.h> #include "pmem.h" #include "pfn.h" #include "nd.h"
include/asm-generic/cacheflush.h +0 -3
@@ -2,9 +2,6 @@#ifndef _ASM_GENERIC_CACHEFLUSH_H#define _ASM_GENERIC_CACHEFLUSH_H -/* Keep includes the same across arches. */ -#include <linux/mm.h> -#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0/*
Signature · 1 line
2.26.2
PATCH 1/1 media: omap3isp: Shuffle cacheflush.h and include mm.h
After mm.h was removed from the asm-generic version of cacheflush.h, s390 allyesconfig shows several warnings of the following nature:
In file included from ./arch/s390/include/generated/asm/cacheflush.h:1,
from drivers/media/platform/omap3isp/isp.c:42:./include/asm-generic/cacheflush.h:16:42: warning: 'struct mm_struct' declared inside parameter list will not be visible outside of this definition or declaration
cacheflush.h does not include mm.h nor does it include any forward declaration of these structures hence the warning. To avoid this, include mm.h explicitly in this file and shuffle cacheflush.h below it.
---
I am aware the fixes tag is kind of irrelevant because that SHA will change in the next linux-next revision and this will probably get folded into the original patch anyways but still.
The other solution would be to add forward declarations of these structs to the top of cacheflush.h, I just chose to do what Christoph did in the original patch. I am happy to do that instead if you all feel that is better.
drivers/media/platform/omap3isp/isp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/platform/omap3isp/isp.c +3 -2
@@ -39,8 +39,6 @@* Troy Laramy <[email protected]> */ -#include <asm/cacheflush.h> -#include <linux/clk.h> #include <linux/clkdev.h> #include <linux/delay.h>
@@ -49,6 +47,7 @@#include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/mfd/syscon.h> +#include <linux/mm.h> #include <linux/module.h> #include <linux/omap-iommu.h> #include <linux/platform_device.h>
@@ -58,6 +57,8 @@#include <linux/sched.h> #include <linux/vmalloc.h> +#include <asm/cacheflush.h> +#ifdef CONFIG_ARM_DMA_USE_IOMMU #include <asm/dma-iommu.h> #endif
Signature · 1 line
2.27.0.rc0
Re: [PATCH] media: omap3isp: Shuffle cacheflush.h and include mm.h
Quoted 2 lines · Nathan Chancellor
After
mm.hwas removed from the asm-generic version ofcacheflush.h, s390 allyesconfig shows several warnings of the following nature:
Hmm, I'm pretty sure I sent the same fix a few days ago in response to a build bot report. But if that didn't get picked up I'm fine with your version of it as well of course:
Geert Uytterhoeven
maintainerRe: [PATCH] media: omap3isp: Shuffle cacheflush.h and include mm.h
In reply to Nathan ChancellorHi Nathan,
CC Laurent
Quoted 9 lines · Nathan Chancellor
After
mm.hwas removed from the asm-generic version ofcacheflush.h, s390 allyesconfig shows several warnings of the following nature:In file included from
./arch/s390/include/generated/asm/cacheflush.h:1,
fromdrivers/media/platform/omap3isp/isp.c:42:./include/asm-generic/cacheflush.h:16:42: warning: 'structmm_struct' declared inside parameter list will not be visible outside of this definition or declaration
Quoted 6 lines
cacheflush.hdoes not includemm.hnor does it include any forward declaration of these structures hence the warning. To avoid this, includemm.hexplicitly in this file and shufflecacheflush.hbelow it.Fixes 19c0054597a0 ("asm-generic: don't include <linux/mm.h> in cacheflush.h")Signed-off-by Nathan Chancellor <[email protected]>
Thanks for your patch!
Quoted 8 lines
I am aware the fixes tag is kind of irrelevant because that SHA will change in the next linux-next revision and this will probably get folded into the original patch anyways but still.
The other solution would be to add forward declarations of these structs to the top of
cacheflush.h, I just chose to do what Christoph did in the original patch. I am happy to do that instead if you all feel that is better.
That actually looks like a better solution to me, as it would address the problem for all users.
Quoted 25 lines
drivers/media/platform/omap3isp/isp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/media/platform/omap3isp/isp.c +1
-2@@ -39,8 +39,6 @@* Troy Laramy <[email protected]> */ -#include <asm/cacheflush.h> -#include <linux/clk.h> #include <linux/clkdev.h> #include <linux/delay.h> @@ -49,6 +47,7 @@#include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/mfd/syscon.h> +#include <linux/mm.h> #include <linux/module.h> #include <linux/omap-iommu.h> #include <linux/platform_device.h>
drivers/media/platform/omap3isp/isp.c line 64
Quoted 8 lines
drivers/media/platform/omap3isp/isp.c +2
-0@@ -58,6 +57,8 @@#include <linux/sched.h> #include <linux/vmalloc.h> +#include <asm/cacheflush.h> +#ifdef CONFIG_ARM_DMA_USE_IOMMU #include <asm/dma-iommu.h> #endif
Why does this file need <asm/cacheflush.h> at all?
It doesn't call any of the flush_*() functions, and seems to compile fine without (on arm32).
Perhaps it was included at the top intentionally, to override the definitions of copy_{to,from}_user_page()? Fortunately that doesn't seem to be the case, from a quick look at the assembler output.
So let's just remove the #include instead?
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH] media: omap3isp: Shuffle cacheflush.h and include mm.h
Hi Geert,
Quoted 74 lines · Geert Uytterhoeven
Hi Nathan,
CC Laurent
Quoted 9 lines · Nathan Chancellor
After
mm.hwas removed from the asm-generic version ofcacheflush.h, s390 allyesconfig shows several warnings of the following nature:In file included from
./arch/s390/include/generated/asm/cacheflush.h:1,
fromdrivers/media/platform/omap3isp/isp.c:42:./include/asm-generic/cacheflush.h:16:42: warning: 'structmm_struct' declared inside parameter list will not be visible outside of this definition or declarationQuoted 6 lines
cacheflush.hdoes not includemm.hnor does it include any forward declaration of these structures hence the warning. To avoid this, includemm.hexplicitly in this file and shufflecacheflush.hbelow it.Fixes 19c0054597a0 ("asm-generic: don't include <linux/mm.h> in cacheflush.h")Signed-off-by Nathan Chancellor <[email protected]>Thanks for your patch!
Quoted 8 lines
I am aware the fixes tag is kind of irrelevant because that SHA will change in the next linux-next revision and this will probably get folded into the original patch anyways but still.
The other solution would be to add forward declarations of these structs to the top of
cacheflush.h, I just chose to do what Christoph did in the original patch. I am happy to do that instead if you all feel that is better.That actually looks like a better solution to me, as it would address the problem for all users.
Quoted 25 lines
drivers/media/platform/omap3isp/isp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/media/platform/omap3isp/isp.c +1
-2@@ -39,8 +39,6 @@* Troy Laramy <[email protected]> */ -#include <asm/cacheflush.h> -#include <linux/clk.h> #include <linux/clkdev.h> #include <linux/delay.h> @@ -49,6 +47,7 @@#include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/mfd/syscon.h> +#include <linux/mm.h> #include <linux/module.h> #include <linux/omap-iommu.h> #include <linux/platform_device.h> drivers/media/platform/omap3isp/isp.c line 64
Quoted 8 lines
drivers/media/platform/omap3isp/isp.c +2
-0@@ -58,6 +57,8 @@#include <linux/sched.h> #include <linux/vmalloc.h> +#include <asm/cacheflush.h> +#ifdef CONFIG_ARM_DMA_USE_IOMMU #include <asm/dma-iommu.h> #endif Why does this file need <
asm/cacheflush.h> at all?
It doesn't call any of the flush_*() functions, and seems to compile fine without (on arm32).
Quoted 5 lines
Perhaps it was included at the top intentionally, to override the definitions of copy_{to,from}_user_page()? Fortunately that doesn't seem to be the case, from a quick look at the assembler output.
So let's just remove the #include instead?
Sounds good to me. I can send a patch if needed or I suppose Andrew can just make a small fixup patch for it. Let me know what I should do.
Cheers,
Nathan
Re: [PATCH] media: omap3isp: Shuffle cacheflush.h and include mm.h
Hi Nathan,
(CC'ing Sakari Ailus and the linux-media mailing list)
Quoted 24 lines · Nathan Chancellor
Quoted 23 lines · Geert Uytterhoeven
Quoted 9 lines · Nathan Chancellor
After
mm.hwas removed from the asm-generic version ofcacheflush.h, s390 allyesconfig shows several warnings of the following nature:In file included from
./arch/s390/include/generated/asm/cacheflush.h:1,
fromdrivers/media/platform/omap3isp/isp.c:42:./include/asm-generic/cacheflush.h:16:42: warning: 'structmm_struct' declared inside parameter list will not be visible outside of this definition or declarationQuoted 6 lines
cacheflush.hdoes not includemm.hnor does it include any forward declaration of these structures hence the warning. To avoid this, includemm.hexplicitly in this file and shufflecacheflush.hbelow it.Fixes 19c0054597a0 ("asm-generic: don't include <linux/mm.h> in cacheflush.h")Signed-off-by Nathan Chancellor <[email protected]>Thanks for your patch!
Quoted 4 lines
I am aware the fixes tag is kind of irrelevant because that SHA will change in the next linux-next revision and this will probably get folded into the original patch anyways but still.
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
The other solution would be to add forward declarations of these structs to the top of
cacheflush.h, I just chose to do what Christoph did in the original patch. I am happy to do that instead if you all feel that is better.That actually looks like a better solution to me, as it would address the problem for all users.
Headers should be self-contained, so that would be the best fix in my opinion.
This being said, as cacheflush.h isn't needed in isp.c, I think we should also drop it. It seems to have been included there since the first driver version, and was likely a left-over from the out-of-tree development. Manual cache handling was part of drivers/media/platform/omap3isp/ispqueue.c and has been removed in commit fbac1400bd1a ("[media] omap3isp: Move to videobuf2").
cacheflush.h can also be dropped from ispvideo.c which suffers from the same issue.
Quoted 46 lines
Quoted 38 lines
Quoted 25 lines
drivers/media/platform/omap3isp/isp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/media/platform/omap3isp/isp.c +1
-2@@ -39,8 +39,6 @@* Troy Laramy <[email protected]> */ -#include <asm/cacheflush.h> -#include <linux/clk.h> #include <linux/clkdev.h> #include <linux/delay.h> @@ -49,6 +47,7 @@#include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/mfd/syscon.h> +#include <linux/mm.h> #include <linux/module.h> #include <linux/omap-iommu.h> #include <linux/platform_device.h> drivers/media/platform/omap3isp/isp.c line 64
Quoted 8 lines
drivers/media/platform/omap3isp/isp.c +2
-0@@ -58,6 +57,8 @@#include <linux/sched.h> #include <linux/vmalloc.h> +#include <asm/cacheflush.h> +#ifdef CONFIG_ARM_DMA_USE_IOMMU #include <asm/dma-iommu.h> #endif Why does this file need <
asm/cacheflush.h> at all?
It doesn't call any of the flush_*() functions, and seems to compile fine without (on arm32).Quoted 5 lines
Perhaps it was included at the top intentionally, to override the definitions of copy_{to,from}_user_page()? Fortunately that doesn't seem to be the case, from a quick look at the assembler output.
So let's just remove the #include instead?
Sounds good to me. I can send a patch if needed or I suppose Andrew can just make a small fixup patch for it. Let me know what I should do.
Signature · 3 lines
Regards, Laurent Pinchart
PATCH 7/29 asm-generic: improve the flush_dcache_page stub
In reply to Christoph HellwigThere is a magic ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE cpp symbol that guards non-stub availability of flush_dcache_pagge. Use that to check if flush_dcache_pagg is implemented.
--- include/asm-generic/cacheflush.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/asm-generic/cacheflush.h +3 -3
@@ -2,8 +2,6 @@#ifndef _ASM_GENERIC_CACHEFLUSH_H#define _ASM_GENERIC_CACHEFLUSH_H -#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 -/* * The cache doesn't need to be flushed when TLB entries change when * the cache is mapped to physical memory, not virtual memory
@@ -42,12 +40,14 @@ static inline void flush_cache_page(struct vm_area_struct *vma, }#endif -#ifndef flush_dcache_page +#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE static inline void flush_dcache_page (struct page *page) { } +#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0#endif +#ifndef flush_dcache_mmap_lockstatic inline void flush_dcache_mmap_lock (struct address_space *mapping) {
Signature · 1 line
2.26.2
PATCH 8/29 alpha: use asm-generic/cacheflush.h
In reply to Christoph HellwigAlpha needs almost no cache flushing routines of its own. Rely on asm-generic/cacheflush.h for the defaults.
--- arch/alpha/include/asm/cacheflush.h | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-)
arch/alpha/include/asm/cacheflush.h +6 -22
@@ -4,19 +4,6 @@#include <linux/mm.h> -/* Caches aren't brain-dead on the Alpha. */ -#define flush_cache_all () do { } while (0) -#define flush_cache_mm (mm) do { } while (0) -#define flush_cache_dup_mm (mm) do { } while (0) -#define flush_cache_range (vma, start, end) do { } while (0) -#define flush_cache_page (vma, vmaddr, pfn) do { } while (0) -#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 -#define flush_dcache_page (page) do { } while (0) -#define flush_dcache_mmap_lock (mapping) do { } while (0) -#define flush_dcache_mmap_unlock (mapping) do { } while (0) -#define flush_cache_vmap (start, end) do { } while (0) -#define flush_cache_vunmap (start, end) do { } while (0) -/* Note that the following two definitions are _highly_ dependent on the contexts in which they are used in the kernel. I personally think it is criminal how loosely defined these macros are. */
@@ -59,20 +46,17 @@ flush_icache_user_range(struct vm_area_struct *vma, struct page *page, mm->context[smp_processor_id ()] =0 ; } } -#else +#define flush_icache_user_range flush_icache_user_range +#else /* CONFIG_SMP */ extern void flush_icache_user_range (struct vm_area_struct *vma,struct page *page,unsigned long addr,int len); -#endif +#define flush_icache_user_range flush_icache_user_range +#endif /* CONFIG_SMP */ /* This is used only in __do_fault and do_swap_page. */ #define flush_icache_page (vma, page) \ - flush_icache_user_range((vma), (page), 0, 0) + flush_icache_user_range((vma), (page), 0, 0) -#define copy_to_user_page (vma, page, vaddr, dst, src, len) \ -do { memcpy(dst, src, len); \ - flush_icache_user_range(vma, page, vaddr, len); \ -} while (0) -#define copy_from_user_page (vma, page, vaddr, dst, src, len) \ - memcpy(dst, src, len) +#include <asm-generic/cacheflush.h> #endif /* _ALPHA_CACHEFLUSH_H */
Signature · 1 line
2.26.2
PATCH 9/29 arm64: use asm-generic/cacheflush.h
In reply to Christoph HellwigARM64 needs almost no cache flushing routines of its own. Rely on asm-generic/cacheflush.h for the defaults.
--- arch/arm64/include/asm/cacheflush.h | 46 ++++------------------------- 1 file changed, 5 insertions(+), 41 deletions(-)
arch/arm64/include/asm/cacheflush.h +5 -41
@@ -94,20 +94,7 @@ static inline void flush_icache_range(unsigned long start, unsigned long end)#endif kick_all_cpus_sync (); } - -static inline void flush_cache_mm (struct mm_struct *mm) -{ -} - -static inline void flush_cache_page (struct vm_area_struct *vma, -unsigned long user_addr,unsigned long pfn) -{ -} - -static inline void flush_cache_range (struct vm_area_struct *vma, -unsigned long start,unsigned long end) -{ -} +#define flush_icache_range flush_icache_range/* * Cache maintenance functions used by the DMA API. No to be used directly.
@@ -123,12 +110,7 @@ extern void __dma_flush_area(const void *, size_t);*/ extern void copy_to_user_page (struct vm_area_struct *,struct page *,unsigned long ,void *,const void *,unsigned long ); -#define copy_from_user_page (vma, page, vaddr, dst, src, len) \ - do { \ - memcpy(dst, src, len); \ - } while (0) - -#define flush_cache_dup_mm (mm) flush_cache_mm(mm) +#define copy_to_user_page copy_to_user_page/* * flush_dcache_page is used when the kernel has written to the page
@@ -154,29 +136,11 @@ static __always_inline void __flush_icache_all(void) dsb(ish); } -#define flush_dcache_mmap_lock (mapping) do { } while (0) -#define flush_dcache_mmap_unlock (mapping) do { } while (0) - -/* -* We don't appear to need to do anything here. In fact, if we did, we'd -* duplicate cache flushing elsewhere performed by flush_dcache_page(). -*/ -#define flush_icache_page (vma,page) do { } while (0) - -/* -* Not required on AArch64 (PIPT or VIPT non-aliasing D-cache). -*/ -static inline void flush_cache_vmap (unsigned long start,unsigned long end) -{ -} - -static inline void flush_cache_vunmap (unsigned long start,unsigned long end) -{ -} -int set_memory_valid (unsigned long addr,int numpages,int enable);int set_direct_map_invalid_noflush (struct page *page);int set_direct_map_default_noflush (struct page *page); -#endif +#include <asm-generic/cacheflush.h> + +#endif /* __ASM_CACHEFLUSH_H */
Signature · 1 line
2.26.2
Re: [PATCH 09/29] arm64: use asm-generic/cacheflush.h
Quoted 4 lines · Christoph Hellwig
ARM64 needs almost no cache flushing routines of its own. Rely on
asm-generic/cacheflush.hfor the defaults.Signed-off-by Christoph Hellwig <[email protected]>
PATCH 10/29 c6x: use asm-generic/cacheflush.h
In reply to Christoph HellwigC6x needs almost no cache flushing routines of its own. Rely on asm-generic/cacheflush.h for the defaults.
--- arch/c6x/include/asm/cacheflush.h | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
arch/c6x/include/asm/cacheflush.h +1 -18
@@ -16,21 +16,6 @@#include <asm/page.h> #include <asm/string.h> -/* -* virtually-indexed cache management (our cache is physically indexed) -*/ -#define flush_cache_all () do {} while (0) -#define flush_cache_mm (mm) do {} while (0) -#define flush_cache_dup_mm (mm) do {} while (0) -#define flush_cache_range (mm, start, end) do {} while (0) -#define flush_cache_page (vma, vmaddr, pfn) do {} while (0) -#define flush_cache_vmap (start, end) do {} while (0) -#define flush_cache_vunmap (start, end) do {} while (0) -#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 -#define flush_dcache_page (page) do {} while (0) -#define flush_dcache_mmap_lock (mapping) do {} while (0) -#define flush_dcache_mmap_unlock (mapping) do {} while (0) -/* * physically-indexed cache management */
@@ -49,14 +34,12 @@ do { \ (unsigned long) page_address(page) + PAGE_SIZE)); \ } while (0) -#define copy_to_user_page (vma, page, vaddr, dst, src, len) \ do { \ memcpy(dst, src, len); \ flush_icache_range((unsigned) (dst), (unsigned) (dst) + (len)); \ } while (0) -#define copy_from_user_page (vma, page, vaddr, dst, src, len) \ - memcpy(dst, src, len) +#include <asm-generic/cacheflush.h> #endif /* _ASM_C6X_CACHEFLUSH_H */
Signature · 1 line
2.26.2
Re: [PATCH 10/29] c6x: use asm-generic/cacheflush.h
Quoted 40 lines · Christoph Hellwig
C6x needs almost no cache flushing routines of its own. Rely on
asm-generic/cacheflush.hfor the defaults.Signed-off-by Christoph Hellwig <[email protected]>--- arch/c6x/include/asm/cacheflush.h | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)arch/c6x/include/asm/cacheflush.h +0
-16@@ -16,21 +16,6 @@#include <asm/page.h> #include <asm/string.h> -/* -* virtually-indexed cache management (our cache is physically indexed) -*/ -#define flush_cache_all () do {} while (0) -#define flush_cache_mm (mm) do {} while (0) -#define flush_cache_dup_mm (mm) do {} while (0) -#define flush_cache_range (mm, start, end) do {} while (0) -#define flush_cache_page (vma, vmaddr, pfn) do {} while (0) -#define flush_cache_vmap (start, end) do {} while (0) -#define flush_cache_vunmap (start, end) do {} while (0) -#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 -#define flush_dcache_page (page) do {} while (0) -#define flush_dcache_mmap_lock (mapping) do {} while (0) -#define flush_dcache_mmap_unlock (mapping) do {} while (0) -/* * physically-indexed cache management */ @@ -49,14 +34,12 @@ do { \ (unsigned long) page_address(page) + PAGE_SIZE)); \ }while (0 ) - #define copy_to_user_page(vma, page, vaddr, dst, src, len) \
arch/c6x/include/asm/cacheflush.h do { \ · line 45
Quoted 10 lines
arch/c6x/include/asm/cacheflush.h +1
-2do { \memcpy (dst, src, len); \flush_icache_range ((unsigned ) (dst), (unsigned ) (dst) + (len)); \ } while (0) -#define copy_from_user_page (vma, page, vaddr, dst, src, len) \ - memcpy(dst, src, len) +#include <asm-generic/cacheflush.h> #endif /* _ASM_C6X_CACHEFLUSH_H */
PATCH 11/29 hexagon: use asm-generic/cacheflush.h
In reply to Christoph HellwigHexagon needs almost no cache flushing routines of its own. Rely on asm-generic/cacheflush.h for the defaults.
--- arch/hexagon/include/asm/cacheflush.h | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
arch/hexagon/include/asm/cacheflush.h +5 -14
@@ -25,29 +25,17 @@#define LINESIZE 32#define LINEBITS 5 -#define flush_cache_all () do { } while (0) -#define flush_cache_mm (mm) do { } while (0) -#define flush_cache_dup_mm (mm) do { } while (0) -#define flush_cache_range (vma, start, end) do { } while (0) -#define flush_cache_page (vma, vmaddr, pfn) do { } while (0) -#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 -#define flush_dcache_page (page) do { } while (0) -#define flush_dcache_mmap_lock (mapping) do { } while (0) -#define flush_dcache_mmap_unlock (mapping) do { } while (0) -#define flush_icache_page (vma, pg) do { } while (0) -#define flush_icache_user_range (vma, pg, adr, len) do { } while (0) -#define flush_cache_vmap (start, end) do { } while (0) -#define flush_cache_vunmap (start, end) do { } while (0) -/* * Flush Dcache range through current map. */ extern void flush_dcache_range (unsigned long start,unsigned long end); +#define flush_dcache_range flush_dcache_range/* * Flush Icache range through current map. */ extern void flush_icache_range (unsigned long start,unsigned long end); +#define flush_icache_range flush_icache_range/* * Memory-management related flushes are there to ensure in non-physically
@@ -78,6 +66,7 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,void copy_to_user_page (struct vm_area_struct *vma,struct page *page,unsigned long vaddr,void *dst,void *src,int len); +#define copy_to_user_page copy_to_user_page#define copy_from_user_page (vma, page, vaddr, dst, src, len) \ memcpy(dst, src, len)
@@ -85,4 +74,6 @@ void copy_to_user_page(struct vm_area_struct *vma, struct page *page,extern void hexagon_inv_dcache_range (unsigned long start,unsigned long end);extern void hexagon_clean_dcache_range (unsigned long start,unsigned long end); +#include <asm-generic/cacheflush.h> +#endif
Signature · 1 line
2.26.2
PATCH 12/29 ia64: use asm-generic/cacheflush.h
In reply to Christoph HellwigIA64 needs almost no cache flushing routines of its own. Rely on asm-generic/cacheflush.h for the defaults.
--- arch/ia64/include/asm/cacheflush.h | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-)
arch/ia64/include/asm/cacheflush.h +3 -25
@@ -12,44 +12,22 @@#include <asm/page.h> -/* -* Cache flushing routines. This is the kind of stuff that can be very expensive, so try -* to avoid them whenever possible. -*/ - -#define flush_cache_all () do { } while (0) -#define flush_cache_mm (mm) do { } while (0) -#define flush_cache_dup_mm (mm) do { } while (0) -#define flush_cache_range (vma, start, end) do { } while (0) -#define flush_cache_page (vma, vmaddr, pfn) do { } while (0) -#define flush_icache_page (vma,page) do { } while (0) -#define flush_cache_vmap (start, end) do { } while (0) -#define flush_cache_vunmap (start, end) do { } while (0) -#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1#define flush_dcache_page (page) \ do { \ clear_bit(PG_arch_1, &(page)->flags); \ } while (0) -#define flush_dcache_mmap_lock (mapping) do { } while (0) -#define flush_dcache_mmap_unlock (mapping) do { } while (0) - -extern void flush_icache_range (unsigned long start,unsigned long end); +extern void flush_icache_range (unsigned long start,unsigned long end); +#define flush_icache_range flush_icache_rangeextern void clflush_cache_range (void *addr,int size); -#define flush_icache_user_range (vma, page, user_addr, len) \ do { \ unsigned long _addr = (unsigned long) page_address(page) + ((user_addr) & ~PAGE_MASK); \ flush_icache_range(_addr, _addr + (len)); \ } while (0) -#define copy_to_user_page (vma, page, vaddr, dst, src, len) \ -do { memcpy(dst, src, len); \ - flush_icache_user_range(vma, page, vaddr, len); \ -} while (0) -#define copy_from_user_page (vma, page, vaddr, dst, src, len) \ - memcpy(dst, src, len) +#include <asm-generic/cacheflush.h> #endif /* _ASM_IA64_CACHEFLUSH_H */
Signature · 1 line
2.26.2
PATCH 13/29 microblaze: use asm-generic/cacheflush.h
In reply to Christoph HellwigMicroblaze needs almost no cache flushing routines of its own. Rely on asm-generic/cacheflush.h for the defaults.
--- arch/microblaze/include/asm/cacheflush.h | 29 ++---------------------- 1 file changed, 2 insertions(+), 27 deletions(-)
arch/microblaze/include/asm/cacheflush.h +2 -27
@@ -57,9 +57,6 @@ void microblaze_cache_init(void);#define invalidate_icache () mbc->iin();#define invalidate_icache_range (start, end) mbc->iinr(start, end); -#define flush_icache_user_range (vma, pg, adr, len) flush_icache(); -#define flush_icache_page (vma, pg) do { } while (0) -#define enable_dcache () mbc->de();#define disable_dcache () mbc->dd();/* FIXME for LL-temac driver */
@@ -77,27 +74,9 @@ do { \flush_dcache_range ((unsigned ) (addr), (unsigned ) (addr) +PAGE_SIZE ); \ }while (0 ); -#define flush_dcache_mmap_lock (mapping) do { } while (0) -#define flush_dcache_mmap_unlock (mapping) do { } while (0) - -#define flush_cache_dup_mm (mm) do { } while (0) -#define flush_cache_vmap (start, end) do { } while (0) -#define flush_cache_vunmap (start, end) do { } while (0) -#define flush_cache_mm (mm) do { } while (0) -#define flush_cache_page (vma, vmaddr, pfn) \ flush_dcache_range(pfn << PAGE_SHIFT, (pfn << PAGE_SHIFT) + PAGE_SIZE); -/* MS: kgdb code use this macro, wrong len with FLASH */ -#if 0 -#define flush_cache_range (vma, start, len) { \ - flush_icache_range((unsigned) (start), (unsigned) (start) + (len)); \ - flush_dcache_range((unsigned) (start), (unsigned) (start) + (len)); \ -} -#endif - -#define flush_cache_range (vma, start, len) do { } while (0) -static inline void copy_to_user_page (struct vm_area_struct *vma,struct page *page,unsigned long vaddr,void *dst,void *src,int len)
@@ -109,12 +88,8 @@ static inline void copy_to_user_page(struct vm_area_struct *vma, flush_dcache_range(addr, addr + PAGE_SIZE); } } +#define copy_to_user_page copy_to_user_page -static inline void copy_from_user_page (struct vm_area_struct *vma, -struct page *page,unsigned long vaddr, -void *dst,void *src,int len) -{ -memcpy (dst, src, len); -} +#include <asm-generic/cacheflush.h> #endif /* _ASM_MICROBLAZE_CACHEFLUSH_H */
Signature · 1 line
2.26.2
PATCH 14/29 m68knommu: use asm-generic/cacheflush.h
In reply to Christoph Hellwigm68knommu needs almost no cache flushing routines of its own. Rely on asm-generic/cacheflush.h for the defaults.
--- arch/m68k/include/asm/cacheflush_no.h | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)
arch/m68k/include/asm/cacheflush_no.h +2 -17
@@ -9,25 +9,8 @@#include <asm/mcfsim.h> #define flush_cache_all () __flush_cache_all() -#define flush_cache_mm (mm) do { } while (0) -#define flush_cache_dup_mm (mm) do { } while (0) -#define flush_cache_range (vma, start, end) do { } while (0) -#define flush_cache_page (vma, vmaddr) do { } while (0)#define flush_dcache_range (start, len) __flush_dcache_all() -#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 -#define flush_dcache_page (page) do { } while (0) -#define flush_dcache_mmap_lock (mapping) do { } while (0) -#define flush_dcache_mmap_unlock (mapping) do { } while (0)#define flush_icache_range (start, len) __flush_icache_all() -#define flush_icache_page (vma,pg) do { } while (0) -#define flush_icache_user_range (vma,pg,adr,len) do { } while (0) -#define flush_cache_vmap (start, end) do { } while (0) -#define flush_cache_vunmap (start, end) do { } while (0) - -#define copy_to_user_page (vma, page, vaddr, dst, src, len) \ - memcpy(dst, src, len) -#define copy_from_user_page (vma, page, vaddr, dst, src, len) \ - memcpy(dst, src, len)void mcf_cache_push (void );
@@ -98,4 +81,6 @@ static inline void cache_clear(unsigned long paddr, int len) __clear_cache_all(); } +#include <asm-generic/cacheflush.h> +#endif /* _M68KNOMMU_CACHEFLUSH_H */
Signature · 1 line
2.26.2
PATCH 15/29 openrisc: use asm-generic/cacheflush.h
In reply to Christoph HellwigOpenRISC needs almost no cache flushing routines of its own. Rely on asm-generic/cacheflush.h for the defaults.
--- arch/openrisc/include/asm/cacheflush.h | 31 +++++--------------------- 1 file changed, 6 insertions(+), 25 deletions(-)
arch/openrisc/include/asm/cacheflush.h +0 -16
@@ -62,31 +62,12 @@ static inline void flush_dcache_page(struct page *page)clear_bit (PG_dc_clean, &page->flags); } -/* -* Other interfaces are not required since we do not have virtually -* indexed or tagged caches. So we can use the default here. -*/ -#define flush_cache_all () do { } while (0) -#define flush_cache_mm (mm) do { } while (0) -#define flush_cache_dup_mm (mm) do { } while (0) -#define flush_cache_range (vma, start, end) do { } while (0) -#define flush_cache_page (vma, vmaddr, pfn) do { } while (0) -#define flush_dcache_mmap_lock (mapping) do { } while (0) -#define flush_dcache_mmap_unlock (mapping) do { } while (0) -#define flush_icache_range (start, end) do { } while (0) -#define flush_icache_page (vma, pg) do { } while (0) -#define flush_icache_user_range (vma, pg, adr, len) do { } while (0) -#define flush_cache_vmap (start, end) do { } while (0) -#define flush_cache_vunmap (start, end) do { } while (0)
PATCH 16/29 powerpc: use asm-generic/cacheflush.h
In reply to Christoph HellwigPower needs almost no cache flushing routines of its own. Rely on asm-generic/cacheflush.h for the defaults.
Also remove the pointless __KERNEL__ ifdef while we're at it.
--- arch/powerpc/include/asm/cacheflush.h | 42 +++++++-------------------- 1 file changed, 10 insertions(+), 32 deletions(-)
arch/powerpc/include/asm/cacheflush.h +9 -30
@@ -4,23 +4,9 @@#ifndef _ASM_POWERPC_CACHEFLUSH_H#define _ASM_POWERPC_CACHEFLUSH_H -#ifdef __KERNEL__ -#include <linux/mm.h> #include <asm/cputable.h> -/* -* No cache flushing is required when address mappings are changed, -* because the caches on PowerPCs are physically addressed. -*/ -#define flush_cache_all () do { } while (0) -#define flush_cache_mm (mm) do { } while (0) -#define flush_cache_dup_mm (mm) do { } while (0) -#define flush_cache_range (vma, start, end) do { } while (0) -#define flush_cache_page (vma, vmaddr, pfn) do { } while (0) -#define flush_icache_page (vma, page) do { } while (0) -#define flush_cache_vunmap (start, end) do { } while (0) -#ifdef CONFIG_PPC_BOOK3S_64 /* * Book3s has no ptesync after setting a pte, so without this ptesync it's
@@ -33,20 +19,20 @@ static inline void flush_cache_vmap(unsigned long start, unsigned long end) { asmvolatile ("ptesync" :::"memory" ); } -#else -static inline void flush_cache_vmap (unsigned long start,unsigned long end) { } -#endif +#define flush_cache_vmap flush_cache_vmap +#endif /* CONFIG_PPC_BOOK3S_64 */ #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1extern void flush_dcache_page (struct page *page); -#define flush_dcache_mmap_lock (mapping) do { } while (0) -#define flush_dcache_mmap_unlock (mapping) do { } while (0)void flush_icache_range (unsigned long start,unsigned long stop); -extern void flush_icache_user_range (struct vm_area_struct *vma, -struct page *page,unsigned long addr, -int len); -extern void flush_dcache_icache_page (struct page *page); +#define flush_icache_range flush_icache_range + +void flush_icache_user_range (struct vm_area_struct *vma,struct page *page, +unsigned long addr,int len); +#define flush_icache_user_range flush_icache_user_range + +void flush_dcache_icache_page (struct page *page);void __flush_dcache_icache (void *page);/**
@@ -111,14 +97,6 @@ static inline void invalidate_dcache_range(unsigned long start,mb ();/* sync */ } -#define copy_to_user_page (vma, page, vaddr, dst, src, len) \ - do { \ - memcpy(dst, src, len); \ - flush_icache_user_range(vma, page, vaddr, len); \ - } while (0) -#define copy_from_user_page (vma, page, vaddr, dst, src, len) \ - memcpy(dst, src, len)
PATCH 17/29 riscv: use asm-generic/cacheflush.h
In reply to Christoph HellwigRISC-V needs almost no cache flushing routines of its own. Rely on asm-generic/cacheflush.h for the defaults.
Also remove the pointless __KERNEL__ ifdef while we're at it.
--- arch/riscv/include/asm/cacheflush.h | 62 ++--------------------------- 1 file changed, 3 insertions(+), 59 deletions(-)
arch/riscv/include/asm/cacheflush.h +3 -59
@@ -8,65 +8,6 @@#include <linux/mm.h> -#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 - -/* -* The cache doesn't need to be flushed when TLB entries change when -* the cache is mapped to physical memory, not virtual memory -*/ -static inline void flush_cache_all (void ) -{ -} - -static inline void flush_cache_mm (struct mm_struct *mm) -{ -} - -static inline void flush_cache_dup_mm (struct mm_struct *mm) -{ -} - -static inline void flush_cache_range (struct vm_area_struct *vma, -unsigned long start, -unsigned long end) -{ -} - -static inline void flush_cache_page (struct vm_area_struct *vma, -unsigned long vmaddr, -unsigned long pfn) -{ -} - -static inline void flush_dcache_mmap_lock (struct address_space *mapping) -{ -} - -static inline void flush_dcache_mmap_unlock (struct address_space *mapping) -{ -} - -static inline void flush_icache_page (struct vm_area_struct *vma, -struct page *page) -{ -} - -static inline void flush_cache_vmap (unsigned long start,unsigned long end) -{ -} - -static inline void flush_cache_vunmap (unsigned long start,unsigned long end) -{ -} - -#define copy_to_user_page (vma, page, vaddr, dst, src, len) \ - do { \ - memcpy(dst, src, len); \ - flush_icache_user_range(vma, page, vaddr, len); \ - } while (0) -#define copy_from_user_page (vma, page, vaddr, dst, src, len) \ - memcpy(dst, src, len) -static inline void local_flush_icache_all (void ) { asmvolatile ("fence.i" :::"memory" );
@@ -79,6 +20,7 @@ static inline void flush_dcache_page(struct page *page)if (test_bit (PG_dcache_clean, &page->flags))clear_bit (PG_dcache_clean, &page->flags); } +#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1/* * RISC-V doesn't have an instruction to flush parts of the instruction cache,
@@ -105,4 +47,6 @@ void flush_icache_mm(struct mm_struct *mm, bool local);#define SYS_RISCV_FLUSH_ICACHE_LOCAL 1UL#define SYS_RISCV_FLUSH_ICACHE_ALL (SYS_RISCV_FLUSH_ICACHE_LOCAL) +#include <asm-generic/cacheflush.h> +#endif /* _ASM_RISCV_CACHEFLUSH_H */
Signature · 1 line
2.26.2
PATCH 18/29 arm,sparc,unicore32: remove flush_icache_user_range
In reply to Christoph Hellwigflush_icache_user_range is only used by <asm-generic/cacheflush.h>, so remove it from the architectures that implement it, but don't use <asm-generic/cacheflush.h>.
--- arch/arm/include/asm/cacheflush.h | 3 --- arch/sparc/include/asm/cacheflush_32.h | 2 -- arch/sparc/include/asm/cacheflush_64.h | 1 - arch/unicore32/include/asm/cacheflush.h | 3 --- 4 files changed, 9 deletions(-)
arch/arm/include/asm/cacheflush.h +0 -3
@@ -318,9 +318,6 @@ extern void flush_kernel_dcache_page(struct page *);#define flush_dcache_mmap_lock (mapping) xa_lock_irq(&mapping->i_pages)#define flush_dcache_mmap_unlock (mapping) xa_unlock_irq(&mapping->i_pages) -#define flush_icache_user_range (vma,page,addr,len) \ - flush_dcache_page(page) -/* * We don't appear to need to do anything here. In fact, if we did, we'd * duplicate cache flushing elsewhere performed by flush_dcache_page().
arch/sparc/include/asm/cacheflush_32.h +0 -2
@@ -17,8 +17,6 @@#define flush_icache_range (start, end) do { } while (0)#define flush_icache_page (vma, pg) do { } while (0) -#define flush_icache_user_range (vma,pg,adr,len) do { } while (0) -#define copy_to_user_page (vma, page, vaddr, dst, src, len) \ do { \ flush_cache_page(vma, vaddr, page_to_pfn(page));\
arch/sparc/include/asm/cacheflush_64.h +0 -1
@@ -49,7 +49,6 @@ void __flush_dcache_range(unsigned long start, unsigned long end);void flush_dcache_page (struct page *page);#define flush_icache_page (vma, pg) do { } while(0) -#define flush_icache_user_range (vma,pg,adr,len) do { } while (0) void flush_ptrace_access(struct vm_area_struct *, struct page *, unsigned long uaddr, void *kaddr,
arch/unicore32/include/asm/cacheflush.h +0 -3
@@ -162,9 +162,6 @@ extern void flush_dcache_page(struct page *);#define flush_dcache_mmap_lock (mapping) do { } while (0)#define flush_dcache_mmap_unlock (mapping) do { } while (0) -#define flush_icache_user_range (vma, page, addr, len) \ - flush_dcache_page(page) -/* * We don't appear to need to do anything here. In fact, if we did, we'd * duplicate cache flushing elsewhere performed by flush_dcache_page().
Signature · 1 line
2.26.2
PATCH 19/29 mm: rename flush_icache_user_range to flush_icache_user_page
In reply to Christoph HellwigThe function currently known as flush_icache_user_range only operates on a single page. Rename it to flush_icache_user_page as we'll need the name flush_icache_user_range for something else soon.
--- arch/alpha/include/asm/cacheflush.h | 10 +++++----- arch/alpha/kernel/smp.c | 2 +- arch/ia64/include/asm/cacheflush.h | 2 +- arch/m68k/include/asm/cacheflush_mm.h | 4 ++-- arch/m68k/mm/cache.c | 2 +- arch/nds32/include/asm/cacheflush.h | 4 ++-- arch/nds32/mm/cacheflush.c | 2 +- arch/openrisc/include/asm/cacheflush.h | 2 +- arch/powerpc/include/asm/cacheflush.h | 4 ++-- arch/powerpc/mm/mem.c | 2 +- arch/riscv/include/asm/cacheflush.h | 3 ++- include/asm-generic/cacheflush.h | 6 +++--- kernel/events/uprobes.c | 2 +- 13 files changed, 23 insertions(+), 22 deletions(-)
arch/alpha/include/asm/cacheflush.h +5 -5
@@ -35,7 +35,7 @@ extern void smp_imb(void);extern void __load_new_mm_context (struct mm_struct *);static inline void -flush_icache_user_range (struct vm_area_struct *vma,struct page *page, +flush_icache_user_page (struct vm_area_struct *vma,struct page *page,unsigned long addr,int len) {if (vma->vm_flags &VM_EXEC ) {
@@ -46,16 +46,16 @@ flush_icache_user_range(struct vm_area_struct *vma, struct page *page, mm->context[smp_processor_id()] = 0; } } -#define flush_icache_user_range flush_icache_user_range +#define flush_icache_user_page flush_icache_user_page#else /* CONFIG_SMP */ -extern void flush_icache_user_range (struct vm_area_struct *vma, +extern void flush_icache_user_page (struct vm_area_struct *vma,struct page *page,unsigned long addr,int len); -#define flush_icache_user_range flush_icache_user_range +#define flush_icache_user_page flush_icache_user_page#endif /* CONFIG_SMP */ /* This is used only in __do_fault and do_swap_page. */ #define flush_icache_page (vma, page) \ - flush_icache_user_range((vma), (page), 0, 0) + flush_icache_user_page((vma), (page), 0, 0)#include <asm-generic/cacheflush.h>
arch/alpha/kernel/smp.c +1 -1
@@ -740,7 +740,7 @@ ipi_flush_icache_page(void *x) }void -flush_icache_user_range (struct vm_area_struct *vma,struct page *page, +flush_icache_user_page (struct vm_area_struct *vma,struct page *page,unsigned long addr,int len) {struct mm_struct *mm = vma->vm_mm;
arch/ia64/include/asm/cacheflush.h +1 -1
@@ -22,7 +22,7 @@ extern void flush_icache_range(unsigned long start, unsigned long end);#define flush_icache_range flush_icache_rangeextern void clflush_cache_range (void *addr,int size); -#define flush_icache_user_range (vma, page, user_addr, len) \ +#define flush_icache_user_page (vma, page, user_addr, len) \ do { \ unsigned long _addr = (unsigned long) page_address(page) + ((user_addr) & ~PAGE_MASK); \ flush_icache_range(_addr, _addr + (len)); \
arch/m68k/include/asm/cacheflush_mm.h +2 -2
@@ -254,7 +254,7 @@ static inline void __flush_page_to_ram(void *vaddr)#define flush_dcache_mmap_unlock (mapping) do { } while (0)#define flush_icache_page (vma, page) __flush_page_to_ram(page_address(page)) -extern void flush_icache_user_range (struct vm_area_struct *vma,struct page *page, +extern void flush_icache_user_page (struct vm_area_struct *vma,struct page *page,unsigned long addr,int len);extern void flush_icache_range (unsigned long address,unsigned long endaddr);
@@ -264,7 +264,7 @@ static inline void copy_to_user_page(struct vm_area_struct *vma, {flush_cache_page (vma, vaddr,page_to_pfn (page));memcpy (dst, src, len); -flush_icache_user_range (vma, page, vaddr, len); +flush_icache_user_page (vma, page, vaddr, len); } static inline void copy_from_user_page(struct vm_area_struct *vma, struct page *page, unsigned long vaddr,
arch/m68k/mm/cache.c +1 -1
@@ -106,7 +106,7 @@ void flush_icache_range(unsigned long address, unsigned long endaddr) }EXPORT_SYMBOL (flush_icache_range); -void flush_icache_user_range (struct vm_area_struct *vma,struct page *page, +void flush_icache_user_page (struct vm_area_struct *vma,struct page *page,unsigned long addr,int len) {if (CPU_IS_COLDFIRE ) {
arch/nds32/include/asm/cacheflush.h +2 -2
@@ -44,9 +44,9 @@ void invalidate_kernel_vmap_range(void *addr, int size);#define flush_dcache_mmap_unlock (mapping) xa_unlock_irq(&(mapping)->i_pages)#else -void flush_icache_user_range (struct vm_area_struct *vma,struct page *page, +void flush_icache_user_page (struct vm_area_struct *vma,struct page *page,unsigned long addr,int len); -#define flush_icache_user_range flush_icache_user_range +#define flush_icache_user_page flush_icache_user_page#include <asm-generic/cacheflush.h> #endif
arch/nds32/mm/cacheflush.c +1 -1
@@ -36,7 +36,7 @@ void flush_icache_page(struct vm_area_struct *vma, struct page *page)local_irq_restore (flags); } -void flush_icache_user_range (struct vm_area_struct *vma,struct page *page, +void flush_icache_user_page (struct vm_area_struct *vma,struct page *page,unsigned long addr,int len) {unsigned long kaddr;
arch/openrisc/include/asm/cacheflush.h +1 -1
@@ -62,7 +62,7 @@ static inline void flush_dcache_page(struct page *page)clear_bit (PG_dc_clean, &page->flags); } -#define flush_icache_user_range (vma, page, addr, len) \ +#define flush_icache_user_page (vma, page, addr, len) \ do { \ if (vma->vm_flags & VM_EXEC) \ sync_icache_dcache(page); \
arch/powerpc/include/asm/cacheflush.h +2 -2
@@ -28,9 +28,9 @@ extern void flush_dcache_page(struct page *page);void flush_icache_range (unsigned long start,unsigned long stop);#define flush_icache_range flush_icache_range -void flush_icache_user_range (struct vm_area_struct *vma,struct page *page, +void flush_icache_user_page (struct vm_area_struct *vma,struct page *page,unsigned long addr,int len); -#define flush_icache_user_range flush_icache_user_range +#define flush_icache_user_page flush_icache_user_pagevoid flush_dcache_icache_page (struct page *page);void __flush_dcache_icache (void *page);
arch/powerpc/mm/mem.c +1 -1
@@ -578,7 +578,7 @@ void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,flush_dcache_page (pg); } -void flush_icache_user_range (struct vm_area_struct *vma,struct page *page, +void flush_icache_user_page (struct vm_area_struct *vma,struct page *page,unsigned long addr,int len) {unsigned long maddr;
arch/riscv/include/asm/cacheflush.h +2 -1
@@ -27,7 +27,8 @@ static inline void flush_dcache_page(struct page *page)* so instead we just flush the whole thing. */ #define flush_icache_range (start, end) flush_icache_all() -#define flush_icache_user_range (vma, pg, addr, len) flush_icache_mm(vma->vm_mm, 0) +#define flush_icache_user_page (vma, pg, addr, len) \ + flush_icache_mm(vma->vm_mm, 0)#ifndef CONFIG_SMP
include/asm-generic/cacheflush.h +3 -3
@@ -73,8 +73,8 @@ static inline void flush_icache_page(struct vm_area_struct *vma, }#endif -#ifndef flush_icache_user_range -static inline void flush_icache_user_range (struct vm_area_struct *vma, +#ifndef flush_icache_user_page +static inline void flush_icache_user_page (struct vm_area_struct *vma,struct page *page,unsigned long addr,int len) {
@@ -97,7 +97,7 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end)#define copy_to_user_page (vma, page, vaddr, dst, src, len) \ do { \ memcpy(dst, src, len); \ - flush_icache_user_range(vma, page, vaddr, len); \ + flush_icache_user_page(vma, page, vaddr, len); \ } while (0)#endif
kernel/events/uprobes.c +1 -1
@@ -1674,7 +1674,7 @@ void __weak arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,copy_to_page (page, vaddr, src, len);/* -* We probably need flush_icache_user_range() but it needs vma. +* We probably need flush_icache_user_page() but it needs vma. * This should work on most of architectures by default. If * architecture needs to do something different it can define * its own version of the function.
Signature · 1 line
2.26.2
PATCH 20/29 asm-generic: add a flush_icache_user_range stub
In reply to Christoph HellwigDefine flush_icache_user_range to flush_icache_range unless the architecture provides its own implementation.
--- include/asm-generic/cacheflush.h | 4 ++++ 1 file changed, 4 insertions(+)
include/asm-generic/cacheflush.h +4 -0
@@ -66,6 +66,10 @@ static inline void flush_icache_range(unsigned long start, unsigned long end) }#endif +#ifndef flush_icache_user_range +#define flush_icache_user_range flush_icache_range +#endif +#ifndef flush_icache_pagestatic inline void flush_icache_page (struct vm_area_struct *vma,struct page *page)
Signature · 1 line
2.26.2
PATCH 21/29 sh: implement flush_icache_user_range
In reply to Christoph HellwigThe SuperH implementation of flush_icache_range seems to be able to cope with user addresses. Just define flush_icache_user_range to flush_icache_range.
--- arch/sh/include/asm/cacheflush.h | 1 + 1 file changed, 1 insertion(+)
arch/sh/include/asm/cacheflush.h +1 -0
@@ -46,6 +46,7 @@ extern void flush_cache_range(struct vm_area_struct *vma,#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1extern void flush_dcache_page (struct page *page);extern void flush_icache_range (unsigned long start,unsigned long end); +#define flush_icache_user_range flush_icache_rangeextern void flush_icache_page (struct vm_area_struct *vma,struct page *page);extern void flush_cache_sigtramp (unsigned long address);
Signature · 1 line
2.26.2
PATCH 22/29 xtensa: implement flush_icache_user_range
In reply to Christoph HellwigThe Xtensa implementation of flush_icache_range seems to be able to cope with user addresses. Just define flush_icache_user_range to flush_icache_range.
--- arch/xtensa/include/asm/cacheflush.h | 2 ++ 1 file changed, 2 insertions(+)
arch/xtensa/include/asm/cacheflush.h +2 -0
@@ -107,6 +107,8 @@ void flush_cache_page(struct vm_area_struct*,#define flush_cache_page local_flush_cache_page#endif +#define flush_icache_user_range flush_icache_range +#define local_flush_cache_all () \ do { \ __flush_invalidate_dcache_all(); \
Signature · 1 line
2.26.2
PATCH 23/29 arm: rename flush_cache_user_range to flush_icache_user_range
In reply to Christoph Hellwigflush_icache_user_range will be the name for a generic primitive. Move the arm name so that arm already has an implementation.
--- arch/arm/include/asm/cacheflush.h | 4 ++-- arch/arm/kernel/traps.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/include/asm/cacheflush.h +2 -2
@@ -258,11 +258,11 @@ extern void flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr#define flush_cache_dup_mm (mm) flush_cache_mm(mm)/* -* flush_cache_user_range is used when we want to ensure that the +* flush_icache_user_range is used when we want to ensure that the * Harvard caches are synchronised for the user space address range. * This is used for the ARM private sys_cacheflush system call. */ -#define flush_cache_user_range (s,e) __cpuc_coherent_user_range(s,e) +#define flush_icache_user_range (s,e) __cpuc_coherent_user_range(s,e)/* * Perform necessary cache operations to ensure that data previously
arch/arm/kernel/traps.c +1 -1
@@ -566,7 +566,7 @@ __do_cache_op(unsigned long start, unsigned long end)if (fatal_signal_pending (current))return 0 ; - ret =flush_cache_user_range (start, start + chunk); + ret =flush_icache_user_range (start, start + chunk);if (ret)return ret;
Signature · 1 line
2.26.2
PATCH 24/29 m68k: implement flush_icache_user_range
In reply to Christoph HellwigRename the current flush_icache_range to flush_icache_user_range as per commit ae92ef8a4424 ("PATCH] flush icache in correct context") there seems to be an assumption that it operates on user addresses. Add a flush_icache_range around it that for now is a no-op.
--- arch/m68k/include/asm/cacheflush_mm.h | 2 ++ arch/m68k/mm/cache.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-)
arch/m68k/include/asm/cacheflush_mm.h +2 -0
@@ -257,6 +257,8 @@ static inline void __flush_page_to_ram(void *vaddr)extern void flush_icache_user_page (struct vm_area_struct *vma,struct page *page,unsigned long addr,int len);extern void flush_icache_range (unsigned long address,unsigned long endaddr); +extern void flush_icache_user_range (unsigned long address, +unsigned long endaddr); static inline void copy_to_user_page(struct vm_area_struct *vma, struct page *page, unsigned long vaddr,
arch/m68k/mm/cache.c +6 -1
@@ -73,7 +73,7 @@ static unsigned long virt_to_phys_slow(unsigned long vaddr)/* Push n pages at kernel virtual address and clear the icache */ /* RZ: use cpush %bc instead of cpush %dc, cinv %ic */ -void flush_icache_range (unsigned long address,unsigned long endaddr) +void flush_icache_user_range (unsigned long address,unsigned long endaddr) {if (CPU_IS_COLDFIRE ) {unsigned long start, end;
@@ -104,6 +104,11 @@ void flush_icache_range(unsigned long address, unsigned long endaddr) : "di" (FLUSH_I)); } } + +void flush_icache_range (unsigned long address,unsigned long endaddr) +{ +flush_icache_user_range (address, endaddr); +}EXPORT_SYMBOL (flush_icache_range); void flush_icache_user_page(struct vm_area_struct *vma, struct page *page,
Signature · 1 line
2.26.2
PATCH 25/29 exec: only build read_code when needed
In reply to Christoph HellwigOnly build read_code when binary formats that use it are built into the kernel.
--- fs/exec.c | 3 +++ 1 file changed, 3 insertions(+)
fs/exec.c +3 -0
@@ -1027,6 +1027,8 @@ int kernel_read_file_from_fd(int fd, void **buf, loff_t *size, loff_t max_size, }EXPORT_SYMBOL_GPL (kernel_read_file_from_fd); +#if defined(CONFIG_HAVE_AOUT ) || defined(CONFIG_BINFMT_FLAT ) || \ + defined(CONFIG_BINFMT_ELF_FDPIC )ssize_t read_code (struct file *file,unsigned long addr,loff_t pos,size_t len) {ssize_t res =vfs_read (file, (void __user *)addr, len, &pos);
@@ -1035,6 +1037,7 @@ ssize_t read_code(struct file *file, unsigned long addr, loff_t pos, size_t len) return res; }EXPORT_SYMBOL (read_code); +#endif /* * Maps the mm_struct mm into the current task struct.
Signature · 1 line
2.26.2
PATCH 26/29 exec: use flush_icache_user_range in read_code
In reply to Christoph Hellwigread_code operates on user addresses.
--- fs/exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/exec.c +1 -1
@@ -1033,7 +1033,7 @@ ssize_t read_code(struct file *file, unsigned long addr, loff_t pos, size_t len) {ssize_t res =vfs_read (file, (void __user *)addr, len, &pos);if (res >0 ) -flush_icache_range (addr, addr + len); +flush_icache_user_range (addr, addr + len);return res; }EXPORT_SYMBOL (read_code);
Signature · 1 line
2.26.2
PATCH 27/29 binfmt_flat: use flush_icache_user_range
In reply to Christoph Hellwigload_flat_file works on user addresses.
--- fs/binfmt_flat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/binfmt_flat.c +1 -1
@@ -854,7 +854,7 @@ static int load_flat_file(struct linux_binprm *bprm,#endif /* CONFIG_BINFMT_FLAT_OLD */ } -flush_icache_range (start_code, end_code); +flush_icache_user_range (start_code, end_code);/* zero the BSS, BRK and stack areas */ if (clear_user((void __user *)(datapos + data_len), bss_len +
Signature · 1 line
2.26.2
PATCH 28/29 nommu: use flush_icache_user_range in brk and mmap
In reply to Christoph HellwigThese obviously operate on user addresses.
--- mm/nommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/nommu.c +2 -2
@@ -443,7 +443,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)/* * Ok, looks good - let it rip. */ -flush_icache_range (mm->brk, brk); +flush_icache_user_range (mm->brk, brk);return mm->brk = brk; }
@@ -1287,7 +1287,7 @@ unsigned long do_mmap(struct file *file,/* we flush the region from the icache only when the first executable * mapping of it is made */ if (vma->vm_flags &VM_EXEC && !region->vm_icache_flushed) { -flush_icache_range (region->vm_start, region->vm_end); +flush_icache_user_range (region->vm_start, region->vm_end); region->vm_icache_flushed = true; }
Signature · 1 line
2.26.2
PATCH 29/29 module: move the set_fs hack for flush_icache_range to m68k
In reply to Christoph Hellwigflush_icache_range generally operates on kernel addresses, but for some reason m68k needed a set_fs override. Move that into the m68k code insted of keeping it in the module loader.
--- arch/m68k/mm/cache.c | 4 ++++ kernel/module.c | 8 -------- 2 files changed, 4 insertions(+), 8 deletions(-)
arch/m68k/mm/cache.c +4 -0
@@ -107,7 +107,11 @@ void flush_icache_user_range(unsigned long address, unsigned long endaddr)void flush_icache_range (unsigned long address,unsigned long endaddr) { +mm_segment_t old_fs =get_fs (); + +set_fs (KERNEL_DS );flush_icache_user_range (address, endaddr); +set_fs (old_fs); }EXPORT_SYMBOL (flush_icache_range);
kernel/module.c +0 -8
@@ -3312,12 +3312,6 @@ static int check_module_license_and_versions(struct module *mod)static void flush_module_icache (const struct module *mod) { -mm_segment_t old_fs; - -/* flush the icache in correct context */ - old_fs =get_fs (); -set_fs (KERNEL_DS ); -/* * Flush the instruction cache, since we've played with text. * Do it before processing of module parameters, so the module
@@ -3329,8 +3323,6 @@ static void flush_module_icache(const struct module *mod) + mod->init_layout.size);flush_icache_range ((unsigned long )mod->core_layout.base, (unsigned long )mod->core_layout.base + mod->core_layout.size); - -set_fs (old_fs); } int __weak module_frob_arch_sections(Elf_Ehdr *hdr,
Signature · 1 line
2.26.2
Re: [PATCH 29/29] module: move the set_fs hack for flush_icache_range to m68k
+++ Christoph Hellwig [15/05/20 16:36 +0200]:
Quoted 11 lines
flush_icache_rangegenerally operates on kernel addresses, but for some reason m68k needed aset_fsoverride. Move that into the m68k code insted of keeping it in the module loader.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Geert Uytterhoeven <[email protected]>---
arch/m68k/mm/cache.c| 4 ++++kernel/module.c| 8 --------2 files changed, 4 insertions(+), 8 deletions(-)
Thanks for cleaning this up. For module.c: