From 09dd9473bb699d3a2acb825c73a65518106eae41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Crianquinn=E2=80=9D?= <“rianquinn@gmail.com”> Date: Mon, 29 Jan 2018 17:19:48 -0700 Subject: [PATCH] Fix Include Issue / Enable Warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bfvmm was not installing its headers, but instead was directly searching for the includes from the source tree, resulting in name collisions with extensions. In addition, warnings were never working, and are by default turned off. Travis however should ensure no warnings occur, which was not working properly. [ISSUES]: https://github.com/Bareflank/hypervisor/issues/585 Signed-off-by: “rianquinn” <“rianquinn@gmail.com”> --- .appveyor.yml | 15 +- bfintrinsics/include/arch/x64/srs.h | 64 +- bfvmm/src/CMakeLists.txt | 4 +- bfvmm/src/debug/CMakeLists.txt | 6 + bfvmm/src/hve/CMakeLists.txt | 6 + bfvmm/src/memory_manager/CMakeLists.txt | 6 + bfvmm/src/vcpu/CMakeLists.txt | 6 + bfvmm/tests/CMakeLists.txt | 4 +- .../serial/test_serial_port_ns16550a.cpp | 4 +- .../vmcs/test_vmcs_check_controls.cpp | 954 +++--- .../intel_x64/vmcs/test_vmcs_check_guest.cpp | 2988 ++++++++--------- .../intel_x64/vmcs/test_vmcs_check_host.cpp | 510 +-- .../support/arch/intel_x64/test_support.h | 8 +- scripts/cmake/config/default.cmake | 44 +- scripts/cmake/config/travis_asan.cmake | 4 + scripts/cmake/config/travis_codecov.cmake | 4 + scripts/cmake/config/travis_format.cmake | 4 + scripts/cmake/config/travis_shared.cmake | 3 + scripts/cmake/config/travis_static.cmake | 3 + scripts/cmake/config/travis_tidy.cmake | 4 + scripts/cmake/config/travis_usan.cmake | 4 + scripts/cmake/depends/libcxx.cmake | 1 + scripts/cmake/depends/libcxxabi.cmake | 1 + scripts/cmake/depends/newlib.cmake | 1 + scripts/cmake/macros.cmake | 17 +- 25 files changed, 2358 insertions(+), 2307 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 8e32c6a4b..62f462f26 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -31,7 +31,8 @@ environment: BFPATH: '%PATH%' PATH: '%PATH%;C:\Program Files\NASM' -test: off +cache: + - ../cache # # Setup Cygwin @@ -71,3 +72,15 @@ build_script: - '%CYG_BASH% -lc "cd $APPVEYOR_BUILD_FOLDER/build_cygwin; cmake -DENABLE_BUILD_TEST=ON .."' - '%CYG_BASH% -lc "cd $APPVEYOR_BUILD_FOLDER/build_cygwin; make -j3"' - '%CYG_BASH% -lc "cd $APPVEYOR_BUILD_FOLDER/build_cygwin; make unittest"' + +test: + + # + # Visual Studio (MSBuild / Static Libraries) + # + - cmake --build . --target test + + # + # Cygwin (Shared Libraries) + # + - '%CYG_BASH% -lc "cd $APPVEYOR_BUILD_FOLDER/build_cygwin; make unittest"' diff --git a/bfintrinsics/include/arch/x64/srs.h b/bfintrinsics/include/arch/x64/srs.h index 9c735344a..832878d88 100644 --- a/bfintrinsics/include/arch/x64/srs.h +++ b/bfintrinsics/include/arch/x64/srs.h @@ -99,10 +99,10 @@ namespace es { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_es(gsl::narrow_cast(set_bits(_read_es(), mask, val << from))); } + { _write_es(gsl::narrow_cast(set_bits(_read_es(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_es(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_es(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -155,10 +155,10 @@ namespace es { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_es(gsl::narrow_cast(set_bits(_read_es(), mask, val << from))); } + { _write_es(gsl::narrow_cast(set_bits(_read_es(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_es(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_es(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -196,10 +196,10 @@ namespace cs { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_cs(gsl::narrow_cast(set_bits(_read_cs(), mask, val << from))); } + { _write_cs(gsl::narrow_cast(set_bits(_read_cs(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_cs(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_cs(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -252,10 +252,10 @@ namespace cs { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_cs(gsl::narrow_cast(set_bits(_read_cs(), mask, val << from))); } + { _write_cs(gsl::narrow_cast(set_bits(_read_cs(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_cs(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_cs(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -293,10 +293,10 @@ namespace ss { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_ss(gsl::narrow_cast(set_bits(_read_ss(), mask, val << from))); } + { _write_ss(gsl::narrow_cast(set_bits(_read_ss(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_ss(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_ss(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -349,10 +349,10 @@ namespace ss { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_ss(gsl::narrow_cast(set_bits(_read_ss(), mask, val << from))); } + { _write_ss(gsl::narrow_cast(set_bits(_read_ss(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_ss(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_ss(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -390,10 +390,10 @@ namespace ds { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_ds(gsl::narrow_cast(set_bits(_read_ds(), mask, val << from))); } + { _write_ds(gsl::narrow_cast(set_bits(_read_ds(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_ds(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_ds(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -446,10 +446,10 @@ namespace ds { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_ds(gsl::narrow_cast(set_bits(_read_ds(), mask, val << from))); } + { _write_ds(gsl::narrow_cast(set_bits(_read_ds(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_ds(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_ds(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -487,10 +487,10 @@ namespace fs { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_fs(gsl::narrow_cast(set_bits(_read_fs(), mask, val << from))); } + { _write_fs(gsl::narrow_cast(set_bits(_read_fs(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_fs(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_fs(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -543,10 +543,10 @@ namespace fs { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_fs(gsl::narrow_cast(set_bits(_read_fs(), mask, val << from))); } + { _write_fs(gsl::narrow_cast(set_bits(_read_fs(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_fs(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_fs(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -584,10 +584,10 @@ namespace gs { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_gs(gsl::narrow_cast(set_bits(_read_gs(), mask, val << from))); } + { _write_gs(gsl::narrow_cast(set_bits(_read_gs(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_gs(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_gs(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -640,10 +640,10 @@ namespace gs { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_gs(gsl::narrow_cast(set_bits(_read_gs(), mask, val << from))); } + { _write_gs(gsl::narrow_cast(set_bits(_read_gs(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_gs(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_gs(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -681,10 +681,10 @@ namespace ldtr { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_ldtr(gsl::narrow_cast(set_bits(_read_ldtr(), mask, val << from))); } + { _write_ldtr(gsl::narrow_cast(set_bits(_read_ldtr(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_ldtr(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_ldtr(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -737,10 +737,10 @@ namespace ldtr { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_ldtr(gsl::narrow_cast(set_bits(_read_ldtr(), mask, val << from))); } + { _write_ldtr(gsl::narrow_cast(set_bits(_read_ldtr(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_ldtr(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_ldtr(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -778,10 +778,10 @@ namespace tr { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_tr(gsl::narrow_cast(set_bits(_read_tr(), mask, val << from))); } + { _write_tr(gsl::narrow_cast(set_bits(_read_tr(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_tr(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_tr(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } @@ -834,10 +834,10 @@ namespace tr { return gsl::narrow_cast(get_bits(sr, mask) >> from); } inline void set(value_type val) - { _write_tr(gsl::narrow_cast(set_bits(_read_tr(), mask, val << from))); } + { _write_tr(gsl::narrow_cast(set_bits(_read_tr(), mask, gsl::narrow_cast(val << from)))); } inline auto set(value_type sr, value_type val) - { _write_tr(gsl::narrow_cast(set_bits(sr, mask, val << from))); } + { _write_tr(gsl::narrow_cast(set_bits(sr, mask, gsl::narrow_cast(val << from)))); } inline void dump(int level, std::string *msg = nullptr) { bfdebug_subnhex(level, name, get(), msg); } diff --git a/bfvmm/src/CMakeLists.txt b/bfvmm/src/CMakeLists.txt index 12ed212a4..48646abe5 100644 --- a/bfvmm/src/CMakeLists.txt +++ b/bfvmm/src/CMakeLists.txt @@ -20,7 +20,9 @@ cmake_minimum_required(VERSION 3.6) project(bfvmm C CXX) include(${SOURCE_CMAKE_DIR}/project.cmake) -init_project() +init_project( + INCLUDES ${CMAKE_CURRENT_LIST_DIR}/../include +) add_subdirectory(debug) add_subdirectory(memory_manager) diff --git a/bfvmm/src/debug/CMakeLists.txt b/bfvmm/src/debug/CMakeLists.txt index 870a5e0ab..bb3593af0 100644 --- a/bfvmm/src/debug/CMakeLists.txt +++ b/bfvmm/src/debug/CMakeLists.txt @@ -46,3 +46,9 @@ add_static_library( DEFINES STATIC_DEBUG DEFINES STATIC_INTRINSICS ) + +# ------------------------------------------------------------------------------ +# Install +# ------------------------------------------------------------------------------ + +install(DIRECTORY ${CMAKE_SOURCE_DIR}/../include/debug DESTINATION include/bfvmm/debug) diff --git a/bfvmm/src/hve/CMakeLists.txt b/bfvmm/src/hve/CMakeLists.txt index 8b9012502..8a32e1fe3 100644 --- a/bfvmm/src/hve/CMakeLists.txt +++ b/bfvmm/src/hve/CMakeLists.txt @@ -49,3 +49,9 @@ add_static_library( DEFINES STATIC_MEMORY_MANAGER DEFINES STATIC_INTRINSICS ) + +# ------------------------------------------------------------------------------ +# Install +# ------------------------------------------------------------------------------ + +install(DIRECTORY ${CMAKE_SOURCE_DIR}/../include/hve DESTINATION include/bfvmm/hve) diff --git a/bfvmm/src/memory_manager/CMakeLists.txt b/bfvmm/src/memory_manager/CMakeLists.txt index d62b1f5e8..84aa411ac 100644 --- a/bfvmm/src/memory_manager/CMakeLists.txt +++ b/bfvmm/src/memory_manager/CMakeLists.txt @@ -43,3 +43,9 @@ add_static_library( DEFINES STATIC_MEMORY_MANAGER DEFINES STATIC_INTRINSICS ) + +# ------------------------------------------------------------------------------ +# Install +# ------------------------------------------------------------------------------ + +install(DIRECTORY ${CMAKE_SOURCE_DIR}/../include/memory_manager DESTINATION include/bfvmm/memory_manager) diff --git a/bfvmm/src/vcpu/CMakeLists.txt b/bfvmm/src/vcpu/CMakeLists.txt index e9f940165..259edc232 100644 --- a/bfvmm/src/vcpu/CMakeLists.txt +++ b/bfvmm/src/vcpu/CMakeLists.txt @@ -54,3 +54,9 @@ add_static_library( DEFINES STATIC_MEMORY_MANAGER DEFINES STATIC_INTRINSICS ) + +# ------------------------------------------------------------------------------ +# Install +# ------------------------------------------------------------------------------ + +install(DIRECTORY ${CMAKE_SOURCE_DIR}/../include/vcpu DESTINATION include/bfvmm/vcpu) diff --git a/bfvmm/tests/CMakeLists.txt b/bfvmm/tests/CMakeLists.txt index aa245f731..d52d9d444 100644 --- a/bfvmm/tests/CMakeLists.txt +++ b/bfvmm/tests/CMakeLists.txt @@ -20,7 +20,9 @@ cmake_minimum_required(VERSION 3.6) project(bfvmm_test C CXX) include(${SOURCE_CMAKE_DIR}/project.cmake) -init_project() +init_project( + INCLUDES ${CMAKE_CURRENT_LIST_DIR}/../include +) add_subdirectory(../src/debug ${CMAKE_CURRENT_BINARY_DIR}/src/debug) add_subdirectory(../src/hve ${CMAKE_CURRENT_BINARY_DIR}/src/hve) diff --git a/bfvmm/tests/debug/serial/test_serial_port_ns16550a.cpp b/bfvmm/tests/debug/serial/test_serial_port_ns16550a.cpp index 7069e55ce..d23571041 100644 --- a/bfvmm/tests/debug/serial/test_serial_port_ns16550a.cpp +++ b/bfvmm/tests/debug/serial/test_serial_port_ns16550a.cpp @@ -30,7 +30,7 @@ static std::map(g_ports[port]); } extern "C" void _outb(uint16_t port, uint8_t val) noexcept @@ -42,7 +42,7 @@ _ind(uint16_t port) noexcept extern "C" void _outd(uint16_t port, uint32_t val) noexcept -{ g_ports[port] = val; } +{ g_ports[port] = gsl::narrow_cast(val); } TEST_CASE("serial: support") { diff --git a/bfvmm/tests/hve/arch/intel_x64/vmcs/test_vmcs_check_controls.cpp b/bfvmm/tests/hve/arch/intel_x64/vmcs/test_vmcs_check_controls.cpp index 8510e1a82..af82b7530 100644 --- a/bfvmm/tests/hve/arch/intel_x64/vmcs/test_vmcs_check_controls.cpp +++ b/bfvmm/tests/hve/arch/intel_x64/vmcs/test_vmcs_check_controls.cpp @@ -41,59 +41,59 @@ static void setup_check_control_pin_based_ctls_reserved_properly_set_paths(std::vector &cfg) { - path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_pinbased_ctls::addr] = 0xffffffff00000000UL; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_pinbased_ctls::addr] = 0xffffffff00000000UL; }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_pinbased_ctls::addr] = 1; }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_pinbased_ctls::addr] = 1; }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { pin_based_vm_execution_controls::set(1UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { pin_based_vm_execution_controls::set(1UL); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_control_proc_based_ctls_reserved_properly_set_paths( std::vector &cfg) { - path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_procbased_ctls::addr] = 0xffffffff00000000UL; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_procbased_ctls::addr] = 0xffffffff00000000UL; }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_procbased_ctls::addr] = 1; }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_procbased_ctls::addr] = 1; }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { primary_processor_based_vm_execution_controls::set(1UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { primary_processor_based_vm_execution_controls::set(1UL); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_control_proc_based_ctls2_reserved_properly_set_paths( std::vector &cfg) { - path.setup = [&] { proc_ctl_disallow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { proc_ctl_disallow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); g_msrs[intel_x64::msrs::ia32_vmx_procbased_ctls2::addr] = 0xffffffff00000000UL; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_procbased_ctls2::addr] |= 1; secondary_processor_based_vm_execution_controls::set(0UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { using namespace secondary_processor_based_vm_execution_controls; g_msrs[intel_x64::msrs::ia32_vmx_procbased_ctls2::addr] = 0xfffffffe00000000UL; @@ -103,90 +103,90 @@ setup_check_control_proc_based_ctls2_reserved_properly_set_paths( // so that an exception isn't thrown in the setup function. set(virtualize_apic_accesses::mask); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_control_cr3_count_less_than_4_paths(std::vector &cfg) { - path.setup = [&] { cr3_target_count::set(3UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { cr3_target_count::set(3UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { cr3_target_count::set(5UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { cr3_target_count::set(5UL); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_control_io_bitmap_address_bits_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow0(intel_x64::msrs::ia32_vmx_true_procbased_ctls::use_io_bitmaps::mask); primary_processor_based_vm_execution_controls::use_io_bitmaps::disable(); g_eax_cpuid[x64::cpuid::addr_size::addr] = 48U; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::use_io_bitmaps::mask); primary_processor_based_vm_execution_controls::use_io_bitmaps::enable(); address_of_io_bitmap_a::set(0x1U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { address_of_io_bitmap_a::set(0xff00000000000000U); address_of_io_bitmap_b::set(0x1U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { address_of_io_bitmap_b::set(0xff00000000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { address_of_io_bitmap_b::set(0xff00000000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { address_of_io_bitmap_a::set(0x1000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { address_of_io_bitmap_a::set(0x1000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { address_of_io_bitmap_b::set(0x1000U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { address_of_io_bitmap_b::set(0x1000U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_msr_bitmap_address_bits_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow0(intel_x64::msrs::ia32_vmx_true_procbased_ctls::use_msr_bitmap::mask); primary_processor_based_vm_execution_controls::use_msr_bitmap::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::use_msr_bitmap::mask); primary_processor_based_vm_execution_controls::use_msr_bitmap::enable(); address_of_msr_bitmap::set(0x1U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { address_of_msr_bitmap::set(0xff00000000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { address_of_msr_bitmap::set(0xff00000000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { address_of_msr_bitmap::set(0x1000U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { address_of_msr_bitmap::set(0x1000U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void @@ -196,401 +196,401 @@ setup_check_control_tpr_shadow_and_virtual_apic_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { pin_ctl_allow1(intel_x64::msrs::ia32_vmx_true_pinbased_ctls::nmi_exiting::mask); pin_based_vm_execution_controls::nmi_exiting::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { pin_ctl_allow0(intel_x64::msrs::ia32_vmx_true_pinbased_ctls::nmi_exiting::mask); pin_ctl_allow1(intel_x64::msrs::ia32_vmx_true_pinbased_ctls::virtual_nmis::mask); pin_based_vm_execution_controls::nmi_exiting::disable(); pin_based_vm_execution_controls::virtual_nmis::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { pin_ctl_allow0(intel_x64::msrs::ia32_vmx_true_pinbased_ctls::virtual_nmis::mask); pin_based_vm_execution_controls::virtual_nmis::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_virtual_nmi_and_nmi_window_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { pin_ctl_allow1(intel_x64::msrs::ia32_vmx_true_pinbased_ctls::virtual_nmis::mask); pin_based_vm_execution_controls::virtual_nmis::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { pin_ctl_allow1(intel_x64::msrs::ia32_vmx_true_pinbased_ctls::virtual_nmis::mask); proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::nmi_window_exiting::mask); pin_based_vm_execution_controls::virtual_nmis::disable(); primary_processor_based_vm_execution_controls::nmi_window_exiting::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow0(intel_x64::msrs::ia32_vmx_true_procbased_ctls::nmi_window_exiting::mask); primary_processor_based_vm_execution_controls::nmi_window_exiting::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_virtual_apic_address_bits_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow0(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::virtualize_apic_accesses::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(primary_processor_based_vm_execution_controls::activate_secondary_controls::mask); proc_ctl2_allow1(secondary_processor_based_vm_execution_controls::virtualize_apic_accesses::mask); secondary_processor_based_vm_execution_controls::virtualize_apic_accesses::enable(); apic_access_address::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { apic_access_address::set(1U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { apic_access_address::set(1U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { apic_access_address::set(0xff00000000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { apic_access_address::set(0xff00000000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { apic_access_address::set(0x1000U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { apic_access_address::set(0x1000U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_x2apic_mode_and_virtual_apic_access_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow0(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::virtualize_x2apic_mode::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::virtualize_x2apic_mode::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::virtualize_x2apic_mode::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::virtualize_apic_accesses::mask); secondary_processor_based_vm_execution_controls::virtualize_x2apic_mode::enable(); secondary_processor_based_vm_execution_controls::virtualize_apic_accesses::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::virtualize_x2apic_mode::mask); secondary_processor_based_vm_execution_controls::virtualize_x2apic_mode::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_virtual_interrupt_and_external_interrupt_paths( std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow0(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::virtual_interrupt_delivery::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::virtual_interrupt_delivery::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { pin_ctl_allow0(intel_x64::msrs::ia32_vmx_true_pinbased_ctls::external_interrupt_exiting::mask); proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::virtual_interrupt_delivery::mask); secondary_processor_based_vm_execution_controls::virtual_interrupt_delivery::enable(); pin_based_vm_execution_controls::external_interrupt_exiting::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { pin_ctl_allow1(intel_x64::msrs::ia32_vmx_true_pinbased_ctls::external_interrupt_exiting::mask); pin_based_vm_execution_controls::external_interrupt_exiting::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_process_posted_interrupt_checks_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { pin_ctl_allow0(intel_x64::msrs::ia32_vmx_true_pinbased_ctls::process_posted_interrupts::mask); pin_based_vm_execution_controls::process_posted_interrupts::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow0(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); pin_ctl_allow1(intel_x64::msrs::ia32_vmx_true_pinbased_ctls::process_posted_interrupts::mask); pin_based_vm_execution_controls::process_posted_interrupts::enable(); primary_processor_based_vm_execution_controls::activate_secondary_controls::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::virtual_interrupt_delivery::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::virtual_interrupt_delivery::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::virtual_interrupt_delivery::mask); exit_ctl_allow0(intel_x64::msrs::ia32_vmx_true_exit_ctls::acknowledge_interrupt_on_exit::mask); secondary_processor_based_vm_execution_controls::virtual_interrupt_delivery::enable(); vm_exit_controls::acknowledge_interrupt_on_exit::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow1(intel_x64::msrs::ia32_vmx_true_exit_ctls::acknowledge_interrupt_on_exit::mask); vm_exit_controls::acknowledge_interrupt_on_exit::enable(); posted_interrupt_notification_vector::set(0x100UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { posted_interrupt_notification_vector::set(0U); posted_interrupt_descriptor_address::set(1U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { posted_interrupt_descriptor_address::set(0xff00000000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { posted_interrupt_descriptor_address::set(0xff00000000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { posted_interrupt_descriptor_address::set(0x1000U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { posted_interrupt_descriptor_address::set(0x1000U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_vpid_checks_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow0(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::enable_vpid::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::enable_vpid::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::enable_vpid::mask); secondary_processor_based_vm_execution_controls::enable_vpid::enable(); virtual_processor_identifier::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { virtual_processor_identifier::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { virtual_processor_identifier::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_enable_ept_checks_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow0(primary_processor_based_vm_execution_controls::activate_secondary_controls::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(primary_processor_based_vm_execution_controls::activate_secondary_controls::mask); proc_ctl2_allow0(secondary_processor_based_vm_execution_controls::enable_ept::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::enable_ept::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(primary_processor_based_vm_execution_controls::activate_secondary_controls::mask); proc_ctl2_allow1(secondary_processor_based_vm_execution_controls::enable_ept::mask); secondary_processor_based_vm_execution_controls::enable_ept::enable(); @@ -598,123 +598,123 @@ setup_check_control_enable_ept_checks_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow0(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::enable_pml::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::enable_pml::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::enable_pml::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::enable_ept::mask); secondary_processor_based_vm_execution_controls::enable_pml::enable(); secondary_processor_based_vm_execution_controls::enable_ept::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::enable_ept::mask); secondary_processor_based_vm_execution_controls::enable_ept::enable(); pml_address::set(0xff00000000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { pml_address::set(1U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { pml_address::set(1U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { pml_address::set(0x1000U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { pml_address::set(0x1000U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_unrestricted_guests_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::virtual_interrupt_delivery::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::unrestricted_guest::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::enable_ept::mask); secondary_processor_based_vm_execution_controls::unrestricted_guest::enable(); secondary_processor_based_vm_execution_controls::enable_ept::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::enable_ept::mask); secondary_processor_based_vm_execution_controls::enable_ept::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); } static void @@ -722,44 +722,44 @@ setup_check_control_enable_vm_functions_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow0(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::vmcs_shadowing::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::vmcs_shadowing::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::vmcs_shadowing::mask); secondary_processor_based_vm_execution_controls::vmcs_shadowing::enable(); vmread_bitmap_address::set(1U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { vmread_bitmap_address::set(0xff00000000000000U); vmwrite_bitmap_address::set(1U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { vmwrite_bitmap_address::set(0xff00000000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { vmwrite_bitmap_address::set(0xff00000000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { vmread_bitmap_address::set(0x1000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { vmread_bitmap_address::set(0x1000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { vmwrite_bitmap_address::set(0x1000U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { vmwrite_bitmap_address::set(0x1000U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_enable_ept_violation_checks_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow0(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::ept_violation_ve::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::ept_violation_ve::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::virtual_interrupt_delivery::mask); secondary_processor_based_vm_execution_controls::ept_violation_ve::enable(); virtualization_exception_information_address::set(1U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { virtualization_exception_information_address::set(0xff00000000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { virtualization_exception_information_address::set(0xff00000000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { virtualization_exception_information_address::set(0x1000U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { virtualization_exception_information_address::set(0x1000U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_vm_exit_ctls_reserved_properly_set_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_exit_ctls::addr] = 0; vm_exit_controls::set(0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_exit_ctls::addr] = 1; }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_exit_ctls::addr] = 1; }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_exit_ctls::addr] = 0xffffffff00000000UL; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_exit_ctls::addr] = 0xffffffff00000000UL; }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_activate_and_save_preemption_timer_must_be_0_paths( std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { pin_ctl_allow1(intel_x64::msrs::ia32_vmx_true_pinbased_ctls::activate_vmx_preemption_timer::mask); pin_based_vm_execution_controls::activate_vmx_preemption_timer::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { pin_ctl_allow0(intel_x64::msrs::ia32_vmx_true_pinbased_ctls::activate_vmx_preemption_timer::mask); exit_ctl_allow1(intel_x64::msrs::ia32_vmx_true_exit_ctls::save_vmx_preemption_timer_value::mask); pin_based_vm_execution_controls::activate_vmx_preemption_timer::disable(); vm_exit_controls::save_vmx_preemption_timer_value::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow0(intel_x64::msrs::ia32_vmx_true_exit_ctls::save_vmx_preemption_timer_value::mask); vm_exit_controls::save_vmx_preemption_timer_value::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_exit_msr_store_address_paths(std::vector &cfg) { - path.setup = [&] { vm_exit_msr_store_count::set(0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { vm_exit_msr_store_count::set(0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { vm_exit_msr_store_count::set(16UL); vm_exit_msr_store_address::set(0xfU); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { g_eax_cpuid[x64::cpuid::addr_size::addr] = 48U; vm_exit_msr_store_address::set(0xff00000000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { g_eax_cpuid[x64::cpuid::addr_size::addr] = 48U; vm_exit_msr_store_address::set(0xfffffffffff0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { g_eax_cpuid[x64::cpuid::addr_size::addr] = 48U; vm_exit_msr_store_address::set(0x10U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_exit_msr_load_address_paths(std::vector &cfg) { - path.setup = [&] { vm_exit_msr_load_count::set(0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { vm_exit_msr_load_count::set(0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { vm_exit_msr_load_count::set(16UL); vmcs::vm_exit_msr_load_address::set(0xfU); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { g_eax_cpuid[x64::cpuid::addr_size::addr] = 48U; vm_exit_msr_load_address::set(0xff00000000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { g_eax_cpuid[x64::cpuid::addr_size::addr] = 48U; vm_exit_msr_load_address::set(0xfffffffffff0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { g_eax_cpuid[x64::cpuid::addr_size::addr] = 48U; vm_exit_msr_load_address::set(0x10U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_control_vm_entry_ctls_reserved_properly_set_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_entry_ctls::addr] = 0; vm_entry_controls::set(0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_entry_ctls::addr] = 1; }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_entry_ctls::addr] = 1; }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_entry_ctls::addr] = 0xffffffff00000000; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_true_entry_ctls::addr] = 0xffffffff00000000; }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void @@ -1023,45 +1023,45 @@ setup_check_control_event_injection_type_vector_checks_paths(std::vector &cfg) { - path.setup = [&] { vm_entry_msr_load_count::set(0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { vm_entry_msr_load_count::set(0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { vm_entry_msr_load_count::set(16UL); vm_entry_msr_load_address::set(0xfU); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { g_eax_cpuid[x64::cpuid::addr_size::addr] = 48U; vm_entry_msr_load_address::set(0xff00000000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { g_eax_cpuid[x64::cpuid::addr_size::addr] = 48U; vm_entry_msr_load_address::set(0xfffffffffff0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { g_eax_cpuid[x64::cpuid::addr_size::addr] = 48U; vm_entry_msr_load_address::set(0x10U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); } TEST_CASE("check_control_vmx_controls_all") diff --git a/bfvmm/tests/hve/arch/intel_x64/vmcs/test_vmcs_check_guest.cpp b/bfvmm/tests/hve/arch/intel_x64/vmcs/test_vmcs_check_guest.cpp index 3136143af..6c1bba293 100644 --- a/bfvmm/tests/hve/arch/intel_x64/vmcs/test_vmcs_check_guest.cpp +++ b/bfvmm/tests/hve/arch/intel_x64/vmcs/test_vmcs_check_guest.cpp @@ -56,2548 +56,2548 @@ disable_v8086() static void setup_check_guest_cr0_for_unsupported_bits_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { guest_cr0::set(0UL); g_msrs[intel_x64::msrs::ia32_vmx_cr0_fixed0::addr] = 0U; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); secondary_processor_based_vm_execution_controls::unrestricted_guest::enable(); g_msrs[intel_x64::msrs::ia32_vmx_cr0_fixed0::addr] = intel_x64::cr0::paging::mask | intel_x64::cr0::protection_enable::mask; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); secondary_processor_based_vm_execution_controls::unrestricted_guest::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_cr0_verify_paging_enabled_paths(std::vector &cfg) { - path.setup = [&] { guest_cr0::set(0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cr0::set(0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_cr0::paging::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_cr0::paging::enable(); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_cr0::protection_enable::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cr0::protection_enable::enable(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_cr4_for_unsupported_bits_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { guest_cr4::set(0U); g_msrs[intel_x64::msrs::ia32_vmx_cr4_fixed0::addr] = 0; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_cr4_fixed0::addr] = 1; }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_cr4_fixed0::addr] = 1; }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_load_debug_controls_verify_reserved_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::load_debug_controls::mask); vm_entry_controls::load_debug_controls::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::load_debug_controls::mask); vm_entry_controls::load_debug_controls::enable(); guest_ia32_debugctl::reserved::set(0xCU); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_debugctl::reserved::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_debugctl::reserved::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_verify_ia_32e_mode_enabled_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::enable(); guest_cr0::set(0UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_cr0::paging::enable(); guest_cr4::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_cr4::physical_address_extensions::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cr4::physical_address_extensions::enable(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_verify_ia_32e_mode_disabled_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::disable(); guest_cr4::pcid_enable_bit::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_cr4::set(0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cr4::set(0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_cr3_for_unsupported_bits_paths(std::vector &cfg) { - path.setup = [&] { guest_cr3::set(0xff00000000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_cr3::set(0xff00000000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_cr3::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cr3::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_load_debug_controls_verify_dr7_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::load_debug_controls::mask); vm_entry_controls::load_debug_controls::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::load_debug_controls::mask); vm_entry_controls::load_debug_controls::enable(); guest_dr7::set(0x100000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_dr7::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_dr7::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ia32_sysenter_esp_canonical_address_paths(std::vector &cfg) { - path.setup = [&] { guest_ia32_sysenter_esp::set(0x800000000000UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_sysenter_esp::set(0x800000000000UL); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_sysenter_esp::set(0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_sysenter_esp::set(0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ia32_sysenter_eip_canonical_address_paths(std::vector &cfg) { - path.setup = [&] { guest_ia32_sysenter_eip::set(0x800000000000UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_sysenter_eip::set(0x800000000000UL); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_sysenter_eip::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_sysenter_eip::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_verify_load_ia32_perf_global_ctrl_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::load_ia32_perf_global_ctrl::mask); vm_entry_controls::load_ia32_perf_global_ctrl::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::load_ia32_perf_global_ctrl::mask); vm_entry_controls::load_ia32_perf_global_ctrl::enable(); guest_ia32_perf_global_ctrl::reserved::set(0xCU); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_perf_global_ctrl::reserved::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_perf_global_ctrl::reserved::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_verify_load_ia32_pat_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::load_ia32_pat::mask); vm_entry_controls::load_ia32_pat::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::load_ia32_pat::mask); vm_entry_controls::load_ia32_pat::enable(); guest_ia32_pat::set(2ULL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_pat::set(2ULL << 8); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_pat::set(2ULL << 8); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_pat::set(2ULL << 16); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_pat::set(2ULL << 16); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_pat::set(2ULL << 24); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_pat::set(2ULL << 24); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_pat::set(2ULL << 32); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_pat::set(2ULL << 32); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_pat::set(2ULL << 40); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_pat::set(2ULL << 40); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_pat::set(2ULL << 48); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_pat::set(2ULL << 48); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_pat::set(2ULL << 56); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_pat::set(2ULL << 56); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_pat::set(0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_pat::set(0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_verify_load_ia32_efer_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::load_ia32_efer::mask); vm_entry_controls::load_ia32_efer::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::load_ia32_efer::mask); vm_entry_controls::load_ia32_efer::enable(); guest_ia32_efer::reserved::set(0xEUL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::disable(); guest_ia32_efer::reserved::set(0x0UL); guest_ia32_efer::lma::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::enable(); guest_ia32_efer::lma::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_ia32_efer::lma::enable(); guest_cr0::paging::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_cr0::paging::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_cr0::paging::enable(); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::disable(); guest_ia32_efer::lma::disable(); guest_ia32_efer::lme::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_efer::lme::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_efer::lme::disable(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_verify_load_ia32_bndcfgs_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::load_ia32_bndcfgs::mask); vm_entry_controls::load_ia32_bndcfgs::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::load_ia32_bndcfgs::mask); vm_entry_controls::load_ia32_bndcfgs::enable(); guest_ia32_bndcfgs::reserved::set(0xCUL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_bndcfgs::set(0x800000000000UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_bndcfgs::set(0x800000000000UL); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ia32_bndcfgs::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ia32_bndcfgs::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_tr_ti_bit_equals_0_paths(std::vector &cfg) { - path.setup = [&] { guest_tr_selector::ti::set(false); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_selector::ti::set(false); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_tr_selector::ti::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_selector::ti::set(true); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_ldtr_ti_bit_equals_0_paths(std::vector &cfg) { - path.setup = [&] { make_unusable(guest_ldtr_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { make_unusable(guest_ldtr_access_rights::addr); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ldtr_access_rights::addr); guest_ldtr_selector::ti::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ldtr_selector::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ldtr_selector::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ss_and_cs_rpl_are_the_same_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::unrestricted_guest::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); secondary_processor_based_vm_execution_controls::unrestricted_guest::disable(); guest_ss_selector::set(0U); guest_cs_selector::rpl::set(3U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_selector::rpl::set(3U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_selector::rpl::set(3U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_cs_base_is_shifted_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_cs_selector::set(0U); guest_cs_base::set(0x10U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_selector::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_selector::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ss_base_is_shifted_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_ss_selector::set(0U); guest_ss_base::set(0x10U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_selector::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_selector::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ds_base_is_shifted_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_ds_selector::set(0U); guest_ds_base::set(0x10U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ds_selector::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ds_selector::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_es_base_is_shifted_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_es_selector::set(0U); guest_es_base::set(0x10U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_es_selector::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_es_selector::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_fs_base_is_shifted_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_fs_selector::set(0U); guest_fs_base::set(0x10U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_fs_selector::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_fs_selector::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_gs_base_is_shifted_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_gs_selector::set(0U); guest_gs_base::set(0x10U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_gs_selector::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_gs_selector::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_tr_base_is_canonical_paths(std::vector &cfg) { - path.setup = [&] { guest_tr_base::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_base::set(0x800000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_tr_base::set(0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_base::set(0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_fs_base_is_canonical_paths(std::vector &cfg) { - path.setup = [&] { guest_fs_base::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_fs_base::set(0x800000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_fs_base::set(0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_fs_base::set(0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_gs_base_is_canonical_paths(std::vector &cfg) { - path.setup = [&] { guest_gs_base::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_gs_base::set(0x800000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_gs_base::set(0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_gs_base::set(0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ldtr_base_is_canonical_paths(std::vector &cfg) { - path.setup = [&] { make_unusable(guest_ldtr_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { make_unusable(guest_ldtr_access_rights::addr); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ldtr_access_rights::addr); guest_ldtr_base::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ldtr_base::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ldtr_base::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_cs_base_upper_dword_0_paths(std::vector &cfg) { - path.setup = [&] { guest_cs_base::set(0xf00000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_base::set(0xf00000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_base::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_base::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ss_base_upper_dword_0_paths(std::vector &cfg) { - path.setup = [&] { make_unusable(guest_ss_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { make_unusable(guest_ss_access_rights::addr); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ss_access_rights::addr); vmcs::guest_ss_base::set(0xf00000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_base::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_base::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ds_base_upper_dword_0_paths(std::vector &cfg) { - path.setup = [&] { make_unusable(guest_ds_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { make_unusable(guest_ds_access_rights::addr); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ds_access_rights::addr); vmcs::guest_ds_base::set(0xf00000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ds_base::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ds_base::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_es_base_upper_dword_0_paths(std::vector &cfg) { - path.setup = [&] { make_unusable(guest_es_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { make_unusable(guest_es_access_rights::addr); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_es_access_rights::addr); vmcs::guest_es_base::set(0xf00000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_es_base::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_es_base::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_cs_limit_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_cs_limit::set(0x10000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_limit::set(0xffffU); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_limit::set(0xffffU); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ss_limit_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_ss_limit::set(0x10000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_limit::set(0xffffU); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_limit::set(0xffffU); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ds_limit_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_ds_limit::set(0x10000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ds_limit::set(0xffffU); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ds_limit::set(0xffffU); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_es_limit_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_es_limit::set(0x10000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_es_limit::set(0xffffU); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_es_limit::set(0xffffU); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_gs_limit_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_gs_limit::set(0x10000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_gs_limit::set(0xffffU); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_gs_limit::set(0xffffU); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_fs_limit_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_fs_limit::set(0x10000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_fs_limit::set(0xffffU); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_fs_limit::set(0xffffU); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_v8086_cs_access_rights_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_cs_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_access_rights::set(0xf3U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_access_rights::set(0xf3U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_v8086_ss_access_rights_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_ss_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_access_rights::set(0xf3U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_access_rights::set(0xf3U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_v8086_ds_access_rights_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_ds_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ds_access_rights::set(0xf3U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ds_access_rights::set(0xf3U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_v8086_es_access_rights_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_es_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_es_access_rights::set(0xf3U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_es_access_rights::set(0xf3U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_v8086_fs_access_rights_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_fs_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_fs_access_rights::set(0xf3U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_fs_access_rights::set(0xf3U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_v8086_gs_access_rights_paths(std::vector &cfg) { - path.setup = [&] { disable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { disable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { enable_v8086(); guest_gs_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_gs_access_rights::set(0xf3U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_gs_access_rights::set(0xf3U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_cs_access_rights_type_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); proc_ctl_allow0(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::disable(); guest_cs_access_rights::set(3U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); secondary_processor_based_vm_execution_controls::unrestricted_guest::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); secondary_processor_based_vm_execution_controls::unrestricted_guest::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_access_rights::set(7U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_access_rights::set(7U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_ss_access_rights_type_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_ss_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ss_access_rights::addr); vmcs::guest_ss_access_rights::set(3U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_access_rights::set(0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_ds_access_rights_type_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_ds_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ds_access_rights::addr); vmcs::guest_ds_access_rights::set(15U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_ds_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ds_access_rights::set(0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_es_access_rights_type_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_es_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_es_access_rights::addr); vmcs::guest_es_access_rights::set(15U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_es_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_es_access_rights::set(0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_fs_access_rights_type_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_fs_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_fs_access_rights::addr); vmcs::guest_fs_access_rights::set(15U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_fs_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_fs_access_rights::set(0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_gs_access_rights_type_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_gs_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_gs_access_rights::addr); vmcs::guest_gs_access_rights::set(15U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_gs_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_gs_access_rights::set(0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_cs_is_not_a_system_descriptor_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); guest_cs_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_access_rights::s::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_access_rights::s::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ss_is_not_a_system_descriptor_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_ss_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ss_access_rights::addr); guest_ss_access_rights::s::set(false); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_access_rights::s::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_access_rights::s::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ds_is_not_a_system_descriptor_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_ds_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ds_access_rights::addr); guest_ds_access_rights::s::set(false); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ds_access_rights::s::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ds_access_rights::s::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_es_is_not_a_system_descriptor_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_es_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_es_access_rights::addr); guest_es_access_rights::s::set(false); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_es_access_rights::s::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_es_access_rights::s::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_fs_is_not_a_system_descriptor_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_fs_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_fs_access_rights::addr); guest_fs_access_rights::s::set(false); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_fs_access_rights::s::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_fs_access_rights::s::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_gs_is_not_a_system_descriptor_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_gs_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_gs_access_rights::addr); guest_gs_access_rights::s::set(false); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_gs_access_rights::s::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_gs_access_rights::s::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_cs_type_not_equal_3_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); guest_cs_access_rights::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_access_rights::set(0x63U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_access_rights::set(0x63U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_access_rights::set(0x03U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_access_rights::set(0x03U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_cs_dpl_adheres_to_ss_dpl_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); guest_cs_access_rights::set(0x3bU); guest_ss_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_access_rights::set(0x30U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_access_rights::set(0x30U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_access_rights::set(0x6dU); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_access_rights::set(0x6dU); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_access_rights::set(0x60U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_access_rights::set(0x60U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_access_rights::set(2U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_access_rights::set(2U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ss_dpl_must_equal_rpl_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); secondary_processor_based_vm_execution_controls::unrestricted_guest::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); secondary_processor_based_vm_execution_controls::unrestricted_guest::disable(); guest_ss_selector::set(0U); guest_ss_access_rights::set(0x60U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_access_rights::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_access_rights::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ss_dpl_must_equal_zero_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); guest_cs_access_rights::set(0U); vmcs::guest_cr0::protection_enable::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_cs_access_rights::set(3U); guest_ss_access_rights::dpl::set(1U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_ds_dpl_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::unrestricted_guest::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); secondary_processor_based_vm_execution_controls::unrestricted_guest::disable(); make_unusable(guest_ds_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ds_access_rights::addr); vmcs::guest_ds_access_rights::type::set(x64::access_rights::type::read_execute_conforming); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { vmcs::guest_ds_access_rights::type::set(x64::access_rights::type::tss_busy); guest_ds_access_rights::dpl::set(0x0U); guest_ds_selector::rpl::set(0x1U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ds_selector::rpl::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ds_selector::rpl::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_es_dpl_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::unrestricted_guest::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); secondary_processor_based_vm_execution_controls::unrestricted_guest::disable(); make_unusable(guest_es_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_es_access_rights::addr); vmcs::guest_es_access_rights::type::set(x64::access_rights::type::read_execute_conforming); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { vmcs::guest_es_access_rights::type::set(x64::access_rights::type::tss_busy); guest_es_access_rights::dpl::set(0x0U); guest_es_selector::rpl::set(0x1U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_es_selector::rpl::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_es_selector::rpl::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_fs_dpl_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::unrestricted_guest::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); secondary_processor_based_vm_execution_controls::unrestricted_guest::disable(); make_unusable(guest_fs_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_fs_access_rights::addr); vmcs::guest_fs_access_rights::type::set(x64::access_rights::type::read_execute_conforming); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { vmcs::guest_fs_access_rights::type::set(x64::access_rights::type::tss_busy); guest_fs_access_rights::dpl::set(0x0U); guest_fs_selector::rpl::set(0x1U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_fs_selector::rpl::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_fs_selector::rpl::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_gs_dpl_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::unrestricted_guest::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::unrestricted_guest::mask); secondary_processor_based_vm_execution_controls::unrestricted_guest::disable(); make_unusable(guest_gs_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_gs_access_rights::addr); vmcs::guest_gs_access_rights::type::set(x64::access_rights::type::read_execute_conforming); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { vmcs::guest_gs_access_rights::type::set(x64::access_rights::type::tss_busy); guest_gs_access_rights::dpl::set(0x0U); guest_gs_selector::rpl::set(0x1U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_gs_selector::rpl::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_gs_selector::rpl::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_cs_must_be_present_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); guest_cs_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_access_rights::present::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_access_rights::present::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ss_must_be_present_if_usable_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_ss_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_access_rights::set(0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_access_rights::present::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_access_rights::present::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ds_must_be_present_if_usable_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_ds_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_ds_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ds_access_rights::set(0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ds_access_rights::present::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ds_access_rights::present::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_es_must_be_present_if_usable_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_es_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_es_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_es_access_rights::set(0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_es_access_rights::present::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_es_access_rights::present::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_fs_must_be_present_if_usable_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_fs_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_fs_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_fs_access_rights::set(0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_fs_access_rights::present::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_fs_access_rights::present::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_gs_must_be_present_if_usable_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_gs_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_gs_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_gs_access_rights::set(0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_gs_access_rights::present::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_gs_access_rights::present::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_cs_access_rights_reserved_must_be_0_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); guest_cs_access_rights::reserved::set(0xffffffffffU); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_access_rights::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_access_rights::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ss_access_rights_reserved_must_be_0_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_ss_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ss_access_rights::addr); guest_ss_access_rights::reserved::set(0x1FFFFUL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_access_rights::reserved::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_access_rights::reserved::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ds_access_rights_reserved_must_be_0_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_ds_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ds_access_rights::addr); guest_ds_access_rights::reserved::set(0xfffffffUL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ds_access_rights::reserved::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ds_access_rights::reserved::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_es_access_rights_reserved_must_be_0_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_es_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_es_access_rights::addr); guest_es_access_rights::reserved::set(0xfffffffUL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_es_access_rights::reserved::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_es_access_rights::reserved::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_fs_access_rights_reserved_must_be_0_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_fs_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_fs_access_rights::addr); guest_fs_access_rights::reserved::set(0xfffffffUL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_fs_access_rights::reserved::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_fs_access_rights::reserved::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_gs_access_rights_reserved_must_be_0_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_gs_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_gs_access_rights::addr); guest_gs_access_rights::reserved::set(0xfffffffUL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_gs_access_rights::reserved::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_gs_access_rights::reserved::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_cs_db_must_be_0_if_l_equals_1_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::enable(); guest_cs_access_rights::l::set(false); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_access_rights::l::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_access_rights::l::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_access_rights::db::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_access_rights::db::set(true); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_cs_granularity_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); guest_cs_limit::set(0U); guest_cs_access_rights::granularity::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_access_rights::granularity::set(false); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_access_rights::granularity::set(false); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_limit::set(0xf000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_limit::set(0xf000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_ss_granularity_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_ss_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ss_access_rights::addr); guest_ss_limit::set(0U); guest_ss_access_rights::granularity::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_access_rights::granularity::set(false); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_access_rights::granularity::set(false); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_limit::set(0xf000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_limit::set(0xf000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_ds_granularity_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_ds_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ds_access_rights::addr); guest_ds_limit::set(0U); guest_ds_access_rights::granularity::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ds_access_rights::granularity::set(false); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ds_access_rights::granularity::set(false); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_ds_limit::set(0xf000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ds_limit::set(0xf000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_es_granularity_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_es_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_es_access_rights::addr); guest_es_limit::set(0U); guest_es_access_rights::granularity::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_es_access_rights::granularity::set(false); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_es_access_rights::granularity::set(false); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_es_limit::set(0xf000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_es_limit::set(0xf000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_fs_granularity_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_fs_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_fs_access_rights::addr); guest_fs_limit::set(0U); guest_fs_access_rights::granularity::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_fs_access_rights::granularity::set(false); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_fs_access_rights::granularity::set(false); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_fs_limit::set(0xf000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_fs_limit::set(0xf000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_gs_granularity_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_gs_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_gs_access_rights::addr); guest_gs_limit::set(0U); guest_gs_access_rights::granularity::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_gs_access_rights::granularity::set(false); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_gs_access_rights::granularity::set(false); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_gs_limit::set(0xf000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_gs_limit::set(0xf000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_cs_access_rights_remaining_reserved_bit_0_paths( std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); guest_cs_access_rights::set(0xE0000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_cs_access_rights::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cs_access_rights::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ss_access_rights_remaining_reserved_bit_0_paths( std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_ss_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ss_access_rights::addr); guest_ss_access_rights::set(0xe0000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_access_rights::set(0x0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_access_rights::set(0x0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ds_access_rights_remaining_reserved_bit_0_paths( std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_ds_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ds_access_rights::addr); guest_ds_access_rights::set(0xe0000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ds_access_rights::set(0x0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ds_access_rights::set(0x0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_es_access_rights_remaining_reserved_bit_0_paths( std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_es_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_es_access_rights::addr); guest_es_access_rights::set(0xe0000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_es_access_rights::set(0x0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_es_access_rights::set(0x0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_fs_access_rights_remaining_reserved_bit_0_paths( std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_fs_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_fs_access_rights::addr); guest_fs_access_rights::set(0xe0000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_fs_access_rights::set(0x0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_fs_access_rights::set(0x0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_gs_access_rights_remaining_reserved_bit_0_paths( std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_gs_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_gs_access_rights::addr); guest_gs_access_rights::set(0xe0000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_gs_access_rights::set(0x0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_gs_access_rights::set(0x0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_tr_type_must_be_11_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { guest_tr_access_rights::set(3U); entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_tr_access_rights::set(11U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_access_rights::set(11U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_tr_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_access_rights::set(0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_tr_must_be_a_system_descriptor_paths(std::vector &cfg) { - path.setup = [&] { guest_tr_access_rights::s::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_access_rights::s::set(true); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_tr_access_rights::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_access_rights::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_tr_must_be_present_paths(std::vector &cfg) { - path.setup = [&] { guest_tr_access_rights::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_access_rights::set(0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_tr_access_rights::present::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_access_rights::present::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_tr_access_rights_reserved_must_be_0_paths(std::vector &cfg) { - path.setup = [&] { guest_tr_access_rights::set(0xf00U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_access_rights::set(0xf00U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_tr_access_rights::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_access_rights::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_tr_granularity_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_tr_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_tr_access_rights::addr); guest_tr_limit::set(0U); guest_tr_access_rights::granularity::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_tr_access_rights::granularity::set(false); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_access_rights::granularity::set(false); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_tr_limit::set(0xf000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_limit::set(0xf000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_tr_must_be_usable_paths(std::vector &cfg) { - path.setup = [&] { make_unusable(guest_tr_access_rights::addr); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { make_unusable(guest_tr_access_rights::addr); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { make_usable(guest_tr_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { make_usable(guest_tr_access_rights::addr); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_tr_access_rights_remaining_reserved_bit_0_paths( std::vector &cfg) { - path.setup = [&] { guest_tr_access_rights::set(0xe0000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_access_rights::set(0xe0000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_tr_access_rights::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_tr_access_rights::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ldtr_type_must_be_2_paths(std::vector &cfg) { - path.setup = [&] { make_unusable(guest_ldtr_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { make_unusable(guest_ldtr_access_rights::addr); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ldtr_access_rights::addr); guest_ldtr_access_rights::type::set(3U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ldtr_access_rights::type::set(2U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ldtr_access_rights::type::set(2U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ldtr_must_be_a_system_descriptor_paths(std::vector &cfg) { - path.setup = [&] { make_unusable(guest_ldtr_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { make_unusable(guest_ldtr_access_rights::addr); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ldtr_access_rights::addr); guest_ldtr_access_rights::s::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ldtr_access_rights::s::set(false); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ldtr_access_rights::s::set(false); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ldtr_must_be_present_paths(std::vector &cfg) { - path.setup = [&] { make_unusable(guest_ldtr_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { make_unusable(guest_ldtr_access_rights::addr); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ldtr_access_rights::addr); guest_ldtr_access_rights::present::set(false); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ldtr_access_rights::present::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ldtr_access_rights::present::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ldtr_access_rights_reserved_must_be_0_paths(std::vector &cfg) { - path.setup = [&] { make_unusable(guest_ldtr_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { make_unusable(guest_ldtr_access_rights::addr); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ldtr_access_rights::addr); guest_ldtr_access_rights::reserved::set(0x100U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ldtr_access_rights::reserved::set(0x0UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ldtr_access_rights::reserved::set(0x0UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_ldtr_granularity_paths(std::vector &cfg) { - path.setup = [&] { enable_v8086(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { enable_v8086(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { disable_v8086(); make_unusable(guest_ldtr_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ldtr_access_rights::addr); guest_ldtr_limit::set(0U); guest_ldtr_access_rights::granularity::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ldtr_access_rights::granularity::set(false); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ldtr_access_rights::granularity::set(false); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_ldtr_limit::set(0xf000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_ldtr_limit::set(0xf000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_ldtr_access_rights_remaining_reserved_bit_0_paths( std::vector &cfg) { - path.setup = [&] { make_unusable(guest_ldtr_access_rights::addr); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { make_unusable(guest_ldtr_access_rights::addr); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { make_usable(guest_ldtr_access_rights::addr); guest_ldtr_access_rights::reserved::set(0xE0000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ldtr_access_rights::reserved::set(0x0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ldtr_access_rights::reserved::set(0x0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_gdtr_base_must_be_canonical_paths(std::vector &cfg) { - path.setup = [&] { guest_gdtr_base::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_gdtr_base::set(0x800000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_gdtr_base::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_gdtr_base::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_idtr_base_must_be_canonical_paths(std::vector &cfg) { - path.setup = [&] { guest_idtr_base::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_idtr_base::set(0x800000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_idtr_base::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_idtr_base::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_gdtr_limit_reserved_bits_paths(std::vector &cfg) { - path.setup = [&] { guest_gdtr_limit::set(0xf0000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_gdtr_limit::set(0xf0000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_gdtr_limit::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_gdtr_limit::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_idtr_limit_reserved_bits_paths(std::vector &cfg) { - path.setup = [&] { guest_idtr_limit::set(0xf0000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_idtr_limit::set(0xf0000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_idtr_limit::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_idtr_limit::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_rip_upper_bits_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::enable(); guest_cs_access_rights::l::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::disable(); guest_rip::set(0xf00000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_rip::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_rip::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_rip_valid_addr_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::enable(); guest_cs_access_rights::l::set(false); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_cs_access_rights::l::set(true); guest_rip::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_rip::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_rip::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_rflags_reserved_bits_paths(std::vector &cfg) { - path.setup = [&] { guest_rflags::reserved::set(0xffffffffU); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_rflags::reserved::set(0xffffffffU); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_rflags::set(0x0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_rflags::set(0x0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_rflags::set(2U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_rflags::set(2U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_rflags_vm_bit_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::disable(); guest_cr0::protection_enable::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_cr0::protection_enable::disable(); guest_rflags::virtual_8086_mode::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_rflags::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_rflags::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void @@ -2605,86 +2605,86 @@ setup_check_guest_rflag_interrupt_enable_paths(std::vector &cfg) { - path.setup = [&] { guest_activity_state::set(4U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_activity_state::set(4U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_activity_state::set(3U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_activity_state::set(3U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_activity_state_not_hlt_when_dpl_not_0_paths(std::vector &cfg) { - path.setup = [&] { guest_activity_state::set(vmcs::guest_activity_state::shutdown); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_activity_state::set(vmcs::guest_activity_state::shutdown); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_activity_state::set(vmcs::guest_activity_state::hlt); guest_ss_access_rights::dpl::set(1UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_ss_access_rights::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_ss_access_rights::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_must_be_active_if_injecting_blocking_state_paths( std::vector &cfg) { - path.setup = [&] { guest_activity_state::set(vmcs::guest_activity_state::active); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_activity_state::set(vmcs::guest_activity_state::active); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_activity_state::set(vmcs::guest_activity_state::hlt); guest_interruptibility_state::blocking_by_sti::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_interruptibility_state::blocking_by_sti::set(false); guest_interruptibility_state::blocking_by_mov_ss::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_interruptibility_state::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_interruptibility_state::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void @@ -2692,53 +2692,53 @@ setup_check_guest_hlt_valid_interrupts_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::entry_to_smm::mask); vm_entry_controls::entry_to_smm::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::entry_to_smm::mask); vm_entry_controls::entry_to_smm::enable(); guest_activity_state::set(vmcs::guest_activity_state::shutdown); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { guest_activity_state::set(vmcs::guest_activity_state::wait_for_sipi); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_activity_state::set(vmcs::guest_activity_state::wait_for_sipi); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_interruptibility_state_reserved_paths(std::vector &cfg) { - path.setup = [&] { guest_interruptibility_state::reserved::set(0xe0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_interruptibility_state::reserved::set(0xe0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_interruptibility_state::reserved::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_interruptibility_state::reserved::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_interruptibility_state_sti_mov_ss_paths(std::vector &cfg) { - path.setup = [&] { guest_interruptibility_state::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_interruptibility_state::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_interruptibility_state::blocking_by_sti::set(true); guest_interruptibility_state::blocking_by_mov_ss::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_guest_interruptibility_state_sti_paths(std::vector &cfg) { - path.setup = [&] { guest_rflags::interrupt_enable_flag::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_rflags::interrupt_enable_flag::enable(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_rflags::interrupt_enable_flag::disable(); guest_interruptibility_state::blocking_by_sti::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_interruptibility_state::blocking_by_sti::set(false); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_interruptibility_state::blocking_by_sti::set(false); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void @@ -2877,34 +2877,34 @@ setup_check_guest_interruptibility_state_external_interrupt_paths( { using namespace vm_entry_interruption_information; - path.setup = [&] { valid_bit::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { valid_bit::disable(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { valid_bit::enable(); interruption_type::set(interruption_type::non_maskable_interrupt); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { interruption_type::set(interruption_type::external_interrupt); guest_interruptibility_state::blocking_by_sti::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_interruptibility_state::blocking_by_sti::set(false); guest_interruptibility_state::blocking_by_mov_ss::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_interruptibility_state::blocking_by_mov_ss::set(false); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_interruptibility_state::blocking_by_mov_ss::set(false); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void @@ -2912,27 +2912,27 @@ setup_check_guest_interruptibility_state_nmi_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::entry_to_smm::mask); vm_entry_controls::entry_to_smm::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::entry_to_smm::mask); vm_entry_controls::entry_to_smm::enable(); guest_interruptibility_state::blocking_by_smi::set(false); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_interruptibility_state::blocking_by_smi::set(true); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_interruptibility_state::blocking_by_smi::set(true); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void @@ -2970,27 +2970,27 @@ setup_check_guest_interruptibility_state_sti_and_nmi_paths(std::vector &cfg) { - path.setup = [&] { guest_interruptibility_state::enclave_interruption::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_interruptibility_state::enclave_interruption::disable(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_interruptibility_state::enclave_interruption::enable(); guest_interruptibility_state::blocking_by_mov_ss::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_interruptibility_state::blocking_by_mov_ss::disable(); g_cpuid_regs.ebx = 0U; }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { g_ebx_cpuid[intel_x64::cpuid::extended_feature_flags::addr] = intel_x64::cpuid::extended_feature_flags::subleaf0::ebx::sgx::mask; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { g_ebx_cpuid[intel_x64::cpuid::extended_feature_flags::addr] = intel_x64::cpuid::extended_feature_flags::subleaf0::ebx::sgx::mask; }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_pending_debug_exceptions_reserved_paths(std::vector &cfg) { - path.setup = [&] { guest_pending_debug_exceptions::set(0xf0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { guest_pending_debug_exceptions::set(0xf0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_pending_debug_exceptions::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_pending_debug_exceptions::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_pending_debug_exceptions_dbg_ctl_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { guest_interruptibility_state::set(0U); guest_activity_state::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_interruptibility_state::blocking_by_sti::set(true); guest_pending_debug_exceptions::bs::disable(); guest_rflags::trap_flag::enable(); guest_ia32_debugctl::btf::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_pending_debug_exceptions::bs::enable(); guest_rflags::trap_flag::disable(); guest_ia32_debugctl::btf::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_pending_debug_exceptions::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_pending_debug_exceptions::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_pending_debug_exceptions_rtm_paths(std::vector &cfg) { - path.setup = [&] { guest_pending_debug_exceptions::rtm::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_pending_debug_exceptions::rtm::disable(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_pending_debug_exceptions::rtm::enable(); guest_pending_debug_exceptions::reserved::set(0xF0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_pending_debug_exceptions::reserved::set(0x00U); guest_pending_debug_exceptions::b0::disable(); guest_pending_debug_exceptions::b1::disable(); @@ -3127,134 +3127,134 @@ setup_check_guest_pending_debug_exceptions_rtm_paths(std::vector &cfg) { - path.setup = [&] { vmcs_link_pointer::set(0xffffffffffffffffU); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { vmcs_link_pointer::set(0xffffffffffffffffU); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { vmcs_link_pointer::set(0xfU); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { vmcs_link_pointer::set(0xfU); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { vmcs_link_pointer::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { vmcs_link_pointer::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_vmcs_link_pointer_valid_addr_paths(std::vector &cfg) { - path.setup = [&] { vmcs_link_pointer::set(0xffffffffffffffffU); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { vmcs_link_pointer::set(0xffffffffffffffffU); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { vmcs_link_pointer::set(0xf000000000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { vmcs_link_pointer::set(0xf000000000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { vmcs_link_pointer::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { vmcs_link_pointer::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_vmcs_link_pointer_first_word_paths(std::vector &cfg) { - path.setup = [&] { vmcs_link_pointer::set(0xffffffffffffffffU); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { vmcs_link_pointer::set(0xffffffffffffffffU); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { vmcs_link_pointer::set(0x10U); g_phys_to_virt_fails = true; }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { g_phys_to_virt_fails = false; g_test_addr = g_vmcs_link_addr; g_msrs[intel_x64::msrs::ia32_vmx_basic::addr] = 1U; }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_basic::addr] = 0U; proc_ctl_allow0(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::vmcs_shadowing::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::vmcs_shadowing::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::vmcs_shadowing::mask); secondary_processor_based_vm_execution_controls::vmcs_shadowing::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { g_vmcs_link_mem[0] = 0x80000000U; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { g_vmcs_link_mem[0] = 0x80000000U; }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_guest_valid_pdpte_with_ept_disabled_paths(std::vector &cfg) { - path.setup = [&] { guest_cr0::paging::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cr0::paging::disable(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_cr0::paging::enable(); guest_cr4::physical_address_extensions::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_cr4::physical_address_extensions::enable(); entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::disable(); proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); @@ -3262,126 +3262,126 @@ setup_check_guest_valid_pdpte_with_ept_disabled_paths(std::vector &cfg) { - path.setup = [&] { guest_cr0::paging::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_cr0::paging::disable(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_cr0::paging::enable(); guest_cr4::physical_address_extensions::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_cr4::physical_address_extensions::enable(); entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); proc_ctl_allow0(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); vm_entry_controls::ia_32e_mode_guest::disable(); primary_processor_based_vm_execution_controls::activate_secondary_controls::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow0(intel_x64::msrs::ia32_vmx_procbased_ctls2::enable_ept::mask); primary_processor_based_vm_execution_controls::activate_secondary_controls::enable(); secondary_processor_based_vm_execution_controls::enable_ept::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { proc_ctl_allow1(intel_x64::msrs::ia32_vmx_true_procbased_ctls::activate_secondary_controls::mask); proc_ctl2_allow1(intel_x64::msrs::ia32_vmx_procbased_ctls2::enable_ept::mask); secondary_processor_based_vm_execution_controls::enable_ept::enable(); guest_pdpte0::set(x64::pdpte::reserved::mask()); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_pdpte0::reserved::set(0U); guest_pdpte1::set(x64::pdpte::reserved::mask()); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_pdpte1::reserved::set(0U); guest_pdpte2::reserved::set(x64::pdpte::reserved::mask()); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { guest_pdpte2::reserved::set(0U); guest_pdpte3::reserved::set(x64::pdpte::reserved::mask()); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { guest_pdpte3::reserved::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { guest_pdpte3::reserved::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } TEST_CASE("check_guest_state_all") diff --git a/bfvmm/tests/hve/arch/intel_x64/vmcs/test_vmcs_check_host.cpp b/bfvmm/tests/hve/arch/intel_x64/vmcs/test_vmcs_check_host.cpp index c667073ab..373831153 100644 --- a/bfvmm/tests/hve/arch/intel_x64/vmcs/test_vmcs_check_host.cpp +++ b/bfvmm/tests/hve/arch/intel_x64/vmcs/test_vmcs_check_host.cpp @@ -37,595 +37,595 @@ test_vmcs_check(std::vector cfg, void(*func)()) static void setup_check_host_cr0_for_unsupported_bits_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { host_cr0::set(0U); g_msrs[intel_x64::msrs::ia32_vmx_cr0_fixed0::addr] = 0; g_msrs[intel_x64::msrs::ia32_vmx_cr0_fixed1::addr] = 0; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_cr0::set(0xFFFFFFFFFFFFFFFFULL); g_msrs[intel_x64::msrs::ia32_vmx_cr0_fixed0::addr] = 0x00000000FFFFFFFFULL; g_msrs[intel_x64::msrs::ia32_vmx_cr0_fixed1::addr] = 0xFFFFFFFF00000000ULL; }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_cr4_for_unsupported_bits_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { host_cr4::set(0U); g_msrs[intel_x64::msrs::ia32_vmx_cr4_fixed0::addr] = 0; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_cr4_fixed0::addr] = 1; }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_vmx_cr4_fixed0::addr] = 1; }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_cr3_for_unsupported_bits_paths(std::vector &cfg) { - path.setup = [&] { host_cr3::set(0xff00000000000000UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_cr3::set(0xff00000000000000UL); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { host_cr3::set(0x1000UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_cr3::set(0x1000UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_host_ia32_sysenter_esp_canonical_address_paths(std::vector &cfg) { - path.setup = [&] { host_ia32_sysenter_esp::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_ia32_sysenter_esp::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_ia32_sysenter_esp::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_ia32_sysenter_esp::set(0x800000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_ia32_sysenter_eip_canonical_address_paths(std::vector &cfg) { - path.setup = [&] { host_ia32_sysenter_eip::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_ia32_sysenter_eip::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_ia32_sysenter_eip::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_ia32_sysenter_eip::set(0x800000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_verify_load_ia32_perf_global_ctrl_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow0(intel_x64::msrs::ia32_vmx_true_exit_ctls::load_ia32_perf_global_ctrl::mask); vm_exit_controls::load_ia32_perf_global_ctrl::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow1(intel_x64::msrs::ia32_vmx_true_exit_ctls::load_ia32_perf_global_ctrl::mask); vm_exit_controls::load_ia32_perf_global_ctrl::enable(); host_ia32_perf_global_ctrl::set(0xcU); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { host_ia32_perf_global_ctrl::set(0x0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_ia32_perf_global_ctrl::set(0x0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_host_verify_load_ia32_pat_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow0(intel_x64::msrs::ia32_vmx_true_exit_ctls::load_ia32_pat::mask); vm_exit_controls::load_ia32_pat::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow1(intel_x64::msrs::ia32_vmx_true_exit_ctls::load_ia32_pat::mask); vm_exit_controls::load_ia32_pat::enable(); host_ia32_pat::pa0::memory_type::set(2ULL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_ia32_pat::pa0::memory_type::set(x64::memory_type::uncacheable); host_ia32_pat::pa1::memory_type::set(2ULL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_ia32_pat::pa1::memory_type::set(x64::memory_type::uncacheable); host_ia32_pat::pa2::memory_type::set(2ULL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_ia32_pat::pa2::memory_type::set(x64::memory_type::uncacheable); host_ia32_pat::pa3::memory_type::set(2ULL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_ia32_pat::pa3::memory_type::set(x64::memory_type::uncacheable); host_ia32_pat::pa4::memory_type::set(2ULL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_ia32_pat::pa4::memory_type::set(x64::memory_type::uncacheable); host_ia32_pat::pa5::memory_type::set(2ULL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_ia32_pat::pa5::memory_type::set(x64::memory_type::uncacheable); host_ia32_pat::pa6::memory_type::set(2ULL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_ia32_pat::pa6::memory_type::set(x64::memory_type::uncacheable); host_ia32_pat::pa7::memory_type::set(2ULL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { host_ia32_pat::pa7::set(x64::memory_type::uncacheable); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_ia32_pat::pa7::set(x64::memory_type::uncacheable); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_host_verify_load_ia32_efer_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow0(intel_x64::msrs::ia32_vmx_true_exit_ctls::load_ia32_efer::mask); vm_exit_controls::load_ia32_efer::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow1(intel_x64::msrs::ia32_vmx_true_exit_ctls::load_ia32_efer::mask); vm_exit_controls::load_ia32_efer::enable(); host_ia32_efer::reserved::set(0xEUL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow0(intel_x64::msrs::ia32_vmx_true_exit_ctls::host_address_space_size::mask); vm_exit_controls::host_address_space_size::disable(); host_ia32_efer::reserved::set(0x0UL); host_ia32_efer::lma::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow1(intel_x64::msrs::ia32_vmx_true_exit_ctls::host_address_space_size::mask); vm_exit_controls::host_address_space_size::enable(); host_ia32_efer::lma::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_ia32_efer::lma::enable(); host_cr0::paging::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_cr0::paging::enable(); host_ia32_efer::lma::enable(); host_ia32_efer::lme::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow0(intel_x64::msrs::ia32_vmx_true_exit_ctls::host_address_space_size::mask); vm_exit_controls::host_address_space_size::disable(); host_ia32_efer::lme::enable(); host_ia32_efer::lma::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { host_ia32_efer::lme::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_ia32_efer::lme::disable(); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_host_es_selector_rpl_ti_equal_zero_paths(std::vector &cfg) { - path.setup = [&] { host_es_selector::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_es_selector::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_es_selector::ti::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_es_selector::ti::set(true); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_es_selector::ti::set(false); host_es_selector::rpl::set(1UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_cs_selector_rpl_ti_equal_zero_paths(std::vector &cfg) { - path.setup = [&] { host_cs_selector::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_cs_selector::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_cs_selector::ti::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_cs_selector::ti::set(true); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_cs_selector::ti::set(false); host_cs_selector::rpl::set(1UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_ss_selector_rpl_ti_equal_zero_paths(std::vector &cfg) { - path.setup = [&] { host_ss_selector::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_ss_selector::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_ss_selector::ti::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_ss_selector::ti::set(true); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_ss_selector::ti::set(false); host_ss_selector::rpl::set(1UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_ds_selector_rpl_ti_equal_zero_paths(std::vector &cfg) { - path.setup = [&] { host_ds_selector::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_ds_selector::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_ds_selector::ti::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_ds_selector::ti::set(true); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_ds_selector::ti::set(false); host_ds_selector::rpl::set(1UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_fs_selector_rpl_ti_equal_zero_paths(std::vector &cfg) { - path.setup = [&] { host_fs_selector::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_fs_selector::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_fs_selector::ti::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_fs_selector::ti::set(true); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_fs_selector::ti::set(false); host_fs_selector::rpl::set(1UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_gs_selector_rpl_ti_equal_zero_paths(std::vector &cfg) { - path.setup = [&] { host_gs_selector::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_gs_selector::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_gs_selector::ti::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_gs_selector::ti::set(true); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_gs_selector::ti::set(false); host_gs_selector::rpl::set(1UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_tr_selector_rpl_ti_equal_zero_paths(std::vector &cfg) { - path.setup = [&] { host_tr_selector::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_tr_selector::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_tr_selector::ti::set(true); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_tr_selector::ti::set(true); }; + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_tr_selector::ti::set(false); host_tr_selector::rpl::set(1UL); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_cs_not_equal_zero_paths(std::vector &cfg) { - path.setup = [&] { host_cs_selector::set(1UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_cs_selector::set(1UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_cs_selector::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_cs_selector::set(0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_tr_not_equal_zero_paths(std::vector &cfg) { - path.setup = [&] { host_tr_selector::set(1UL); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_tr_selector::set(1UL); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_tr_selector::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_tr_selector::set(0U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_ss_not_equal_zero_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow1(intel_x64::msrs::ia32_vmx_true_exit_ctls::host_address_space_size::mask); vm_exit_controls::host_address_space_size::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow0(intel_x64::msrs::ia32_vmx_true_exit_ctls::host_address_space_size::mask); vm_exit_controls::host_address_space_size::disable(); host_ss_selector::set(0U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { host_ss_selector::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_ss_selector::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_host_fs_canonical_base_address_paths(std::vector &cfg) { - path.setup = [&] { host_fs_base::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_fs_base::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_fs_base::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_fs_base::set(0x800000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_gs_canonical_base_address_paths(std::vector &cfg) { - path.setup = [&] { host_gs_base::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_gs_base::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_gs_base::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_gs_base::set(0x800000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_gdtr_canonical_base_address_paths(std::vector &cfg) { - path.setup = [&] { host_gdtr_base::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_gdtr_base::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_gdtr_base::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_gdtr_base::set(0x800000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_idtr_canonical_base_address_paths(std::vector &cfg) { - path.setup = [&] { host_idtr_base::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_idtr_base::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_idtr_base::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_idtr_base::set(0x800000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_tr_canonical_base_address_paths(std::vector &cfg) { - path.setup = [&] { host_tr_base::set(1U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_tr_base::set(1U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { host_tr_base::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.setup = [&] { host_tr_base::set(0x800000000000U); }; + g_path.throws_exception = true; + cfg.push_back(g_path); } static void setup_check_host_if_outside_ia32e_mode_paths(std::vector &cfg) { - path.setup = [&] { g_msrs[intel_x64::msrs::ia32_efer::addr] = intel_x64::msrs::ia32_efer::lma::mask; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_efer::addr] = intel_x64::msrs::ia32_efer::lma::mask; }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_efer::addr] = 0; entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { vm_entry_controls::ia_32e_mode_guest::disable(); vm_exit_controls::host_address_space_size::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow0(intel_x64::msrs::ia32_vmx_true_exit_ctls::host_address_space_size::mask); vm_exit_controls::host_address_space_size::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_host_address_space_size_exit_ctl_is_set_paths(std::vector &cfg) { - path.setup = [&] { g_msrs[intel_x64::msrs::ia32_efer::addr] = 0; }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_efer::addr] = 0; }; + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { g_msrs[intel_x64::msrs::ia32_efer::addr] = intel_x64::msrs::ia32_efer::lma::mask; exit_ctl_allow0(intel_x64::msrs::ia32_vmx_true_exit_ctls::host_address_space_size::mask); vm_exit_controls::host_address_space_size::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow1(intel_x64::msrs::ia32_vmx_true_exit_ctls::host_address_space_size::mask); vm_exit_controls::host_address_space_size::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_host_address_space_disabled_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow1(intel_x64::msrs::ia32_vmx_true_exit_ctls::host_address_space_size::mask); vm_exit_controls::host_address_space_size::enable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow0(intel_x64::msrs::ia32_vmx_true_exit_ctls::host_address_space_size::mask); entry_ctl_allow1(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_exit_controls::host_address_space_size::disable(); vm_entry_controls::ia_32e_mode_guest::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { entry_ctl_allow0(intel_x64::msrs::ia32_vmx_true_entry_ctls::ia_32e_mode_guest::mask); vm_entry_controls::ia_32e_mode_guest::disable(); host_cr4::pcid_enable_bit::enable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_cr4::set(0U); host_rip::set(0xf000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { host_rip::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_rip::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } static void setup_check_host_address_space_enabled_paths(std::vector &cfg) { - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow0(intel_x64::msrs::ia32_vmx_true_exit_ctls::host_address_space_size::mask); vm_exit_controls::host_address_space_size::disable(); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.throws_exception = false; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { exit_ctl_allow1(intel_x64::msrs::ia32_vmx_true_exit_ctls::host_address_space_size::mask); vm_exit_controls::host_address_space_size::enable(); host_cr4::physical_address_extensions::disable(); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { + g_path.setup = [&] { host_cr4::physical_address_extensions::enable(); host_rip::set(0x800000000000U); }; - path.throws_exception = true; - cfg.push_back(path); + g_path.throws_exception = true; + cfg.push_back(g_path); - path.setup = [&] { host_rip::set(0U); }; - path.throws_exception = false; - cfg.push_back(path); + g_path.setup = [&] { host_rip::set(0U); }; + g_path.throws_exception = false; + cfg.push_back(g_path); } TEST_CASE("check_host_state_all") diff --git a/bfvmm/tests/support/arch/intel_x64/test_support.h b/bfvmm/tests/support/arch/intel_x64/test_support.h index c2927fc7e..b86a23a15 100644 --- a/bfvmm/tests/support/arch/intel_x64/test_support.h +++ b/bfvmm/tests/support/arch/intel_x64/test_support.h @@ -124,7 +124,7 @@ std::map g_mock_mem {{ struct control_flow_path { std::function setup{}; bool throws_exception{false}; -} path; +} g_path; struct cpuid_regs { uint32_t eax; @@ -363,15 +363,15 @@ physint_to_virtptr(uintptr_t ptr) extern "C" void vmcs_launch(state_save_intel_x64 *state_save) noexcept -{ } +{ bfignored(state_save); } extern "C" void vmcs_promote(state_save_intel_x64 *state_save, const void *guest_gdt) noexcept -{ } +{ bfignored(state_save); bfignored(guest_gdt); } extern "C" void vmcs_resume(state_save_intel_x64 *state_save) noexcept -{ } +{ bfignored(state_save); } extern "C" void exit_handler_entry(void) noexcept diff --git a/scripts/cmake/config/default.cmake b/scripts/cmake/config/default.cmake index 2ab989aa8..2113184d8 100644 --- a/scripts/cmake/config/default.cmake +++ b/scripts/cmake/config/default.cmake @@ -247,34 +247,12 @@ set(DEFAULT_CACHE_DIR ${CMAKE_SOURCE_DIR}/../cache "Default cache directory" ) -set(DEFAULT_DEPENDS_DIR ${CMAKE_SOURCE_DIR}/../depends - CACHE INTERNAL - "Default external dependencies directory" -) - -set(DEFAULT_PREFIXES_DIR ${CMAKE_SOURCE_DIR}/../prefixes - CACHE INTERNAL - "Default prefixes directory" -) - if(EXISTS ${DEFAULT_CACHE_DIR}) get_filename_component(DEFAULT_CACHE_DIR "${DEFAULT_CACHE_DIR}" ABSOLUTE) else() set(DEFAULT_CACHE_DIR ${CMAKE_BINARY_DIR}/cache) endif() -if(EXISTS ${DEFAULT_DEPENDS_DIR}) - get_filename_component(DEFAULT_DEPENDS_DIR "${DEFAULT_DEPENDS_DIR}" ABSOLUTE) -else() - set(DEFAULT_DEPENDS_DIR ${CMAKE_BINARY_DIR}/depends) -endif() - -if(EXISTS ${DEFAULT_PREFIXES_DIR}) - get_filename_component(DEFAULT_PREFIXES_DIR "${DEFAULT_PREFIXES_DIR}" ABSOLUTE) -else() - set(DEFAULT_PREFIXES_DIR ${CMAKE_BINARY_DIR}/prefixes) -endif() - add_config( CONFIG_NAME CACHE_DIR CONFIG_TYPE PATH @@ -283,20 +261,18 @@ add_config( SKIP_VALIDATION ) -add_config( - CONFIG_NAME DEPENDS_DIR - CONFIG_TYPE PATH - DEFAULT_VAL ${DEFAULT_DEPENDS_DIR} - DESCRIPTION "External dependencies directory" - SKIP_VALIDATION +# ------------------------------------------------------------------------------ +# Non-configurable directories +# ------------------------------------------------------------------------------ + +set(DEPENDS_DIR ${CMAKE_BINARY_DIR}/depends + CACHE INTERNAL + "External dependencies directory" ) -add_config( - CONFIG_NAME PREFIXES_DIR - CONFIG_TYPE PATH - DEFAULT_VAL ${DEFAULT_PREFIXES_DIR} - DESCRIPTION "Prefixes directory" - SKIP_VALIDATION +set(PREFIXES_DIR ${CMAKE_BINARY_DIR}/prefixes + CACHE INTERNAL + "Prefixes directory" ) # ------------------------------------------------------------------------------ diff --git a/scripts/cmake/config/travis_asan.cmake b/scripts/cmake/config/travis_asan.cmake index 409edef6a..5fa897b58 100644 --- a/scripts/cmake/config/travis_asan.cmake +++ b/scripts/cmake/config/travis_asan.cmake @@ -17,6 +17,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA set(ENABLE_ASAN ON) + set(ENABLE_BUILD_VMM OFF) set(ENABLE_BUILD_USERSPACE OFF) set(ENABLE_BUILD_TEST ON) + +set(CMAKE_BUILD_TYPE Debug) +set(ENABLE_COMPILER_WARNINGS ON) diff --git a/scripts/cmake/config/travis_codecov.cmake b/scripts/cmake/config/travis_codecov.cmake index 3eee71cdb..4469a7b19 100644 --- a/scripts/cmake/config/travis_codecov.cmake +++ b/scripts/cmake/config/travis_codecov.cmake @@ -17,6 +17,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA set(ENABLE_CODECOV ON) + set(ENABLE_BUILD_VMM OFF) set(ENABLE_BUILD_USERSPACE OFF) set(ENABLE_BUILD_TEST ON) + +set(CMAKE_BUILD_TYPE Debug) +set(ENABLE_COMPILER_WARNINGS ON) diff --git a/scripts/cmake/config/travis_format.cmake b/scripts/cmake/config/travis_format.cmake index c1ab576f5..0d18171e5 100644 --- a/scripts/cmake/config/travis_format.cmake +++ b/scripts/cmake/config/travis_format.cmake @@ -17,6 +17,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA set(ENABLE_FORMAT ON) + set(ENABLE_BUILD_VMM ON) set(ENABLE_BUILD_USERSPACE ON) set(ENABLE_BUILD_TEST ON) + +set(CMAKE_BUILD_TYPE Debug) +set(ENABLE_COMPILER_WARNINGS ON) diff --git a/scripts/cmake/config/travis_shared.cmake b/scripts/cmake/config/travis_shared.cmake index 293d5f645..4dccbe9dc 100644 --- a/scripts/cmake/config/travis_shared.cmake +++ b/scripts/cmake/config/travis_shared.cmake @@ -18,3 +18,6 @@ set(BUILD_SHARED_LIBS ON) set(BUILD_STATIC_LIBS OFF) + +set(CMAKE_BUILD_TYPE Release) +set(ENABLE_COMPILER_WARNINGS ON) diff --git a/scripts/cmake/config/travis_static.cmake b/scripts/cmake/config/travis_static.cmake index 63136b268..a79faab0b 100644 --- a/scripts/cmake/config/travis_static.cmake +++ b/scripts/cmake/config/travis_static.cmake @@ -18,3 +18,6 @@ set(BUILD_SHARED_LIBS OFF) set(BUILD_STATIC_LIBS ON) + +set(CMAKE_BUILD_TYPE Release) +set(ENABLE_COMPILER_WARNINGS ON) diff --git a/scripts/cmake/config/travis_tidy.cmake b/scripts/cmake/config/travis_tidy.cmake index 5778f2f3b..ff575f11c 100644 --- a/scripts/cmake/config/travis_tidy.cmake +++ b/scripts/cmake/config/travis_tidy.cmake @@ -17,6 +17,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA set(ENABLE_TIDY ON) + set(ENABLE_BUILD_VMM OFF) set(ENABLE_BUILD_USERSPACE OFF) set(ENABLE_BUILD_TEST ON) + +set(CMAKE_BUILD_TYPE Debug) +set(ENABLE_COMPILER_WARNINGS ON) diff --git a/scripts/cmake/config/travis_usan.cmake b/scripts/cmake/config/travis_usan.cmake index f65b73dc0..c1aaeaf1d 100644 --- a/scripts/cmake/config/travis_usan.cmake +++ b/scripts/cmake/config/travis_usan.cmake @@ -17,6 +17,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA set(ENABLE_USAN ON) + set(ENABLE_BUILD_VMM OFF) set(ENABLE_BUILD_USERSPACE OFF) set(ENABLE_BUILD_TEST ON) + +set(CMAKE_BUILD_TYPE Debug) +set(ENABLE_COMPILER_WARNINGS ON) diff --git a/scripts/cmake/depends/libcxx.cmake b/scripts/cmake/depends/libcxx.cmake index a10d3f8a2..f4328b914 100644 --- a/scripts/cmake/depends/libcxx.cmake +++ b/scripts/cmake/depends/libcxx.cmake @@ -27,6 +27,7 @@ if((ENABLE_BUILD_VMM OR ENABLE_BUILD_TEST) AND NOT WIN32) generate_flags( vmm + NOWARNINGS ) list(APPEND LIBCXX_CONFIGURE_FLAGS diff --git a/scripts/cmake/depends/libcxxabi.cmake b/scripts/cmake/depends/libcxxabi.cmake index ee9f3cd1a..a92202be1 100644 --- a/scripts/cmake/depends/libcxxabi.cmake +++ b/scripts/cmake/depends/libcxxabi.cmake @@ -27,6 +27,7 @@ if((ENABLE_BUILD_VMM OR ENABLE_BUILD_TEST) AND NOT WIN32) generate_flags( vmm + NOWARNINGS ) list(APPEND LIBCXXABI_CONFIGURE_FLAGS diff --git a/scripts/cmake/depends/newlib.cmake b/scripts/cmake/depends/newlib.cmake index 5af2729dc..2a57101d5 100644 --- a/scripts/cmake/depends/newlib.cmake +++ b/scripts/cmake/depends/newlib.cmake @@ -40,6 +40,7 @@ if((ENABLE_BUILD_VMM OR ENABLE_BUILD_TEST) AND NOT WIN32) generate_flags( vmm + NOWARNINGS ) list(APPEND LD_FLAGS diff --git a/scripts/cmake/macros.cmake b/scripts/cmake/macros.cmake index 270bee8c4..e060db849 100644 --- a/scripts/cmake/macros.cmake +++ b/scripts/cmake/macros.cmake @@ -189,8 +189,9 @@ endmacro(include_external_extensions) # @param CXX_FLAGS Additional CXX flags to add to CMAKE_CXX_FLAGS # function(generate_flags PREFIX) + set(options NOWARNINGS) set(multiVal C_FLAGS CXX_FLAGS) - cmake_parse_arguments(ARG "" "${oneVal}" "${multiVal}" ${ARGN}) + cmake_parse_arguments(ARG "${options}" "" "${multiVal}" ${ARGN}) list(APPEND _C_FLAGS ${ARG_C_FLAGS}) list(APPEND _CXX_FLAGS ${ARG_CXX_FLAGS}) @@ -244,14 +245,19 @@ function(generate_flags PREFIX) message(FATAL_ERROR "Invalid prefix: ${PREFIX}") endif() - if(ENABLE_COMPILER_WARNINGS) + if(ENABLE_COMPILER_WARNINGS AND NOT ARG_NOWARNINGS) list(APPEND _C_FLAGS ${BFFLAGS_WARNING_C}) list(APPEND _CXX_FLAGS ${BFFLAGS_WARNING_CXX}) endif() - if(BUILD_TYPE STREQUAL "Release") - list(APPEND _C_FLAGS -O3 -DNDEBUG) - list(APPEND _CXX_FLAGS -O3 -DNDEBUG) + if(CMAKE_BUILD_TYPE STREQUAL "Release") + if(NOT WIN32) + list(APPEND _C_FLAGS -Werror) + list(APPEND _CXX_FLAGS -Werror) + else() + list(APPEND _C_FLAGS /WX) + list(APPEND _CXX_FLAGS /WX) + endif() endif() string(REPLACE ";" " " _C_FLAGS "${_C_FLAGS}") @@ -942,7 +948,6 @@ macro(init_project) ${SOURCE_BFSDK_DIR}/include ${SOURCE_BFELF_LOADER_DIR}/include ${SOURCE_BFINTRINSICS_DIR}/include - ${SOURCE_BFVMM_DIR}/include ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/include )