mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-01 22:54:01 +00:00
riscv: mm: synchronize MMU after pte change
commit bf587caae3
upstream.
Because RISC-V compliant implementations can cache invalid entries
in TLB, an SFENCE.VMA is necessary after changes to the page table.
This patch adds an SFENCE.vma for the vmalloc_fault path.
Signed-off-by: ShihPo Hung <shihpo.hung@sifive.com>
[paul.walmsley@sifive.com: reversed tab->whitespace conversion,
wrapped comment lines]
Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@sifive.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: linux-riscv@lists.infradead.org
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
5ad9a23e6d
commit
a96ac5cb8a
1 changed files with 13 additions and 0 deletions
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <asm/pgalloc.h>
|
||||
#include <asm/ptrace.h>
|
||||
#include <asm/tlbflush.h>
|
||||
|
||||
/*
|
||||
* This routine handles page faults. It determines the address and the
|
||||
|
@ -281,6 +282,18 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
|
|||
pte_k = pte_offset_kernel(pmd_k, addr);
|
||||
if (!pte_present(*pte_k))
|
||||
goto no_context;
|
||||
|
||||
/*
|
||||
* The kernel assumes that TLBs don't cache invalid
|
||||
* entries, but in RISC-V, SFENCE.VMA specifies an
|
||||
* ordering constraint, not a cache flush; it is
|
||||
* necessary even after writing invalid entries.
|
||||
* Relying on flush_tlb_fix_spurious_fault would
|
||||
* suffice, but the extra traps reduce
|
||||
* performance. So, eagerly SFENCE.VMA.
|
||||
*/
|
||||
local_flush_tlb_page(addr);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue