RISC-V: Avoid using invalid intermediate translations
PATCH 1/1 RISC-V: Avoid using invalid intermediate translations
This is almost entirely a comment.
Signed-off-by Palmer Dabbelt <[email protected]>
--- arch/riscv/kernel/head.S | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
arch/riscv/kernel/head.S +10 -2
@@ -99,7 +99,9 @@ relocate: /* * Load trampoline page directory, which will cause us to trap to - * stvec if VA != PA, or simply fall through if VA == PA + * stvec if VA != PA, or simply fall through if VA == PA. We need a + * full fence here because setup_vm() just wrote these PTEs and we need + * to ensure the new translations are in use. */ la a0, trampoline_pg_dir srl a0, a0, PAGE_SHIFT
@@ -118,8 +120,14 @@ relocate: la gp, __global_pointer$ .option pop - /* Switch to kernel page tables */ + /* + * Switch to kernel page tables. A full fence is necessary in order to + * avoid using the trampoline translations, which are only correct for + * the first superpage. Fetching the fence is guarnteed to work + * because that first superpage is translated the same way. + */ csrw sptbr, a2 + sfence.vma ret
Signature · 7 lines
2.21.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv