Skip to content

Commit fade9c2

Browse files
Fuad Tabbawilldeacon
authored andcommitted
arm64: Rename arm64-internal cache maintenance functions
Although naming across the codebase isn't that consistent, it tends to follow certain patterns. Moreover, the term "flush" isn't defined in the Arm Architecture reference manual, and might be interpreted to mean clean, invalidate, or both for a cache. Rename arm64-internal functions to make the naming internally consistent, as well as making it consistent with the Arm ARM, by specifying whether it applies to the instruction, data, or both caches, whether the operation is a clean, invalidate, or both. Also specify which point the operation applies to, i.e., to the point of unification (PoU), coherency (PoC), or persistence (PoP). This commit applies the following sed transformation to all files under arch/arm64: "s/\b__flush_cache_range\b/caches_clean_inval_pou_macro/g;"\ "s/\b__flush_icache_range\b/caches_clean_inval_pou/g;"\ "s/\binvalidate_icache_range\b/icache_inval_pou/g;"\ "s/\b__flush_dcache_area\b/dcache_clean_inval_poc/g;"\ "s/\b__inval_dcache_area\b/dcache_inval_poc/g;"\ "s/__clean_dcache_area_poc\b/dcache_clean_poc/g;"\ "s/\b__clean_dcache_area_pop\b/dcache_clean_pop/g;"\ "s/\b__clean_dcache_area_pou\b/dcache_clean_pou/g;"\ "s/\b__flush_cache_user_range\b/caches_clean_inval_user_pou/g;"\ "s/\b__flush_icache_all\b/icache_inval_all_pou/g;" Note that __clean_dcache_area_poc is deliberately missing a word boundary check at the beginning in order to match the efistub symbols in image-vars.h. Also note that, despite its name, __flush_icache_range operates on both instruction and data caches. The name change here reflects that. No functional change intended. Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Fuad Tabba <tabba@google.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Link: https://lore.kernel.org/r/20210524083001.2586635-19-tabba@google.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 393239b commit fade9c2

25 files changed

Lines changed: 98 additions & 98 deletions

arch/arm64/include/asm/arch_gicv3.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static inline u32 gic_read_rpr(void)
125125
#define gic_write_lpir(v, c) writeq_relaxed(v, c)
126126

127127
#define gic_flush_dcache_to_poc(a,l) \
128-
__flush_dcache_area((unsigned long)(a), (unsigned long)(a)+(l))
128+
dcache_clean_inval_poc((unsigned long)(a), (unsigned long)(a)+(l))
129129

130130
#define gits_read_baser(c) readq_relaxed(c)
131131
#define gits_write_baser(v, c) writeq_relaxed(v, c)

arch/arm64/include/asm/cacheflush.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,54 +34,54 @@
3434
* - start - virtual start address (inclusive)
3535
* - end - virtual end address (exclusive)
3636
*
37-
* __flush_icache_range(start, end)
37+
* caches_clean_inval_pou(start, end)
3838
*
3939
* Ensure coherency between the I-cache and the D-cache region to
4040
* the Point of Unification.
4141
*
42-
* __flush_cache_user_range(start, end)
42+
* caches_clean_inval_user_pou(start, end)
4343
*
4444
* Ensure coherency between the I-cache and the D-cache region to
4545
* the Point of Unification.
4646
* Use only if the region might access user memory.
4747
*
48-
* invalidate_icache_range(start, end)
48+
* icache_inval_pou(start, end)
4949
*
5050
* Invalidate I-cache region to the Point of Unification.
5151
*
52-
* __flush_dcache_area(start, end)
52+
* dcache_clean_inval_poc(start, end)
5353
*
5454
* Clean and invalidate D-cache region to the Point of Coherency.
5555
*
56-
* __inval_dcache_area(start, end)
56+
* dcache_inval_poc(start, end)
5757
*
5858
* Invalidate D-cache region to the Point of Coherency.
5959
*
60-
* __clean_dcache_area_poc(start, end)
60+
* dcache_clean_poc(start, end)
6161
*
6262
* Clean D-cache region to the Point of Coherency.
6363
*
64-
* __clean_dcache_area_pop(start, end)
64+
* dcache_clean_pop(start, end)
6565
*
6666
* Clean D-cache region to the Point of Persistence.
6767
*
68-
* __clean_dcache_area_pou(start, end)
68+
* dcache_clean_pou(start, end)
6969
*
7070
* Clean D-cache region to the Point of Unification.
7171
*/
72-
extern void __flush_icache_range(unsigned long start, unsigned long end);
73-
extern void invalidate_icache_range(unsigned long start, unsigned long end);
74-
extern void __flush_dcache_area(unsigned long start, unsigned long end);
75-
extern void __inval_dcache_area(unsigned long start, unsigned long end);
76-
extern void __clean_dcache_area_poc(unsigned long start, unsigned long end);
77-
extern void __clean_dcache_area_pop(unsigned long start, unsigned long end);
78-
extern void __clean_dcache_area_pou(unsigned long start, unsigned long end);
79-
extern long __flush_cache_user_range(unsigned long start, unsigned long end);
72+
extern void caches_clean_inval_pou(unsigned long start, unsigned long end);
73+
extern void icache_inval_pou(unsigned long start, unsigned long end);
74+
extern void dcache_clean_inval_poc(unsigned long start, unsigned long end);
75+
extern void dcache_inval_poc(unsigned long start, unsigned long end);
76+
extern void dcache_clean_poc(unsigned long start, unsigned long end);
77+
extern void dcache_clean_pop(unsigned long start, unsigned long end);
78+
extern void dcache_clean_pou(unsigned long start, unsigned long end);
79+
extern long caches_clean_inval_user_pou(unsigned long start, unsigned long end);
8080
extern void sync_icache_aliases(unsigned long start, unsigned long end);
8181

8282
static inline void flush_icache_range(unsigned long start, unsigned long end)
8383
{
84-
__flush_icache_range(start, end);
84+
caches_clean_inval_pou(start, end);
8585

8686
/*
8787
* IPI all online CPUs so that they undergo a context synchronization
@@ -135,7 +135,7 @@ extern void copy_to_user_page(struct vm_area_struct *, struct page *,
135135
#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
136136
extern void flush_dcache_page(struct page *);
137137

138-
static __always_inline void __flush_icache_all(void)
138+
static __always_inline void icache_inval_all_pou(void)
139139
{
140140
if (cpus_have_const_cap(ARM64_HAS_CACHE_DIC))
141141
return;

arch/arm64/include/asm/efi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void efi_virtmap_unload(void);
137137

138138
static inline void efi_capsule_flush_cache_range(void *addr, int size)
139139
{
140-
__flush_dcache_area((unsigned long)addr, (unsigned long)addr + size);
140+
dcache_clean_inval_poc((unsigned long)addr, (unsigned long)addr + size);
141141
}
142142

143143
#endif /* _ASM_EFI_H */

arch/arm64/include/asm/kvm_mmu.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static inline void *__kvm_vector_slot2addr(void *base,
181181
struct kvm;
182182

183183
#define kvm_flush_dcache_to_poc(a,l) \
184-
__flush_dcache_area((unsigned long)(a), (unsigned long)(a)+(l))
184+
dcache_clean_inval_poc((unsigned long)(a), (unsigned long)(a)+(l))
185185

186186
static inline bool vcpu_has_cache_enabled(struct kvm_vcpu *vcpu)
187187
{
@@ -209,12 +209,12 @@ static inline void __invalidate_icache_guest_page(kvm_pfn_t pfn,
209209
{
210210
if (icache_is_aliasing()) {
211211
/* any kind of VIPT cache */
212-
__flush_icache_all();
212+
icache_inval_all_pou();
213213
} else if (is_kernel_in_hyp_mode() || !icache_is_vpipt()) {
214214
/* PIPT or VPIPT at EL2 (see comment in __kvm_tlb_flush_vmid_ipa) */
215215
void *va = page_address(pfn_to_page(pfn));
216216

217-
invalidate_icache_range((unsigned long)va,
217+
icache_inval_pou((unsigned long)va,
218218
(unsigned long)va + size);
219219
}
220220
}

arch/arm64/kernel/alternative.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static void __nocfi __apply_alternatives(struct alt_region *region, bool is_modu
181181
*/
182182
if (!is_module) {
183183
dsb(ish);
184-
__flush_icache_all();
184+
icache_inval_all_pou();
185185
isb();
186186

187187
/* Ignore ARM64_CB bit from feature mask */

arch/arm64/kernel/efi-entry.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SYM_CODE_START(efi_enter_kernel)
2929
*/
3030
ldr w1, =kernel_size
3131
add x1, x0, x1
32-
bl __clean_dcache_area_poc
32+
bl dcache_clean_poc
3333
ic ialluis
3434

3535
/*
@@ -38,7 +38,7 @@ SYM_CODE_START(efi_enter_kernel)
3838
*/
3939
adr x0, 0f
4040
adr x1, 3f
41-
bl __clean_dcache_area_poc
41+
bl dcache_clean_poc
4242
0:
4343
/* Turn off Dcache and MMU */
4444
mrs x0, CurrentEL

arch/arm64/kernel/head.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ SYM_CODE_START_LOCAL(preserve_boot_args)
118118
// MMU off
119119

120120
add x1, x0, #0x20 // 4 x 8 bytes
121-
b __inval_dcache_area // tail call
121+
b dcache_inval_poc // tail call
122122
SYM_CODE_END(preserve_boot_args)
123123

124124
/*
@@ -268,7 +268,7 @@ SYM_FUNC_START_LOCAL(__create_page_tables)
268268
*/
269269
adrp x0, init_pg_dir
270270
adrp x1, init_pg_end
271-
bl __inval_dcache_area
271+
bl dcache_inval_poc
272272

273273
/*
274274
* Clear the init page tables.
@@ -381,11 +381,11 @@ SYM_FUNC_START_LOCAL(__create_page_tables)
381381

382382
adrp x0, idmap_pg_dir
383383
adrp x1, idmap_pg_end
384-
bl __inval_dcache_area
384+
bl dcache_inval_poc
385385

386386
adrp x0, init_pg_dir
387387
adrp x1, init_pg_end
388-
bl __inval_dcache_area
388+
bl dcache_inval_poc
389389

390390
ret x28
391391
SYM_FUNC_END(__create_page_tables)

arch/arm64/kernel/hibernate-asm.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* Because this code has to be copied to a 'safe' page, it can't call out to
4646
* other functions by PC-relative address. Also remember that it may be
4747
* mid-way through over-writing other functions. For this reason it contains
48-
* code from __flush_icache_range() and uses the copy_page() macro.
48+
* code from caches_clean_inval_pou() and uses the copy_page() macro.
4949
*
5050
* This 'safe' page is mapped via ttbr0, and executed from there. This function
5151
* switches to a copy of the linear map in ttbr1, performs the restore, then
@@ -87,7 +87,7 @@ SYM_CODE_START(swsusp_arch_suspend_exit)
8787
copy_page x0, x1, x2, x3, x4, x5, x6, x7, x8, x9
8888

8989
add x1, x10, #PAGE_SIZE
90-
/* Clean the copied page to PoU - based on __flush_icache_range() */
90+
/* Clean the copied page to PoU - based on caches_clean_inval_pou() */
9191
raw_dcache_line_size x2, x3
9292
sub x3, x2, #1
9393
bic x4, x10, x3

arch/arm64/kernel/hibernate.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static int create_safe_exec_page(void *src_start, size_t length,
210210
return -ENOMEM;
211211

212212
memcpy(page, src_start, length);
213-
__flush_icache_range((unsigned long)page, (unsigned long)page + length);
213+
caches_clean_inval_pou((unsigned long)page, (unsigned long)page + length);
214214
rc = trans_pgd_idmap_page(&trans_info, &trans_ttbr0, &t0sz, page);
215215
if (rc)
216216
return rc;
@@ -381,17 +381,17 @@ int swsusp_arch_suspend(void)
381381
ret = swsusp_save();
382382
} else {
383383
/* Clean kernel core startup/idle code to PoC*/
384-
__flush_dcache_area((unsigned long)__mmuoff_data_start,
384+
dcache_clean_inval_poc((unsigned long)__mmuoff_data_start,
385385
(unsigned long)__mmuoff_data_end);
386-
__flush_dcache_area((unsigned long)__idmap_text_start,
386+
dcache_clean_inval_poc((unsigned long)__idmap_text_start,
387387
(unsigned long)__idmap_text_end);
388388

389389
/* Clean kvm setup code to PoC? */
390390
if (el2_reset_needed()) {
391-
__flush_dcache_area(
391+
dcache_clean_inval_poc(
392392
(unsigned long)__hyp_idmap_text_start,
393393
(unsigned long)__hyp_idmap_text_end);
394-
__flush_dcache_area((unsigned long)__hyp_text_start,
394+
dcache_clean_inval_poc((unsigned long)__hyp_text_start,
395395
(unsigned long)__hyp_text_end);
396396
}
397397

@@ -477,7 +477,7 @@ int swsusp_arch_resume(void)
477477
* The hibernate exit text contains a set of el2 vectors, that will
478478
* be executed at el2 with the mmu off in order to reload hyp-stub.
479479
*/
480-
__flush_dcache_area((unsigned long)hibernate_exit,
480+
dcache_clean_inval_poc((unsigned long)hibernate_exit,
481481
(unsigned long)hibernate_exit + exit_size);
482482

483483
/*

arch/arm64/kernel/idreg-override.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ asmlinkage void __init init_feature_override(void)
237237

238238
for (i = 0; i < ARRAY_SIZE(regs); i++) {
239239
if (regs[i]->override)
240-
__flush_dcache_area((unsigned long)regs[i]->override,
240+
dcache_clean_inval_poc((unsigned long)regs[i]->override,
241241
(unsigned long)regs[i]->override +
242242
sizeof(*regs[i]->override));
243243
}

0 commit comments

Comments
 (0)