Virtual PC PAE?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
lweb20
Member
Member
Posts: 39
Joined: Tue Jul 23, 2013 12:54 pm

Virtual PC PAE?

Post 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)
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Virtual PC PAE?

Post by alexfru »

What's the version of Virtual PC? What about regular 4KB pages?
User avatar
iansjack
Member
Member
Posts: 4709
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Virtual PC PAE?

Post 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.
lweb20
Member
Member
Posts: 39
Joined: Tue Jul 23, 2013 12:54 pm

Re: Virtual PC PAE?

Post 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. :?
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Virtual PC PAE?

Post 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?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Virtual PC PAE?

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
lweb20
Member
Member
Posts: 39
Joined: Tue Jul 23, 2013 12:54 pm

Re: Virtual PC PAE?

Post by lweb20 »

But ... how do you detect if it is actually available? to switch to legacy paging if PAE can not be enabled. :roll:
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Virtual PC PAE?

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
lweb20
Member
Member
Posts: 39
Joined: Tue Jul 23, 2013 12:54 pm

Re: Virtual PC PAE?

Post 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?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Virtual PC PAE?

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Virtual PC PAE?

Post 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.
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Virtual PC PAE?

Post 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.
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Virtual PC PAE?

Post 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.
lweb20
Member
Member
Posts: 39
Joined: Tue Jul 23, 2013 12:54 pm

Re: Virtual PC PAE?

Post 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:
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Virtual PC PAE?

Post by Combuster »

Have you tried running SGDT and SIDT (after doing LGDT and LIDT) in VirtualPC and printed the result? Did that surprise you?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply