From: Palmer Dabbelt Date: Wed, 27 Mar 2019 00:40:24 +0000 (-0700) Subject: RISC-V: Avoid using invalid intermediate translations X-Git-Tag: v5.15~6313^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c3aeb82a0f4612bf0d94fbf74c3738db2c32fe5;p=platform%2Fkernel%2Flinux-starfive.git RISC-V: Avoid using invalid intermediate translations This is almost entirely a comment. Signed-off-by: Palmer Dabbelt Reviewed-by: Anup Patel --- diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index 987d464..370c66c 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -96,7 +96,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 @@ -115,8 +117,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 CSR_SATP, a2 + sfence.vma ret