Skip to content

Commit 3494d58

Browse files
committed
Merge tag 'xtensa-20201119' of git://github.com/jcmvbkbc/linux-xtensa
Pull xtensa fixes from Max Filippov: - fix placement of cache alias remapping area - disable preemption around cache alias management calls - add missing __user annotation to strncpy_from_user argument * tag 'xtensa-20201119' of git://github.com/jcmvbkbc/linux-xtensa: xtensa: uaccess: Add missing __user to strncpy_from_user() prototype xtensa: disable preemption around cache alias management calls xtensa: fix TLBTEMP area placement
2 parents 131ad0b + dc293f2 commit 3494d58

4 files changed

Lines changed: 22 additions & 5 deletions

File tree

Documentation/xtensa/mmu.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ Default MMUv2-compatible layout::
8282
+------------------+
8383
| VMALLOC area | VMALLOC_START 0xc0000000 128MB - 64KB
8484
+------------------+ VMALLOC_END
85-
| Cache aliasing | TLBTEMP_BASE_1 0xc7ff0000 DCACHE_WAY_SIZE
85+
+------------------+
86+
| Cache aliasing | TLBTEMP_BASE_1 0xc8000000 DCACHE_WAY_SIZE
8687
| remap area 1 |
8788
+------------------+
8889
| Cache aliasing | TLBTEMP_BASE_2 DCACHE_WAY_SIZE
@@ -124,7 +125,8 @@ Default MMUv2-compatible layout::
124125
+------------------+
125126
| VMALLOC area | VMALLOC_START 0xa0000000 128MB - 64KB
126127
+------------------+ VMALLOC_END
127-
| Cache aliasing | TLBTEMP_BASE_1 0xa7ff0000 DCACHE_WAY_SIZE
128+
+------------------+
129+
| Cache aliasing | TLBTEMP_BASE_1 0xa8000000 DCACHE_WAY_SIZE
128130
| remap area 1 |
129131
+------------------+
130132
| Cache aliasing | TLBTEMP_BASE_2 DCACHE_WAY_SIZE
@@ -167,7 +169,8 @@ Default MMUv2-compatible layout::
167169
+------------------+
168170
| VMALLOC area | VMALLOC_START 0x90000000 128MB - 64KB
169171
+------------------+ VMALLOC_END
170-
| Cache aliasing | TLBTEMP_BASE_1 0x97ff0000 DCACHE_WAY_SIZE
172+
+------------------+
173+
| Cache aliasing | TLBTEMP_BASE_1 0x98000000 DCACHE_WAY_SIZE
171174
| remap area 1 |
172175
+------------------+
173176
| Cache aliasing | TLBTEMP_BASE_2 DCACHE_WAY_SIZE

arch/xtensa/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
*/
7070
#define VMALLOC_START (XCHAL_KSEG_CACHED_VADDR - 0x10000000)
7171
#define VMALLOC_END (VMALLOC_START + 0x07FEFFFF)
72-
#define TLBTEMP_BASE_1 (VMALLOC_END + 1)
72+
#define TLBTEMP_BASE_1 (VMALLOC_START + 0x08000000)
7373
#define TLBTEMP_BASE_2 (TLBTEMP_BASE_1 + DCACHE_WAY_SIZE)
7474
#if 2 * DCACHE_WAY_SIZE > ICACHE_WAY_SIZE
7575
#define TLBTEMP_SIZE (2 * DCACHE_WAY_SIZE)

arch/xtensa/include/asm/uaccess.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ strncpy_from_user(char *dst, const char __user *src, long count)
302302
return -EFAULT;
303303
}
304304
#else
305-
long strncpy_from_user(char *dst, const char *src, long count);
305+
long strncpy_from_user(char *dst, const char __user *src, long count);
306306
#endif
307307

308308
/*

arch/xtensa/mm/cache.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ static inline void kmap_invalidate_coherent(struct page *page,
7070
kvaddr = TLBTEMP_BASE_1 +
7171
(page_to_phys(page) & DCACHE_ALIAS_MASK);
7272

73+
preempt_disable();
7374
__invalidate_dcache_page_alias(kvaddr,
7475
page_to_phys(page));
76+
preempt_enable();
7577
}
7678
}
7779
}
@@ -156,6 +158,7 @@ void flush_dcache_page(struct page *page)
156158
if (!alias && !mapping)
157159
return;
158160

161+
preempt_disable();
159162
virt = TLBTEMP_BASE_1 + (phys & DCACHE_ALIAS_MASK);
160163
__flush_invalidate_dcache_page_alias(virt, phys);
161164

@@ -166,6 +169,7 @@ void flush_dcache_page(struct page *page)
166169

167170
if (mapping)
168171
__invalidate_icache_page_alias(virt, phys);
172+
preempt_enable();
169173
}
170174

171175
/* There shouldn't be an entry in the cache for this page anymore. */
@@ -199,8 +203,10 @@ void local_flush_cache_page(struct vm_area_struct *vma, unsigned long address,
199203
unsigned long phys = page_to_phys(pfn_to_page(pfn));
200204
unsigned long virt = TLBTEMP_BASE_1 + (address & DCACHE_ALIAS_MASK);
201205

206+
preempt_disable();
202207
__flush_invalidate_dcache_page_alias(virt, phys);
203208
__invalidate_icache_page_alias(virt, phys);
209+
preempt_enable();
204210
}
205211
EXPORT_SYMBOL(local_flush_cache_page);
206212

@@ -227,11 +233,13 @@ update_mmu_cache(struct vm_area_struct * vma, unsigned long addr, pte_t *ptep)
227233
unsigned long phys = page_to_phys(page);
228234
unsigned long tmp;
229235

236+
preempt_disable();
230237
tmp = TLBTEMP_BASE_1 + (phys & DCACHE_ALIAS_MASK);
231238
__flush_invalidate_dcache_page_alias(tmp, phys);
232239
tmp = TLBTEMP_BASE_1 + (addr & DCACHE_ALIAS_MASK);
233240
__flush_invalidate_dcache_page_alias(tmp, phys);
234241
__invalidate_icache_page_alias(tmp, phys);
242+
preempt_enable();
235243

236244
clear_bit(PG_arch_1, &page->flags);
237245
}
@@ -265,7 +273,9 @@ void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
265273

266274
if (alias) {
267275
unsigned long t = TLBTEMP_BASE_1 + (vaddr & DCACHE_ALIAS_MASK);
276+
preempt_disable();
268277
__flush_invalidate_dcache_page_alias(t, phys);
278+
preempt_enable();
269279
}
270280

271281
/* Copy data */
@@ -280,9 +290,11 @@ void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
280290
if (alias) {
281291
unsigned long t = TLBTEMP_BASE_1 + (vaddr & DCACHE_ALIAS_MASK);
282292

293+
preempt_disable();
283294
__flush_invalidate_dcache_range((unsigned long) dst, len);
284295
if ((vma->vm_flags & VM_EXEC) != 0)
285296
__invalidate_icache_page_alias(t, phys);
297+
preempt_enable();
286298

287299
} else if ((vma->vm_flags & VM_EXEC) != 0) {
288300
__flush_dcache_range((unsigned long)dst,len);
@@ -304,7 +316,9 @@ extern void copy_from_user_page(struct vm_area_struct *vma, struct page *page,
304316

305317
if (alias) {
306318
unsigned long t = TLBTEMP_BASE_1 + (vaddr & DCACHE_ALIAS_MASK);
319+
preempt_disable();
307320
__flush_invalidate_dcache_page_alias(t, phys);
321+
preempt_enable();
308322
}
309323

310324
memcpy(dst, src, len);

0 commit comments

Comments
 (0)