We now jump to userspace !
This commit is contained in:
parent
3c1e97c157
commit
d0d546e073
|
@ -40,11 +40,12 @@ KeJumpToUserspace:
|
||||||
; rdx = user space stack
|
; rdx = user space stack
|
||||||
|
|
||||||
; Build a fake iret frame
|
; Build a fake iret frame
|
||||||
push QWORD 0x10 ; Selector 0x20 (User Data) + RPL 3
|
push QWORD 0x23 ; Selector 0x20 (User Data) + RPL 3
|
||||||
push rdx ; User space stack
|
push rdx ; User space stack
|
||||||
push QWORD 0x202 ; rflags = interrupt enable + reserved bit
|
push QWORD 0x202 ; rflags = interrupt enable + reserved bit
|
||||||
push QWORD 0x08 ; Selector 0x18 (User Code) + RPL 3
|
push QWORD 0x1B ; Selector 0x18 (User Code) + RPL 3
|
||||||
push rsi ; Entry point in user space
|
push rsi ; Entry point in user space
|
||||||
|
|
||||||
iretq
|
iretq
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,18 +43,19 @@ void MmInitGdt(void)
|
||||||
memzero((void *)&tss, sizeof(tss));
|
memzero((void *)&tss, sizeof(tss));
|
||||||
|
|
||||||
// Kernel codeseg
|
// Kernel codeseg
|
||||||
gdt[1].access = PRESENTSEG | RESERVED | RESERVED2;
|
gdt[1].access = PRESENTSEG | READABLE | RESERVED | RESERVED2;
|
||||||
gdt[1].flags = LONG;
|
gdt[1].flags = LONG;
|
||||||
|
|
||||||
// Kernel dataseg
|
// Kernel dataseg
|
||||||
gdt[2].access = PRESENTSEG;
|
gdt[2].access = PRESENTSEG | READABLE | RESERVED2;
|
||||||
|
gdt[2].flags = LONG;
|
||||||
|
|
||||||
// User codeseg
|
// User codeseg
|
||||||
gdt[3].access = PRESENTSEG | RESERVED | RESERVED2 | USER | USER2;
|
gdt[3].access = PRESENTSEG | RESERVED | RESERVED2 | USER | USER2;
|
||||||
gdt[3].flags = LONG;
|
gdt[3].flags = LONG;
|
||||||
|
|
||||||
// User dataseg
|
// User dataseg
|
||||||
gdt[4].access = PRESENTSEG | USER | USER2;
|
gdt[4].access = PRESENTSEG | READABLE | RESERVED2 | USER | USER2;
|
||||||
|
|
||||||
tssDesc.access = TSS_TYPE | PRESENTSEG;
|
tssDesc.access = TSS_TYPE | PRESENTSEG;
|
||||||
tssDesc.lowBase = (ulong)&tss & 0xFFFF;
|
tssDesc.lowBase = (ulong)&tss & 0xFFFF;
|
||||||
|
|
Loading…
Reference in New Issue