map out PID 0's access in going to secure mode

This commit is contained in:
bunnie 2025-10-24 21:16:00 +08:00
parent 0d369f8a9f
commit d44f489a83

View file

@ -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);