Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+28 -11
+16
arch/nios2/include/asm/pgtable.h
··· 291 291 #define update_mmu_cache(vma, addr, ptep) \ 292 292 update_mmu_cache_range(NULL, vma, addr, ptep, 1) 293 293 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 + 294 310 #endif /* _ASM_NIOS2_PGTABLE_H */
+1 -4
arch/nios2/kernel/cpuinfo.c
··· 46 46 cpuinfo.cpu_clock_freq = fcpu(cpu, "clock-frequency"); 47 47 48 48 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>"); 53 50 54 51 cpuinfo.has_div = of_property_read_bool(cpu, "altr,has-div"); 55 52 cpuinfo.has_mul = of_property_read_bool(cpu, "altr,has-mul");
+11 -7
arch/nios2/mm/tlb.c
··· 144 144 if (((pteaddr >> 2) & 0xfffff) != (addr >> PAGE_SHIFT)) 145 145 continue; 146 146 147 + tlbmisc = RDCTL(CTL_TLBMISC); 147 148 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)); 149 150 150 - tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT); 151 + tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT) | (tlbmisc & TLBMISC_PID); 151 152 WRCTL(CTL_TLBMISC, tlbmisc); 152 153 WRCTL(CTL_PTEADDR, pteaddr_invalid(addr)); 153 154 WRCTL(CTL_TLBACC, 0); ··· 238 237 if (pid != mmu_pid) 239 238 continue; 240 239 241 - tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT); 240 + tlbmisc = TLBMISC_WE | (way << TLBMISC_WAY_SHIFT) | 241 + (pid << TLBMISC_PID_SHIFT); 242 242 WRCTL(CTL_TLBMISC, tlbmisc); 243 243 WRCTL(CTL_TLBACC, 0); 244 244 } ··· 274 272 /* remember pid/way until we return */ 275 273 get_misc_and_pid(&org_misc, &pid_misc); 276 274 277 - /* Start at way 0, way is auto-incremented after each TLBACC write */ 278 - WRCTL(CTL_TLBMISC, TLBMISC_WE); 279 - 280 275 /* Map each TLB entry to physcal address 0 with no-access and a 281 276 bad ptbase */ 282 277 for (line = 0; line < cpuinfo.tlb_num_lines; line++) { 283 278 WRCTL(CTL_PTEADDR, pteaddr_invalid(addr)); 284 - for (way = 0; way < cpuinfo.tlb_num_ways; way++) 279 + for (way = 0; way < cpuinfo.tlb_num_ways; way++) { 280 + // Code such as replace_tlb_one_pid assumes that no duplicate entries exist 281 + // for a single address across ways, so also use way as a dummy PID 282 + WRCTL(CTL_TLBMISC, TLBMISC_WE | (way << TLBMISC_WAY_SHIFT) | 283 + (way << TLBMISC_PID_SHIFT)); 285 284 WRCTL(CTL_TLBACC, 0); 285 + } 286 286 287 287 addr += PAGE_SIZE; 288 288 }