diff --git a/src/framework/jinux-frame/src/arch/x86/cpu.rs b/src/framework/jinux-frame/src/arch/x86/cpu.rs index 2c1a21f87..2e6c5dca0 100644 --- a/src/framework/jinux-frame/src/arch/x86/cpu.rs +++ b/src/framework/jinux-frame/src/arch/x86/cpu.rs @@ -35,10 +35,9 @@ pub fn this_cpu() -> u32 { #[derive(Clone, Default, Copy, Debug)] #[repr(C)] pub struct UserContext { - pub(crate) user_context: RawUserContext, - pub fp_regs: FpRegs, - /// trap information, this field is all zero when it is syscall - pub trap_information: TrapInformation, + user_context: RawUserContext, + fp_regs: FpRegs, + trap_information: TrapInformation, } #[derive(Clone, Default, Copy, Debug)] @@ -57,6 +56,18 @@ impl UserContext { pub fn general_regs_mut(&mut self) -> &mut GeneralRegs { &mut self.user_context.general } + + pub fn trap_information(&self) -> &TrapInformation { + &self.trap_information + } + + pub fn fp_regs(&self) -> &FpRegs { + &self.fp_regs + } + + pub fn fp_regs_mut(&mut self) -> &mut FpRegs { + &mut self.fp_regs + } } impl UserContextApiInternal for UserContext { diff --git a/src/services/libs/jinux-std/src/syscall/execve.rs b/src/services/libs/jinux-std/src/syscall/execve.rs index 885914ad0..13bd76d46 100644 --- a/src/services/libs/jinux-std/src/syscall/execve.rs +++ b/src/services/libs/jinux-std/src/syscall/execve.rs @@ -53,7 +53,7 @@ pub fn sys_execve( let default_content = UserContext::default(); *context.general_regs_mut() = *default_content.general_regs(); context.set_fsbase(default_content.fsbase()); - context.fp_regs = default_content.fp_regs; + *context.fp_regs_mut() = *default_content.fp_regs(); // set new entry point context.set_rip(elf_load_info.entry_point() as _); debug!("entry_point: 0x{:x}", elf_load_info.entry_point()); diff --git a/src/services/libs/jinux-std/src/thread/exception.rs b/src/services/libs/jinux-std/src/thread/exception.rs index 4bd45a6f6..c52cdf7d5 100644 --- a/src/services/libs/jinux-std/src/thread/exception.rs +++ b/src/services/libs/jinux-std/src/thread/exception.rs @@ -1,4 +1,3 @@ -use jinux_frame::user::UserContextApi; use jinux_frame::{cpu::*, vm::VmIo}; use crate::vm::page_fault_handler::PageFaultHandler; @@ -6,9 +5,9 @@ use crate::{prelude::*, process::signal::signals::fault::FaultSignal}; /// We can't handle most exceptions, just send self a fault signal before return to user space. pub fn handle_exception(context: &mut UserContext) { - let trap_info = context.trap_information.clone(); + let trap_info = context.trap_information(); let exception = CpuException::to_cpu_exception(trap_info.id as u16).unwrap(); - log_trap_info(exception, &trap_info); + log_trap_info(exception, trap_info); let current = current!(); let root_vmar = current.root_vmar();