Skip to content

Commit 8ad8e34

Browse files
authored
Merge pull request #974 from rianquinn/master
Adds missing unit tests for the loader
2 parents 1728c30 + dcbe193 commit 8ad8e34

File tree

841 files changed

+32442
-20383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

841 files changed

+32442
-20383
lines changed

.github/workflows/ccpp.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ jobs:
3333
shell: bash
3434
- name: Validate Source Formatting
3535
run: |
36-
sudo tar -xzvf hypervisor/utils/linux/llvm-bareflank.tar.gz -C /usr/lib/
36+
wget https://github.com/Bareflank/llvm-project/releases/download/v11.0.0-bsl/llvm-bareflank.tar.gz
37+
sudo tar -xzvf llvm-bareflank.tar.gz -C /usr/lib/
3738
export PATH="/usr/lib/llvm-bareflank/bin:$PATH"
3839
mkdir build && cd build
3940
cmake -GNinja -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_BUILD_TYPE=DEBUG -DENABLE_CLANG_FORMAT=ON ../hypervisor
@@ -60,7 +61,8 @@ jobs:
6061
shell: bash
6162
- name: Validate Compliance
6263
run: |
63-
sudo tar -xzvf hypervisor/utils/linux/llvm-bareflank.tar.gz -C /usr/lib/
64+
wget https://github.com/Bareflank/llvm-project/releases/download/v11.0.0-bsl/llvm-bareflank.tar.gz
65+
sudo tar -xzvf llvm-bareflank.tar.gz -C /usr/lib/
6466
export PATH="/usr/lib/llvm-bareflank/bin:$PATH"
6567
mkdir build && cd build
6668
cmake -GNinja -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_BUILD_TYPE=CLANG_TIDY -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON -DBSL_DEBUG_LEVEL=bsl::VVV ../hypervisor
@@ -80,7 +82,8 @@ jobs:
8082
shell: bash
8183
- name: Validate Compliance
8284
run: |
83-
sudo tar -xzvf hypervisor/utils/linux/llvm-bareflank.tar.gz -C /usr/lib/
85+
wget https://github.com/Bareflank/llvm-project/releases/download/v11.0.0-bsl/llvm-bareflank.tar.gz
86+
sudo tar -xzvf llvm-bareflank.tar.gz -C /usr/lib/
8487
chmod +x hypervisor/utils/linux/include-what-you-use
8588
sudo cp hypervisor/utils/linux/include-what-you-use /usr/lib/llvm-bareflank/bin/
8689
export PATH="/usr/lib/llvm-bareflank/bin:$PATH"

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ if(NOT CMAKE_BUILD_TYPE STREQUAL RELEASE AND NOT CMAKE_BUILD_TYPE STREQUAL MINSI
5050
add_subdirectory(example/default/tests)
5151
add_subdirectory(kernel/tests)
5252
add_subdirectory(lib/tests)
53-
#add_subdirectory(loader/tests)
53+
add_subdirectory(loader/tests)
5454
add_subdirectory(runtime/tests)
5555
add_subdirectory(syscall/tests)
5656
add_subdirectory(vmmctl/tests)

cmake/depend/bsl.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
FetchContent_Declare(
2323
bsl
2424
GIT_REPOSITORY https://github.com/bareflank/bsl.git
25-
GIT_TAG a79658a00c653f567775fdbd43a8924403843329
25+
GIT_TAG 4215efc76ff0997a44f39a16f6f84b487cef5bf6
2626
)
2727

2828
FetchContent_GetProperties(bsl)

cmake/function/hypervisor_add_integration_target.cmake

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@ macro(hypervisor_add_integration_target NAME)
2727
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
2828
add_custom_target(integration_${NAME}
2929
COMMAND sync
30-
COMMAND sudo vmmctl/vmmctl start ${CMAKE_BINARY_DIR}/kernel ${CMAKE_BINARY_DIR}/ext_cross_compile/build/integration/integration_${NAME} | true
30+
COMMAND sudo vmmctl/vmmctl start ${CMAKE_BINARY_DIR}/kernel_bin ${CMAKE_BINARY_DIR}/ext_cross_compile/build/integration/integration_${NAME} | true
3131
COMMAND sudo vmmctl/vmmctl dump
3232
VERBATIM
3333
)
3434
add_custom_target(${NAME}
3535
COMMAND sync
36-
COMMAND sudo vmmctl/vmmctl start ${CMAKE_BINARY_DIR}/kernel ${CMAKE_BINARY_DIR}/ext_cross_compile/build/integration/integration_${NAME} | true
36+
COMMAND sudo vmmctl/vmmctl start ${CMAKE_BINARY_DIR}/kernel_bin ${CMAKE_BINARY_DIR}/ext_cross_compile/build/integration/integration_${NAME} | true
3737
COMMAND sudo vmmctl/vmmctl dump
3838
VERBATIM
3939
)
4040
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
4141
add_custom_target(integration_${NAME}
42-
COMMAND vmmctl/vmmctl start ${CMAKE_BINARY_DIR}/kernel ${CMAKE_BINARY_DIR}/ext_cross_compile/build/integration/integration_${NAME} | true
42+
COMMAND vmmctl/vmmctl start ${CMAKE_BINARY_DIR}/kernel_bin ${CMAKE_BINARY_DIR}/ext_cross_compile/build/integration/integration_${NAME} | true
4343
COMMAND vmmctl/vmmctl dump
4444
VERBATIM
4545
)
4646
add_custom_target(${NAME}
47-
COMMAND vmmctl/vmmctl start ${CMAKE_BINARY_DIR}/kernel ${CMAKE_BINARY_DIR}/ext_cross_compile/build/integration/integration_${NAME} | true
47+
COMMAND vmmctl/vmmctl start ${CMAKE_BINARY_DIR}/kernel_bin ${CMAKE_BINARY_DIR}/ext_cross_compile/build/integration/integration_${NAME} | true
4848
COMMAND vmmctl/vmmctl dump
4949
VERBATIM
5050
)

kernel/integration/CMakeLists.txt

+28-1
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,44 @@ list(APPEND HEADERS
2828
hypervisor_add_integration(bf_callback_op_register_bootstrap HEADERS)
2929
hypervisor_add_integration(bf_callback_op_register_fail HEADERS)
3030
hypervisor_add_integration(bf_callback_op_register_vmexit HEADERS)
31+
hypervisor_add_integration(bf_debug_op_dump_ext HEADERS)
32+
hypervisor_add_integration(bf_debug_op_dump_huge_pool HEADERS)
33+
hypervisor_add_integration(bf_debug_op_dump_page_pool HEADERS)
34+
hypervisor_add_integration(bf_debug_op_dump_vm HEADERS)
35+
hypervisor_add_integration(bf_debug_op_dump_vmexit_log HEADERS)
36+
hypervisor_add_integration(bf_debug_op_dump_vp HEADERS)
37+
hypervisor_add_integration(bf_debug_op_dump_vs HEADERS)
38+
hypervisor_add_integration(bf_debug_op_out HEADERS)
39+
hypervisor_add_integration(bf_debug_op_write_c HEADERS)
40+
hypervisor_add_integration(bf_debug_op_write_str HEADERS)
3141
hypervisor_add_integration(bf_handle_op_close_handle HEADERS)
3242
hypervisor_add_integration(bf_handle_op_open_handle HEADERS)
43+
hypervisor_add_integration(bf_intrinsic_op_rdmsr HEADERS)
44+
hypervisor_add_integration(bf_intrinsic_op_wrmsr HEADERS)
45+
hypervisor_add_integration(bf_mem_op_alloc_huge HEADERS)
46+
hypervisor_add_integration(bf_mem_op_alloc_page HEADERS)
3347
hypervisor_add_integration(bf_vm_op_create_vm HEADERS)
3448
hypervisor_add_integration(bf_vm_op_destroy_vm HEADERS)
3549
hypervisor_add_integration(bf_vm_op_map_direct HEADERS)
50+
hypervisor_add_integration(bf_vm_op_tlb_flush HEADERS)
3651
hypervisor_add_integration(bf_vm_op_unmap_direct HEADERS)
37-
#hypervisor_add_integration(bf_vm_op_unmap_direct_broadcast HEADERS)
3852
hypervisor_add_integration(bf_vp_op_create_vp HEADERS)
3953
hypervisor_add_integration(bf_vp_op_destroy_vp HEADERS)
4054
hypervisor_add_integration(bf_vs_op_create_vs HEADERS)
4155
hypervisor_add_integration(bf_vs_op_destroy_vs HEADERS)
56+
hypervisor_add_integration(bf_vs_op_advance_ip_and_run_current HEADERS)
57+
hypervisor_add_integration(bf_vs_op_advance_ip_and_run HEADERS)
58+
hypervisor_add_integration(bf_vs_op_advance_ip_and_set_active HEADERS)
59+
hypervisor_add_integration(bf_vs_op_clear HEADERS)
60+
hypervisor_add_integration(bf_vs_op_init_as_root HEADERS)
61+
hypervisor_add_integration(bf_vs_op_migrate HEADERS)
62+
hypervisor_add_integration(bf_vs_op_promote HEADERS)
63+
hypervisor_add_integration(bf_vs_op_read HEADERS)
64+
hypervisor_add_integration(bf_vs_op_run_current HEADERS)
65+
hypervisor_add_integration(bf_vs_op_run HEADERS)
66+
hypervisor_add_integration(bf_vs_op_set_active HEADERS)
67+
hypervisor_add_integration(bf_vs_op_tlb_flush HEADERS)
68+
hypervisor_add_integration(bf_vs_op_write HEADERS)
4269
hypervisor_add_integration(fast_fail_exit_from_bootstrap_with_no_syscall HEADERS)
4370
hypervisor_add_integration(fast_fail_exit_from_bootstrap_with_segfault HEADERS)
4471
hypervisor_add_integration(fast_fail_exit_from_bootstrap_with_wait HEADERS)

kernel/integration/CMakeLists_Targets.cmake

+28-1
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,44 @@ include(${CMAKE_CURRENT_LIST_DIR}/../../cmake/function/hypervisor_add_integratio
2424
hypervisor_add_integration_target(bf_callback_op_register_bootstrap)
2525
hypervisor_add_integration_target(bf_callback_op_register_fail)
2626
hypervisor_add_integration_target(bf_callback_op_register_vmexit)
27+
hypervisor_add_integration_target(bf_debug_op_dump_ext)
28+
hypervisor_add_integration_target(bf_debug_op_dump_huge_pool)
29+
hypervisor_add_integration_target(bf_debug_op_dump_page_pool)
30+
hypervisor_add_integration_target(bf_debug_op_dump_vm)
31+
hypervisor_add_integration_target(bf_debug_op_dump_vmexit_log)
32+
hypervisor_add_integration_target(bf_debug_op_dump_vp)
33+
hypervisor_add_integration_target(bf_debug_op_dump_vs)
34+
hypervisor_add_integration_target(bf_debug_op_out)
35+
hypervisor_add_integration_target(bf_debug_op_write_c)
36+
hypervisor_add_integration_target(bf_debug_op_write_str)
2737
hypervisor_add_integration_target(bf_handle_op_close_handle)
2838
hypervisor_add_integration_target(bf_handle_op_open_handle)
39+
hypervisor_add_integration_target(bf_intrinsic_op_rdmsr)
40+
hypervisor_add_integration_target(bf_intrinsic_op_wrmsr)
41+
hypervisor_add_integration_target(bf_mem_op_alloc_huge)
42+
hypervisor_add_integration_target(bf_mem_op_alloc_page)
2943
hypervisor_add_integration_target(bf_vm_op_create_vm)
3044
hypervisor_add_integration_target(bf_vm_op_destroy_vm)
3145
hypervisor_add_integration_target(bf_vm_op_map_direct)
46+
hypervisor_add_integration_target(bf_vm_op_tlb_flush)
3247
hypervisor_add_integration_target(bf_vm_op_unmap_direct)
33-
hypervisor_add_integration_target(bf_vm_op_unmap_direct_broadcast)
3448
hypervisor_add_integration_target(bf_vp_op_create_vp)
3549
hypervisor_add_integration_target(bf_vp_op_destroy_vp)
3650
hypervisor_add_integration_target(bf_vs_op_create_vs)
3751
hypervisor_add_integration_target(bf_vs_op_destroy_vs)
52+
hypervisor_add_integration_target(bf_vs_op_advance_ip_and_run_current)
53+
hypervisor_add_integration_target(bf_vs_op_advance_ip_and_run)
54+
hypervisor_add_integration_target(bf_vs_op_advance_ip_and_set_active)
55+
hypervisor_add_integration_target(bf_vs_op_clear)
56+
hypervisor_add_integration_target(bf_vs_op_init_as_root)
57+
hypervisor_add_integration_target(bf_vs_op_migrate)
58+
hypervisor_add_integration_target(bf_vs_op_promote)
59+
hypervisor_add_integration_target(bf_vs_op_read)
60+
hypervisor_add_integration_target(bf_vs_op_run_current)
61+
hypervisor_add_integration_target(bf_vs_op_run)
62+
hypervisor_add_integration_target(bf_vs_op_set_active)
63+
hypervisor_add_integration_target(bf_vs_op_tlb_flush)
64+
hypervisor_add_integration_target(bf_vs_op_write)
3865
hypervisor_add_integration_target(fast_fail_exit_from_bootstrap_with_no_syscall)
3966
hypervisor_add_integration_target(fast_fail_exit_from_bootstrap_with_segfault)
4067
hypervisor_add_integration_target(fast_fail_exit_from_bootstrap_with_wait)

kernel/integration/bf_callback_op_register_bootstrap.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ namespace syscall
102102
/// called on each PP while the hypervisor is being bootstrapped.
103103
///
104104
/// <!-- inputs/outputs -->
105-
/// @param ppid the physical process to bootstrap
105+
/// @param ppid0 the physical process to bootstrap
106106
///
107107
extern "C" void
108-
bootstrap_entry(bsl::safe_u16::value_type const ppid) noexcept
108+
bootstrap_entry(bsl::safe_u16::value_type const ppid0) noexcept
109109
{
110110
/// NOTE:
111111
/// - Call into the bootstrap handler. This entry point serves as a
@@ -121,7 +121,7 @@ namespace syscall
121121
g_mut_intrinsic, // --
122122
g_mut_vp_pool, // --
123123
g_mut_vs_pool, // --
124-
bsl::to_u16(ppid))};
124+
bsl::to_u16(ppid0))};
125125

126126
if (bsl::unlikely(!ret)) {
127127
bsl::print<bsl::V>() << bsl::here();
@@ -241,26 +241,26 @@ namespace syscall
241241
extern "C" void
242242
ext_main_entry(bsl::uint32 const version) noexcept
243243
{
244-
bsl::safe_umx hndl{};
245-
bf_status_t ret{};
244+
bsl::safe_umx mut_hndl{};
245+
bf_status_t mut_ret{};
246246

247247
if (bsl::unlikely(!bf_is_spec1_supported(bsl::to_u32(version)))) {
248248
bsl::error() << "integration test not supported\n" << bsl::here();
249249
return bf_control_op_exit();
250250
}
251251

252-
ret = bf_handle_op_open_handle_impl(BF_SPEC_ID1_VAL.get(), hndl.data());
253-
integration::require(ret == BF_STATUS_SUCCESS);
252+
mut_ret = bf_handle_op_open_handle_impl(BF_SPEC_ID1_VAL.get(), mut_hndl.data());
253+
integration::require(mut_ret == BF_STATUS_SUCCESS);
254254

255255
// register nullptr
256-
ret = bf_callback_op_register_bootstrap_impl(hndl.get(), nullptr);
257-
integration::require(ret != BF_STATUS_SUCCESS);
256+
mut_ret = bf_callback_op_register_bootstrap_impl(mut_hndl.get(), nullptr);
257+
integration::require(mut_ret != BF_STATUS_SUCCESS);
258258

259259
// register twice
260-
ret = bf_callback_op_register_bootstrap_impl(hndl.get(), &bootstrap_entry);
261-
integration::require(ret == BF_STATUS_SUCCESS);
262-
ret = bf_callback_op_register_bootstrap_impl(hndl.get(), &bootstrap_entry);
263-
integration::require(ret != BF_STATUS_SUCCESS);
260+
mut_ret = bf_callback_op_register_bootstrap_impl(mut_hndl.get(), &bootstrap_entry);
261+
integration::require(mut_ret == BF_STATUS_SUCCESS);
262+
mut_ret = bf_callback_op_register_bootstrap_impl(mut_hndl.get(), &bootstrap_entry);
263+
integration::require(mut_ret != BF_STATUS_SUCCESS);
264264

265265
bsl::debug() << "success. remaining backtrace is expected\n" << bsl::here();
266266
return bf_control_op_exit();

kernel/integration/bf_callback_op_register_fail.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ namespace syscall
102102
/// called on each PP while the hypervisor is being bootstrapped.
103103
///
104104
/// <!-- inputs/outputs -->
105-
/// @param ppid the physical process to bootstrap
105+
/// @param ppid0 the physical process to bootstrap
106106
///
107107
extern "C" void
108-
bootstrap_entry(bsl::safe_u16::value_type const ppid) noexcept
108+
bootstrap_entry(bsl::safe_u16::value_type const ppid0) noexcept
109109
{
110110
/// NOTE:
111111
/// - Call into the bootstrap handler. This entry point serves as a
@@ -121,7 +121,7 @@ namespace syscall
121121
g_mut_intrinsic, // --
122122
g_mut_vp_pool, // --
123123
g_mut_vs_pool, // --
124-
bsl::to_u16(ppid))};
124+
bsl::to_u16(ppid0))};
125125

126126
if (bsl::unlikely(!ret)) {
127127
bsl::print<bsl::V>() << bsl::here();
@@ -241,26 +241,26 @@ namespace syscall
241241
extern "C" void
242242
ext_main_entry(bsl::uint32 const version) noexcept
243243
{
244-
bsl::safe_umx hndl{};
245-
bf_status_t ret{};
244+
bsl::safe_umx mut_hndl{};
245+
bf_status_t mut_ret{};
246246

247247
if (bsl::unlikely(!bf_is_spec1_supported(bsl::to_u32(version)))) {
248248
bsl::error() << "integration test not supported\n" << bsl::here();
249249
return bf_control_op_exit();
250250
}
251251

252-
ret = bf_handle_op_open_handle_impl(BF_SPEC_ID1_VAL.get(), hndl.data());
253-
integration::require(ret == BF_STATUS_SUCCESS);
252+
mut_ret = bf_handle_op_open_handle_impl(BF_SPEC_ID1_VAL.get(), mut_hndl.data());
253+
integration::require(mut_ret == BF_STATUS_SUCCESS);
254254

255255
// register nullptr
256-
ret = bf_callback_op_register_fail_impl(hndl.get(), nullptr);
257-
integration::require(ret != BF_STATUS_SUCCESS);
256+
mut_ret = bf_callback_op_register_fail_impl(mut_hndl.get(), nullptr);
257+
integration::require(mut_ret != BF_STATUS_SUCCESS);
258258

259259
// register twice
260-
ret = bf_callback_op_register_fail_impl(hndl.get(), &fail_entry);
261-
integration::require(ret == BF_STATUS_SUCCESS);
262-
ret = bf_callback_op_register_fail_impl(hndl.get(), &fail_entry);
263-
integration::require(ret != BF_STATUS_SUCCESS);
260+
mut_ret = bf_callback_op_register_fail_impl(mut_hndl.get(), &fail_entry);
261+
integration::require(mut_ret == BF_STATUS_SUCCESS);
262+
mut_ret = bf_callback_op_register_fail_impl(mut_hndl.get(), &fail_entry);
263+
integration::require(mut_ret != BF_STATUS_SUCCESS);
264264

265265
bsl::debug() << "success. remaining backtrace is expected\n" << bsl::here();
266266
return bf_control_op_exit();

kernel/integration/bf_callback_op_register_vmexit.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ namespace syscall
102102
/// called on each PP while the hypervisor is being bootstrapped.
103103
///
104104
/// <!-- inputs/outputs -->
105-
/// @param ppid the physical process to bootstrap
105+
/// @param ppid0 the physical process to bootstrap
106106
///
107107
extern "C" void
108-
bootstrap_entry(bsl::safe_u16::value_type const ppid) noexcept
108+
bootstrap_entry(bsl::safe_u16::value_type const ppid0) noexcept
109109
{
110110
/// NOTE:
111111
/// - Call into the bootstrap handler. This entry point serves as a
@@ -121,7 +121,7 @@ namespace syscall
121121
g_mut_intrinsic, // --
122122
g_mut_vp_pool, // --
123123
g_mut_vs_pool, // --
124-
bsl::to_u16(ppid))};
124+
bsl::to_u16(ppid0))};
125125

126126
if (bsl::unlikely(!ret)) {
127127
bsl::print<bsl::V>() << bsl::here();
@@ -241,26 +241,26 @@ namespace syscall
241241
extern "C" void
242242
ext_main_entry(bsl::uint32 const version) noexcept
243243
{
244-
bsl::safe_umx hndl{};
245-
bf_status_t ret{};
244+
bsl::safe_umx mut_hndl{};
245+
bf_status_t mut_ret{};
246246

247247
if (bsl::unlikely(!bf_is_spec1_supported(bsl::to_u32(version)))) {
248248
bsl::error() << "integration test not supported\n" << bsl::here();
249249
return bf_control_op_exit();
250250
}
251251

252-
ret = bf_handle_op_open_handle_impl(BF_SPEC_ID1_VAL.get(), hndl.data());
253-
integration::require(ret == BF_STATUS_SUCCESS);
252+
mut_ret = bf_handle_op_open_handle_impl(BF_SPEC_ID1_VAL.get(), mut_hndl.data());
253+
integration::require(mut_ret == BF_STATUS_SUCCESS);
254254

255255
// register nullptr
256-
ret = bf_callback_op_register_vmexit_impl(hndl.get(), nullptr);
257-
integration::require(ret != BF_STATUS_SUCCESS);
256+
mut_ret = bf_callback_op_register_vmexit_impl(mut_hndl.get(), nullptr);
257+
integration::require(mut_ret != BF_STATUS_SUCCESS);
258258

259259
// register twice
260-
ret = bf_callback_op_register_vmexit_impl(hndl.get(), &vmexit_entry);
261-
integration::require(ret == BF_STATUS_SUCCESS);
262-
ret = bf_callback_op_register_vmexit_impl(hndl.get(), &vmexit_entry);
263-
integration::require(ret != BF_STATUS_SUCCESS);
260+
mut_ret = bf_callback_op_register_vmexit_impl(mut_hndl.get(), &vmexit_entry);
261+
integration::require(mut_ret == BF_STATUS_SUCCESS);
262+
mut_ret = bf_callback_op_register_vmexit_impl(mut_hndl.get(), &vmexit_entry);
263+
integration::require(mut_ret != BF_STATUS_SUCCESS);
264264

265265
bsl::debug() << "success. remaining backtrace is expected\n" << bsl::here();
266266
return bf_control_op_exit();

0 commit comments

Comments
 (0)