Skip to content

Commit

Permalink
some more debugging to help trace through dict sync issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bunnie committed Nov 3, 2022
1 parent b04dcc2 commit ff2a7f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions services/pddb/src/backend/basis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,7 @@ impl BasisCacheEntry {
}
}
// generate nonce and write out
log::debug!("patching pp {:x?} with aad {:x?}, data {:x?}", pp, self.aad, &page[..256]);
hw.data_encrypt_and_patch_page(&self.cipher, &self.aad, &mut page, &pp);

// 4. Check for dirty keys, if there are still some, update vpage_num to target them; otherwise
Expand All @@ -1594,6 +1595,7 @@ impl BasisCacheEntry {
}
Ok(())
} else {
log::error!("dict sync could not happen, dictionary name invalid!");
Err(Error::new(ErrorKind::NotFound, "dict_sync called with an invalid dictionary name"))
}
}
Expand Down
4 changes: 4 additions & 0 deletions services/pddb/src/backend/hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,16 @@ impl PddbOs {
/// exactly to the first entry in the page table
pub(crate) fn patch_data(&self, data: &[u8], offset: u32) {
log::trace!("patch offset: {:x} len: {:x}", offset, data.len());
// log::trace!("patch bef: {:x?}", &self.pddb_mr.as_slice::<u8>()[offset as usize + self.data_phys_base.as_usize()..offset as usize + self.data_phys_base.as_usize() + 48]);
assert!(data.len() + offset as usize <= PDDB_A_LEN - self.data_phys_base.as_usize(), "attempt to store past disk boundary");
self.spinor.patch(
self.pddb_mr.as_slice(),
xous::PDDB_LOC,
&data,
offset + self.data_phys_base.as_u32(),
).expect("couldn't write to data region in the PDDB");
//log::trace!("patch aft: {:x?}", &self.pddb_mr.as_slice::<u8>()[offset as usize + self.data_phys_base.as_usize()..offset as usize + self.data_phys_base.as_usize() + 48]);
//log::trace!("patch end: {:x?}", &self.pddb_mr.as_slice::<u8>()[offset as usize + self.data_phys_base.as_usize() + 4048..offset as usize + self.data_phys_base.as_usize() + 4096])
}
fn patch_pagetable(&self, data: &[u8], offset: u32) {
if cfg!(feature = "mbbb") {
Expand Down Expand Up @@ -1620,6 +1623,7 @@ impl PddbOs {
msg: &data,
}
).expect("couldn't encrypt data");
// log::trace!("calling patch. nonce {:x?}, ct {:x?}, data {:x?}", nonce.as_slice(), &ciphertext[..32], &data[..32]);
self.patch_data(&[nonce.as_slice(), &ciphertext].concat(), pp.page_number() * PAGE_SIZE as u32);
}

Expand Down

0 comments on commit ff2a7f8

Please sign in to comment.