ionescu007 / SimpleVisor

SimpleVisor is a simple, portable, Intel VT-x hypervisor with two specific goals: using the least amount of assembly code (10 lines), and having the smallest amount of VMX-related code to support dynamic hyperjacking and unhyperjacking (that is, virtualizing the host state from within the host). It works on Windows and UEFI.
http://ionescu007.github.io/SimpleVisor/
1.69k stars 259 forks source link

Question:ShvVmxMtrrAdjustEffectiveMemoryType Wrong? #29

Closed Thor-Heimdallr closed 5 years ago

Thor-Heimdallr commented 6 years ago

This judgment can guarantee 2M space is within the scope of it? if (((LargePageAddress + _2MB) >= VpData->MtrrData[i].PhysicalAddressMin) && (LargePageAddress <= VpData->MtrrData[i].PhysicalAddressMax)) I think It should be: if (((LargePageAddress + _2MB) <= VpData->MtrrData[i].PhysicalAddressMax) && (LargePageAddress >= VpData->MtrrData[i].PhysicalAddressMin))

ionescu007 commented 6 years ago

The goal is not to check if the page is fully enclosed within the MTRR, but if any piece of the region touches the MTRR.

Consider:

        Xs          Xe
              Rs            Re

Where X is the virtual region, and R is the 2MB MTRR space.

Your check would fail because Xs >= Rs is FALSE.

Best regards, Alex Ionescu