Skip to content

Commit

Permalink
Update to aarch64-paging crate v0.6.0
Browse files Browse the repository at this point in the history
Update to v0.6.0 while making the necessary changes to catch up with the
crate's breaking changes
  • Loading branch information
ardbiesheuvel committed May 31, 2024
1 parent 73b6186 commit fa32384
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mmio = "2.1.0"
fdt = "0.1.5"
once_cell = { version = "1.18.0", default-features = false, features = ["alloc"] }
efiloader = "0.0.1"
aarch64-paging = "0.5.0"
aarch64-paging = "0.6.0"
aarch64-intrinsics = { version = "1.0.0", optional = true }

[features]
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ extern "C" fn efilite_main(base: *mut u8, used: isize, avail: usize) {
let mut mapper = mapper::MemoryMapper::new();

let (ro_flags, rw_flags, dev_flags) = {
let flags = Attributes::VALID | Attributes::NON_GLOBAL;
let flags = Attributes::VALID | Attributes::ACCESSED | Attributes::NON_GLOBAL;
(
flags | Attributes::NORMAL | Attributes::READ_ONLY,
flags | Attributes::NORMAL | Attributes::EXECUTE_NEVER,
flags | Attributes::DEVICE_NGNRE | Attributes::EXECUTE_NEVER,
flags | Attributes::ATTRIBUTE_INDEX_1 | Attributes::READ_ONLY,
flags | Attributes::ATTRIBUTE_INDEX_1 | Attributes::PXN,
flags | Attributes::ATTRIBUTE_INDEX_0 | Attributes::PXN | Attributes::UXN,
)
};

Expand Down Expand Up @@ -193,7 +193,7 @@ extern "C" fn efilite_main(base: *mut u8, used: isize, avail: usize) {
info!("Remapping statically allocated regions:\n");
mapper.map_reserved_range(&ldrange!(_rtcode_start, _rtcode_end), ro_flags);
mapper.map_reserved_range(&ldrange!(_dtb_end, _rtdata_end), rw_flags);
mapper.map_range(&dtb, ro_flags | Attributes::EXECUTE_NEVER);
mapper.map_range(&dtb, ro_flags | Attributes::PXN);

// Switch to the new ID map so we can use all of DRAM
mapper.activate();
Expand Down
14 changes: 9 additions & 5 deletions src/mapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ pub(crate) struct MemoryMapper {
impl MemoryMapper {
pub(crate) fn new() -> MemoryMapper {
MemoryMapper {
idmap: RefCell::new(idmap::IdMap::new(ASID, PAGING_ROOT_LEVEL)),
idmap: RefCell::new(idmap::IdMap::new(
ASID,
PAGING_ROOT_LEVEL,
TranslationRegime::El1And0,
)),
reserved: Vec::new(),
}
}
Expand All @@ -33,8 +37,8 @@ impl MemoryMapper {
match attributes & (EFI_MEMORY_RO | EFI_MEMORY_XP) {
0 => Attributes::empty(),
EFI_MEMORY_RO => Attributes::READ_ONLY,
EFI_MEMORY_XP => Attributes::EXECUTE_NEVER,
_ => Attributes::EXECUTE_NEVER | Attributes::READ_ONLY,
EFI_MEMORY_XP => Attributes::PXN,
_ => Attributes::PXN | Attributes::READ_ONLY,
}
}

Expand All @@ -43,7 +47,7 @@ impl MemoryMapper {
if flags & Attributes::READ_ONLY.bits() != 0 {
ret |= EFI_MEMORY_RO;
}
if flags & Attributes::EXECUTE_NEVER.bits() != 0 {
if flags & Attributes::PXN.bits() != 0 {
ret |= EFI_MEMORY_XP;
}
ret
Expand Down Expand Up @@ -112,7 +116,7 @@ impl efiloader::MemoryMapper for MemoryMapper {

fn query_range(&self, range: &Range<usize>) -> Option<u64> {
let r = MemoryRegion::new(range.start, range.end);
let mask = Attributes::READ_ONLY | Attributes::EXECUTE_NEVER;
let mask = Attributes::READ_ONLY | Attributes::PXN;
let mut any = Attributes::empty();
let mut all = mask;

Expand Down

0 comments on commit fa32384

Please sign in to comment.