MCPcopy Create free account
hub / github.com/HoShiMin/Kernel-Bridge / BuildNestedPagingTables

Function BuildNestedPagingTables

Kernel-Bridge/API/Hypervisor.cpp:278–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276 };
277
278 static void BuildNestedPagingTables(__out NESTED_PAGING_TABLES* Npt)
279 {
280 using namespace PhysicalMemory;
281
282 if (!Npt) return;
283
284 Npt->Pml4e.x64.Page2Mb.P = TRUE; // Present
285 Npt->Pml4e.x64.Page2Mb.RW = TRUE; // Writeable
286 Npt->Pml4e.x64.Page2Mb.US = TRUE; // User
287 Npt->Pml4e.x64.Page2Mb.PDP = PAGE_TO_PFN(reinterpret_cast<UINT64>(GetPhysicalAddress(&Npt->Pdpe[0])));
288
289 for (int i = 0; i < _ARRAYSIZE(Npt->Pdpe); ++i)
290 {
291 Npt->Pdpe[i].x64.NonPageSize.Page2Mb.P = TRUE; // Present
292 Npt->Pdpe[i].x64.NonPageSize.Page2Mb.RW = TRUE; // Writeable
293 Npt->Pdpe[i].x64.NonPageSize.Page2Mb.US = TRUE; // User
294 Npt->Pdpe[i].x64.NonPageSize.Page2Mb.PD = PAGE_TO_PFN(reinterpret_cast<UINT64>(GetPhysicalAddress(&Npt->Pde[i][0])));
295
296 for (int j = 0; j < _ARRAYSIZE(Npt->Pde[i]); ++j)
297 {
298 Npt->Pde[i][j].x64.Page2Mb.P = TRUE; // Present
299 Npt->Pde[i][j].x64.Page2Mb.RW = TRUE; // Writeable
300 Npt->Pde[i][j].x64.Page2Mb.US = TRUE; // User
301 Npt->Pde[i][j].x64.Page2Mb.PS = TRUE; // Large page
302 Npt->Pde[i][j].x64.Page2Mb.PhysicalPageFrameNumber = i * _ARRAYSIZE(Npt->Pde[i]) + j;
303 }
304 }
305 }
306
307 // Defined in the VMM.asm:
308 extern "C" void SvmVmmRun(void* InitialVmmStackPointer);

Callers 1

VirtualizeProcessorFunction · 0.85

Calls 1

GetPhysicalAddressFunction · 0.85

Tested by

no test coverage detected