Skip to content

Commit 27dff9a

Browse files
committed
openrisc: fix SMP tlb flush NULL pointer dereference
Throughout the OpenRISC kernel port VMA is passed as NULL when flushing kernel tlb entries. Somehow this was missed when I was testing c28b274 ("openrisc: Implement proper SMP tlb flushing") and now the SMP kernel fails to completely boot. In OpenRISC VMA is used only to determine which cores need to have their TLB entries flushed. This patch updates the logic to flush tlbs on all cores when the VMA is passed as NULL. Also, we update places VMA is passed as NULL to use flush_tlb_kernel_range instead. Now, the only place VMA is passed as NULL is in the implementation of flush_tlb_kernel_range. Fixes: c28b274 ("openrisc: Implement proper SMP tlb flushing") Reported-by: Jan Henrik Weinstock <[email protected]> Signed-off-by: Stafford Horne <[email protected]>
1 parent 210893c commit 27dff9a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

arch/openrisc/kernel/dma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ page_set_nocache(pte_t *pte, unsigned long addr,
3333
* Flush the page out of the TLB so that the new page flags get
3434
* picked up next time there's an access
3535
*/
36-
flush_tlb_page(NULL, addr);
36+
flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
3737

3838
/* Flush page out of dcache */
3939
for (cl = __pa(addr); cl < __pa(next); cl += cpuinfo->dcache_block_size)
@@ -56,7 +56,7 @@ page_clear_nocache(pte_t *pte, unsigned long addr,
5656
* Flush the page out of the TLB so that the new page flags get
5757
* picked up next time there's an access
5858
*/
59-
flush_tlb_page(NULL, addr);
59+
flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
6060

6161
return 0;
6262
}

arch/openrisc/kernel/smp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static inline void ipi_flush_tlb_range(void *info)
272272
local_flush_tlb_range(NULL, fd->addr1, fd->addr2);
273273
}
274274

275-
static void smp_flush_tlb_range(struct cpumask *cmask, unsigned long start,
275+
static void smp_flush_tlb_range(const struct cpumask *cmask, unsigned long start,
276276
unsigned long end)
277277
{
278278
unsigned int cpuid;
@@ -320,7 +320,9 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
320320
void flush_tlb_range(struct vm_area_struct *vma,
321321
unsigned long start, unsigned long end)
322322
{
323-
smp_flush_tlb_range(mm_cpumask(vma->vm_mm), start, end);
323+
const struct cpumask *cmask = vma ? mm_cpumask(vma->vm_mm)
324+
: cpu_online_mask;
325+
smp_flush_tlb_range(cmask, start, end);
324326
}
325327

326328
/* Instruction cache invalidate - performed on each cpu */

0 commit comments

Comments
 (0)