some more debugging to help trace through dict sync issues

This commit is contained in:
bunnie 2022-11-03 21:06:04 +08:00
parent b04dcc21ef
commit ff2a7f8240
2 changed files with 6 additions and 0 deletions

View file

@ -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
@ -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"))
}
}

View file

@ -373,6 +373,7 @@ 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(),
@ -380,6 +381,8 @@ impl PddbOs {
&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") {
@ -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);
}