From 0c7a48590de42fd16608e8a30035ff2e90956e14 Mon Sep 17 00:00:00 2001 From: Jianyong Wu Date: Tue, 24 Oct 2023 08:11:18 +0000 Subject: [PATCH] aarch64: fix get time runtime service failure When enable efi_rtc inside guest kernel, a warning occurs: [ 0.764401] [Firmware Bug]: Unable to handle paging request in EFI runtime service [ 0.770671] ------------[ cut here ]------------ [ 0.772014] WARNING: CPU: 0 PID: 1 at drivers/firmware/efi/runtime-wrappers.c:262 virt_efi_get_time+0x12c/0x17c It derives from that there is lack of memory map descriptor for IO address of RTC_PL031 passed to kernel. Allocate IO Map for it before execute kernel/bootloader can avoid this failure and then we can get the right time inside guest. Fixes: #289 Signed-off-by: Jianyong Wu --- src/efi/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/efi/mod.rs b/src/efi/mod.rs index 1d725cfe..32f8de5a 100644 --- a/src/efi/mod.rs +++ b/src/efi/mod.rs @@ -1181,6 +1181,19 @@ pub fn efi_exec( let wrapped_fs = file::FileSystemWrapper::new(fs, efi_part_id); + // allocate descriptor for RTC on aarch64 + #[cfg(target_arch = "aarch64")] + if Status::SUCCESS + != ALLOCATOR.borrow_mut().add_initial_allocation( + efi::MEMORY_MAPPED_IO, + 1, + crate::arch::aarch64::layout::map::mmio::PL031_START as u64, + r_efi::efi::MEMORY_RUNTIME, + ) + { + log!("Failed to allocate memory map descriptor for RTC PL031\n"); + } + let image = new_image_handle( crate::efi::EFI_BOOT_PATH, 0 as Handle,