From ebc39372096280a4a5957d3e3836c859e5d78a79 Mon Sep 17 00:00:00 2001 From: Robert Morris Date: Tue, 16 Jul 2019 17:02:21 -0400 Subject: conservatively call sfence.vma before every satp load. --- kernel/riscv.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'kernel/riscv.h') diff --git a/kernel/riscv.h b/kernel/riscv.h index e5c0f64..e35f3bc 100644 --- a/kernel/riscv.h +++ b/kernel/riscv.h @@ -312,6 +312,17 @@ r_ra() return x; } +// tell the machine to finish any previous writes to +// PTEs, so that a subsequent use of a virtual +// address or load of the SATP will see those writes. +// perhaps this also flushes the TLB. +static inline void +sfence_vma() +{ + // the zero, zero means flush all TLB entries. + asm volatile("sfence.vma zero, zero"); +} + #define PGSIZE 4096 // bytes per page #define PGSHIFT 12 // bits of offset within a page -- cgit v1.2.3