From 356ab47c3c7b374f4fee77cf009c27dd9d4a697f Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 20 Oct 2025 02:18:28 +0800 Subject: [PATCH] add coreuser table setup to boot0 I think it belongs here, because this "should" be a "baked in" setting. Maybe I'll regret that, because it really enforces a hardware one-way door on changing/updating the coreuser maps, but also, I think it makes it a bit stronger if there is no easy way to bypass/override that setting. --- bao1x-boot/boot0/src/platform/bao1x/bao1x.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bao1x-boot/boot0/src/platform/bao1x/bao1x.rs b/bao1x-boot/boot0/src/platform/bao1x/bao1x.rs index 681cb816f..a370df238 100644 --- a/bao1x-boot/boot0/src/platform/bao1x/bao1x.rs +++ b/bao1x-boot/boot0/src/platform/bao1x/bao1x.rs @@ -105,6 +105,13 @@ pub fn early_init() { // malleable (no hardware lock to prevent update), which is a potential vulnerability. init_hash(); + // this is a security-critical initialization. Failure to do this correctly breaks + // the hardware access control scheme for key/data slots. + let mut cu = bao1x_hal::coreuser::Coreuser::new(); + // safety: this is safe because it's followed by a `protect()` call. + unsafe { cu.set() }; + cu.protect(); + // TxRx setup #[cfg(feature = "unsafe-dev")] let mut udma_uart = {