Skip to content

Commit bbff27b

Browse files
committed
Merge tag 'nios2_updates_for_v6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/dinguyen/linux
Pull nios2 updates fromDinh Nguyen: - Use strscpy() and simply setup_cpuinfo() - Remove conflicting mappings when flushing tlb entries - Force update_mmu_cache on spurious pagefaults * tag 'nios2_updates_for_v6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/dinguyen/linux: nios2: Replace strcpy() with strscpy() and simplify setup_cpuinfo() nios2: do not introduce conflicting mappings when flushing tlb entries nios2: force update_mmu_cache on spurious tlb-permission--related pagefaults
2 parents 408aa67 + aa264d9 commit bbff27b

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

arch/nios2/include/asm/pgtable.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,20 @@ void update_mmu_cache_range(struct vm_fault *vmf, struct vm_area_struct *vma,
291291
#define update_mmu_cache(vma, addr, ptep) \
292292
update_mmu_cache_range(NULL, vma, addr, ptep, 1)
293293

294+
static inline int pte_same(pte_t pte_a, pte_t pte_b);
295+
296+
#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
297+
static inline int ptep_set_access_flags(struct vm_area_struct *vma,
298+
unsigned long address, pte_t *ptep,
299+
pte_t entry, int dirty)
300+
{
301+
if (!pte_same(*ptep, entry))
302+
set_ptes(vma->vm_mm, address, ptep, entry, 1);
303+
/*
304+
* update_mmu_cache will unconditionally execute, handling both
305+
* the case that the PTE changed and the spurious fault case.
306+
*/
307+
return true;
308+
}
309+
294310
#endif /* _ASM_NIOS2_PGTABLE_H */

arch/nios2/kernel/cpuinfo.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ void __init setup_cpuinfo(void)
4646
cpuinfo.cpu_clock_freq = fcpu(cpu, "clock-frequency");
4747

4848
str = of_get_property(cpu, "altr,implementation", &len);
49-
if (str)
50-
strscpy(cpuinfo.cpu_impl, str, sizeof(cpuinfo.cpu_impl));
51-
else
52-
strcpy(cpuinfo.cpu_impl, "<unknown>");
49+
strscpy(cpuinfo.cpu_impl, str ?: "<unknown>");
5350

5451
cpuinfo.has_div = of_property_read_bool(cpu, "altr,has-div");
5552
cpuinfo.has_mul = of_property_read_bool(cpu, "altr,has-mul");

arch/nios2/mm/tlb.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,11 @@ static void flush_tlb_one(unsigned long addr)
144144
if (((pteaddr >> 2) & 0xfffff) != (addr >> PAGE_SHIFT))
145145
continue;
146146

147+
tlbmisc = RDCTL(CTL_TLBMISC);
147148
pr_debug("Flush entry by writing way=%dl pid=%ld\n",
148-
way, (pid_misc >> TLBMISC_PID_SHIFT));
149+
way, ((tlbmisc >> TLBMISC_PID_SHIFT) & TLBMISC_PID_MASK));
149150

150-
tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT);
151+
tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT) | (tlbmisc & TLBMISC_PID);
151152
WRCTL(CTL_TLBMISC, tlbmisc);
152153
WRCTL(CTL_PTEADDR, pteaddr_invalid(addr));
153154
WRCTL(CTL_TLBACC, 0);
@@ -237,7 +238,8 @@ void flush_tlb_pid(unsigned long mmu_pid)
237238
if (pid != mmu_pid)
238239
continue;
239240

240-
tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT);
241+
tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT) |
242+
(pid << TLBMISC_PID_SHIFT);
241243
WRCTL(CTL_TLBMISC, tlbmisc);
242244
WRCTL(CTL_TLBACC, 0);
243245
}
@@ -272,15 +274,17 @@ void flush_tlb_all(void)
272274
/* remember pid/way until we return */
273275
get_misc_and_pid(&org_misc, &pid_misc);
274276

275-
/* Start at way 0, way is auto-incremented after each TLBACC write */
276-
WRCTL(CTL_TLBMISC, TLBMISC_WE);
277-
278277
/* Map each TLB entry to physcal address 0 with no-access and a
279278
bad ptbase */
280279
for (line = 0; line < cpuinfo.tlb_num_lines; line++) {
281280
WRCTL(CTL_PTEADDR, pteaddr_invalid(addr));
282-
for (way = 0; way < cpuinfo.tlb_num_ways; way++)
281+
for (way = 0; way < cpuinfo.tlb_num_ways; way++) {
282+
// Code such as replace_tlb_one_pid assumes that no duplicate entries exist
283+
// for a single address across ways, so also use way as a dummy PID
284+
WRCTL(CTL_TLBMISC, TLBMISC_WE | (way << TLBMISC_WAY_SHIFT) |
285+
(way << TLBMISC_PID_SHIFT));
283286
WRCTL(CTL_TLBACC, 0);
287+
}
284288

285289
addr += PAGE_SIZE;
286290
}

0 commit comments

Comments
 (0)