Skip to content

Commit 2ca916e

Browse files
tool: loader map spin table page for BCM2711
The previous commit restricts the loader to only mapping itself rather than the first 1GB of memory. This is fine for most platforms as the only other thing they need to access is the UART which is now also separately mapped in. The one exception is the BCM2711/Raspberry Pi 4B where the a spin table is used for SMP booting which is located in the first page of memory, so we need to explicitly map that in as well. This code is a bit of hack since it assumes the CPU release addrs are always in the first 2MB of memory but the only platform we have right now that uses spin tables is the Raspberry Pi 4B. So we can merge the previous patch, we add this so that we don't have to regress the Raspberry Pi 4B. Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
1 parent 5aa5ef6 commit 2ca916e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tool/microkit/src/loader.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,23 @@ impl<'a> Loader<'a> {
547547
boot_lvl2_lower[start..end].copy_from_slice(&pt_entry.to_le_bytes());
548548
}
549549

550+
// TODO: this is a complete hack specific to BCM2711/Raspberry Pi 4B and
551+
// will be removed with patches that re-do this loader mapping code.
552+
if elf.find_symbol("cpus_release_addr").is_ok() {
553+
let lvl2_idx = Aarch64::lvl2_index(0);
554+
// Make sure we don't override the loader mappings done above.
555+
assert!(Aarch64::lvl2_index(start_addr) != lvl2_idx);
556+
assert!(Aarch64::lvl1_index(start_addr) == Aarch64::lvl1_index(0));
557+
#[allow(clippy::identity_op)] // keep the (0 << 2) for clarity
558+
let pt_entry: u64 = ((lvl2_idx as u64) << AARCH64_2MB_BLOCK_BITS) |
559+
(1 << 10) | // access flag
560+
(0 << 2) | // strongly ordered memory
561+
(1 << 0); // 2M block
562+
let start = 8 * lvl2_idx;
563+
let end = 8 * (lvl2_idx + 1);
564+
boot_lvl2_lower[start..end].copy_from_slice(&pt_entry.to_le_bytes());
565+
}
566+
550567
let boot_lvl0_upper: [u8; PAGE_TABLE_SIZE] = [0; PAGE_TABLE_SIZE];
551568
{
552569
let pt_entry = (boot_lvl1_upper_addr | 3).to_le_bytes();

0 commit comments

Comments
 (0)