add the "trusted init" check to hosted mode

need to debug a problem with the IMEF connecting/disconnecting
causing trusted init to fail when there is more than one
plugin in the system.
This commit is contained in:
bunnie 2022-06-18 01:30:49 +08:00
parent 11932898ac
commit c46579117b
7 changed files with 40 additions and 3 deletions

View file

@ -17,7 +17,7 @@ pub(crate) fn icontray_server() {
// one connection only, should be the GAM
// however, because the predictor is connected only on demand -- we leave this as open-ended, which
// means anyone could send something to this server if they knew the name of it.
let ime_sh_sid = xns.register_name(SERVER_NAME_ICONTRAY, None).expect("can't register server");
let ime_sh_sid = xns.register_name(SERVER_NAME_ICONTRAY, None /*Some(1)*/).expect("can't register server");
let mytriggers = PredictionTriggers {
newline: false,

View file

@ -128,9 +128,14 @@ fn wrapped_main() -> ! {
// these connections should be established:
// - GAM
// - keyrom (for verifying font maps)
#[cfg(any(target_os = "none", target_os = "xous"))]
let sid = xns
.register_name(api::SERVER_NAME_GFX, Some(2))
.expect("can't register server");
#[cfg(not(any(target_os = "none", target_os = "xous")))]
let sid = xns
.register_name(api::SERVER_NAME_GFX, Some(1))
.expect("can't register server");
draw_boot_logo(&mut display);

View file

@ -510,7 +510,10 @@ fn main() -> ! {
// - one connection from the key server
// - one connection from shellchat for command line
// - another connection from shellchat for oqc testing
#[cfg(any(target_os = "none", target_os = "xous"))]
let jtag_sid = xns.register_name(api::SERVER_NAME_JTAG, Some(3)).expect("can't register server");
#[cfg(not(any(target_os = "none", target_os = "xous")))]
let jtag_sid = xns.register_name(api::SERVER_NAME_JTAG, Some(2)).expect("can't register server");
log::trace!("registered with NS -- {:?}", jtag_sid);
let mut jtag = JtagMach::new();

View file

@ -743,7 +743,7 @@ fn main() -> ! {
#[cfg(any(target_os = "none", target_os = "xous"))]
let kbd_sid = xns.register_name(api::SERVER_NAME_KBD, Some(4)).expect("can't register server");
#[cfg(not(any(target_os = "none", target_os = "xous")))]
let kbd_sid = xns.register_name(api::SERVER_NAME_KBD, Some(5)).expect("can't register server");
let kbd_sid = xns.register_name(api::SERVER_NAME_KBD, Some(4)).expect("can't register server");
log::trace!("registered with NS -- {:?}", kbd_sid);
// Create a new kbd object

View file

@ -125,7 +125,10 @@ fn main() -> ! {
// - time server
// - llio
// I2C can be used to set time, which can have security implications; we are more strict on counting who can have access to this resource.
#[cfg(any(target_os = "none", target_os = "xous"))]
let i2c_sid = xns.register_name(api::SERVER_NAME_I2C, Some(3)).expect("can't register I2C thread");
#[cfg(not(any(target_os = "none", target_os = "xous")))]
let i2c_sid = xns.register_name(api::SERVER_NAME_I2C, Some(1)).expect("can't register I2C thread");
log::trace!("registered I2C thread with NS -- {:?}", i2c_sid);
let _ = thread::spawn({
let i2c_sid = i2c_sid.clone();

View file

@ -109,6 +109,7 @@ mod implementation {
jtag: jtag::Jtag,
xns: xous_names::XousNames,
ticktimer: ticktimer_server::Ticktimer,
gam: gam::Gam,
}
#[allow(dead_code)]
@ -118,10 +119,11 @@ mod implementation {
let jtag = jtag::Jtag::new(&xns).expect("couldn't connect to jtag server");
RootKeys {
password_type: None,
xns,
// must occupy tihs connection for the system to boot properly
jtag,
ticktimer: ticktimer_server::Ticktimer::new().unwrap(),
gam: gam::Gam::new(&xns).expect("couldn't connect to GAM"),
xns,
}
}
pub fn suspend(&self) {
@ -165,12 +167,15 @@ mod implementation {
Ok(())
}
pub fn do_key_init(&mut self, rootkeys_modal: &mut Modal, main_cid: xous::CID) -> Result<(), RootkeyResult> {
self.xous_init_interlock();
self.fake_progress(rootkeys_modal, main_cid, t!("rootkeys.setup_wait", xous::LANG))
}
pub fn do_gateware_update(&mut self, rootkeys_modal: &mut Modal, main_cid: xous::CID, _provision_bbram: bool) -> Result<(), RootkeyResult> {
self.xous_init_interlock();
self.fake_progress(rootkeys_modal, main_cid, t!("rootkeys.gwup_starting", xous::LANG))
}
pub fn do_sign_xous(&mut self, rootkeys_modal: &mut Modal, main_cid: xous::CID) -> Result<(), RootkeyResult> {
self.xous_init_interlock();
self.fake_progress(rootkeys_modal, main_cid, t!("rootkeys.init.signing_kernel", xous::LANG))
}
pub fn purge_password(&mut self, _ptype: PasswordType) {}
@ -293,6 +298,24 @@ mod implementation {
}
}
}
fn xous_init_interlock(&self) {
loop {
if self.xns.trusted_init_done().expect("couldn't query init done status on xous-names") {
break;
} else {
log::warn!("trusted init of xous-names not finished, rootkeys is holding off on sensitive operations");
self.ticktimer.sleep_ms(650).expect("couldn't sleep");
}
}
loop {
if self.gam.trusted_init_done().expect("couldn't query init done status on GAM") {
break;
} else {
log::warn!("trusted init of GAM not finished, rootkeys is holding off on sensitive operations");
self.ticktimer.sleep_ms(650).expect("couldn't sleep");
}
}
}
}
}

View file

@ -609,7 +609,10 @@ fn main() -> ! {
- PDDB
- keyboard (for updating the key map setting, which needs to be loaded upstream of the PDDB)
*/
#[cfg(any(target_os = "none", target_os = "xous"))]
let spinor_sid = xns.register_name(api::SERVER_NAME_SPINOR, Some(5)).expect("can't register server");
#[cfg(not(any(target_os = "none", target_os = "xous")))]
let spinor_sid = xns.register_name(api::SERVER_NAME_SPINOR, Some(2)).expect("can't register server");
log::trace!("registered with NS -- {:?}", spinor_sid);
let handler_conn = xous::connect(spinor_sid).expect("couldn't create interrupt handler callback connection");