Skip to content

Commit 0e4dcd7

Browse files
committed
fix[syscall]: fix syscall arch_prctl
1 parent 60c307d commit 0e4dcd7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

api/src/syscall/task/thread.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use axerrno::{AxError, AxResult};
2+
use axhal::uspace::UserContext;
23
use axtask::current;
34
use num_enum::TryFromPrimitive;
45
use starry_core::task::AsThread;
@@ -54,13 +55,13 @@ pub fn sys_set_tid_address(clear_child_tid: usize) -> AxResult<isize> {
5455

5556
#[cfg(target_arch = "x86_64")]
5657
pub fn sys_arch_prctl(
57-
tf: &mut axhal::context::TrapFrame,
58+
tf: &mut UserContext,
5859
code: i32,
5960
addr: usize,
6061
) -> AxResult<isize> {
6162
use starry_vm::VmMutPtr;
6263

63-
let code = ArchPrctlCode::try_from(code).map_err(|_| axerrno::AxError::EINVAL)?;
64+
let code = ArchPrctlCode::try_from(code).map_err(|_| axerrno::AxError::InvalidInput)?;
6465
debug!("sys_arch_prctl: code = {:?}, addr = {:#x}", code, addr);
6566

6667
match code {
@@ -76,7 +77,7 @@ pub fn sys_arch_prctl(
7677
}
7778
ArchPrctlCode::GetGs => {
7879
(addr as *mut usize)
79-
.vm_write(unsafe { x86::msr::rdmsr(x86::msr::IA32_KERNEL_GSBASE) })?;
80+
.vm_write(unsafe { x86::msr::rdmsr(x86::msr::IA32_KERNEL_GSBASE) as _ })?;
8081
Ok(0)
8182
}
8283
ArchPrctlCode::SetGs => {
@@ -86,6 +87,6 @@ pub fn sys_arch_prctl(
8687
Ok(0)
8788
}
8889
ArchPrctlCode::GetCpuid => Ok(0),
89-
ArchPrctlCode::SetCpuid => Err(axerrno::AxError::ENODEV),
90+
ArchPrctlCode::SetCpuid => Err(axerrno::AxError::NoSuchDevice),
9091
}
9192
}

0 commit comments

Comments
 (0)