[SOLVED] IDT entries in vm86 are set to wrong positions

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
HugeCode
Member
Member
Posts: 112
Joined: Mon Dec 17, 2012 9:12 am

[SOLVED] IDT entries in vm86 are set to wrong positions

Post by HugeCode »

Hi all. I'm running this simple assembly in vm86:

Code: Select all

xor bh, bh
xor cl, cl
xor ch, ch

mov al, 'A'
mov ah, 0x0A
int 0x10
hier:	jmp hier
When I try to call interrupt, OS halts (VirtualBox) or jumps to 0xffffffff (VMWare). It happens directly on INT instruction:
Screenshot_1.png
Screenshot_1.png (1.42 KiB) Viewed 1978 times
00:00:08.329874 eax=00000a41 ebx=0000000e ecx=000003f0 edx=000003fe esi=00100136 edi=0000ff91
00:00:08.329876 eip=00007c0a esp=00ffffc3 ebp=00ffffd3 iopl=0 vm nv dn ei pl zr na po nc
00:00:08.329879 cs={0000 base=0000000000000000 limit=0000ffff flags=000000f3} dr0=00000000 dr1=00000000
00:00:08.329883 ds={0000 base=0000000000000000 limit=0000ffff flags=000000f3} dr2=00000000 dr3=00000000
00:00:08.329886 es={0000 base=0000000000000000 limit=0000ffff flags=000000f3} dr4=00000000 dr5=00000000
00:00:08.329888 fs={1065 base=0000000000010650 limit=0000ffff flags=000000f3} dr6=ffff0ff0 dr7=00000400
00:00:08.329891 gs={fffb base=00000000000fffb0 limit=0000ffff flags=000000f3} cr0=00000011 cr2=00000000
00:00:08.329894 ss={0023 base=0000000000000230 limit=0000ffff flags=000000f3} cr3=00000000 cr4=00000000
00:00:08.329897 gdtr=0000000000008186:0027 idtr=0000000000000000:ffff eflags=00020606
I also tried to trace interrupt addresses, and they seem to be incorrect:
Screenshot_1.png
Screenshot_1.png (3.89 KiB) Viewed 1978 times
Does anybody know what can cause such thing? I haven't been manipulating with data on 0x0-0x3FF. Are entries invalid or it's fault of code?
Please help.
Combuster wrote:Learn to debug.
It's all I can do with VMWare.
Last edited by HugeCode on Fri Jul 05, 2013 6:15 am, edited 1 time in total.
User avatar
Air
Posts: 4
Joined: Wed May 01, 2013 4:54 pm

Re: IDT entries in vm86 are set to wrong positions

Post by Air »

try to setup stack first:

Code: Select all

xor ax,ax
mov ss,ax
mov sp,0x7c00
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: IDT entries in vm86 are set to wrong positions

Post by Combuster »

HugeCode wrote:
Combuster wrote:Learn to debug.
It's all I can do with VMWare.
Image
Debugging implies doing your homework, not just dumping everything in the hope someone else fixes it, and especially not code you don't understand and a question that's listed in the FAQ.

RTFM INT.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
rdos
Member
Member
Posts: 3306
Joined: Wed Oct 01, 2008 1:55 pm

Re: IDT entries in vm86 are set to wrong positions

Post by rdos »

The IDTR seems to be incorrect. Since you have IOPL=0, all int instructions will trap to protected mode, and since your protected mode IDTR points to zero (the typical real-mode position), I bet you try to execute protection fault by using some real-mode interrupt vectors.
HugeCode
Member
Member
Posts: 112
Joined: Mon Dec 17, 2012 9:12 am

Re: IDT entries in vm86 are set to wrong positions

Post by HugeCode »

OK. I read something in intel manual, but I'm bit confused. Do I have to fill TSS (which I'm not using currently) with some data to have interrupt redirected, or I only need to set VME bit?

When I set VME bit, interrupts are working, but values on 0x0 (and 0x40) are different from that which were there in bootloader. Do I have to save them?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: IDT entries in vm86 are set to wrong positions

Post by Combuster »

You need a TSS to be even able to run unprivileged code at all.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
HugeCode
Member
Member
Posts: 112
Joined: Mon Dec 17, 2012 9:12 am

Re: IDT entries in vm86 are set to wrong positions

Post by HugeCode »

Ok. Thanks. I'll play with it.
Post Reply