error at iret
Posted: Sun Mar 01, 2009 9:37 pm
I wrote a trap, but the return is error, error at iret.
the trap source code is:
the call code is:
but when i debug it, it error at iret.
I found a problem when i debug it,
the cs's value is 0x0008, but the value is 0x00000008 in the stack, why?
the stak's base address is 0, the limit is 0xFFFF, read/write.
the error information is:
the trap source code is:
Code: Select all
IDT_32 proc near
mov ax, GDT_Video_Sel
mov gs, ax
mov bx, (9 * 80 + 5) * 2 ; row 9, col 5
mov al, 'C'
mov ah, 14
mov gs:[bx], ax
iret
IDT_32 endp
Code: Select all
mov ax, GDT_Stack_Sel
mov ss, ax
mov sp, 0FFFEh
; test stack
push eax
push ebx
pop ebx
pop eax
int 32
I found a problem when i debug it,
Code: Select all
<bochs:12> s
Next at t=2082176
(0) [0x00007de5] 0008:00000000000001e5 (unk. ctxt): int 0x20 ;
cd20
<bochs:13> dump_cpu
eax:0x00000018, ebx:0x0000032a, ecx:0x00000000, edx:0x00000000
ebp:0x00000000, esp:0x0000fffe, esi:0xffff88ca, edi:0x00080000
eip:0x000001e5, eflags:0x00000002, inhibit_mask:0
cs:s=0x0008, dl=0x7c00ffff, dh=0x00009a00, valid=1
ss:s=0x0018, dl=0x0000ffff, dh=0x00009200, valid=7
ds:s=0x07c0, dl=0x7c00ffff, dh=0x00009300, valid=1
es:s=0x07c0, dl=0x7c00ffff, dh=0x00009300, valid=1
fs:s=0x0000, dl=0x0000ffff, dh=0x00009300, valid=1
gs:s=0x0020, dl=0x8000ffff, dh=0x0000920b, valid=5
ldtr:s=0x0000, dl=0x00000000, dh=0x00000000, valid=0
tr:s=0x0000, dl=0x00000000, dh=0x00000000, valid=0
gdtr:base=0x00007c08, limit=0x1000
idtr:base=0x00007c40, limit=0x800
dr0:0x00000000, dr1:0x00000000, dr2:0x00000000
dr3:0x00000000, dr6:0xffff0ff0, dr7:0x00000400
cr0:0x00000011, cr1:0x00000000, cr2:0x00000000
cr3:0x00000000, cr4:0x00000000
done
Code: Select all
<bochs:17> s
Next at t=2082177
(0) [0x00007d59] 0028:0000000000000000 (unk. ctxt): mov ax, 0x0020 ;
b82000
<bochs:18> x /16bx 0xfff0
[bochs]:
0x0000fff0 <bogus+ 0>: 0x00 0x00 0xe7 0x01 0x00 0x00
0x08 0x00
0x0000fff8 <bogus+ 8>: 0x00 0x00 0x02 0x00 0x00 0x00
0x00 0x00
the stak's base address is 0, the limit is 0xFFFF, read/write.
the error information is:
Code: Select all
<bochs:20> s 6
Next at t=2082183
(0) [0x00007d68] 0028:000000000000000f (unk. ctxt): iret ;
cf
<bochs:21> s
00002082183e[CPU0 ] iret: return CS selector null
00002082183i[CPU0 ] protected mode
00002082183i[CPU0 ] CS.d_b = 16 bit
00002082183i[CPU0 ] SS.d_b = 16 bit
00002082183i[CPU0 ] EFER = 0x00000000
00002082183i[CPU0 ] | RAX=0000000000000e43 RBX=00000000000005aa
00002082183i[CPU0 ] | RCX=0000000000000000 RDX=0000000000000000
00002082183i[CPU0 ] | RSP=000000000000fff2 RBP=0000000000000000
00002082183i[CPU0 ] | RSI=00000000ffff88ca RDI=0000000000080000
00002082183i[CPU0 ] | R8=0000000000000000 R9=0000000000000000
00002082183i[CPU0 ] | R10=0000000000000000 R11=0000000000000000
00002082183i[CPU0 ] | R12=0000000000000000 R13=0000000000000000
00002082183i[CPU0 ] | R14=0000000000000000 R15=0000000000000000
00002082183i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf af pf cf
00002082183i[CPU0 ] | SEG selector base limit G D
00002082183i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00002082183i[CPU0 ] | CS:0028( 0005| 0| 0) 00007d59 0000ffff 0 0
00002082183i[CPU0 ] | DS:07c0( 0005| 0| 0) 00007c00 0000ffff 0 0
00002082183i[CPU0 ] | SS:0018( 0003| 0| 0) 00000000 0000ffff 0 0
00002082183i[CPU0 ] | ES:07c0( 0005| 0| 0) 00007c00 0000ffff 0 0
00002082183i[CPU0 ] | FS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00002082183i[CPU0 ] | GS:0020( 0004| 0| 0) 000b8000 0000ffff 0 0
00002082183i[CPU0 ] | MSR_FS_BASE:0000000000000000
00002082183i[CPU0 ] | MSR_GS_BASE:00000000000b8000
00002082183i[CPU0 ] | RIP=000000000000000f (000000000000000f)
00002082183i[CPU0 ] | CR0=0x00000011 CR1=0x0 CR2=0x0000000000000000
00002082183i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00002082183i[CPU0 ] >> iret : CF
00002082183e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown
status is 00h, resetting
00002082183i[SYS ] bx_pc_system_c::Reset(SOFTWARE) called
00002082183i[APIC0] local apic in CPU 0 initializing
00002082183e[CPU0 ] CPU_LOOP bx_guard.interrupt_requested=1
Next at t=2082183
(0) [0x00007d68] 0028:000f (unk. ctxt): iret ; cf