vmbase: Explicitly map valid memory ranges
The new version of aarch64-paging crate introduces a breaking change in
'Mapping::map_range' API. Unless 'Attributes::VALID' is explicitly
passed to 'map_range', the VALID bit is no longer set in leaf page table
entries (blocks and pages).
This change explicitly sets the VALID bit in all places where `map_range`
is called.
Bug: 245267332
Test: atest MicrodroidTestApp
Change-Id: Ide81433f2b719f35cdf7a80b7694b63e79a0275e
diff --git a/rialto/src/main.rs b/rialto/src/main.rs
index 03fa107..0f92d3f 100644
--- a/rialto/src/main.rs
+++ b/rialto/src/main.rs
@@ -44,21 +44,21 @@
const PT_ROOT_LEVEL: usize = 1;
const PT_ASID: usize = 1;
-const PROT_DEV: Attributes = Attributes::from_bits_truncate(
- Attributes::DEVICE_NGNRE.bits() | Attributes::EXECUTE_NEVER.bits(),
-);
-const PROT_RX: Attributes = Attributes::from_bits_truncate(
- Attributes::NORMAL.bits() | Attributes::NON_GLOBAL.bits() | Attributes::READ_ONLY.bits(),
-);
-const PROT_RO: Attributes = Attributes::from_bits_truncate(
- Attributes::NORMAL.bits()
- | Attributes::NON_GLOBAL.bits()
- | Attributes::READ_ONLY.bits()
- | Attributes::EXECUTE_NEVER.bits(),
-);
-const PROT_RW: Attributes = Attributes::from_bits_truncate(
- Attributes::NORMAL.bits() | Attributes::NON_GLOBAL.bits() | Attributes::EXECUTE_NEVER.bits(),
-);
+const PROT_DEV: Attributes =
+ Attributes::DEVICE_NGNRE.union(Attributes::EXECUTE_NEVER).union(Attributes::VALID);
+const PROT_RX: Attributes = Attributes::NORMAL
+ .union(Attributes::NON_GLOBAL)
+ .union(Attributes::READ_ONLY)
+ .union(Attributes::VALID);
+const PROT_RO: Attributes = Attributes::NORMAL
+ .union(Attributes::NON_GLOBAL)
+ .union(Attributes::READ_ONLY)
+ .union(Attributes::EXECUTE_NEVER)
+ .union(Attributes::VALID);
+const PROT_RW: Attributes = Attributes::NORMAL
+ .union(Attributes::NON_GLOBAL)
+ .union(Attributes::EXECUTE_NEVER)
+ .union(Attributes::VALID);
#[global_allocator]
static HEAP_ALLOCATOR: LockedHeap<32> = LockedHeap::<32>::new();