a20 line on Hyper-v virtual machine

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
ggodw000
Member
Member
Posts: 396
Joined: Wed Nov 18, 2015 3:04 pm
Location: San Jose San Francisco Bay Area
Contact:

a20 line on Hyper-v virtual machine

Post 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.,
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails
FallenAvatar
Member
Member
Posts: 283
Joined: Mon Jan 03, 2011 6:58 pm

Re: a20 line on Hyper-v virtual machine

Post by FallenAvatar »

intx13
Member
Member
Posts: 112
Joined: Wed Sep 07, 2011 3:34 pm

Re: a20 line on Hyper-v virtual machine

Post 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.
ggodw000
Member
Member
Posts: 396
Joined: Wed Nov 18, 2015 3:04 pm
Location: San Jose San Francisco Bay Area
Contact:

Re: a20 line on Hyper-v virtual machine

Post 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.
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails
feryno
Member
Member
Posts: 72
Joined: Thu Feb 09, 2012 6:53 am
Location: Czechoslovakia
Contact:

Re: a20 line on Hyper-v virtual machine

Post 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.
hypervisor-based solutions developer (Intel, AMD)
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: a20 line on Hyper-v virtual machine

Post 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.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
linguofreak
Member
Member
Posts: 510
Joined: Wed Mar 09, 2011 3:55 am

Re: a20 line on Hyper-v virtual machine

Post 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.
Post Reply