diff --git a/src/arch/aarch64/kernel/processor.rs b/src/arch/aarch64/kernel/processor.rs index 4ef9c0aed7..50faf312f9 100644 --- a/src/arch/aarch64/kernel/processor.rs +++ b/src/arch/aarch64/kernel/processor.rs @@ -115,12 +115,13 @@ pub fn halt() { } /// Shutdown the system -pub fn shutdown() -> ! { +#[allow(unused_variables)] +pub fn shutdown(error_code: i32) -> ! { info!("Shutting down system"); cfg_if::cfg_if! { if #[cfg(feature = "semihosting")] { - semihosting::process::exit(0) + semihosting::process::exit(error_code) } else { unsafe { const PSCI_SYSTEM_OFF: u64 = 0x84000008; diff --git a/src/arch/riscv64/kernel/processor.rs b/src/arch/riscv64/kernel/processor.rs index 399e87e69d..63c2449921 100644 --- a/src/arch/riscv64/kernel/processor.rs +++ b/src/arch/riscv64/kernel/processor.rs @@ -227,12 +227,13 @@ pub fn halt() { } /// Shutdown the system -pub fn shutdown() -> ! { +#[allow(unused_variables)] +pub fn shutdown(error_code: i32) -> ! { info!("Shutting down system"); cfg_if::cfg_if! { if #[cfg(feature = "semihosting")] { - semihosting::process::exit(0) + semihosting::process::exit(error_code) } else { // use SBI shutdown sbi::legacy::shutdown() diff --git a/src/arch/x86_64/kernel/processor.rs b/src/arch/x86_64/kernel/processor.rs index f09cad23f7..711bedd537 100644 --- a/src/arch/x86_64/kernel/processor.rs +++ b/src/arch/x86_64/kernel/processor.rs @@ -997,7 +997,7 @@ fn triple_fault() -> ! { } /// Shutdown the system -pub fn shutdown() -> ! { +pub fn shutdown(error_code: i32) -> ! { info!("Shutting down system"); let acpi_result: Result = { #[cfg(feature = "acpi")] @@ -1019,7 +1019,11 @@ pub fn shutdown() -> ! { PlatformInfo::Multiboot { .. } => { // Try QEMU's debug exit let exit_handler = qemu_exit::X86::new(0xf4, 3); - exit_handler.exit_success() + if error_code == 0 { + exit_handler.exit_success() + } else { + exit_handler.exit_failure() + } } PlatformInfo::Uhyve { .. } => todo!(), } diff --git a/src/arch/x86_64/mm/paging.rs b/src/arch/x86_64/mm/paging.rs index 284e6ef09e..1f44845a81 100644 --- a/src/arch/x86_64/mm/paging.rs +++ b/src/arch/x86_64/mm/paging.rs @@ -3,7 +3,7 @@ use core::ptr; use x86_64::instructions::tlb; use x86_64::registers::control::Cr3; -use x86_64::structures::paging::mapper::UnmapError; +use x86_64::structures::paging::mapper::{TranslateResult, UnmapError}; pub use x86_64::structures::paging::PageTableFlags as PageTableEntryFlags; use x86_64::structures::paging::{ Mapper, Page, PageTable, PageTableIndex, PhysFrame, RecursivePageTable, Size2MiB, Translate, @@ -68,9 +68,20 @@ unsafe fn recursive_page_table() -> RecursivePageTable<'static> { pub fn virtual_to_physical(virtual_address: VirtAddr) -> Option { let virtual_address = x86_64::VirtAddr::new(virtual_address.0); let page_table = unsafe { recursive_page_table() }; - page_table - .translate_addr(virtual_address) - .map(|addr| PhysAddr(addr.as_u64())) + let translate = page_table.translate(virtual_address); + + match translate { + TranslateResult::NotMapped | TranslateResult::InvalidFrameAddress(_) => { + warn!( + "Uable to determine the physical address of 0x{:X}", + virtual_address + ); + None + } + TranslateResult::Mapped { frame, offset, .. } => { + Some(PhysAddr((frame.start_address() + offset).as_u64())) + } + } } #[no_mangle] diff --git a/src/syscalls/interfaces/mod.rs b/src/syscalls/interfaces/mod.rs index bf32eecfbf..332a9360b9 100644 --- a/src/syscalls/interfaces/mod.rs +++ b/src/syscalls/interfaces/mod.rs @@ -48,7 +48,7 @@ pub trait SyscallInterface: Send + Sync { (argc, argv, envv) } - fn shutdown(&self, _arg: i32) -> ! { - arch::processor::shutdown() + fn shutdown(&self, error_code: i32) -> ! { + arch::processor::shutdown(error_code) } } diff --git a/src/syscalls/interfaces/uhyve.rs b/src/syscalls/interfaces/uhyve.rs index 7b66b7948e..a365516d21 100644 --- a/src/syscalls/interfaces/uhyve.rs +++ b/src/syscalls/interfaces/uhyve.rs @@ -167,8 +167,8 @@ impl SyscallInterface for Uhyve { (syscmdsize.argc, argv, env) } - fn shutdown(&self, arg: i32) -> ! { - let mut sysexit = SysExit::new(arg); + fn shutdown(&self, error_code: i32) -> ! { + let mut sysexit = SysExit::new(error_code); uhyve_send(UHYVE_PORT_EXIT, &mut sysexit); loop { diff --git a/xtask/src/ci/qemu.rs b/xtask/src/ci/qemu.rs index 9951a860f1..0962112129 100644 --- a/xtask/src/ci/qemu.rs +++ b/xtask/src/ci/qemu.rs @@ -193,6 +193,7 @@ impl Qemu { if self.build.cargo_build.artifact.arch == Arch::Aarch64 { memory = memory.max(256); } + memory = memory.max(64); memory }