Skip to content

Commit 7abf187

Browse files
committed
check if 0.5.1mshv crates work with az linux 2
Signed-off-by: Simon Davies <[email protected]>
1 parent 2fb20c0 commit 7abf187

File tree

6 files changed

+14
-116
lines changed

6 files changed

+14
-116
lines changed

Cargo.lock

Lines changed: 3 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hyperlight_host/Cargo.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ gdbstub_arch = { version = "0.3.1", optional = true }
7171
seccompiler = { version = "0.5.0", optional = true }
7272
kvm-bindings = { version = "0.12", features = ["fam-wrappers"], optional = true }
7373
kvm-ioctls = { version = "0.22", optional = true }
74-
mshv-bindings2 = { package="mshv-bindings", version = "=0.2.1", optional = true }
75-
mshv-ioctls2 = { package="mshv-ioctls", version = "=0.2.1", optional = true}
76-
mshv-bindings3 = { package="mshv-bindings", version = "0.5.1", optional = true }
77-
mshv-ioctls3 = { package="mshv-ioctls", version = "0.5.1", optional = true}
74+
mshv-bindings = { version = "0.5" }
75+
mshv-ioctls = { version = "0.5"}
7876

7977
[dev-dependencies]
8078
uuid = { version = "1.17.0", features = ["v4"] }
@@ -125,8 +123,8 @@ executable_heap = []
125123
print_debug = []
126124
crashdump = ["dep:tempfile"] # Dumps the VM state to a file on unexpected errors or crashes. The path of the file will be printed on stdout and logged. This feature can only be used in debug builds.
127125
kvm = ["dep:kvm-bindings", "dep:kvm-ioctls"]
128-
mshv2 = ["dep:mshv-bindings2", "dep:mshv-ioctls2"]
129-
mshv3 = ["dep:mshv-bindings3", "dep:mshv-ioctls3"]
126+
mshv2 = []
127+
mshv3 = []
130128
# This enables easy debug in the guest
131129
gdb = ["dep:gdbstub", "dep:gdbstub_arch"]
132130
fuzzing = ["hyperlight-common/fuzzing"]

src/hyperlight_host/src/error.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
#[cfg(mshv2)]
18-
extern crate mshv_ioctls2 as mshv_ioctls;
19-
20-
#[cfg(mshv3)]
21-
extern crate mshv_ioctls3 as mshv_ioctls;
22-
2317
use std::array::TryFromSliceError;
2418
use std::cell::{BorrowError, BorrowMutError};
2519
use std::convert::Infallible;

src/hyperlight_host/src/hypervisor/gdb/mshv_debug.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
#[cfg(mshv2)]
18-
extern crate mshv_bindings2 as mshv_bindings;
19-
#[cfg(mshv2)]
20-
extern crate mshv_ioctls2 as mshv_ioctls;
21-
22-
#[cfg(mshv3)]
23-
extern crate mshv_bindings3 as mshv_bindings;
24-
#[cfg(mshv3)]
25-
extern crate mshv_ioctls3 as mshv_ioctls;
26-
2717
use std::collections::HashMap;
2818

2919
use mshv_bindings::{

src/hyperlight_host/src/hypervisor/hyperv_linux.rs

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,9 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
#[cfg(mshv2)]
18-
extern crate mshv_bindings2 as mshv_bindings;
19-
#[cfg(mshv2)]
20-
extern crate mshv_ioctls2 as mshv_ioctls;
21-
22-
#[cfg(mshv3)]
23-
extern crate mshv_bindings3 as mshv_bindings;
24-
#[cfg(mshv3)]
25-
extern crate mshv_ioctls3 as mshv_ioctls;
26-
2717
use std::fmt::{Debug, Formatter};
2818

2919
use log::{error, LevelFilter};
30-
#[cfg(mshv2)]
31-
use mshv_bindings::hv_message;
3220
#[cfg(gdb)]
3321
use mshv_bindings::{
3422
hv_intercept_parameters, hv_intercept_type_HV_INTERCEPT_TYPE_EXCEPTION,
@@ -41,7 +29,7 @@ use mshv_bindings::{
4129
hv_register_name_HV_X64_REGISTER_RIP, hv_register_value, mshv_user_mem_region,
4230
FloatingPointUnit, SegmentRegister, SpecialRegisters, StandardRegisters,
4331
};
44-
#[cfg(mshv3)]
32+
#[cfg(any(mshv3, mshv2))]
4533
use mshv_bindings::{
4634
hv_partition_property_code_HV_PARTITION_PROPERTY_SYNTHETIC_PROC_FEATURES,
4735
hv_partition_synthetic_processor_features,
@@ -71,7 +59,8 @@ use crate::{log_then_return, new_error, Result};
7159
mod debug {
7260
use std::sync::{Arc, Mutex};
7361

74-
use super::mshv_bindings::hv_x64_exception_intercept_message;
62+
use mshv_bindings::hv_x64_exception_intercept_message;
63+
7564
use super::{HypervLinuxDriver, *};
7665
use crate::hypervisor::gdb::{DebugMsg, DebugResponse, VcpuStopReason, X86_64Regs};
7766
use crate::hypervisor::handlers::DbgMemAccessHandlerCaller;
@@ -319,9 +308,7 @@ impl HypervLinuxDriver {
319308
) -> Result<Self> {
320309
let mshv = Mshv::new()?;
321310
let pr = Default::default();
322-
#[cfg(mshv2)]
323-
let vm_fd = mshv.create_vm_with_config(&pr)?;
324-
#[cfg(mshv3)]
311+
#[cfg(any(mshv2, mshv3))]
325312
let vm_fd = {
326313
// It's important to avoid create_vm() and explicitly use
327314
// create_vm_with_args() with an empty arguments structure
@@ -577,12 +564,7 @@ impl Hypervisor for HypervLinuxDriver {
577564
#[cfg(gdb)]
578565
const EXCEPTION_INTERCEPT: hv_message_type = hv_message_type_HVMSG_X64_EXCEPTION_INTERCEPT;
579566

580-
#[cfg(mshv2)]
581-
let run_result = {
582-
let hv_message: hv_message = Default::default();
583-
&self.vcpu_fd.run(hv_message)
584-
};
585-
#[cfg(mshv3)]
567+
#[cfg(any(mshv2, mshv3))]
586568
let run_result = &self.vcpu_fd.run();
587569

588570
let result = match run_result {

src/hyperlight_host/src/mem/memory_region.rs

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
#[cfg(mshv2)]
18-
extern crate mshv_bindings2 as mshv_bindings;
19-
#[cfg(mshv2)]
20-
extern crate mshv_ioctls2 as mshv_ioctls;
21-
22-
#[cfg(mshv3)]
23-
extern crate mshv_bindings3 as mshv_bindings;
24-
#[cfg(mshv3)]
25-
extern crate mshv_ioctls3 as mshv_ioctls;
26-
2717
use std::ops::Range;
2818

2919
use bitflags::bitflags;
@@ -32,11 +22,7 @@ use hyperlight_common::mem::PAGE_SHIFT;
3222
use hyperlight_common::mem::PAGE_SIZE_USIZE;
3323
#[cfg(mshv)]
3424
use mshv_bindings::{hv_x64_memory_intercept_message, mshv_user_mem_region};
35-
#[cfg(mshv2)]
36-
use mshv_bindings::{
37-
HV_MAP_GPA_EXECUTABLE, HV_MAP_GPA_PERMISSIONS_NONE, HV_MAP_GPA_READABLE, HV_MAP_GPA_WRITABLE,
38-
};
39-
#[cfg(mshv3)]
25+
#[cfg(any(mshv2, mshv3))]
4026
use mshv_bindings::{
4127
MSHV_SET_MEM_BIT_EXECUTABLE, MSHV_SET_MEM_BIT_UNMAP, MSHV_SET_MEM_BIT_WRITABLE,
4228
};
@@ -232,26 +218,7 @@ impl From<MemoryRegion> for mshv_user_mem_region {
232218
let guest_pfn = region.guest_region.start as u64 >> PAGE_SHIFT;
233219
let userspace_addr = region.host_region.start as u64;
234220

235-
#[cfg(mshv2)]
236-
{
237-
let flags = region.flags.iter().fold(0, |acc, flag| {
238-
let flag_value = match flag {
239-
MemoryRegionFlags::NONE => HV_MAP_GPA_PERMISSIONS_NONE,
240-
MemoryRegionFlags::READ => HV_MAP_GPA_READABLE,
241-
MemoryRegionFlags::WRITE => HV_MAP_GPA_WRITABLE,
242-
MemoryRegionFlags::EXECUTE => HV_MAP_GPA_EXECUTABLE,
243-
_ => 0, // ignore any unknown flags
244-
};
245-
acc | flag_value
246-
});
247-
mshv_user_mem_region {
248-
guest_pfn,
249-
size,
250-
userspace_addr,
251-
flags,
252-
}
253-
}
254-
#[cfg(mshv3)]
221+
#[cfg(any(mshv2, mshv3))]
255222
{
256223
let flags: u8 = region.flags.iter().fold(0, |acc, flag| {
257224
let flag_value = match flag {

0 commit comments

Comments
 (0)