Code: Select all
_start:
ud2
dd 0xdeadbeef
jmp _start
xor rbp, rbp
mov edi, 0
mov rsi, env
call main
xor rdi, rdi
call _exit
ret
Code: Select all
PSTUB : FFFFFFFF:8012D740 Executing [/initrd/testapp]
PSTUB : FFFFFFFF:8012D740 Program entry: 00000000:001000D0 -> F8EBDEAD:BEEF0B0F
INT06 : #UD Invalid Opcode Exception. RIP: 00000000:001000D0
Code: Select all
SCHED : Current Process: FFFFFFFF:8012E740 Next Process: FFFFFFFF:8012F150, CR3: 00000000:01FEE000 Remain: 10
SCHED : Current Process: FFFFFFFF:8012F150 Next Process: FFFFFFFF:8012E740, CR3: 00000000:01FF1000 Remain: 10
SCHED : Current Process: FFFFFFFF:8012E740 Next Process: FFFFFFFF:8012F150, CR3: 00000000:01FEE000 Remain: 10
SCHED : Current Process: FFFFFFFF:8012F150 Next Process: FFFFFFFF:8012FB60, CR3: 00000000:00000000 Remain: 10
KMAIN : kthread(pid=3): echo #2
SCHED : Current Process: FFFFFFFF:8012FB60 Next Process: FFFFFFFF:8012E740, CR3: 00000000:01FF1000 Remain: 10
SCHED : Current Process: FFFFFFFF:8012E740 Next Process: FFFFFFFF:8012F150, CR3: 00000000:01FEE000 Remain: 10
SCHED : Current Process: FFFFFFFF:8012F150 Next Process: FFFFFFFF:8012E740, CR3: 00000000:01FF1000 Remain: 10
however, other kthread seems not disturbed and run normally.
my code to get ring3:
Code: Select all
; void enter_ring3 ( unsigned long ring3_ip, unsigned long ring3_sp );
enter_ring3:
; jmp rdi
mov ecx, SEG_DATA64_3 +3
;mov ds, cx
;mov es, cx
push rcx
push rsi
push 0x0202 ; rflags
push SEG_CODE64_3 +3
push rdi
iretq
ps. cpu exception (INT00-13) has IST=1, and PIC timer has IST=2.
I have kernel stack per each thread, and swap rsp0 on TSS upon reschedule.
EDIT:solved