From d44f489a8314738e5a8389220e6ac2858ea18efd Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 24 Oct 2025 21:16:00 +0800 Subject: [PATCH] map out PID 0's access in going to secure mode --- libs/bao1x-hal/src/coreuser.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/bao1x-hal/src/coreuser.rs b/libs/bao1x-hal/src/coreuser.rs index 2547dc01a..e25a52060 100644 --- a/libs/bao1x-hal/src/coreuser.rs +++ b/libs/bao1x-hal/src/coreuser.rs @@ -151,6 +151,10 @@ impl Coreuser { /// Sets a "one way door" that disallows any further updating to these fields. pub fn protect(&mut self) { + // map default ASID into the least trusted user (away from boot0) + self.csr.rmwf(utra::coreuser::MAP_HI_LUT7, 0); + self.csr.rmwf(utra::coreuser::USERVALUE_USER7, LEAST_TRUSTED_USER.as_dense()); + // invert sense for Xous mode - User process 3 is trusted, the kernel is not! self.csr.rmwf(utra::coreuser::CONTROL_INVERT_PRIV, 1); self.csr.wo(utra::coreuser::PROTECT, 1);