summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorPaul Walmsley <paul.walmsley@sifive.com>2019-08-07 19:07:34 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-09-06 10:23:23 +0200
commit6ad482444c981f6dc456ed5e8d856e253049f3fd (patch)
treeb92c56a262954facdb7dbaf20d3882d72dcf8f15 /arch
parent325fd0056cc0f6c9d8f5eaa75e64f2d761847764 (diff)
downloadlinux-stable-6ad482444c981f6dc456ed5e8d856e253049f3fd.tar.gz
linux-stable-6ad482444c981f6dc456ed5e8d856e253049f3fd.tar.bz2
linux-stable-6ad482444c981f6dc456ed5e8d856e253049f3fd.zip
riscv: fix flush_tlb_range() end address for flush_tlb_page()
[ Upstream commit eb93685847a9055283d05951c1b205e737f38533 ] The RISC-V kernel implementation of flush_tlb_page() when CONFIG_SMP is set is wrong. It passes zero to flush_tlb_range() as the final address to flush, but it should be at least 'addr'. Some other Linux architecture ports use the beginning address to flush, plus PAGE_SIZE, as the final address to flush. This might flush slightly more than what's needed, but it seems unlikely that being more clever would improve anything. So let's just take that implementation for now. While here, convert the macro into a static inline function, primarily to avoid unintentional multiple evaluations of 'addr'. This second version of the patch fixes a coding style issue found by Christoph Hellwig <hch@lst.de>. Reported-by: Andreas Schwab <schwab@suse.de> Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/riscv/include/asm/tlbflush.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/arch/riscv/include/asm/tlbflush.h b/arch/riscv/include/asm/tlbflush.h
index 687dd19735a7..4d9bbe8438bf 100644
--- a/arch/riscv/include/asm/tlbflush.h
+++ b/arch/riscv/include/asm/tlbflush.h
@@ -53,10 +53,17 @@ static inline void remote_sfence_vma(struct cpumask *cmask, unsigned long start,
}
#define flush_tlb_all() sbi_remote_sfence_vma(NULL, 0, -1)
-#define flush_tlb_page(vma, addr) flush_tlb_range(vma, addr, 0)
+
#define flush_tlb_range(vma, start, end) \
remote_sfence_vma(mm_cpumask((vma)->vm_mm), start, (end) - (start))
-#define flush_tlb_mm(mm) \
+
+static inline void flush_tlb_page(struct vm_area_struct *vma,
+ unsigned long addr)
+{
+ flush_tlb_range(vma, addr, addr + PAGE_SIZE);
+}
+
+#define flush_tlb_mm(mm) \
remote_sfence_vma(mm_cpumask(mm), 0, -1)
#endif /* CONFIG_SMP */