mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
add some skeletal jtag access routines to rootkeys
This commit is contained in:
parent
dc931d4a35
commit
192109d09a
6 changed files with 87 additions and 0 deletions
|
|
@ -1,5 +1,8 @@
|
||||||
pub(crate) const SERVER_NAME_JTAG: &str = "_JTAG Server_";
|
pub(crate) const SERVER_NAME_JTAG: &str = "_JTAG Server_";
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub const XCS750_IDCODE: u32 = 0x362F093;
|
||||||
|
|
||||||
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
||||||
pub struct EfuseRecord {
|
pub struct EfuseRecord {
|
||||||
pub key: [u8; 32],
|
pub key: [u8; 32],
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,10 @@ impl Jtag {
|
||||||
let erec = self.efuse_fetch().expect("couldn't read efuse record");
|
let erec = self.efuse_fetch().expect("couldn't read efuse record");
|
||||||
if (erec.cntl & 0x20) != 0 { Ok(true) } else { Ok(false) }
|
if (erec.cntl & 0x20) != 0 { Ok(true) } else { Ok(false) }
|
||||||
}
|
}
|
||||||
|
pub fn get_raw_control_bits(&self) -> Result<u8, xous::Error> {
|
||||||
|
let erec = self.efuse_fetch().expect("couldn't read efuse record");
|
||||||
|
Ok(erec.cntl)
|
||||||
|
}
|
||||||
fn mod_ctl_efuse(&self, bits_to_set: u8) -> Result<bool, xous::Error> {
|
fn mod_ctl_efuse(&self, bits_to_set: u8) -> Result<bool, xous::Error> {
|
||||||
let erec = self.efuse_fetch().expect("couldn't read efuse record");
|
let erec = self.efuse_fetch().expect("couldn't read efuse record");
|
||||||
let response = send_message(self.conn,
|
let response = send_message(self.conn,
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ pub(crate) enum Opcode {
|
||||||
KeysInitialized,
|
KeysInitialized,
|
||||||
/// check that the digital signature on the gateware
|
/// check that the digital signature on the gateware
|
||||||
CheckGatewareSignature,
|
CheckGatewareSignature,
|
||||||
|
/// check if the efuse has been locked down
|
||||||
|
IsEfuseSecured,
|
||||||
|
/// quick check to see if the JTAG can read its IDCODE
|
||||||
|
IsJtagWorking,
|
||||||
|
|
||||||
TestUx,
|
TestUx,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -501,6 +501,31 @@ impl<'a> RootKeys {
|
||||||
}
|
}
|
||||||
pub fn kernel_base(&self) -> u32 { self.kernel_base }
|
pub fn kernel_base(&self) -> u32 { self.kernel_base }
|
||||||
|
|
||||||
|
/// returns None if there is an obvious problem with the JTAG interface
|
||||||
|
/// otherwise returns the result. "secured" would be the most paranoid setting
|
||||||
|
/// which is all the bits burned. There are other combinations that are also
|
||||||
|
/// totally valid based on your usage scenario, however, but the have yet to
|
||||||
|
/// be implemented (see the JTAG crate for more info); however, we reflect
|
||||||
|
/// all of the calls through rootkeys so we aren't exposing JTAG attack surface
|
||||||
|
/// to the rest of the world.
|
||||||
|
pub fn is_efuse_secured(&self) -> Option<bool> {
|
||||||
|
if self.jtag.get_id().unwrap() != jtag::XCS750_IDCODE {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
if (self.jtag.get_raw_control_bits().expect("couldn't get control bits") & 0x3f) != 0x3F {
|
||||||
|
return Some(false)
|
||||||
|
} else {
|
||||||
|
return Some(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn is_jtag_working(&self) -> bool {
|
||||||
|
if self.jtag.get_id().unwrap() == jtag::XCS750_IDCODE {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn xns_interlock(&self) {
|
fn xns_interlock(&self) {
|
||||||
loop {
|
loop {
|
||||||
if self.xns.trusted_init_done().expect("couldn't query init done status") {
|
if self.xns.trusted_init_done().expect("couldn't query init done status") {
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,37 @@ impl RootKeys {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_efuse_secured(&self) -> Result<Option<bool>, xous::Error> {
|
||||||
|
let response = send_message(self.conn,
|
||||||
|
Message::new_blocking_scalar(Opcode::IsEfuseSecured.to_usize().unwrap(), 0, 0, 0, 0)
|
||||||
|
)?;
|
||||||
|
if let xous::Result::Scalar1(result) = response {
|
||||||
|
if result == 2 {
|
||||||
|
Ok(None)
|
||||||
|
} else if result == 1 {
|
||||||
|
Ok(Some(true))
|
||||||
|
} else {
|
||||||
|
Ok(Some(false))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Err(xous::Error::InternalError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn is_jtag_working(&self) -> Result<bool, xous::Error> {
|
||||||
|
let response = send_message(self.conn,
|
||||||
|
Message::new_blocking_scalar(Opcode::IsJtagWorking.to_usize().unwrap(), 0, 0, 0, 0)
|
||||||
|
)?;
|
||||||
|
if let xous::Result::Scalar1(result) = response {
|
||||||
|
if result == 1 {
|
||||||
|
Ok(true)
|
||||||
|
} else {
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Err(xous::Error::InternalError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn test_ux(&mut self, arg: usize) {
|
pub fn test_ux(&mut self, arg: usize) {
|
||||||
send_message(self.conn,
|
send_message(self.conn,
|
||||||
Message::new_scalar(Opcode::TestUx.to_usize().unwrap(),
|
Message::new_scalar(Opcode::TestUx.to_usize().unwrap(),
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,8 @@ mod implementation {
|
||||||
pub fn test(&mut self, rootkeys_modal: &mut Modal, main_cid: xous::CID) -> Result<(), RootkeyResult> {
|
pub fn test(&mut self, rootkeys_modal: &mut Modal, main_cid: xous::CID) -> Result<(), RootkeyResult> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
pub fn is_jtag_working(&self) -> bool {false}
|
||||||
|
pub fn is_efuse_secured(&self) -> Option<bool> {None}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -208,6 +210,24 @@ fn xmain() -> ! {
|
||||||
xous::return_scalar(msg.sender, 0).unwrap();
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
Some(Opcode::IsEfuseSecured) => msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
||||||
|
if let Some(secured) = keys.is_efuse_secured() {
|
||||||
|
if secured {
|
||||||
|
xous::return_scalar(msg.sender, 1).unwrap();
|
||||||
|
} else {
|
||||||
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
xous::return_scalar(msg.sender, 2).unwrap();
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
Some(Opcode::IsJtagWorking) => msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
||||||
|
if keys.is_jtag_working() {
|
||||||
|
xous::return_scalar(msg.sender, 1).unwrap();
|
||||||
|
} else {
|
||||||
|
xous::return_scalar(msg.sender, 0).unwrap();
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
// UX flow opcodes
|
// UX flow opcodes
|
||||||
Some(Opcode::UxTryInitKeys) => msg_scalar_unpack!(msg, _, _, _, _, {
|
Some(Opcode::UxTryInitKeys) => msg_scalar_unpack!(msg, _, _, _, _, {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue