Skip to content

Commit 07c0a5f

Browse files
committed
remove some copiler warnings and minor compilor errors
1 parent fb1d497 commit 07c0a5f

9 files changed

Lines changed: 47 additions & 52 deletions

File tree

src/arch/aarch64/kernel/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ use memory_addresses::{PhysAddr, VirtAddr};
2727

2828
pub(crate) use self::interrupts::wakeup_core;
2929
pub(crate) use self::processor::set_oneshot_timer;
30-
use crate::arch::kernel::core_local::*;
31-
use crate::arch::mm::paging::{BasePageSize, PageSize};
3230
#[cfg(all(feature = "common-os", feature = "fork"))]
3331
pub use self::scheduler::prepare_fork_child_stack;
32+
use crate::arch::kernel::core_local::*;
33+
use crate::arch::mm::paging::{BasePageSize, PageSize};
3434
use crate::config::*;
3535
#[cfg(feature = "smp")]
3636
use crate::env::FdtStartInfo;

src/arch/aarch64/mm/paging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ pub fn drop_user_space(l0_phys: usize) {
11111111
pub fn clear_user_space() {
11121112
use aarch64_cpu::registers::TTBR0_EL1;
11131113

1114-
use crate::core_scheduler;
1114+
use crate::arch::kernel::core_local::core_scheduler;
11151115
use crate::fd::STDERR_FILENO;
11161116

11171117
core_scheduler()

src/arch/aarch64/start/hermit_entry.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,39 @@ pub unsafe extern "C" fn pre_init(boot_info: Option<&'static RawBootInfo>, cpu_i
9090
// Memory barrier
9191
dsb(SY);
9292

93+
// On CPUs that implement FEAT_PAN (ARMv8.1+, e.g. Apple Silicon under
94+
// HVF), `PSTATE.PAN` may default to 1, which would make every kernel
95+
// write to a USER_ACCESSIBLE page (e.g. clearing the user-space TLS
96+
// region during `load_application`) trap as a permission fault.
97+
// Hermit's common-os path needs the kernel to be able to set up
98+
// user pages on behalf of the loader, so:
99+
// 1. set SCTLR_EL1.SPAN=1 so `PSTATE.PAN` is *not* forced to 1 on
100+
// exception entry (otherwise every SVC/IRQ would re-set PAN
101+
// and our `msr pan, #0` below would only hold for one trap), and
102+
// 2. clear `PSTATE.PAN` itself.
103+
// On older CPUs without FEAT_PAN (e.g. Cortex-A72) the PAN field in
104+
// ID_AA64MMFR1_EL1 reads zero, so we skip the `msr pan, #0` (which
105+
// would otherwise UNDEF).
106+
#[cfg(feature = "common-os")]
107+
unsafe {
108+
asm!(
109+
// SCTLR_EL1.SPAN <- 1: keep PSTATE.PAN unchanged on exception entry.
110+
"mrs {tmp}, sctlr_el1",
111+
"orr {tmp}, {tmp}, #(1 << 23)",
112+
"msr sctlr_el1, {tmp}",
113+
"isb",
114+
// Clear PSTATE.PAN if the CPU implements FEAT_PAN.
115+
"mrs {tmp}, id_aa64mmfr1_el1",
116+
"ubfx {tmp}, {tmp}, #20, #4",
117+
"cbz {tmp}, 1f",
118+
".arch_extension pan",
119+
"msr pan, #0",
120+
"1:",
121+
tmp = out(reg) _,
122+
options(nostack, preserves_flags),
123+
);
124+
}
125+
93126
if cpu_id == 0 {
94127
unsafe {
95128
env::set_start_info(*boot_info.unwrap());

src/arch/aarch64/start/smp.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -190,38 +190,5 @@ unsafe extern "C" fn smp_start_rust() -> ! {
190190
// Memory barrier
191191
dsb(SY);
192192

193-
// On CPUs that implement FEAT_PAN (ARMv8.1+, e.g. Apple Silicon under
194-
// HVF), `PSTATE.PAN` may default to 1, which would make every kernel
195-
// write to a USER_ACCESSIBLE page (e.g. clearing the user-space TLS
196-
// region during `load_application`) trap as a permission fault.
197-
// Hermit's common-os path needs the kernel to be able to set up
198-
// user pages on behalf of the loader, so:
199-
// 1. set SCTLR_EL1.SPAN=1 so `PSTATE.PAN` is *not* forced to 1 on
200-
// exception entry (otherwise every SVC/IRQ would re-set PAN
201-
// and our `msr pan, #0` below would only hold for one trap), and
202-
// 2. clear `PSTATE.PAN` itself.
203-
// On older CPUs without FEAT_PAN (e.g. Cortex-A72) the PAN field in
204-
// ID_AA64MMFR1_EL1 reads zero, so we skip the `msr pan, #0` (which
205-
// would otherwise UNDEF).
206-
#[cfg(feature = "common-os")]
207-
unsafe {
208-
asm!(
209-
// SCTLR_EL1.SPAN <- 1: keep PSTATE.PAN unchanged on exception entry.
210-
"mrs {tmp}, sctlr_el1",
211-
"orr {tmp}, {tmp}, #(1 << 23)",
212-
"msr sctlr_el1, {tmp}",
213-
"isb",
214-
// Clear PSTATE.PAN if the CPU implements FEAT_PAN.
215-
"mrs {tmp}, id_aa64mmfr1_el1",
216-
"ubfx {tmp}, {tmp}, #20, #4",
217-
"cbz {tmp}, 9f",
218-
".arch_extension pan",
219-
"msr pan, #0",
220-
"9:",
221-
tmp = out(reg) _,
222-
options(nostack, preserves_flags),
223-
);
224-
}
225-
226193
crate::rt::application_processor_main()
227194
}

src/arch/riscv64/mm/paging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ pub fn prepare_mem_copy_on_write() {
10901090
/// maps the new one.
10911091
#[cfg(feature = "common-os")]
10921092
pub fn clear_user_space() {
1093-
use crate::core_scheduler;
1093+
use crate::arch::kernel::core_local::core_scheduler;
10941094
use crate::fd::STDERR_FILENO;
10951095

10961096
core_scheduler()

src/arch/x86_64/kernel/mod.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@ use core::ptr;
55
use core::slice;
66
use core::sync::atomic::{AtomicPtr, AtomicU32, Ordering};
77

8+
#[cfg(feature = "common-os")]
9+
use memory_addresses::{PhysAddr, VirtAddr};
810
use x86_64::registers::control::{Cr0, Cr4};
911

1012
pub(crate) use self::apic::{set_oneshot_timer, wakeup_core};
1113
#[cfg(all(feature = "common-os", feature = "fork"))]
1214
pub use self::switch::prepare_fork_child_stack;
13-
use crate::env;
15+
use crate::arch::x86_64::kernel::core_local::*;
1416
#[cfg(feature = "uhyve")]
1517
use crate::env::{self, UhyveStartInfo};
16-
use crate::arch::x86_64::kernel::core_local::*;
17-
use hermit_entry::boot_info::RawBootInfo;
18-
#[cfg(feature = "common-os")]
19-
use memory_addresses::{PhysAddr, VirtAddr};
20-
use x86_64::registers::control::{Cr0, Cr4};
2118

2219
#[cfg(feature = "acpi")]
2320
pub mod acpi;
@@ -187,7 +184,6 @@ where
187184
use x86_64::structures::paging::{PageSize, Size4KiB as BasePageSize};
188185

189186
use crate::arch::mm::paging::{self, PageTableEntryFlags, PageTableEntryFlagsExt};
190-
use crate::mm::{FrameAlloc, PageRangeAllocator};
191187
use crate::fd::{Fd, RawFd, stdio};
192188
#[cfg(feature = "fork")]
193189
use crate::mm::frame_ref_inc;
@@ -342,9 +338,8 @@ pub unsafe fn jump_to_user_land(
342338
};
343339

344340
use crate::arch::kernel::scheduler::TaskStacks;
345-
use crate::arch::x86_64::mm::paging::PageTableEntryFlagsExt;
346-
use crate::mm::{FrameAlloc, PageRangeAllocator};
347341
use crate::arch::mm::paging;
342+
use crate::arch::x86_64::mm::paging::PageTableEntryFlagsExt;
348343
#[cfg(feature = "fork")]
349344
use crate::mm::frame_ref_inc;
350345
use crate::mm::vma::*;

src/arch/x86_64/mm/paging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ pub fn drop_user_space(pml4_phys: usize) {
468468

469469
#[cfg(feature = "common-os")]
470470
pub fn clear_user_space() {
471-
use crate::core_scheduler;
471+
use crate::arch::kernel::core_local::core_scheduler;
472472
use crate::fd::STDERR_FILENO;
473473

474474
core_scheduler()

src/mm/physicalmem.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ use core::sync::atomic::{AtomicUsize, Ordering};
77
use align_address::Align;
88
use free_list::{FreeList, PageLayout, PageRange};
99
use hermit_sync::InterruptTicketMutex;
10+
#[cfg(any(feature = "common-os", feature = "hermit-entry"))]
11+
use memory_addresses::PhysAddr;
1012
use memory_addresses::VirtAddr;
1113

14+
#[cfg(any(feature = "common-os", feature = "hermit-entry"))]
15+
use crate::arch::mm::paging::PageTableEntryFlags;
1216
#[cfg(all(target_arch = "x86_64", feature = "hermit-entry"))]
1317
use crate::arch::mm::paging::PageTableEntryFlagsExt;
1418
use crate::arch::mm::paging::{self, HugePageSize, PageSize};
@@ -147,10 +151,6 @@ pub fn total_memory_size() -> usize {
147151

148152
#[cfg(feature = "hermit-entry")]
149153
pub unsafe fn map_frame_range(frame_range: PageRange) {
150-
use memory_addresses::PhysAddr;
151-
152-
use crate::arch::mm::paging::PageTableEntryFlags;
153-
154154
cfg_select! {
155155
target_arch = "aarch64" => {
156156
type IdentityPageSize = paging::BasePageSize;

src/syscalls/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ pub unsafe extern "C" fn sys_pipe(pipefd: *mut RawFd) -> i32 {
922922
#[cfg(not(feature = "common-os"))]
923923
#[hermit_macro::system(errno)]
924924
#[unsafe(no_mangle)]
925-
pub unsafe extern "C" fn sys_pipe(pipefd: *mut RawFd) -> i32 {
925+
pub unsafe extern "C" fn sys_pipe(_pipefd: *mut RawFd) -> i32 {
926926
-i32::from(Errno::Nosys)
927927
}
928928

0 commit comments

Comments
 (0)