mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
fix bug where RestoreDna backup op fails to be set.
This commit is contained in:
parent
4ead1010cd
commit
7ad418be7c
3 changed files with 28 additions and 2 deletions
|
|
@ -2652,6 +2652,21 @@ impl<'a> RootKeys {
|
|||
).map_err(|_| xous::Error::InternalError)?;
|
||||
Ok(())
|
||||
}
|
||||
pub fn write_restore_dna(&mut self, mut header: BackupHeader, backup_ct: backups::BackupDataCt) -> Result<(), xous::Error> {
|
||||
header.op = BackupOp::RestoreDna; // set the "restore DNA" flag
|
||||
|
||||
// condense the data into a single block, to reduce read/write cycles on the block
|
||||
let mut block = [0u8; size_of::<BackupHeader>() + size_of::<backups::BackupDataCt>()];
|
||||
block[..size_of::<BackupHeader>()].copy_from_slice(header.as_ref());
|
||||
block[size_of::<BackupHeader>()..].copy_from_slice(backup_ct.as_ref());
|
||||
self.spinor.patch(
|
||||
self.kernel(),
|
||||
self.kernel_base(),
|
||||
&block,
|
||||
xous::KERNEL_BACKUP_OFFSET
|
||||
).map_err(|_| xous::Error::InternalError)?;
|
||||
Ok(())
|
||||
}
|
||||
pub fn read_backup(&mut self) -> Result<(BackupHeader, backups::BackupDataCt), xous::Error> {
|
||||
let mut header = BackupHeader::default();
|
||||
let mut ct = backups::BackupDataCt::default();
|
||||
|
|
|
|||
|
|
@ -344,6 +344,14 @@ mod implementation {
|
|||
pub fn should_prompt_for_update(&self) -> bool {true}
|
||||
pub fn set_prompt_for_update(&self, _state: bool) {}
|
||||
pub fn write_backup(&mut self, header: BackupHeader, backup_ct: backups::BackupDataCt) -> Result<(), xous::Error> {
|
||||
header.op = BackupOp::Backup;
|
||||
log::info!("backup header: {:?}", header);
|
||||
log::info!("backup ciphertext: {:x?}", backup_ct.as_ref());
|
||||
Ok(())
|
||||
}
|
||||
pub fn write_restore_dna(&mut self, mut header: BackupHeader, backup_ct: backups::BackupDataCt) -> Result<(), xous::Error> {
|
||||
header.op = BackupOp::RestoreDna;
|
||||
log::info!("write restore_dna called");
|
||||
log::info!("backup header: {:?}", header);
|
||||
log::info!("backup ciphertext: {:x?}", backup_ct.as_ref());
|
||||
Ok(())
|
||||
|
|
@ -1541,13 +1549,15 @@ fn main() -> ! {
|
|||
let (mut header, ct) = keys.read_backup()
|
||||
.expect("Internal error: we're doing a backup, but somehow the backup record has disappeared on us!");
|
||||
if u64::from_le_bytes(header.dna) == llio.soc_dna().unwrap() {
|
||||
log::info!("erasing backup block");
|
||||
// we're restoring to the same device, we're done!
|
||||
keys.erase_backup();
|
||||
} else {
|
||||
log::info!("DNA is not the same; setting flag to trigger RestoreDna flow");
|
||||
// one more step...have to re-encrypt the PDDB's basis to the new device's DNA.
|
||||
// we'll handle this *after* the reboot, because we may need a newer SoC version, etc.
|
||||
header.op = BackupOp::RestoreDna;
|
||||
keys.write_backup(header, ct)
|
||||
header.op = BackupOp::RestoreDna; // it gets set inside the call too; could lose this line but testing is painful on this flow.
|
||||
keys.write_restore_dna(header, ct)
|
||||
.expect("Couldn't set flag for restore with new DNA: some data loss will occur.");
|
||||
}
|
||||
log::info!("going to into reboot arc");
|
||||
|
|
|
|||
|
|
@ -413,6 +413,7 @@ fn wrapped_main() -> ! {
|
|||
let restore_header = keys.lock().unwrap().get_restore_header();
|
||||
match restore_header {
|
||||
Ok(Some(header)) => {
|
||||
log::info!("Restore header op: {:?}", header.op);
|
||||
match header.op {
|
||||
BackupOp::Restore => {
|
||||
// set the keyboard layout according to the restore record.
|
||||
|
|
|
|||
Loading…
Reference in a new issue