mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
minor improvements across boot0 flow
- improve bollards to include "die" jumps where appropriate - cleanup warnings in unsafe-dev feature - panic handler calls die repeatedly - upgrade jump api
This commit is contained in:
parent
df10c50c14
commit
1a43540037
2 changed files with 15 additions and 14 deletions
|
|
@ -75,15 +75,15 @@ pub unsafe extern "C" fn rust_entry() -> ! {
|
||||||
csprng.random_delay();
|
csprng.random_delay();
|
||||||
rram.wfo(utra::rrc::SFR_RRCCR_SFR_RRCCR, bao1x_hal::rram::SECURITY_MODE);
|
rram.wfo(utra::rrc::SFR_RRCCR_SFR_RRCCR, bao1x_hal::rram::SECURITY_MODE);
|
||||||
|
|
||||||
bollard!(4);
|
bollard!(bao1x_hal::sigcheck::die_no_std, 4);
|
||||||
// Mesh check takes 100ms for the signal to propagate. Setup the mesh check here, then check the
|
// Mesh check takes 100ms for the signal to propagate. Setup the mesh check here, then check the
|
||||||
// result in boot1. In boot1, the opposite state (`true`) is checked.
|
// result in boot1. In boot1, the opposite state (`true`) is checked.
|
||||||
mesh_setup(false, None);
|
mesh_setup(false, None);
|
||||||
bollard!(4);
|
bollard!(bao1x_hal::sigcheck::die_no_std, 4);
|
||||||
csprng.random_delay();
|
csprng.random_delay();
|
||||||
bollard!(4);
|
bollard!(bao1x_hal::sigcheck::die_no_std, 4);
|
||||||
rram.wfo(utra::rrc::SFR_RRCCR_SFR_RRCCR, bao1x_hal::rram::SECURITY_MODE);
|
rram.wfo(utra::rrc::SFR_RRCCR_SFR_RRCCR, bao1x_hal::rram::SECURITY_MODE);
|
||||||
bollard!(4);
|
bollard!(bao1x_hal::sigcheck::die_no_std, 4);
|
||||||
|
|
||||||
crate::println!("\n~~boot0 up! ({})~~\n", crate::version::SEMVER);
|
crate::println!("\n~~boot0 up! ({})~~\n", crate::version::SEMVER);
|
||||||
csprng.random_delay(); // always random-delay after printing
|
csprng.random_delay(); // always random-delay after printing
|
||||||
|
|
@ -361,7 +361,7 @@ pub unsafe extern "C" fn rust_entry() -> ! {
|
||||||
if use_skipping {
|
if use_skipping {
|
||||||
disable_clock_skipping();
|
disable_clock_skipping();
|
||||||
}
|
}
|
||||||
jump_to((target ^ u32::from_le_bytes(tag)) as usize);
|
jump_to(target as usize, u32::from_le_bytes(tag) as usize);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
crate::println!("Sigcheck err: {:?}", e);
|
crate::println!("Sigcheck err: {:?}", e);
|
||||||
|
|
|
||||||
|
|
@ -150,9 +150,8 @@ pub fn early_init() -> Csprng {
|
||||||
|
|
||||||
irq_setup();
|
irq_setup();
|
||||||
// set up the reactive sensors
|
// set up the reactive sensors
|
||||||
bao1x_api::bollard!(4);
|
bollard!(die, 4);
|
||||||
bao1x_hal::hardening::reset_sensors();
|
bao1x_hal::hardening::reset_sensors();
|
||||||
bao1x_api::bollard!(4);
|
|
||||||
bollard!(die, 4);
|
bollard!(die, 4);
|
||||||
csprng.random_delay();
|
csprng.random_delay();
|
||||||
// ensure paranoid mode is respected
|
// ensure paranoid mode is respected
|
||||||
|
|
@ -186,9 +185,9 @@ pub fn early_init() -> Csprng {
|
||||||
// in combination with the previous check inside init_clock_asic_350mhz means you need
|
// in combination with the previous check inside init_clock_asic_350mhz means you need
|
||||||
// three successful glitches to bypass these checks: one to skip PLL setting, and one each
|
// three successful glitches to bypass these checks: one to skip PLL setting, and one each
|
||||||
// for the checks. There is also a random_delay() inserted between the previous check and now.
|
// for the checks. There is also a random_delay() inserted between the previous check and now.
|
||||||
bao1x_api::bollard!(4);
|
bollard!(die, 4);
|
||||||
bao1x_hal::hardening::check_pll();
|
bao1x_hal::hardening::check_pll();
|
||||||
bao1x_api::bollard!(4);
|
bollard!(die, 4);
|
||||||
|
|
||||||
// this is a security-critical initialization. Failure to do this correctly breaks
|
// this is a security-critical initialization. Failure to do this correctly breaks
|
||||||
// all the hardware hashes. It's done once, in boot0. Note that the constants *are*
|
// all the hardware hashes. It's done once, in boot0. Note that the constants *are*
|
||||||
|
|
@ -215,8 +214,8 @@ pub fn early_init() -> Csprng {
|
||||||
|
|
||||||
// TxRx setup
|
// TxRx setup
|
||||||
#[cfg(feature = "unsafe-dev")]
|
#[cfg(feature = "unsafe-dev")]
|
||||||
let mut udma_uart = {
|
let _udma_uart = {
|
||||||
let mut udma_uart = setup_rx(perclk);
|
let udma_uart = setup_rx(perclk);
|
||||||
enable_irq(utra::irqarray5::IRQARRAY5_IRQ);
|
enable_irq(utra::irqarray5::IRQARRAY5_IRQ);
|
||||||
udma_uart
|
udma_uart
|
||||||
};
|
};
|
||||||
|
|
@ -285,11 +284,11 @@ pub fn init_hash() {
|
||||||
RIPMD_X.iter().chain(
|
RIPMD_X.iter().chain(
|
||||||
RAMSEG_SHA3.iter()
|
RAMSEG_SHA3.iter()
|
||||||
))))))))))));
|
))))))))))));
|
||||||
bao1x_api::bollard!(4);
|
bao1x_api::bollard!(die, 4);
|
||||||
for (dst, &src) in sce_mem.iter_mut().zip(constants) {
|
for (dst, &src) in sce_mem.iter_mut().zip(constants) {
|
||||||
*dst = src;
|
*dst = src;
|
||||||
}
|
}
|
||||||
bao1x_api::bollard!(4);
|
bao1x_api::bollard!(die, 4);
|
||||||
let mut combo_hash = CSR::new(utra::combohash::HW_COMBOHASH_BASE as *mut u32);
|
let mut combo_hash = CSR::new(utra::combohash::HW_COMBOHASH_BASE as *mut u32);
|
||||||
combo_hash.wo(utra::combohash::SFR_OPT3, 0); // u32 big-endian constant load
|
combo_hash.wo(utra::combohash::SFR_OPT3, 0); // u32 big-endian constant load
|
||||||
combo_hash.wfo(utra::combohash::SFR_CRFUNC_CR_FUNC, HashFunction::Init as u32);
|
combo_hash.wfo(utra::combohash::SFR_CRFUNC_CR_FUNC, HashFunction::Init as u32);
|
||||||
|
|
@ -335,7 +334,9 @@ mod panic_handler {
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn handle_panic(_arg: &PanicInfo) -> ! {
|
fn handle_panic(_arg: &PanicInfo) -> ! {
|
||||||
crate::println!("{}", _arg);
|
crate::println!("{}", _arg);
|
||||||
loop {}
|
loop {
|
||||||
|
bao1x_hal::sigcheck::die_no_std();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue