Page 1 of 1

Problem with V8086 mode...

Posted: Mon Apr 30, 2007 7:44 pm
by pcmattman
I'm trying to get real mode tasks to work in my OS. I understand that I need to have a handler for GPF (?) to handle priveleged instructions in the task, but for now the task is just an infinite loop in 16-bit mode.

The problem is, my OS keeps triple-faulting:

Code: Select all

00041567843i[CPU0 ] LOCK prefix unallowed (op1=0x53, attr=0x0, mod=0x0, nnn=0)
00041567843e[CPU0 ] fetch_raw_descriptor: GDT: index (ff57)1fea > limit (77)
00041567843e[CPU0 ] fetch_raw_descriptor: GDT: index (ff57)1fea > limit (77)
00041567843i[CPU0 ] v8086 mode
00041567843i[CPU0 ] CS.d_b = 16 bit
00041567843i[CPU0 ] SS.d_b = 16 bit
00041567843i[CPU0 ] | EAX=00000000  EBX=00000000  ECX=00000000  EDX=00000000
00041567843i[CPU0 ] | ESP=001065c2  EBP=0000cfca  ESI=00000000  EDI=00000000
00041567843i[CPU0 ] | IOPL=0 id vip vif ac VM RF nt of df IF tf SF zf af pf cf
00041567843i[CPU0 ] | SEG selector     base    limit G D
00041567843i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00041567843i[CPU0 ] |  CS:0008( 0001| 0|  3) 00000080 0000ffff 0 0
00041567843i[CPU0 ] |  DS:0003( 0002| 0|  3) 00000030 0000ffff 0 0
00041567843i[CPU0 ] |  SS:0008( 0002| 0|  3) 00000080 0000ffff 0 0
00041567843i[CPU0 ] |  ES:0202( 0002| 0|  3) 00002020 0000ffff 0 0
00041567843i[CPU0 ] |  FS:0000( 0002| 0|  3) 00000000 0000ffff 0 0
00041567843i[CPU0 ] |  GS:0000( 0002| 0|  3) 00000000 0000ffff 0 0
00041567843i[CPU0 ] | EIP=00000003 (00000003)
00041567843i[CPU0 ] | CR0=0x00000011 CR1=0 CR2=0x00000000
00041567843i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00041567843i[CPU0 ] >> lock push bx : F053
00041567843e[CPU0 ] exception(): 3rd (10) exception with no resolution, shutdown status is 00h, resetting
Any ideas?

Posted: Tue May 01, 2007 4:26 am
by Combuster
have you provided a correct CS and EIP in the IDT for all exceptions?

Posted: Tue May 01, 2007 3:36 pm
by pcmattman
Do I need to make a new IDT for V8086 tasks? I thought I had the right CS:EIP for all the exceptions.

Posted: Wed May 02, 2007 3:54 am
by crackers
pcmattman wrote:Do I need to make a new IDT for V8086 tasks? I thought I had the right CS:EIP for all the exceptions.
It depends on how you're taking care of interrupts (for example looping interrupts back to V86 task) - but in most cases it's not nessecery.
I can see that you're not using paging. Does it mean that all your V86 tasks are working in first MB?

Posted: Wed May 02, 2007 3:56 am
by pcmattman
All tasks are loaded into the first MB. For now, they are all loaded to a constant location (but I only ever load one, so it's not really a problem).

Posted: Wed May 02, 2007 5:56 am
by crackers
Hmmmm..... For me it looks like after entering V86 mode CS and EIP are loaded with wrong values from TSS (values not initialized?). V86 is trying to execute some random commands (last one is "lock push bx"). After that you're getting GPF and TS.
Maybe you're overwritting some system structures (entries from IDT or GDT) for example when you're loading your v86 task into memory ?
Are you using task gate descriptors in IDT, because your OS behave like it could'nt find TSS for task gate from IDT in GDT.