-
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 #119 from softickllc/irqfd
shim: Initial support for KVM_IRQFD
- Loading branch information
Showing
9 changed files
with
200 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/// @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_IRQFD_HPP | ||
#define KVM_IRQFD_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 padding field | ||
constexpr auto PAD_SIZE_IRQFD{16_umx}; | ||
/// @struct kvm_irqfd | ||
/// | ||
/// <!-- description --> | ||
/// @brief Allows setting an eventfd to directly trigger a guest interrupt. | ||
/// | ||
struct kvm_irqfd final | ||
{ | ||
/** @brief specifies the file descriptor to use as the eventfd */ | ||
bsl::uint32 fd; | ||
/** @brief specifies the irqchip pin toggled by this event*/ | ||
bsl::uint32 gsi; | ||
/** @brief The flag is used to remove irqfd */ | ||
bsl::uint32 flags; | ||
/** @brief Additional eventfd the user must pass when KVM_IRQFD_FLAG_RESAMPLE is set */ | ||
bsl::uint32 resamplefd; | ||
/** @brief TODO*/ | ||
bsl::array<bsl::uint8, PAD_SIZE_IRQFD.get()> pad; | ||
}; | ||
} | ||
|
||
#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 irqfd{mut_vcpu.send(shim::KVM_IRQFD)}; | ||
integration::verify(irqfd.is_pos()); | ||
integration::verify(irqfd >= 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
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