mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
kernel: riscv: fix memory reuse bug
Memory that was marked as reserved-but-not-in-use could get reallocated. Practically speaking, this caused threads to share stack, which makes things spooky. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
8f809c2a51
commit
93d295b93b
1 changed files with 6 additions and 0 deletions
|
|
@ -593,6 +593,12 @@ pub fn virt_to_phys(virt: usize) -> Result<usize, xous_kernel::Error> {
|
|||
|
||||
// Ensure the entry hasn't already been mapped.
|
||||
if l0_pt.entries[vpn0] & MMUFlags::VALID.bits() == 0 {
|
||||
// The memory has been reserved, but isn't pointing anywhere yet.
|
||||
if l0_pt.entries[vpn0] != 0 {
|
||||
return Err(xous_kernel::Error::MemoryInUse);
|
||||
}
|
||||
|
||||
// The address hasn't been allocated
|
||||
return Err(xous_kernel::Error::BadAddress);
|
||||
}
|
||||
Ok((l0_pt.entries[vpn0] >> 10) << 12)
|
||||
|
|
|
|||
Loading…
Reference in a new issue