lgdt not loading gdtr
Posted: Sat Aug 25, 2012 4:35 pm
Hello!
I'm writing my kernel in Visual Studio 2010(express), running from GRUB. I'm trying to load my GDT, with this code:
GDTPointer is defined like so:
My problem is, that triple fault is issued. This is log form bochs:
info gdt says base is 0x0 and limit 65535. So my question is: what's going on? What did I do wrong? Where the hell did that xgetbv come from?
I'm writing my kernel in Visual Studio 2010(express), running from GRUB. I'm trying to load my GDT, with this code:
Code: Select all
GDTPointer pointer;
pointer.Limit = (5*sizeof(GDTEntry))-1;// 1 less than size of the table they said
pointer.Offset = (uint32)&entries;
GDTPointer *gdtPtr = &pointer;
out << "Setting up GDT" << "\n";
out << "Limit: " << (unsigned int)gdtPtr->Limit << "\n";
out << "Offset: " << (unsigned int)gdtPtr->Offset << "\n";
__asm {
cli
mov eax, gdtPtr
lgdt eax
push 0x8
push reload
retf
reload:
mov ax, 0x10
mov ds, ax
mov ss, ax
mov es, ax
mov fs, ax
mov gs, ax
sti
}
Code: Select all
#pragma pack(push, 1)
struct GDTPointer {
uint16 Limit;
uint32 Offset;
};
#pragma pack(pop)
Code: Select all
00045560726e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x
06)
00045560726e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x
0d)
00045560726e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x
08)
00045560726i[CPU0 ] CPU is in protected mode (active)
00045560726i[CPU0 ] CS.mode = 32 bit
00045560726i[CPU0 ] SS.mode = 32 bit
00045560726i[CPU0 ] | EAX=005ffd87 EBX=00033640 ECX=00100e08 EDX=0000009d
00045560726i[CPU0 ] | ESP=005ffd7b EBP=005ffd93 ESI=005fffee EDI=00033708
00045560726i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf ZF af PF cf
00045560726i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00045560726i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 1
00045560726i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00045560726i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00045560726i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00045560726i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00045560726i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
00045560726i[CPU0 ] | EIP=0010076a (0010076a)
00045560726i[CPU0 ] | CR0=0x60000011 CR2=0x00000000
00045560726i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
(0).[45560726] [0x000000000010076a] 0008:000000000010076a (unk. ctxt): xgetbv
; 0f01d0
00045560726e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown
status is 00h, resetting