*** BLURB HERE ***
Hanjun Guo (2): arm64: cache: Add flush_dcache_area() for module use arm64: cache: Export and add cache invalidation and clean ABIs for module use
arch/arm64/include/asm/cacheflush.h | 51 +++++++++++++++++++++++++++++ arch/arm64/mm/flush.c | 3 ++ 2 files changed, 54 insertions(+)
From: Hanjun Guo guohanjun@huawei.com
hulk inclusion category: feature bugzilla: 46503 CVE: NA
---------------------------
Adding flush_dcache_area() for module use, and export __flush_dcache_area() for that purpose.
Signed-off-by: Hanjun Guo guohanjun@huawei.com --- arch/arm64/include/asm/cacheflush.h | 6 ++++++ arch/arm64/mm/flush.c | 1 + 2 files changed, 7 insertions(+)
diff --git a/arch/arm64/include/asm/cacheflush.h b/arch/arm64/include/asm/cacheflush.h index 9384fd8fc13c..c7da50bd45be 100644 --- a/arch/arm64/include/asm/cacheflush.h +++ b/arch/arm64/include/asm/cacheflush.h @@ -96,6 +96,12 @@ static inline void flush_icache_range(unsigned long start, unsigned long end) } #define flush_icache_range flush_icache_range
+static inline void flush_dcache_area(void *addr, size_t len) +{ + __flush_dcache_area(addr, len); +} +#define flush_dcache_area flush_dcache_area + /* * Cache maintenance functions used by the DMA API. No to be used directly. */ diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c index ac485163a4a7..5bddfbeeec56 100644 --- a/arch/arm64/mm/flush.c +++ b/arch/arm64/mm/flush.c @@ -76,6 +76,7 @@ EXPORT_SYMBOL(flush_dcache_page); * Additional functions defined in assembly. */ EXPORT_SYMBOL(__flush_icache_range); +EXPORT_SYMBOL(__flush_dcache_area);
#ifdef CONFIG_ARCH_HAS_PMEM_API void arch_wb_cache_pmem(void *addr, size_t size)
From: Hanjun Guo guohanjun@huawei.com
hulk inclusion category: feature bugzilla: 46503 CVE: NA
---------------------------
Adding more invalidation and clean ABIs for kernel and kernel module use.
For now we have 7 functions for module:
void flush_icache_range(unsigned long start, unsigned long end); void inval_dcache_area(void *addr, size_t len); void clean_dcache_area(void *addr, size_t len); void flush_dcache_area(void *addr, size_t len); void inval_dcache_range(unsigned long start, unsigned long end); void clean_dcache_range(unsigned long start, unsigned long end); void flush_dcache_range(unsigned long start, unsigned long end);
Signed-off-by: Hanjun Guo guohanjun@huawei.com --- arch/arm64/include/asm/cacheflush.h | 45 +++++++++++++++++++++++++++++ arch/arm64/mm/flush.c | 2 ++ 2 files changed, 47 insertions(+)
diff --git a/arch/arm64/include/asm/cacheflush.h b/arch/arm64/include/asm/cacheflush.h index c7da50bd45be..32fec97f7602 100644 --- a/arch/arm64/include/asm/cacheflush.h +++ b/arch/arm64/include/asm/cacheflush.h @@ -96,12 +96,57 @@ static inline void flush_icache_range(unsigned long start, unsigned long end) } #define flush_icache_range flush_icache_range
+/* + * Ensure that any D-cache lines for the interval [addr, addr+len) + * are invalidated. + * + * addr: kernel address + * len: size of the address + */ +static inline void inval_dcache_area(void *addr, size_t len) +{ + __inval_dcache_area(addr, len); +} + +/* Ensure that any D-cache lines for the interval [addr, addr+len) + * are cleaned to the PoC. + * + * addr: kernel address + * len: size of the address + */ +static inline void clean_dcache_area(void *addr, size_t len) +{ + __clean_dcache_area_poc(addr, len); +} + +/* Ensure that any D-cache lines for the interval [addr, addr+len) + * are cleaned and invalidated to the PoC. + * + * addr: kernel address + * len: size of the address + */ static inline void flush_dcache_area(void *addr, size_t len) { __flush_dcache_area(addr, len); } #define flush_dcache_area flush_dcache_area
+/* start and end are kernel addresses */ +static inline void inval_dcache_range(unsigned long start, unsigned long end) +{ + __inval_dcache_area((void *)start, end - start); +} + +static inline void clean_dcache_range(unsigned long start, unsigned long end) +{ + __clean_dcache_area_poc((void *)start, end - start); +} + +static inline void flush_dcache_range(unsigned long start, unsigned long end) +{ + __flush_dcache_area((void *)start, end - start); +} + /* * Cache maintenance functions used by the DMA API. No to be used directly. */ diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c index 5bddfbeeec56..263eb09cde07 100644 --- a/arch/arm64/mm/flush.c +++ b/arch/arm64/mm/flush.c @@ -76,6 +76,8 @@ EXPORT_SYMBOL(flush_dcache_page); * Additional functions defined in assembly. */ EXPORT_SYMBOL(__flush_icache_range); +EXPORT_SYMBOL(__inval_dcache_area); +EXPORT_SYMBOL(__clean_dcache_area_poc); EXPORT_SYMBOL(__flush_dcache_area);
#ifdef CONFIG_ARCH_HAS_PMEM_API