-
Notifications
You must be signed in to change notification settings - Fork 99
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
handle cr3 #52
Comments
Are you building as debug or as release? And what code did you use that improved performance? |
release build, run on host, i9-13900HX. for (size_t j = 0; j < 512; ++j) {
#if 0
// identity-map every GPA to the corresponding HPA
auto& pde = ept.pds_2mb[i][j];
pde.flags = 0;
pde.read_access = 1;
pde.write_access = 1;
pde.execute_access = 1;
pde.ignore_pat = 0;
pde.large_page = 1;
pde.accessed = 0;
pde.dirty = 0;
pde.user_mode_execute = 1;
pde.suppress_ve = 0;
pde.page_frame_number = (i << 9) + j;
pde.memory_type = calc_mtrr_mem_type(mtrrs,
pde.page_frame_number << 21, 0x1000 << 9);
#else
if (i == 0 && j == 0)
{
PVOID64 PtePhys = (PVOID64)(MmGetPhysicalAddress((PVOID)(ept.PteForFirstLargePage)).QuadPart);
ept.pds[i][j].read_access = TRUE;
ept.pds[i][j].write_access = TRUE;
ept.pds[i][j].execute_access = TRUE;
ept.pds[i][j].page_frame_number = PAGE_TO_PFN(reinterpret_cast<UINT64>(PtePhys));
for (unsigned int k = 0; k < _ARRAYSIZE(ept.PteForFirstLargePage); ++k)
{
uint8_t MemType = MEMORY_TYPE_UNCACHEABLE;
if (mtrrs.IsSupported)
{
MemType = calc_mtrr_mem_type(mtrrs, PFN_TO_PAGE(static_cast<unsigned long long>(k)), PAGE_SIZE);
}
ept.PteForFirstLargePage[k].read_access = TRUE;
ept.PteForFirstLargePage[k].write_access = TRUE;
ept.PteForFirstLargePage[k].execute_access = TRUE;
ept.PteForFirstLargePage[k].memory_type = static_cast<unsigned char>(MemType);
ept.PteForFirstLargePage[k].page_frame_number = k;
}
}
else
{
unsigned long long PagePfn = i * _ARRAYSIZE(ept.pds[i]) + j;
constexpr unsigned long long LargePageSize = 2 * 1048576; // 2 Mb
uint8_t MemType = MEMORY_TYPE_UNCACHEABLE;
if (mtrrs.IsSupported)
{
MemType = calc_mtrr_mem_type(mtrrs, PFN_TO_LARGE_PAGE(PagePfn), LargePageSize);
}
ept.pds_2mb[i][j].read_access = TRUE;
ept.pds_2mb[i][j].write_access = TRUE;
ept.pds_2mb[i][j].execute_access = TRUE;
ept.pds_2mb[i][j].memory_type = static_cast<unsigned char>(MemType);
ept.pds_2mb[i][j].large_page = TRUE;
ept.pds_2mb[i][j].page_frame_number = PagePfn;
}
#endif
} |
FYI: You can set this to 0 if you aren't targeting an EAC game. |
Perfect! |
hv/hv/exit-handlers.cpp
Line 487 in cd4d402
thank you very much for open source such clean code
while I know this is not abide by with Intel sdm, is there a way to handle cr3 in another way?
when I read large amounts of data,
emulate_mov_to_cr3
is called very frequently.caused my fps from 150+ to 50-
exclude other issue causing lower fps:
I have solved this but just c2p from other hv, code is not pretty so I didn't pull it.
#37
The text was updated successfully, but these errors were encountered: