Page 1 of 1

a20 line on Hyper-v virtual machine

Posted: Wed Nov 18, 2015 7:15 pm
by ggodw000
Hello there I implemented simple code to check a20 line that tests initial a20 state and toggle between enable/disable and check the a20 status again. Status check is done using port 92[1].
However, no matter setting the bit is set at 92[1], the actual test for a20 always comes out as turned on. Is i how it is designed for VM on hyperv?
The actual check that does the a20 status is:

save contents of 0000:0500h and ffff:510
copy 00h to 0000:0500h
copy 0ffh to ffff:0510h

compare 0000:0500 to ff.
if a20 is turned, the comparison should equal. (ffff:0510 wrapped to 0:500h)
if not comparison should not equal.

This is all done in real-mode.

Thanks.,

Re: a20 line on Hyper-v virtual machine

Posted: Wed Nov 18, 2015 7:45 pm
by FallenAvatar

Re: a20 line on Hyper-v virtual machine

Posted: Thu Nov 19, 2015 10:29 am
by intx13
The A20 line is usually enabled on reset or (if not) by BIOS on modern PCs. Additionally, once enabled you probably won't be able to disable it even if you wanted to. So your bootloader really only needs to turn it on if it's not already on. My bare-metal projects include code to turn on the A20 line but I've never been able to test it, since I don't have a system that doesn't boot without it already enabled.

Re: a20 line on Hyper-v virtual machine

Posted: Fri Nov 20, 2015 12:24 am
by ggodw000
ok thanks, it looks like a20 is always enabled on hyper-v. May be just leave it there then.
I always put the logic wrong on my OP.

Re: a20 line on Hyper-v virtual machine

Posted: Fri Nov 20, 2015 3:40 am
by feryno
Properly designed hypervisor may intercept all attempts to turn off A20 (few ways via various ports) and then simulate A20 off for nonroot mode using EPT (Intel) / Nested Paging (AMD). Root mode will alway run with A20 on, as well nonroot, just physical memory for nonroot will look like A20 disabled.

Re: a20 line on Hyper-v virtual machine

Posted: Fri Nov 20, 2015 8:29 am
by SpyderTL
You'll find that Virtual Machines are not true hardware "simulators". There are a lot of things that VMs do differently (or not at all) that real hardware does.

The rule of thumb appears to be, as long as Windows runs, that's good enough.

In most cases, end user performance is more important than strict accuracy. You'll find that some unimportant hardware registers aren't even implemented, or are just hard wired to a specific value.

Re: a20 line on Hyper-v virtual machine

Posted: Mon Nov 23, 2015 9:47 pm
by linguofreak
ggodw000 wrote:ok thanks, it looks like a20 is always enabled on hyper-v. May be just leave it there then.
Unless your operating system will be running old DOS code, you don't need for it to be off (and probably need it to be on). Even then, you can simulate A20 being off with paging without needing to do anything with the A20 line at all. So if your A20 enabling code finds that A20 is already on, you're good to go. The only time you have a problem is if you can't turn it on.