Skip to content

Commit d351f2d

Browse files
committed
fix: adapt nightly 2025
1 parent 1e107bc commit d351f2d

File tree

3 files changed

+28
-33
lines changed

3 files changed

+28
-33
lines changed

src/exception.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -325,20 +325,18 @@ fn current_el_sync_handler(tf: &mut TrapFrame) {
325325
///
326326
/// - This function is not typically called directly from Rust code. Instead, it is
327327
/// invoked as part of the low-level hypervisor or VM exit handling routines.
328-
#[naked]
328+
#[unsafe(naked)]
329329
#[unsafe(no_mangle)]
330330
unsafe extern "C" fn vmexit_trampoline() -> ! {
331-
unsafe {
332-
core::arch::naked_asm!(
333-
// Curretly `sp` points to the base address of `Aarch64VCpu.ctx`, which stores guest's `TrapFrame`.
334-
"add x9, sp, 34 * 8", // Skip the exception frame.
335-
// Currently `x9` points to `&Aarch64VCpu.host_stack_top`, see `run_guest()` in vcpu.rs.
336-
"ldr x10, [x9]", // Get `host_stack_top` value from `&Aarch64VCpu.host_stack_top`.
337-
"mov sp, x10", // Set `sp` as the host stack top.
338-
restore_regs_from_stack!(), // Restore host function context frame.
339-
"ret", // Control flow is handed back to Aarch64VCpu.run(), simulating the normal return of the `run_guest` function.
340-
)
341-
}
331+
core::arch::naked_asm!(
332+
// Curretly `sp` points to the base address of `Aarch64VCpu.ctx`, which stores guest's `TrapFrame`.
333+
"add x9, sp, 34 * 8", // Skip the exception frame.
334+
// Currently `x9` points to `&Aarch64VCpu.host_stack_top`, see `run_guest()` in vcpu.rs.
335+
"ldr x10, [x9]", // Get `host_stack_top` value from `&Aarch64VCpu.host_stack_top`.
336+
"mov sp, x10", // Set `sp` as the host stack top.
337+
restore_regs_from_stack!(), // Restore host function context frame.
338+
"ret", // Control flow is handed back to Aarch64VCpu.run(), simulating the normal return of the `run_guest` function.
339+
)
342340
}
343341

344342
/// Deal with invalid aarch64 exception.

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![no_std]
2-
#![feature(naked_functions)]
32
#![feature(doc_cfg)]
43
#![doc = include_str!("../README.md")]
54

src/vcpu.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<H: AxVCpuHal> Aarch64VCpu<H> {
183183
///
184184
/// When a VM-Exit happens when guest's vCpu is running,
185185
/// the control flow will be redirected to this function through `return_run_guest`.
186-
#[naked]
186+
#[unsafe(naked)]
187187
unsafe extern "C" fn run_guest(&mut self) -> usize {
188188
// Fixes: https://github.com/arceos-hypervisor/arm_vcpu/issues/22
189189
//
@@ -192,25 +192,23 @@ impl<H: AxVCpuHal> Aarch64VCpu<H> {
192192
// original `run_guest` with the current naked one, we eliminate the dummy code path of the
193193
// original version, and ensure that the compiler does not perform any unexpected return
194194
// value optimization.
195-
unsafe {
196-
core::arch::naked_asm!(
197-
// Save host context.
198-
save_regs_to_stack!(),
199-
// Save current host stack top to `self.host_stack_top`.
200-
//
201-
// 'extern "C"' here specifies the aapcs64 calling convention, according to which
202-
// the first and only parameter, the pointer of self, should be in x0:
203-
"mov x9, sp",
204-
"add x0, x0, {host_stack_top_offset}",
205-
"str x9, [x0]",
206-
// Go to `context_vm_entry`.
207-
"b context_vm_entry",
208-
// Panic if the control flow comes back here, which should never happen.
209-
"b {run_guest_panic}",
210-
host_stack_top_offset = const core::mem::size_of::<TrapFrame>(),
211-
run_guest_panic = sym Self::run_guest_panic,
212-
);
213-
}
195+
core::arch::naked_asm!(
196+
// Save host context.
197+
save_regs_to_stack!(),
198+
// Save current host stack top to `self.host_stack_top`.
199+
//
200+
// 'extern "C"' here specifies the aapcs64 calling convention, according to which
201+
// the first and only parameter, the pointer of self, should be in x0:
202+
"mov x9, sp",
203+
"add x0, x0, {host_stack_top_offset}",
204+
"str x9, [x0]",
205+
// Go to `context_vm_entry`.
206+
"b context_vm_entry",
207+
// Panic if the control flow comes back here, which should never happen.
208+
"b {run_guest_panic}",
209+
host_stack_top_offset = const core::mem::size_of::<TrapFrame>(),
210+
run_guest_panic = sym Self::run_guest_panic,
211+
);
214212
}
215213

216214
/// This function is called when the control flow comes back to `run_guest`. To provide a error

0 commit comments

Comments
 (0)