@@ -93,8 +93,8 @@ impl TaskExt {
9393 let kstack_top = curr. kernel_stack_top ( ) . unwrap ( ) ;
9494 info ! (
9595 "Enter user space: entry={:#x}, ustack={:#x}, kstack={:#x}" ,
96- curr. task_ext( ) . uctx. get_ip ( ) ,
97- curr. task_ext( ) . uctx. get_sp ( ) ,
96+ curr. task_ext( ) . uctx. ip ( ) ,
97+ curr. task_ext( ) . uctx. sp ( ) ,
9898 kstack_top,
9999 ) ;
100100 unsafe { curr. task_ext ( ) . uctx . enter_uspace ( kstack_top) } ;
@@ -110,6 +110,10 @@ impl TaskExt {
110110 new_task
111111 . ctx_mut ( )
112112 . set_page_table_root ( new_aspace. page_table_root ( ) ) ;
113+ #[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ]
114+ new_task
115+ . ctx_mut ( )
116+ . set_tls ( axhal:: arch:: read_thread_pointer ( ) . into ( ) ) ;
113117
114118 let trap_frame = read_trapframe_from_kstack ( current_task. get_kernel_stack_top ( ) . unwrap ( ) ) ;
115119 let mut new_uctx = UspaceContext :: from ( & trap_frame) ;
@@ -118,7 +122,11 @@ impl TaskExt {
118122 }
119123 // Skip current instruction
120124 #[ cfg( any( target_arch = "riscv64" , target_arch = "loongarch64" ) ) ]
121- new_uctx. set_ip ( new_uctx. get_ip ( ) + 4 ) ;
125+ {
126+ let new_uctx_ip = new_uctx. ip ( ) ;
127+ new_uctx. set_ip ( new_uctx_ip + 4 ) ;
128+ }
129+
122130 new_uctx. set_retval ( 0 ) ;
123131 let return_id: u64 = new_task. id ( ) . as_u64 ( ) ;
124132 let new_task_ext = TaskExt :: new (
@@ -248,8 +256,8 @@ pub fn spawn_user_task(
248256 let kstack_top = curr. kernel_stack_top ( ) . unwrap ( ) ;
249257 info ! (
250258 "Enter user space: entry={:#x}, ustack={:#x}, kstack={:#x}" ,
251- curr. task_ext( ) . uctx. get_ip ( ) ,
252- curr. task_ext( ) . uctx. get_sp ( ) ,
259+ curr. task_ext( ) . uctx. ip ( ) ,
260+ curr. task_ext( ) . uctx. sp ( ) ,
253261 kstack_top,
254262 ) ;
255263 unsafe { curr. task_ext ( ) . uctx . enter_uspace ( kstack_top) } ;
0 commit comments