-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from softickllc/setgetlapic
shim: Initial support for KVM_{GET,SET}_LAPIC
- Loading branch information
Showing
13 changed files
with
308 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* @copyright | ||
* Copyright (C) 2020 Assured Information Security, Inc. | ||
* | ||
* @copyright | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* @copyright | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* @copyright | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
#ifndef KVM_LAPIC_STATE_HPP | ||
#define KVM_LAPIC_STATE_HPP | ||
|
||
#include <bsl/array.hpp> | ||
#include <bsl/convert.hpp> | ||
#include <bsl/safe_integral.hpp> | ||
|
||
#pragma pack(push, 1) | ||
|
||
namespace shim | ||
{ | ||
/// @brief defines the size of the padding3 field | ||
constexpr auto KVM_APIC_REG_SIZE{1024_umx}; | ||
/// @struct kvm_lapic_state | ||
/// | ||
/// <!-- description --> | ||
/// @brief see /include/uapi/linux/kvm.h in Linux for more details. | ||
/// | ||
struct kvm_lapic_state final | ||
{ | ||
/// @brief TODO | ||
bsl::array<bsl::uint8, KVM_APIC_REG_SIZE.get()> regs; | ||
}; | ||
|
||
} | ||
|
||
#pragma pack(pop) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/// @copyright | ||
/// Copyright (C) 2020 Assured Information Security, Inc. | ||
/// | ||
/// @copyright | ||
/// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
/// of this software and associated documentation files (the "Software"), to deal | ||
/// in the Software without restriction, including without limitation the rights | ||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
/// copies of the Software, and to permit persons to whom the Software is | ||
/// furnished to do so, subject to the following conditions: | ||
/// | ||
/// @copyright | ||
/// The above copyright notice and this permission notice shall be included in | ||
/// all copies or substantial portions of the Software. | ||
/// | ||
/// @copyright | ||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
/// SOFTWARE. | ||
|
||
#include <integration_utils.hpp> | ||
#include <ioctl_t.hpp> | ||
#include <shim_platform_interface.hpp> | ||
|
||
#include <bsl/convert.hpp> | ||
#include <bsl/enable_color.hpp> | ||
#include <bsl/exit_code.hpp> | ||
#include <bsl/safe_integral.hpp> | ||
|
||
/// <!-- description --> | ||
/// @brief Provides the main entry point for this application. | ||
/// | ||
/// <!-- inputs/outputs --> | ||
/// @return bsl::exit_success on success, bsl::exit_failure otherwise. | ||
/// | ||
[[nodiscard]] auto | ||
main() noexcept -> bsl::exit_code | ||
{ | ||
bsl::enable_color(); | ||
integration::ioctl_t mut_system_ctl{shim::DEVICE_NAME}; | ||
auto const vmfd{mut_system_ctl.send(shim::KVM_CREATE_VM)}; | ||
integration::ioctl_t mut_vm{bsl::to_i32(vmfd)}; | ||
auto const vcpufd{mut_vm.send(shim::KVM_CREATE_VCPU)}; | ||
integration::ioctl_t mut_vcpu{bsl::to_i32(vcpufd)}; | ||
constexpr auto mut_ret{0_i64}; | ||
{ | ||
auto const lapic{mut_vcpu.send(shim::KVM_GET_LAPIC)}; | ||
integration::verify(lapic.is_pos()); | ||
integration::verify(lapic >= mut_ret.get()); | ||
} | ||
return bsl::exit_success; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/// @copyright | ||
/// Copyright (C) 2020 Assured Information Security, Inc. | ||
/// | ||
/// @copyright | ||
/// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
/// of this software and associated documentation files (the "Software"), to deal | ||
/// in the Software without restriction, including without limitation the rights | ||
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
/// copies of the Software, and to permit persons to whom the Software is | ||
/// furnished to do so, subject to the following conditions: | ||
/// | ||
/// @copyright | ||
/// The above copyright notice and this permission notice shall be included in | ||
/// all copies or substantial portions of the Software. | ||
/// | ||
/// @copyright | ||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
/// SOFTWARE. | ||
|
||
#include <integration_utils.hpp> | ||
#include <ioctl_t.hpp> | ||
#include <shim_platform_interface.hpp> | ||
|
||
#include <bsl/convert.hpp> | ||
#include <bsl/enable_color.hpp> | ||
#include <bsl/exit_code.hpp> | ||
#include <bsl/safe_integral.hpp> | ||
|
||
/// <!-- description --> | ||
/// @brief Provides the main entry point for this application. | ||
/// | ||
/// <!-- inputs/outputs --> | ||
/// @return bsl::exit_success on success, bsl::exit_failure otherwise. | ||
/// | ||
[[nodiscard]] auto | ||
main() noexcept -> bsl::exit_code | ||
{ | ||
bsl::enable_color(); | ||
integration::ioctl_t mut_system_ctl{shim::DEVICE_NAME}; | ||
auto const vmfd{mut_system_ctl.send(shim::KVM_CREATE_VM)}; | ||
integration::ioctl_t mut_vm{bsl::to_i32(vmfd)}; | ||
auto const vcpufd{mut_vm.send(shim::KVM_CREATE_VCPU)}; | ||
integration::ioctl_t mut_vcpu{bsl::to_i32(vcpufd)}; | ||
constexpr auto mut_ret{0_i64}; | ||
{ | ||
auto const lapic{mut_vcpu.send(shim::KVM_SET_LAPIC)}; | ||
integration::verify(lapic.is_pos()); | ||
integration::verify(lapic >= mut_ret.get()); | ||
} | ||
return bsl::exit_success; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.