Skip to content

Commit 74e9347

Browse files
committed
Merge tag 'loongarch-fixes-6.6-3' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
Pull LoongArch fixes from Huacai ChenL "Fix 4-level pagetable building, disable WUC for pgprot_writecombine() like ioremap_wc(), use correct annotation for exception handlers, and a trivial cleanup" * tag 'loongarch-fixes-6.6-3' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson: LoongArch: Disable WUC for pgprot_writecombine() like ioremap_wc() LoongArch: Replace kmap_atomic() with kmap_local_page() in copy_user_highpage() LoongArch: Export symbol invalid_pud_table for modules building LoongArch: Use SYM_CODE_* to annotate exception handlers
2 parents 54fb58a + 278be83 commit 74e9347

File tree

8 files changed

+51
-41
lines changed

8 files changed

+51
-41
lines changed

arch/loongarch/include/asm/io.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
5252
* @offset: bus address of the memory
5353
* @size: size of the resource to map
5454
*/
55-
extern pgprot_t pgprot_wc;
56-
5755
#define ioremap_wc(offset, size) \
58-
ioremap_prot((offset), (size), pgprot_val(pgprot_wc))
56+
ioremap_prot((offset), (size), \
57+
pgprot_val(wc_enabled ? PAGE_KERNEL_WUC : PAGE_KERNEL_SUC))
5958

6059
#define ioremap_cache(offset, size) \
6160
ioremap_prot((offset), (size), pgprot_val(PAGE_KERNEL))

arch/loongarch/include/asm/linkage.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,12 @@
3333
.cfi_endproc; \
3434
SYM_END(name, SYM_T_FUNC)
3535

36+
#define SYM_CODE_START(name) \
37+
SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN) \
38+
.cfi_startproc;
39+
40+
#define SYM_CODE_END(name) \
41+
.cfi_endproc; \
42+
SYM_END(name, SYM_T_NONE)
43+
3644
#endif

arch/loongarch/include/asm/pgtable-bits.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,15 @@ static inline pgprot_t pgprot_noncached(pgprot_t _prot)
105105
return __pgprot(prot);
106106
}
107107

108+
extern bool wc_enabled;
109+
108110
#define pgprot_writecombine pgprot_writecombine
109111

110112
static inline pgprot_t pgprot_writecombine(pgprot_t _prot)
111113
{
112114
unsigned long prot = pgprot_val(_prot);
113115

114-
prot = (prot & ~_CACHE_MASK) | _CACHE_WUC;
116+
prot = (prot & ~_CACHE_MASK) | (wc_enabled ? _CACHE_WUC : _CACHE_SUC);
115117

116118
return __pgprot(prot);
117119
}

arch/loongarch/kernel/entry.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
.text
1919
.cfi_sections .debug_frame
2020
.align 5
21-
SYM_FUNC_START(handle_syscall)
21+
SYM_CODE_START(handle_syscall)
2222
csrrd t0, PERCPU_BASE_KS
2323
la.pcrel t1, kernelsp
2424
add.d t1, t1, t0
@@ -71,7 +71,7 @@ SYM_FUNC_START(handle_syscall)
7171
bl do_syscall
7272

7373
RESTORE_ALL_AND_RET
74-
SYM_FUNC_END(handle_syscall)
74+
SYM_CODE_END(handle_syscall)
7575
_ASM_NOKPROBE(handle_syscall)
7676

7777
SYM_CODE_START(ret_from_fork)

arch/loongarch/kernel/genex.S

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ SYM_FUNC_START(__arch_cpu_idle)
3131
1: jr ra
3232
SYM_FUNC_END(__arch_cpu_idle)
3333

34-
SYM_FUNC_START(handle_vint)
34+
SYM_CODE_START(handle_vint)
3535
BACKUP_T0T1
3636
SAVE_ALL
3737
la_abs t1, __arch_cpu_idle
@@ -46,11 +46,11 @@ SYM_FUNC_START(handle_vint)
4646
la_abs t0, do_vint
4747
jirl ra, t0, 0
4848
RESTORE_ALL_AND_RET
49-
SYM_FUNC_END(handle_vint)
49+
SYM_CODE_END(handle_vint)
5050

51-
SYM_FUNC_START(except_vec_cex)
51+
SYM_CODE_START(except_vec_cex)
5252
b cache_parity_error
53-
SYM_FUNC_END(except_vec_cex)
53+
SYM_CODE_END(except_vec_cex)
5454

5555
.macro build_prep_badv
5656
csrrd t0, LOONGARCH_CSR_BADV
@@ -66,7 +66,7 @@ SYM_FUNC_END(except_vec_cex)
6666

6767
.macro BUILD_HANDLER exception handler prep
6868
.align 5
69-
SYM_FUNC_START(handle_\exception)
69+
SYM_CODE_START(handle_\exception)
7070
666:
7171
BACKUP_T0T1
7272
SAVE_ALL
@@ -76,7 +76,7 @@ SYM_FUNC_END(except_vec_cex)
7676
jirl ra, t0, 0
7777
668:
7878
RESTORE_ALL_AND_RET
79-
SYM_FUNC_END(handle_\exception)
79+
SYM_CODE_END(handle_\exception)
8080
SYM_DATA(unwind_hint_\exception, .word 668b - 666b)
8181
.endm
8282

@@ -93,7 +93,7 @@ SYM_FUNC_END(except_vec_cex)
9393
BUILD_HANDLER watch watch none
9494
BUILD_HANDLER reserved reserved none /* others */
9595

96-
SYM_FUNC_START(handle_sys)
96+
SYM_CODE_START(handle_sys)
9797
la_abs t0, handle_syscall
9898
jr t0
99-
SYM_FUNC_END(handle_sys)
99+
SYM_CODE_END(handle_sys)

arch/loongarch/kernel/setup.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,19 @@ static void __init smbios_parse(void)
161161
}
162162

163163
#ifdef CONFIG_ARCH_WRITECOMBINE
164-
pgprot_t pgprot_wc = PAGE_KERNEL_WUC;
164+
bool wc_enabled = true;
165165
#else
166-
pgprot_t pgprot_wc = PAGE_KERNEL_SUC;
166+
bool wc_enabled = false;
167167
#endif
168168

169-
EXPORT_SYMBOL(pgprot_wc);
169+
EXPORT_SYMBOL(wc_enabled);
170170

171171
static int __init setup_writecombine(char *p)
172172
{
173173
if (!strcmp(p, "on"))
174-
pgprot_wc = PAGE_KERNEL_WUC;
174+
wc_enabled = true;
175175
else if (!strcmp(p, "off"))
176-
pgprot_wc = PAGE_KERNEL_SUC;
176+
wc_enabled = false;
177177
else
178178
pr_warn("Unknown writecombine setting \"%s\".\n", p);
179179

arch/loongarch/mm/init.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ void copy_user_highpage(struct page *to, struct page *from,
4343
{
4444
void *vfrom, *vto;
4545

46-
vto = kmap_atomic(to);
47-
vfrom = kmap_atomic(from);
46+
vfrom = kmap_local_page(from);
47+
vto = kmap_local_page(to);
4848
copy_page(vto, vfrom);
49-
kunmap_atomic(vfrom);
50-
kunmap_atomic(vto);
49+
kunmap_local(vfrom);
50+
kunmap_local(vto);
5151
/* Make sure this page is cleared on other CPU's too before using it */
5252
smp_wmb();
5353
}
@@ -240,6 +240,7 @@ pgd_t swapper_pg_dir[_PTRS_PER_PGD] __section(".bss..swapper_pg_dir");
240240
pgd_t invalid_pg_dir[_PTRS_PER_PGD] __page_aligned_bss;
241241
#ifndef __PAGETABLE_PUD_FOLDED
242242
pud_t invalid_pud_table[PTRS_PER_PUD] __page_aligned_bss;
243+
EXPORT_SYMBOL(invalid_pud_table);
243244
#endif
244245
#ifndef __PAGETABLE_PMD_FOLDED
245246
pmd_t invalid_pmd_table[PTRS_PER_PMD] __page_aligned_bss;

arch/loongarch/mm/tlbex.S

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
#define PTRS_PER_PTE_BITS (PAGE_SHIFT - 3)
1818

1919
.macro tlb_do_page_fault, write
20-
SYM_FUNC_START(tlb_do_page_fault_\write)
20+
SYM_CODE_START(tlb_do_page_fault_\write)
2121
SAVE_ALL
2222
csrrd a2, LOONGARCH_CSR_BADV
2323
move a0, sp
2424
REG_S a2, sp, PT_BVADDR
2525
li.w a1, \write
2626
bl do_page_fault
2727
RESTORE_ALL_AND_RET
28-
SYM_FUNC_END(tlb_do_page_fault_\write)
28+
SYM_CODE_END(tlb_do_page_fault_\write)
2929
.endm
3030

3131
tlb_do_page_fault 0
3232
tlb_do_page_fault 1
3333

34-
SYM_FUNC_START(handle_tlb_protect)
34+
SYM_CODE_START(handle_tlb_protect)
3535
BACKUP_T0T1
3636
SAVE_ALL
3737
move a0, sp
@@ -41,9 +41,9 @@ SYM_FUNC_START(handle_tlb_protect)
4141
la_abs t0, do_page_fault
4242
jirl ra, t0, 0
4343
RESTORE_ALL_AND_RET
44-
SYM_FUNC_END(handle_tlb_protect)
44+
SYM_CODE_END(handle_tlb_protect)
4545

46-
SYM_FUNC_START(handle_tlb_load)
46+
SYM_CODE_START(handle_tlb_load)
4747
csrwr t0, EXCEPTION_KS0
4848
csrwr t1, EXCEPTION_KS1
4949
csrwr ra, EXCEPTION_KS2
@@ -187,16 +187,16 @@ nopage_tlb_load:
187187
csrrd ra, EXCEPTION_KS2
188188
la_abs t0, tlb_do_page_fault_0
189189
jr t0
190-
SYM_FUNC_END(handle_tlb_load)
190+
SYM_CODE_END(handle_tlb_load)
191191

192-
SYM_FUNC_START(handle_tlb_load_ptw)
192+
SYM_CODE_START(handle_tlb_load_ptw)
193193
csrwr t0, LOONGARCH_CSR_KS0
194194
csrwr t1, LOONGARCH_CSR_KS1
195195
la_abs t0, tlb_do_page_fault_0
196196
jr t0
197-
SYM_FUNC_END(handle_tlb_load_ptw)
197+
SYM_CODE_END(handle_tlb_load_ptw)
198198

199-
SYM_FUNC_START(handle_tlb_store)
199+
SYM_CODE_START(handle_tlb_store)
200200
csrwr t0, EXCEPTION_KS0
201201
csrwr t1, EXCEPTION_KS1
202202
csrwr ra, EXCEPTION_KS2
@@ -343,16 +343,16 @@ nopage_tlb_store:
343343
csrrd ra, EXCEPTION_KS2
344344
la_abs t0, tlb_do_page_fault_1
345345
jr t0
346-
SYM_FUNC_END(handle_tlb_store)
346+
SYM_CODE_END(handle_tlb_store)
347347

348-
SYM_FUNC_START(handle_tlb_store_ptw)
348+
SYM_CODE_START(handle_tlb_store_ptw)
349349
csrwr t0, LOONGARCH_CSR_KS0
350350
csrwr t1, LOONGARCH_CSR_KS1
351351
la_abs t0, tlb_do_page_fault_1
352352
jr t0
353-
SYM_FUNC_END(handle_tlb_store_ptw)
353+
SYM_CODE_END(handle_tlb_store_ptw)
354354

355-
SYM_FUNC_START(handle_tlb_modify)
355+
SYM_CODE_START(handle_tlb_modify)
356356
csrwr t0, EXCEPTION_KS0
357357
csrwr t1, EXCEPTION_KS1
358358
csrwr ra, EXCEPTION_KS2
@@ -497,16 +497,16 @@ nopage_tlb_modify:
497497
csrrd ra, EXCEPTION_KS2
498498
la_abs t0, tlb_do_page_fault_1
499499
jr t0
500-
SYM_FUNC_END(handle_tlb_modify)
500+
SYM_CODE_END(handle_tlb_modify)
501501

502-
SYM_FUNC_START(handle_tlb_modify_ptw)
502+
SYM_CODE_START(handle_tlb_modify_ptw)
503503
csrwr t0, LOONGARCH_CSR_KS0
504504
csrwr t1, LOONGARCH_CSR_KS1
505505
la_abs t0, tlb_do_page_fault_1
506506
jr t0
507-
SYM_FUNC_END(handle_tlb_modify_ptw)
507+
SYM_CODE_END(handle_tlb_modify_ptw)
508508

509-
SYM_FUNC_START(handle_tlb_refill)
509+
SYM_CODE_START(handle_tlb_refill)
510510
csrwr t0, LOONGARCH_CSR_TLBRSAVE
511511
csrrd t0, LOONGARCH_CSR_PGD
512512
lddir t0, t0, 3
@@ -521,4 +521,4 @@ SYM_FUNC_START(handle_tlb_refill)
521521
tlbfill
522522
csrrd t0, LOONGARCH_CSR_TLBRSAVE
523523
ertn
524-
SYM_FUNC_END(handle_tlb_refill)
524+
SYM_CODE_END(handle_tlb_refill)

0 commit comments

Comments
 (0)