Skip to content

Commit

Permalink
fix(x86_64/apic): map SMP bootcode to allocated physical address inst…
Browse files Browse the repository at this point in the history
…ead of fixed one
  • Loading branch information
sarahspberrypi authored and mkroening committed Dec 1, 2023
1 parent 054d2d6 commit 5cf666f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/arch/x86_64/kernel/apic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,20 +693,18 @@ pub fn boot_application_processors() {
"SMP Boot Code is larger than a page"
);
debug!("SMP boot code is {} bytes long", smp_boot_code.len());
// We can only allocate full pages of physmem
let length = BasePageSize::SIZE as usize;
let phys_addr: PhysAddr = crate::arch::mm::physicalmem::allocate(length).unwrap();

// Identity-map the boot code page and copy over the code.
debug!(
"Mapping SMP boot code to physical and virtual address {:p}",
SMP_BOOT_CODE_ADDRESS
);
let mut flags = PageTableEntryFlags::empty();
flags.normal().writable();
paging::map::<BasePageSize>(
SMP_BOOT_CODE_ADDRESS,
PhysAddr(SMP_BOOT_CODE_ADDRESS.as_u64()),
1,
flags,
debug!(
"Mapping SMP boot code from physical address {phys_addr:x} to virtual address {:p}",
SMP_BOOT_CODE_ADDRESS
);
//map physical memory to SMP_BOOT_CODE_ADDRESS in virtual memory
paging::map::<BasePageSize>(SMP_BOOT_CODE_ADDRESS, phys_addr, 1, flags);
unsafe {
ptr::copy_nonoverlapping(
smp_boot_code.as_ptr(),
Expand Down

0 comments on commit 5cf666f

Please sign in to comment.