Skip to content

E_INVALID_ARG for WHvMapGpaRange #2

@steffengy

Description

@steffengy

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions