Commit 4c3aeb82 authored by Palmer Dabbelt's avatar Palmer Dabbelt

RISC-V: Avoid using invalid intermediate translations

This is almost entirely a comment.
Signed-off-by: default avatarPalmer Dabbelt <palmer@sifive.com>
Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
parent 9a6e7af0
...@@ -96,7 +96,9 @@ relocate: ...@@ -96,7 +96,9 @@ relocate:
/* /*
* Load trampoline page directory, which will cause us to trap to * 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 la a0, trampoline_pg_dir
srl a0, a0, PAGE_SHIFT srl a0, a0, PAGE_SHIFT
...@@ -115,8 +117,14 @@ relocate: ...@@ -115,8 +117,14 @@ relocate:
la gp, __global_pointer$ la gp, __global_pointer$
.option pop .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 CSR_SATP, a2 csrw CSR_SATP, a2
sfence.vma
ret ret
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment