ltr exception (bochs)
Posted: Sun Nov 16, 2014 2:35 pm
Hi All,
I get below errors when running bochs with my kernel (x86-64).
My code works with qemu and with a normal laptop.
I have 5 gdt starting at 0x500. They look like below
(in the order NULL, KRN_CODE, KRN_DATA, USER_CODE, USER_DATA, TSS):
TSS is located at 0x600 and is length 0xa0
GDT pointer looks like this:
So I will first setup all descriptors including tss and call "lgdt [gdt_address]".
The TSS is the fifth position so I will load this with:
asm("mov %0, %%rax":: "r"((u64_t)segment_offset));
asm("ltrw %%ax":);
(or just plain "ltr $0x2b")
When I do this bochs will restart. If not then everything is dandy.
Does anyone know what I am doing wrong?
Regards,
StaringL
I get below errors when running bochs with my kernel (x86-64).
Code: Select all
00156933951d[CPU0 ] inhibit interrupts mask = 3
00156933960e[CPU0 ] fetch_raw_descriptor64: extended attributes DWORD4 TYPE != 0
00156933960d[CPU0 ] exception(0x0d): error_code=0028
00156933960d[CPU0 ] interrupt(): vector = 0d, TYPE = 3, EXT = 1
00156933960e[CPU0 ] interrupt(long mode): IDT entry extended attributes DWORD4 TYPE != 0
00156933960d[CPU0 ] exception(0x0d): error_code=006a
00156933960d[CPU0 ] exception(0x08): error_code=0000
00156933960d[CPU0 ] interrupt(): vector = 08, TYPE = 3, EXT = 1
00156933960e[CPU0 ] interrupt(long mode): IDT entry extended attributes DWORD4 TYPE != 0
00156933960d[CPU0 ] exception(0x0d): error_code=0042
00156933960i[CPU0 ] CPU is in long mode (active)
00156933960i[CPU0 ] CS.mode = 64 bit
00156933960i[CPU0 ] SS.mode = 64 bit
00156933960i[CPU0 ] EFER = 0x00000500
00156933960i[CPU0 ] | RAX=000000000000002b RBX=0000000000000000
00156933960i[CPU0 ] | RCX=00000000c0000080 RDX=0000000000000010
00156933960i[CPU0 ] | RSP=000000000000efc4 RBP=0000000000000000
00156933960i[CPU0 ] | RSI=00408900060000a0 RDI=000000000000002b
00156933960i[CPU0 ] | R8=0000000000000000 R9=0000000000000000
00156933960i[CPU0 ] | R10=00000000000082f5 R11=0000000000000000
00156933960i[CPU0 ] | R12=0000000000000000 R13=0000000000000000
00156933960i[CPU0 ] | R14=0000000000000000 R15=0000000000000000
00156933960i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf af pf cf
00156933960i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00156933960i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 00000000 0 0
00156933960i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 00000000 0 0
00156933960i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 00000000 0 0
00156933960i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 00000000 0 0
00156933960i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 00000000 0 0
00156933960i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 00000000 0 0
00156933960i[CPU0 ] | MSR_FS_BASE:0000000000000000
00156933960i[CPU0 ] | MSR_GS_BASE:0000000000000000
00156933960i[CPU0 ] | RIP=0000000000008ab5 (0000000000008ab5)
00156933960i[CPU0 ] | CR0=0xe0000011 CR2=0x0000000000000000
00156933960i[CPU0 ] | CR3=0x00002000 CR4=0x000000b0
00156933960i[CPU0 ] 0x0000000000008ab5>> ltr ax : 0F00D8
00156933960e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
I have 5 gdt starting at 0x500. They look like below
(in the order NULL, KRN_CODE, KRN_DATA, USER_CODE, USER_DATA, TSS):
Code: Select all
(gdb) p/x *(unsigned long *)0x500
$9 = 0x0
(gdb) p/x *(unsigned long *)0x508
$10 = 0x20980000000000
(gdb) p/x *(unsigned long *)0x510
$11 = 0x930000000000
(gdb) p/x *(unsigned long *)0x518
$12 = 0x20f80000000000
(gdb) p/x *(unsigned long *)0x520
$13 = 0x920000000000
(gdb) p/x *(unsigned long *)0x528
$14 = 0x408900060000a0
(gdb)
GDT pointer looks like this:
Code: Select all
(gdb) p/x hal_cpu_config_gdtp
$16 = {limit = 0x37, base = 0x500}
(gdb) p/x &hal_cpu_config_gdtp
$17 = 0x16018
The TSS is the fifth position so I will load this with:
asm("mov %0, %%rax":: "r"((u64_t)segment_offset));
asm("ltrw %%ax":);
(or just plain "ltr $0x2b")
When I do this bochs will restart. If not then everything is dandy.
Does anyone know what I am doing wrong?
Regards,
StaringL