Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E_INVALID_ARG for WHvMapGpaRange #2

Open
steffengy opened this issue Jun 26, 2019 · 1 comment
Open

E_INVALID_ARG for WHvMapGpaRange #2

steffengy opened this issue Jun 26, 2019 · 1 comment

Comments

@steffengy
Copy link

Building the binaries and starting simpleator.exe N:\path\to\testapp.exe yielded an E_INVALID_ARG in the debug console so I tried to look into it:

  1. It seems like the source address isn't aligned to a page boundary, as it should be, so WHvMapGpaRange yields that HRESULT.
  2. After fixing that and calling it manually small mappings work (roughly < 1<<36) when adding similar code as below directly after SemVmCreatePartition.
    For bigger sizes, we get E_INVALID_ARG again.

Any idea whats going on there?
Are some kind of limits put onto the guest address space?

Running Win10 Pro 1903 x64, HyperV Platform and HyperV enabled.

MEM_ADDRESS_REQUIREMENTS addrReqs = { 0 };
addrReqs.Alignment = 65536; // align to page boundary, should be dwAllocationGranularity
MEM_EXTENDED_PARAMETER additional = { 0 };
additional.Type = MemExtendedParameterAddressRequirements;
additional.Pointer = &addrReqs;
auto addr = VirtualAlloc2(GetCurrentProcess(),
		NULL,
		4096,
		MEM_COMMIT | MEM_TOP_DOWN,
		PAGE_READWRITE,
		&additional,
		1);
// This works: WHV_GUEST_PHYSICAL_ADDRESS size = 0x0000000b40000000;
WHV_GUEST_PHYSICAL_ADDRESS size = 0x0000000b80000000;
auto ret = WHvMapGpaRange(semPartition->PartitionHandle,
		addr,
		4096,
		size, 
		WHvMapGpaRangeFlagRead | WHvMapGpaRangeFlagWrite);
// ret == E_INVALID_ARG
return 0;
@danyhm
Copy link

danyhm commented Oct 12, 2021

@steffengy @ionescu007 I had the same problem. I fixed it by adjusting s_TcbRegionAddress and s_Pml4PhysicalAddress to lower values according to the maximum RAM supported by my CPU model. I think the TCB boundary of 256Gb and PML4 boundary of 512Gb are the maximum values by the architect but the hypervisor limits them based on the actual CPU model installed on the system. for me the maximum value seems to be 64Gb on an intel-i7-3612qm (the maximum supported ram is 32Gb actually!)

but as soon as I run the simpleator I get the Unhandled Exit reason 4 which is WHvRunVpExitReasonUnrecoverableException.
any idea why the testapp is not working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants