libsel4utils: Instruction fence after bootstrap

On RISC-V platforms, perform an instruction fence after copying the text
segment into a new vspace. We need to make sure the text segment is
written back from the L1D$ to main memory and visible to the I$.

Signed-off-by: Nils Wistoff <nwistoff@iis.ee.ethz.ch>
diff --git a/libsel4utils/src/vspace/bootstrap.c b/libsel4utils/src/vspace/bootstrap.c
index 07ef5ff..6d9d80b 100644
--- a/libsel4utils/src/vspace/bootstrap.c
+++ b/libsel4utils/src/vspace/bootstrap.c
@@ -459,7 +459,10 @@
 #ifdef CONFIG_ARCH_ARM
         seL4_ARM_Page_Unify_Instruction(dest.capPtr, 0, PAGE_SIZE_4K);
         seL4_ARM_Page_Unify_Instruction(cap, 0, PAGE_SIZE_4K);
-#endif /* CONFIG_ARCH_ARM */
+#elif CONFIG_ARCH_RISCV
+        /* Ensure that the writes to memory that may be executed become visible */
+        asm volatile("fence.i" ::: "memory");
+#endif
 
         /* unmap our copy */
         vspace_unmap_pages(current, dest_addr, 1, seL4_PageBits, VSPACE_PRESERVE);