virtual mode...
virtual mode...
Hi...
I'm tring to have a support for virtual mode in my kernel
I made a simple virtual task it dosen't do any thing just
prints a simple message and go back...
My hardware multitasking works fine and I can switch from PL0
to PL3 and go back,my virtual task works in PL3...
I just changed the EFLAGS to 0x23202L that means I sat the VM bit to 1
It suppose to work but unfortunately it didn't and I got
general protection fault, so here's a minimized vesion of my kernel
and an IMG file.
please note paging isn't enabled.
Thanx.
I'm tring to have a support for virtual mode in my kernel
I made a simple virtual task it dosen't do any thing just
prints a simple message and go back...
My hardware multitasking works fine and I can switch from PL0
to PL3 and go back,my virtual task works in PL3...
I just changed the EFLAGS to 0x23202L that means I sat the VM bit to 1
It suppose to work but unfortunately it didn't and I got
general protection fault, so here's a minimized vesion of my kernel
and an IMG file.
please note paging isn't enabled.
Thanx.
- Attachments
-
- a.tar.gz
- IMG
- (46.98 KiB) Downloaded 110 times
-
- knl.tar.gz
- kernel
- (14.95 KiB) Downloaded 101 times
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
GPF fires in Virtual Mode when it hits a priveleged instruction, such as IRET, or INT.
You need to, in your GPF handler, check for VM bit in EFLAGS and then emulate the instruction (search google for virtual 8086 mode monitor).
Also, I'd suggest changing your IOPL to 0, as you'll save yourself a lot of trouble later. At IOPL0 your GPF handler is asked to handle all priveleged instructions (the safest way to do it).
You need to, in your GPF handler, check for VM bit in EFLAGS and then emulate the instruction (search google for virtual 8086 mode monitor).
Also, I'd suggest changing your IOPL to 0, as you'll save yourself a lot of trouble later. At IOPL0 your GPF handler is asked to handle all priveleged instructions (the safest way to do it).
CPL is the Code Segment's Privilege Level and is equal to the DPL field of the Code Segment's Descriptor in the GDT/LDT. CPL is not the RPL because RPL is the 3 rightmost bits of the Segment Selector.
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
humm...
so my question would be can a virtual task work in PL0?
My virtual task suppose to work in PL3,but as soon as I
enable multitasking I get general protection fault...
I don't know what's wrong with my code, my hardware
multitasking works fine and I can switch from PL0
to PL3 and go back successfully, I only changed EFLAGS
from 0x3202L to 0x23202L so the VM bit is set to 1
but unfortunately it didn't work.
so would you please check the code above ...
Thanx.
so my question would be can a virtual task work in PL0?
My virtual task suppose to work in PL3,but as soon as I
enable multitasking I get general protection fault...
I don't know what's wrong with my code, my hardware
multitasking works fine and I can switch from PL0
to PL3 and go back successfully, I only changed EFLAGS
from 0x3202L to 0x23202L so the VM bit is set to 1
but unfortunately it didn't work.
so would you please check the code above ...
Thanx.
Hi...
tss[1].eip=(dword)&task;
cs:eip points to task() which is my virtual task
also the tss[1].cs=0x18 | 3 and tss[0].cs=0x18 | 3
0x18 is code segment descriptor PL3
I'm sure of this descriptor It was working fine before
enabling VM bit in EFLAGS...
let's form this again:
my hardware multitasking consists of two tasks:
main() which is PL0 and task() which is PL3
my multitasking works fine and I can switch between PL0 and PL3
successfully, but when I changed the EFLAGS from 0x3202L to 0x23202L
I got general protection fault ...
paging not enabled.
Thanx.
tss[1].eip=(dword)&task;
cs:eip points to task() which is my virtual task
also the tss[1].cs=0x18 | 3 and tss[0].cs=0x18 | 3
0x18 is code segment descriptor PL3
I'm sure of this descriptor It was working fine before
enabling VM bit in EFLAGS...
let's form this again:
my hardware multitasking consists of two tasks:
main() which is PL0 and task() which is PL3
my multitasking works fine and I can switch between PL0 and PL3
successfully, but when I changed the EFLAGS from 0x3202L to 0x23202L
I got general protection fault ...
paging not enabled.
Thanx.
Hi...
Also I'll read the Intel manual again but ,did any one
find out what's wrong with my code ?I've checked it out
about more than thousand times and till now I don't know
what's wrong with it.
It's realy confusing ...right now I just want to enable virtual mode
print a message and go back that's it.
Thanx.
Okay I know thatI'm talking about the IOPL, the I/O privilege level. Completely different from the CPL and RPL.
Also I'll read the Intel manual again but ,did any one
find out what's wrong with my code ?I've checked it out
about more than thousand times and till now I don't know
what's wrong with it.
It's realy confusing ...right now I just want to enable virtual mode
print a message and go back that's it.
Thanx.
- Combuster
- 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:
(hint)
EIP > segment limit
(hint)
virtual 8086 mode
(hint)
64k segments
(hint)
request to check things
(hint)
obviousness of the problem
(HINT)
The whole idea of debugging is to find the problem and that what causes it. Bochs bluntly shoves the first under your nose, so all you have to do is to find out where that faulty eip comes from and why. If you have trouble doing that, IMNSHO asking about that would be far better than a request to find the bug.
EIP > segment limit
(hint)
virtual 8086 mode
(hint)
64k segments
(hint)
request to check things
(hint)
obviousness of the problem
(HINT)
The whole idea of debugging is to find the problem and that what causes it. Bochs bluntly shoves the first under your nose, so all you have to do is to find out where that faulty eip comes from and why. If you have trouble doing that, IMNSHO asking about that would be far better than a request to find the bug.
Hi...
I'm using Bochs 2.2.6 for windows I downloaded it as an .exe file
It doesn't have a debugger.
Thanx.
Okay,would some one please tell me where did this faulty eip come from?so all you have to do is to find out where that faulty eip comes from and why. If you have trouble doing that, IMNSHO asking about that would be far better than a request to find the bug.
unfortunately I don't have oneBochs' debugger is your best friend in this situation.
I'm using Bochs 2.2.6 for windows I downloaded it as an .exe file
It doesn't have a debugger.
Thanx.