From 963f5de117170b74ce44d610e5dc11793c0dd5a9 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Wed, 17 Jan 2018 11:14:25 +0100 Subject: [PATCH] vbox5: increase boot speed of Linux guests Until now, if we examined an EPT fault and the corresponding guest physical memory was not allocated, we forwarded the faulting instruction to the instruction emulator, which in turn handled the memory allocation implicitly. This lead to long instruction emulation times on certain instructions (e.g. 'rep mov' on large memory junks). Therefore, we now allocate and map the corresponding guest physical memory immediately in the EPT fault handler and directly return to the guest. fixes #2645 --- repos/ports/src/virtualbox5/spec/nova/pgm.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/repos/ports/src/virtualbox5/spec/nova/pgm.cc b/repos/ports/src/virtualbox5/spec/nova/pgm.cc index 1422c3709..4d5facb0e 100644 --- a/repos/ports/src/virtualbox5/spec/nova/pgm.cc +++ b/repos/ports/src/virtualbox5/spec/nova/pgm.cc @@ -44,6 +44,21 @@ int Vcpu_handler::map_memory(RTGCPHYS GCPhys, size_t cbWrite, _ept_fault_addr_type = PGM_PAGE_GET_TYPE(pPage); + /* + * If page is not allocated (== zero page) and no MMIO or active page, allocate and map it + * immediately. Important do not do this if A20 gate is disabled, A20 gate + * is handled by IEM/REM in this case. + */ + if (PGM_PAGE_IS_ZERO(pPage) + && !PGM_PAGE_IS_ALLOCATED(pPage) + && !PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(pPage) + && !PGM_PAGE_IS_SPECIAL_ALIAS_MMIO(pPage) + && PGM_A20_IS_ENABLED(pVCpu)) { + pgmLock(pVM); + pgmPhysPageMakeWritable(pVM, pPage, GCPhys); + pgmUnlock(pVM); + } + if (PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(pPage) || PGM_PAGE_IS_SPECIAL_ALIAS_MMIO(pPage) || PGM_PAGE_IS_ZERO(pPage)) {