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 about "UINT64 PageFrameNumber : 36" #30

Open wbenny opened 6 years ago

wbenny commented 6 years ago

Hi, In VMX_EPTP, VMX_EPML4E, VMX_PDPTE, MTRR_VARIABLE_BASE & MTRR_VARIABLE_MASK structures, there is a member defined as: UINT64 PageFrameNumber : 36

Intel manual says size of this field should be MAXPHYADDR, which is obtained by CPUID.80000008H:EAX[7:0] (39 on my machine).

Intel also says:

the width is generally 36 if CPUID.01H:EDX.PAE [bit 6] = 1 and 32 otherwise.) ... MAXPHYADDR is at most 52

My question is: couldn't this cause problems (assuming the available RAM is really, really big) & wouldn't it be better to simply define this field as: UINT64 PageFrameNumber : 52 ?

I assume "unused" bits are set to 0 anyway.

ionescu007 commented 6 years ago

Yep that’s probably not a bad idea.

On Sun, May 13, 2018 at 9:16 AM Parallel Xenoexcite < notifications@github.com> wrote:

Hi, In VMX_EPTP, VMX_EPML4E, VMX_PDPTE, MTRR_VARIABLE_BASE & MTRR_VARIABLE_MASK structures, there is a member defined as: UINT64 PageFrameNumber : 36

Intel manual says size of this field should be MAXPHYADDR, which is obtained by CPUID.80000008H:EAX[7:0] (39 on my machine).

Intel also says:

the width is generally 36 if CPUID.01H:EDX.PAE [bit 6] = 1 and 32 otherwise.) ... MAXPHYADDR is at most 52

My question is: couldn't this cause problems & wouldn't it be better to simply define this field as: UINT64 PageFrameNumber : 52 ?

I assume "unused" bits are set to 0 anyway.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ionescu007/SimpleVisor/issues/30, or mute the thread https://github.com/notifications/unsubscribe-auth/AFxIeLFWyG3PJmTeLY0m-lsbbk6ce8wWks5tyFxngaJpZM4T83Gr .

-- Best regards, Alex Ionescu

hypervisor commented 4 years ago

Hey, I had the same question in mind a while ago, why did you decide against this in your hypervisor? https://github.com/wbenny/hvpp/blob/master/src/hvpp/hvpp/ia32/paging.h#L78 here you hardcode 36 bits, is this because of something you discovered or does it just not really matter?

wbenny commented 4 years ago

Hi @dxgkrnl, I generated the structs automatically using my other project - https://github.com/wbenny/ia32-doc. In my case, the 36 ended up there because I hardcoded MAXPHYADDR = 48 before generation. Explanation is in the comments https://github.com/wbenny/ia32-doc/blob/3acb567dae0325e889881105d528795f1aa8b237/ia32doc/doc.py#L31

Hope it helps.