mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
fix missing corner case in cache refill
This commit is contained in:
parent
5b00daba0d
commit
b7d5eca720
1 changed files with 22 additions and 20 deletions
|
|
@ -376,26 +376,28 @@ impl DictCacheEntry {
|
||||||
pub (crate) fn refill_small_key(&mut self, hw: &mut PddbOs, v2p_map: &HashMap::<VirtAddr, PhysPage>, cipher: &Aes256GcmSiv,
|
pub (crate) fn refill_small_key(&mut self, hw: &mut PddbOs, v2p_map: &HashMap::<VirtAddr, PhysPage>, cipher: &Aes256GcmSiv,
|
||||||
data_cache: &mut PlaintextCache, key_name: &str) {
|
data_cache: &mut PlaintextCache, key_name: &str) {
|
||||||
if let Some(kcache) = self.keys.get_mut(key_name) {
|
if let Some(kcache) = self.keys.get_mut(key_name) {
|
||||||
if let Some(pool_index) = small_storage_index_from_key(&kcache, self.index) {
|
if kcache.flags.valid() { // invalid keys were previously deleted, and have nothing to fill
|
||||||
let ksp = &mut self.small_pool[pool_index];
|
if let Some(pool_index) = small_storage_index_from_key(&kcache, self.index) {
|
||||||
assert!(ksp.contents.contains(&key_name.to_string()), "refill called on a non-existent key. This is an illegal state.");
|
let ksp = &mut self.small_pool[pool_index];
|
||||||
// now grab the *data* referred to by this key. Maybe this is a "bad" idea -- this can really eat up RAM fast to hold
|
assert!(ksp.contents.contains(&key_name.to_string()), "refill called on a non-existent key. This is an illegal state.");
|
||||||
// all the small pool data right away, but let's give it a try and see how it works. Later on we can always skip this.
|
// now grab the *data* referred to by this key. Maybe this is a "bad" idea -- this can really eat up RAM fast to hold
|
||||||
// manage a separate small cache for data blocks, under the theory that small keys tend to be packed together
|
// all the small pool data right away, but let's give it a try and see how it works. Later on we can always skip this.
|
||||||
let data_vaddr = small_storage_base_vaddr_from_indices(self.index, pool_index);
|
// manage a separate small cache for data blocks, under the theory that small keys tend to be packed together
|
||||||
data_cache.fill(hw, v2p_map, cipher, &self.aad, VirtAddr::new(data_vaddr).unwrap());
|
let data_vaddr = small_storage_base_vaddr_from_indices(self.index, pool_index);
|
||||||
if let Some(page) = data_cache.data.as_ref() {
|
data_cache.fill(hw, v2p_map, cipher, &self.aad, VirtAddr::new(data_vaddr).unwrap());
|
||||||
let start_offset = size_of::<JournalType>() + (kcache.start % VPAGE_SIZE as u64) as usize;
|
if let Some(page) = data_cache.data.as_ref() {
|
||||||
let mut data = page[start_offset..start_offset + kcache.len as usize].to_vec();
|
let start_offset = size_of::<JournalType>() + (kcache.start % VPAGE_SIZE as u64) as usize;
|
||||||
data.reserve_exact((kcache.reserved - kcache.len) as usize);
|
let mut data = page[start_offset..start_offset + kcache.len as usize].to_vec();
|
||||||
kcache.data = Some(KeyCacheData::Small(
|
data.reserve_exact((kcache.reserved - kcache.len) as usize);
|
||||||
KeySmallData {
|
kcache.data = Some(KeyCacheData::Small(
|
||||||
clean: true,
|
KeySmallData {
|
||||||
data
|
clean: true,
|
||||||
}
|
data
|
||||||
));
|
}
|
||||||
} else {
|
));
|
||||||
log::error!("Key {}'s data region at pp: {:x?} va: {:x} is unreadable", key_name, data_cache.tag, kcache.start);
|
} else {
|
||||||
|
log::error!("Key {}'s data region at pp: {:x?} va: {:x} is unreadable", key_name, data_cache.tag, kcache.start);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue