mirror of
https://github.com/momo5502/hypervisor.git
synced 2025-04-19 13:42:55 +00:00
Prepare refactoring pasted code
This commit is contained in:
parent
bd82bdb561
commit
a284af51ec
@ -279,7 +279,6 @@ void ShvVmxEptInitialize(vmx::vm_state* VpData)
|
|||||||
{
|
{
|
||||||
UINT32 i, j;
|
UINT32 i, j;
|
||||||
vmx::pdpte tempEpdpte;
|
vmx::pdpte tempEpdpte;
|
||||||
vmx::large_pde tempEpde;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fill out the EPML4E which covers the first 512GB of RAM
|
// Fill out the EPML4E which covers the first 512GB of RAM
|
||||||
@ -311,14 +310,17 @@ void ShvVmxEptInitialize(vmx::vm_state* VpData)
|
|||||||
//
|
//
|
||||||
// Fill out a RWX Large PDE
|
// Fill out a RWX Large PDE
|
||||||
//
|
//
|
||||||
tempEpde.full = 0;
|
epde_2mb temp_epde;
|
||||||
tempEpde.read = tempEpde.write = tempEpde.execute = 1;
|
temp_epde.flags = 0;
|
||||||
tempEpde.large = 1;
|
temp_epde.read_access = 1;
|
||||||
|
temp_epde.write_access = 1;
|
||||||
|
temp_epde.execute_access = 1;
|
||||||
|
temp_epde.large_page = 1;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Loop every 1GB of RAM (described by the PDPTE)
|
// Loop every 1GB of RAM (described by the PDPTE)
|
||||||
//
|
//
|
||||||
__stosq((UINT64*)VpData->epde, tempEpde.full, PDPTE_ENTRY_COUNT * PDE_ENTRY_COUNT);
|
__stosq((UINT64*)VpData->epde, temp_epde.flags, PDPTE_ENTRY_COUNT * PDE_ENTRY_COUNT);
|
||||||
for (i = 0; i < PDPTE_ENTRY_COUNT; i++)
|
for (i = 0; i < PDPTE_ENTRY_COUNT; i++)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -327,9 +329,9 @@ void ShvVmxEptInitialize(vmx::vm_state* VpData)
|
|||||||
for (j = 0; j < PDE_ENTRY_COUNT; j++)
|
for (j = 0; j < PDE_ENTRY_COUNT; j++)
|
||||||
{
|
{
|
||||||
VpData->epde[i][j].page_frame_number = (i * 512) + j;
|
VpData->epde[i][j].page_frame_number = (i * 512) + j;
|
||||||
VpData->epde[i][j].type = ShvVmxMtrrAdjustEffectiveMemoryType(VpData,
|
VpData->epde[i][j].memory_type = ShvVmxMtrrAdjustEffectiveMemoryType(VpData,
|
||||||
VpData->epde[i][j].page_frame_number * _2MB,
|
VpData->epde[i][j].page_frame_number * _2MB,
|
||||||
MEMORY_TYPE_WRITE_BACK);
|
MEMORY_TYPE_WRITE_BACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
#include <ia32.hpp>
|
#include <ia32.hpp>
|
||||||
|
|
||||||
#define PML4E_ENTRY_COUNT 512
|
#define PML4E_ENTRY_COUNT 512 // EPT_PML4E_ENTRY_COUNT
|
||||||
#define PDPTE_ENTRY_COUNT 512
|
#define PDPTE_ENTRY_COUNT 512 // EPT_PDPTE_ENTRY_COUNT
|
||||||
#define PDE_ENTRY_COUNT 512
|
#define PDE_ENTRY_COUNT 512 // EPT_PDE_ENTRY_COUNT
|
||||||
|
|
||||||
namespace vmx
|
namespace vmx
|
||||||
{
|
{
|
||||||
@ -61,33 +61,6 @@ namespace vmx
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct large_pde
|
|
||||||
{
|
|
||||||
union
|
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
uint64_t read : 1;
|
|
||||||
uint64_t write : 1;
|
|
||||||
uint64_t execute : 1;
|
|
||||||
uint64_t type : 3;
|
|
||||||
uint64_t ignore_pat : 1;
|
|
||||||
uint64_t large : 1;
|
|
||||||
uint64_t accessed : 1;
|
|
||||||
uint64_t dirty : 1;
|
|
||||||
uint64_t user_mode_execute : 1;
|
|
||||||
uint64_t software_use : 1;
|
|
||||||
uint64_t reserved : 9;
|
|
||||||
uint64_t page_frame_number : 27;
|
|
||||||
uint64_t reserved_high : 4;
|
|
||||||
uint64_t software_use_high : 11;
|
|
||||||
uint64_t suppress_vme : 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
uint64_t full;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct kdescriptor
|
struct kdescriptor
|
||||||
{
|
{
|
||||||
uint16_t pad[3];
|
uint16_t pad[3];
|
||||||
@ -141,7 +114,7 @@ namespace vmx
|
|||||||
DECLSPEC_ALIGN(PAGE_SIZE) uint8_t msr_bitmap[PAGE_SIZE]{};
|
DECLSPEC_ALIGN(PAGE_SIZE) uint8_t msr_bitmap[PAGE_SIZE]{};
|
||||||
DECLSPEC_ALIGN(PAGE_SIZE) epml4e epml4[PML4E_ENTRY_COUNT]{};
|
DECLSPEC_ALIGN(PAGE_SIZE) epml4e epml4[PML4E_ENTRY_COUNT]{};
|
||||||
DECLSPEC_ALIGN(PAGE_SIZE) pdpte epdpt[PDPTE_ENTRY_COUNT]{};
|
DECLSPEC_ALIGN(PAGE_SIZE) pdpte epdpt[PDPTE_ENTRY_COUNT]{};
|
||||||
DECLSPEC_ALIGN(PAGE_SIZE) large_pde epde[PDPTE_ENTRY_COUNT][PDE_ENTRY_COUNT]{};
|
DECLSPEC_ALIGN(PAGE_SIZE) epde_2mb epde[PDPTE_ENTRY_COUNT][PDE_ENTRY_COUNT]{};
|
||||||
|
|
||||||
DECLSPEC_ALIGN(PAGE_SIZE) vmcs vmx_on{};
|
DECLSPEC_ALIGN(PAGE_SIZE) vmcs vmx_on{};
|
||||||
DECLSPEC_ALIGN(PAGE_SIZE) vmcs vmcs{};
|
DECLSPEC_ALIGN(PAGE_SIZE) vmcs vmcs{};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user