mirror of
https://github.com/Bareflank/hypervisor
synced 2026-08-17 06:23:04 -04:00
Merge pull request #970 from rianquinn/master
Fix issues with the fast fail logic
This commit is contained in:
commit
ace605a80b
7 changed files with 62 additions and 9 deletions
|
|
@ -22,7 +22,7 @@
|
|||
FetchContent_Declare(
|
||||
bsl
|
||||
GIT_REPOSITORY https://github.com/bareflank/bsl.git
|
||||
GIT_TAG 1874ee51007ecf49537215899bce7afb5a3d7227
|
||||
GIT_TAG 2c5f979d3f2f6718a55f474f957e7eadc25f3dbc
|
||||
)
|
||||
|
||||
FetchContent_GetProperties(bsl)
|
||||
|
|
|
|||
|
|
@ -231,8 +231,8 @@ target_link_libraries(kernel PRIVATE
|
|||
# Install
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# if(CMAKE_BUILD_TYPE STREQUAL RELEASE OR CMAKE_BUILD_TYPE STREQUAL MINSIZEREL)
|
||||
# add_custom_command(TARGET kernel POST_BUILD COMMAND ${CMAKE_STRIP} kernel)
|
||||
# endif()
|
||||
if(CMAKE_BUILD_TYPE STREQUAL RELEASE OR CMAKE_BUILD_TYPE STREQUAL MINSIZEREL)
|
||||
add_custom_command(TARGET kernel POST_BUILD COMMAND ${CMAKE_STRIP} kernel)
|
||||
endif()
|
||||
|
||||
install(TARGETS kernel DESTINATION bin)
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ namespace mk
|
|||
constexpr auto VMCS_HOST_FS_BASE{0x6C06_umx};
|
||||
/// @brief encoding for: host_gs_base
|
||||
constexpr auto VMCS_HOST_GS_BASE{0x6C08_umx};
|
||||
/// @brief encoding for: host_tr_baseD
|
||||
/// @brief encoding for: host_tr_base
|
||||
constexpr auto VMCS_HOST_TR_BASE{0x6C0A_umx};
|
||||
/// @brief encoding for: host_gdtr_base
|
||||
constexpr auto VMCS_HOST_GDTR_BASE{0x6C0C_umx};
|
||||
|
|
|
|||
|
|
@ -51,9 +51,6 @@ namespace mk
|
|||
fast_fail(tls_t &mut_tls, intrinsic_t &mut_intrinsic, ext_t *const pmut_ext) noexcept
|
||||
-> bsl::errc_type
|
||||
{
|
||||
bsl::print() << bsl::red << "\nfast failing:";
|
||||
bsl::print() << bsl::rst << bsl::endl;
|
||||
|
||||
if (nullptr != pmut_ext) {
|
||||
auto const ret{pmut_ext->fail(mut_tls, mut_intrinsic)};
|
||||
if (bsl::unlikely(!ret)) {
|
||||
|
|
|
|||
|
|
@ -334,7 +334,9 @@ skip_load_pat:
|
|||
mov rax, [rsp + 0x010]
|
||||
vmload rax
|
||||
|
||||
sti
|
||||
vmrun rax
|
||||
cli
|
||||
|
||||
mov rax, [rsp + 0x010]
|
||||
vmsave rax
|
||||
|
|
|
|||
|
|
@ -186,6 +186,18 @@ namespace lib
|
|||
return IOCTL_INVALID_HNDL != m_hndl;
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Returns the handle associated with this IOCTL
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return Returns the handle associated with this IOCTL
|
||||
///
|
||||
[[nodiscard]] constexpr auto
|
||||
handle() const noexcept -> bsl::safe_i32
|
||||
{
|
||||
return m_hndl;
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Sends a request to the driver without read or writing
|
||||
/// data.
|
||||
|
|
@ -205,7 +217,7 @@ namespace lib
|
|||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-vararg)
|
||||
bsl::safe_i32 const ret{::ioctl(m_hndl.get(), req.get())};
|
||||
bsl::safe_i32 const ret{::ioctl(m_hndl.get(), req.get(), nullptr)};
|
||||
if (bsl::unlikely(ret.is_neg())) {
|
||||
bsl::error() << "ioctl failed\n";
|
||||
return bsl::to_i64(ret);
|
||||
|
|
@ -278,6 +290,36 @@ namespace lib
|
|||
return bsl::to_i64(ret);
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Writes data to the device driver
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @param req the request
|
||||
/// @param data an integral to write to the IOCTL
|
||||
/// @return Returns a negative error code on failure, or
|
||||
/// something 0 or positive on success.
|
||||
///
|
||||
[[nodiscard]] constexpr auto
|
||||
// NOLINTNEXTLINE(bsl-using-ident-unique-namespace)
|
||||
write(bsl::safe_umx const &req, bsl::safe_i64 const &data) const noexcept -> bsl::safe_i64
|
||||
{
|
||||
bsl::expects(data.is_valid_and_checked());
|
||||
|
||||
if (bsl::unlikely(IOCTL_INVALID_HNDL == m_hndl)) {
|
||||
bsl::error() << "ioctl failed because the handle to the driver is invalid\n";
|
||||
return bsl::safe_i64::magic_neg_1();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-vararg)
|
||||
bsl::safe_i32 const ret{::ioctl(m_hndl.get(), req.get(), data.get())};
|
||||
if (bsl::unlikely(ret.is_neg())) {
|
||||
bsl::error() << "ioctl failed\n";
|
||||
return bsl::to_i64(ret);
|
||||
}
|
||||
|
||||
return bsl::to_i64(ret);
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Reads/writes data from/to the device driver
|
||||
///
|
||||
|
|
|
|||
|
|
@ -252,6 +252,18 @@ namespace lib
|
|||
return nullptr != m_hndl;
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Returns the handle associated with this IOCTL
|
||||
///
|
||||
/// <!-- inputs/outputs -->
|
||||
/// @return Returns the handle associated with this IOCTL
|
||||
///
|
||||
[[nodiscard]] constexpr auto
|
||||
handle() const noexcept -> HANDLE
|
||||
{
|
||||
return m_hndl;
|
||||
}
|
||||
|
||||
/// <!-- description -->
|
||||
/// @brief Sends a request to the driver without read or writing
|
||||
/// data.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue