Page 1 of 2

Virtual PC PAE?

Posted: Mon Aug 04, 2014 9:42 pm
by lweb20
Hello, this is my first post. I've done tests on several virtual machines as Bochs, VMWare, VirtualBox and on real machines and PAE paging works correctly. I use a detection method with cpuid to see if PAE is available or not, but... Virtual PC detects PAE is available and when enable PAE paging triple failure happens.

This is my code.

Code: Select all

#define CPUID_PAE 6
#define TestBit(value, place)	((value >> place) & 1)

void cpuid(unsigned int code, CPUID_Regs* regs)
{
	asm(
		"cpuid\n"
		: "=a"(regs->EAX), "=b"(regs->EBX), "=c"(regs->ECX), "=d"(regs->EDX)
		: "a"(code));
}
void cpuid_features(CPUID_Regs* regs)
{
	cpuid(0x1, regs);
}

...

CPUID_Regs regs;
cpuid_features(&regs);
	
if(!TestBit(regs.EDX, CPUID_PAE))return false;

Help me please. Thanks. And sorry for my bad English.


Edit: I use 2MB pages.

Virtual PC dump:
MAX STANDARD FUNCTIONS: 2
FEATURES (EDX): 0x7C0A97B (111110000001010100101111011)

Re: Virtual PC PAE?

Posted: Mon Aug 04, 2014 11:29 pm
by alexfru
What's the version of Virtual PC? What about regular 4KB pages?

Re: Virtual PC PAE?

Posted: Tue Aug 05, 2014 12:54 am
by iansjack
PAE requires not only a compatible CPU but also a compatible chipset. I suspect that the Intel 440BX chipset emulated by Virtual PC does not support PAE.

Virtual PC is really only useful for Microsoft consumer OSs. Even then there are better alternatives.

Re: Virtual PC PAE?

Posted: Tue Aug 05, 2014 1:15 am
by lweb20
alexfru wrote:What's the version of Virtual PC? What about regular 4KB pages?
Is the last version: Virtual PC SP1 (6.0.192.0)
I don't try with 4KB pages. I will try.
iansjack wrote:PAE requires not only a compatible CPU but also a compatible chipset. I suspect that the Intel 440BX chipset emulated by Virtual PC does not support PAE.

Virtual PC is really only useful for Microsoft consumer OSs. Even then there are better alternatives.
I don't think virtual pc indicating that supports PAE when not supported. :?

Re: Virtual PC PAE?

Posted: Tue Aug 05, 2014 1:30 am
by alexfru
iansjack wrote:PAE requires not only a compatible CPU but also a compatible chipset.
How so? Shouldn't virtual to physical address translation be completely transparent to everything outside of the CPU?

Re: Virtual PC PAE?

Posted: Tue Aug 05, 2014 1:56 am
by Combuster
I think he actually meant that having a 32-bit chipset (rather than a 36-bit one) will imply that PAE offers no advantages since the actual memory range doesn't get extended.

Of course this is insufficient excuse as PAE does give you access to the NX bit - which is an advantage, and it's the developers responsibility not to make accesses to undefined memory.

Re: Virtual PC PAE?

Posted: Tue Aug 05, 2014 2:06 am
by lweb20
But ... how do you detect if it is actually available? to switch to legacy paging if PAE can not be enabled. :roll:

Re: Virtual PC PAE?

Posted: Tue Aug 05, 2014 2:14 am
by Combuster
If the processor says it supports PAE (by virtue of CPUID), then it is also allowed to use that mode of execution.

Although I wouldn't be surprised if some VMs out there were incapable of performing PAE shadow mapping while still letting the guest see the capability bits. After all, pretty much every VM out there is lying about supporting VME - with Bochs being the only one to actually support it.

Re: Virtual PC PAE?

Posted: Tue Aug 05, 2014 2:29 am
by lweb20
Combuster wrote:If the processor says it supports PAE (by virtue of CPUID), then it is also allowed to use that mode of execution.

Although I wouldn't be surprised if some VMs out there were incapable of performing PAE shadow mapping while still letting the guest see the capability bits. After all, pretty much every VM out there is lying about supporting VME - with Bochs being the only one to actually support it.
VMWare, Bochs and VirtualBox supports PAE "correctly" (not triple fault). Only Virtual PC is the problem. Apparently virtual pc does not support NX because the EDX register of CPUID (0x80000001, 20) is zero.

I will try to enable PAE with 4KB pages :( and if not work I don't know what do.

Any other ideas?

Re: Virtual PC PAE?

Posted: Tue Aug 05, 2014 2:31 am
by Combuster
Perform VM identification and sanitize CPUID flags based on that. Basically if SGDT/SIDT doesn't do the opposite of LGDT/LIDT, you can be absolutely sure it's not actual hardware you're talking to.

Re: Virtual PC PAE?

Posted: Tue Aug 05, 2014 2:34 am
by alexfru
VM hosts have all kinds of bugs and limitations in emulation of the CPU and hardware (I know of a bunch in Hyper-V). That's just how it is.

Re: Virtual PC PAE?

Posted: Tue Aug 05, 2014 2:36 am
by alexfru
Combuster wrote:Perform VM identification and sanitize CPUID flags based on that. Basically if SGDT/SIDT doesn't do the opposite of LGDT/LIDT, you can be absolutely sure it's not actual hardware you're talking to.
There are many ways to check for virtual environment and bugs in it, and this one is a necessary but not sufficient one.

Re: Virtual PC PAE?

Posted: Tue Aug 05, 2014 2:38 am
by alexfru
lweb20 wrote: Apparently virtual pc does not support NX because the EDX register of CPUID (0x80000001, 20) is zero.

I will try to enable PAE with 4KB pages :( and if not work I don't know what do.

Any other ideas?
Based on my experience with Virtual PC and knowledge of it, I'd just ditch it.

Re: Virtual PC PAE?

Posted: Tue Aug 05, 2014 2:46 am
by lweb20
Combuster wrote:Perform VM identification and sanitize CPUID flags based on that. Basically if SGDT/SIDT doesn't do the opposite of LGDT/LIDT, you can be absolutely sure it's not actual hardware you're talking to.
I'm sorry, I can not understand. You tell me that sidt must be opposed lidt? and what also sgdt and lgdt? sgdt save and lgdt load .. Maybe I misunderstood.

Sorry for my bad english and my ignorance :oops:

Re: Virtual PC PAE?

Posted: Tue Aug 05, 2014 2:55 am
by Combuster
Have you tried running SGDT and SIDT (after doing LGDT and LIDT) in VirtualPC and printed the result? Did that surprise you?