kernel: riscv: return ShareViolation when memory is shared

When memory has been shared, it is no longer valid. However, it is still
"in use".

Return a `ShareViolation` error in this case so we can check for it
elsewhere.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2021-02-17 17:20:40 +08:00
parent b77827f2ed
commit 3b85392877

View file

@ -583,8 +583,13 @@ pub fn virt_to_phys(virt: usize) -> Result<usize, xous_kernel::Error> {
return Err(xous_kernel::Error::BadAddress);
}
// If the page is "Valid" but shared, issue a sharing violation
if l0_pt.entries[vpn0] & MMUFlags::S.bits() == 0 {
return Err(xous_kernel::Error::ShareViolation);
}
// Ensure the entry hasn't already been mapped.
if l0_pt.entries[vpn0] & 1 == 0 {
if l0_pt.entries[vpn0] & MMUFlags::VALID.bits() == 0 {
return Err(xous_kernel::Error::BadAddress);
}
Ok((l0_pt.entries[vpn0] >> 10) << 12)