From 4404982a55e547d77dd6e3f2e66675d7b7136e51 Mon Sep 17 00:00:00 2001 From: WangRunji Date: Mon, 25 Feb 2019 00:20:37 +0800 Subject: [PATCH] impl sys_arch_prctl set fs --- kernel/src/syscall/ctrl.rs | 14 ++++++++++++++ kernel/src/syscall/mod.rs | 7 +++---- 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 kernel/src/syscall/ctrl.rs diff --git a/kernel/src/syscall/ctrl.rs b/kernel/src/syscall/ctrl.rs new file mode 100644 index 0000000..3a18f50 --- /dev/null +++ b/kernel/src/syscall/ctrl.rs @@ -0,0 +1,14 @@ +use super::*; + +pub fn sys_arch_prctl(code: i32, addr: usize, tf: &mut TrapFrame) -> SysResult { + const ARCH_SET_FS: i32 = 0x1002; + match code { + #[cfg(target_arch = "x86_64")] + ARCH_SET_FS => { + info!("sys_arch_prctl: set FS to {:#x}", addr); + tf.fsbase = addr; + Ok(0) + } + _ => Err(SysError::Inval), + } +} diff --git a/kernel/src/syscall/mod.rs b/kernel/src/syscall/mod.rs index 267d338..cd892e8 100644 --- a/kernel/src/syscall/mod.rs +++ b/kernel/src/syscall/mod.rs @@ -17,11 +17,13 @@ use self::fs::*; use self::mem::*; use self::proc::*; use self::time::*; +use self::ctrl::*; mod fs; mod mem; mod proc; mod time; +mod ctrl; /// System call dispatcher pub fn syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> isize { @@ -102,10 +104,7 @@ pub fn syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> isize { warn!("sys_sigaltstack is unimplemented"); Ok(0) } - 158 => { - warn!("sys_arch_prctl is unimplemented"); - Ok(0) - } + 158 => sys_arch_prctl(args[0] as i32, args[1], tf), 218 => { warn!("sys_set_tid_address is unimplemented"); Ok(0)