From 464063ffd298dbb2e08538acfa5c8464bd0bd86b Mon Sep 17 00:00:00 2001 From: kettenis Date: Mon, 25 Mar 2024 23:10:03 +0000 Subject: [PATCH] Add missing SFENCE.VMA instructions after switching page tables during early kernel bootstrap. ok jsg@, mlarkin@ --- sys/arch/riscv64/riscv64/locore.S | 6 +++++- sys/arch/riscv64/riscv64/pmap.c | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/arch/riscv64/riscv64/locore.S b/sys/arch/riscv64/riscv64/locore.S index f7c3f0f01c5..847e918265c 100644 --- a/sys/arch/riscv64/riscv64/locore.S +++ b/sys/arch/riscv64/riscv64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.17 2023/12/12 07:37:21 deraadt Exp $ */ +/* $OpenBSD: locore.S,v 1.18 2024/03/25 23:10:03 kettenis Exp $ */ /*- * Copyright (c) 2015-2018 Ruslan Bukin @@ -160,6 +160,8 @@ _start_kern_bootstrap: .align 2 va: + sfence.vma + /* Set the global pointer again, this time with the virtual address. */ .option push .option norelax @@ -314,6 +316,8 @@ cpu_hatch: .align 2 mpva: + sfence.vma + /* Set the global pointer again, this time with the virtual address. */ .option push .option norelax diff --git a/sys/arch/riscv64/riscv64/pmap.c b/sys/arch/riscv64/riscv64/pmap.c index 485f7e25e63..c26107fdc73 100644 --- a/sys/arch/riscv64/riscv64/pmap.c +++ b/sys/arch/riscv64/riscv64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.38 2024/01/23 19:51:10 kettenis Exp $ */ +/* $OpenBSD: pmap.c,v 1.39 2024/03/25 23:10:03 kettenis Exp $ */ /* * Copyright (c) 2019-2020 Brian Bamsch @@ -1371,6 +1371,7 @@ pmap_bootstrap(long kvo, vaddr_t l1pt, vaddr_t kernelstart, vaddr_t kernelend, //switching to new page table uint64_t satp = pmap_kernel()->pm_satp; __asm volatile("csrw satp, %0" :: "r" (satp) : "memory"); + sfence_vma(); printf("all mapped\n"); -- 2.20.1