CPU restarts at Ring3 syscalls - for Ring0 works fine
Posted: Wed Jan 13, 2021 9:06 am
Hi!
I'm developing my own OS. Successfully started a task in user mode (CPL 3) but when I called a dummy system call it always restarted the CPU. The facts:
architecture: x86, simple 80386 instruction set I use. Test and debug in qemu.
the problem happens in protected mode, fully set GDT and IDT, no paging. Right before the syscall CPU is in a totally consistent state.
dummy syscall means an interrupt gate with DPL=3, resides in kernel (0x8 CS selector), type=0xee, executes cli hlt. Worked fine if I called it from kernel.
User space code is written in C++,with inline asm. Works fine without syscalls.
Eflags' IF is set.
Stacks are OK (both SS and ESP)
IDT vectors look like this: 0x0008090c 0x0010ee00 (DPL=3, S=0, P=1, type=e, selector=8, offset=0x10090c. All offsets are correct.
The restart happens at the 'int 0x30' instruction.
Do you have any idea, what I've missed?
Thanks in advance,
Robert
I'm developing my own OS. Successfully started a task in user mode (CPL 3) but when I called a dummy system call it always restarted the CPU. The facts:
architecture: x86, simple 80386 instruction set I use. Test and debug in qemu.
the problem happens in protected mode, fully set GDT and IDT, no paging. Right before the syscall CPU is in a totally consistent state.
dummy syscall means an interrupt gate with DPL=3, resides in kernel (0x8 CS selector), type=0xee, executes cli hlt. Worked fine if I called it from kernel.
User space code is written in C++,with inline asm. Works fine without syscalls.
Eflags' IF is set.
Stacks are OK (both SS and ESP)
IDT vectors look like this: 0x0008090c 0x0010ee00 (DPL=3, S=0, P=1, type=e, selector=8, offset=0x10090c. All offsets are correct.
The restart happens at the 'int 0x30' instruction.
Do you have any idea, what I've missed?
Thanks in advance,
Robert