Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing definitions for SVM ExitCode required for CVM guest #111

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 178 additions & 7 deletions mshv-bindings/src/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* automatically generated by rust-bindgen 0.65.1 */
/* automatically generated by rust-bindgen 0.66.1 */
/*
* Kernel (uapi) headers used for these bindings are as follows:
* include/hyperv/hvgdk_mini.h
Expand Down Expand Up @@ -262,8 +262,15 @@ pub const HVCALL_DELETE_PORT: u32 = 88;
pub const HVCALL_DISCONNECT_PORT: u32 = 91;
pub const HVCALL_POST_MESSAGE: u32 = 92;
pub const HVCALL_SIGNAL_EVENT: u32 = 93;
pub const HVCALL_INITIALIZE_EVENT_LOG_BUFFER_GROUP: u32 = 96;
pub const HVCALL_FINALIZE_EVENT_LOG_BUFFER_GROUP: u32 = 97;
pub const HVCALL_CREATE_EVENT_LOG_BUFFER: u32 = 98;
pub const HVCALL_DELETE_EVENT_LOG_BUFFER: u32 = 99;
pub const HVCALL_MAP_EVENT_LOG_BUFFER: u32 = 100;
pub const HVCALL_UNMAP_EVENT_LOG_BUFFER: u32 = 101;
pub const HVCALL_SET_EVENT_LOG_GROUP_SOURCES: u32 = 102;
pub const HVCALL_RELEASE_EVENT_LOG_BUFFER: u32 = 103;
pub const HVCALL_FLUSH_EVENT_LOG_BUFFER: u32 = 104;
pub const HVCALL_POST_DEBUG_DATA: u32 = 105;
pub const HVCALL_RETRIEVE_DEBUG_DATA: u32 = 106;
pub const HVCALL_RESET_DEBUG_SESSION: u32 = 107;
Expand Down Expand Up @@ -371,6 +378,7 @@ pub const HV_MAP_GPA_USER_EXECUTABLE: u32 = 8;
pub const HV_MAP_GPA_EXECUTABLE: u32 = 12;
pub const HV_MAP_GPA_PERMISSIONS_MASK: u32 = 15;
pub const HV_MAP_GPA_ADJUSTABLE: u32 = 32768;
pub const HV_MAP_GPA_NOT_CACHED: u32 = 2097152;
pub const HVHDK_H_VERSION: u32 = 25212;
pub const HV_X64_REGISTER_CLASS_GENERAL: u32 = 0;
pub const HV_X64_REGISTER_CLASS_IP: u32 = 1;
Expand Down Expand Up @@ -414,6 +422,7 @@ pub const HV_X64_PENDING_EXCEPTION: u32 = 3;
pub const HV_GPA_ATTRIBUTE_INTERCEPT_MAX_RANGES: u32 = 29;
pub const HV_GET_SET_VP_STATE_TYPE_PFN: u32 = 2147483648;
pub const HV_ROOT_SCHEDULER_MAX_VPS_PER_CHILD_PARTITION: u32 = 1024;
pub const HV_EVENTLOG_BUFFER_INDEX_NONE: u32 = 4294967295;
pub const HV_DISPATCH_VP_FLAG_CLEAR_INTERCEPT_SUSPEND: u32 = 1;
pub const HV_DISPATCH_VP_FLAG_ENABLE_CALLER_INTERRUPTS: u32 = 2;
pub const HV_DISPATCH_VP_FLAG_SET_CALLER_SPEC_CTRL: u32 = 4;
Expand All @@ -436,6 +445,7 @@ pub const MSHV_IRQFD_FLAG_DEASSIGN: u32 = 1;
pub const MSHV_IRQFD_FLAG_RESAMPLE: u32 = 2;
pub const MSHV_IOCTL: u32 = 184;
pub const MSHV_DIAG_IOCTL: u32 = 185;
pub const MSHV_TRACE_IOCTL: u32 = 186;
pub const MSHV_CREATE_DEVICE_TEST: u32 = 1;
pub const MSHV_DEV_VFIO_GROUP: u32 = 1;
pub const MSHV_DEV_VFIO_GROUP_ADD: u32 = 1;
Expand Down Expand Up @@ -3430,14 +3440,36 @@ impl hv_register_vsm_partition_config__bindgen_ty_1 {
}
}
#[inline]
pub fn intercept_restore_partition_time(&self) -> __u64 {
unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u64) }
}
#[inline]
pub fn set_intercept_restore_partition_time(&mut self, val: __u64) {
unsafe {
let val: u64 = ::std::mem::transmute(val);
self._bitfield_1.set(13usize, 1u8, val as u64)
}
}
#[inline]
pub fn intercept_not_present(&self) -> __u64 {
unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u64) }
}
#[inline]
pub fn set_intercept_not_present(&mut self, val: __u64) {
unsafe {
let val: u64 = ::std::mem::transmute(val);
self._bitfield_1.set(14usize, 1u8, val as u64)
}
}
#[inline]
pub fn mbz(&self) -> __u64 {
unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 51u8) as u64) }
unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 49u8) as u64) }
}
#[inline]
pub fn set_mbz(&mut self, val: __u64) {
unsafe {
let val: u64 = ::std::mem::transmute(val);
self._bitfield_1.set(13usize, 51u8, val as u64)
self._bitfield_1.set(15usize, 49u8, val as u64)
}
}
#[inline]
Expand All @@ -3452,6 +3484,8 @@ impl hv_register_vsm_partition_config__bindgen_ty_1 {
intercept_cpuid_unimplemented: __u64,
intercept_unrecoverable_exception: __u64,
intercept_page: __u64,
intercept_restore_partition_time: __u64,
intercept_not_present: __u64,
mbz: __u64,
) -> __BindgenBitfieldUnit<[u8; 8usize]> {
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default();
Expand Down Expand Up @@ -3501,7 +3535,17 @@ impl hv_register_vsm_partition_config__bindgen_ty_1 {
let intercept_page: u64 = unsafe { ::std::mem::transmute(intercept_page) };
intercept_page as u64
});
__bindgen_bitfield_unit.set(13usize, 51u8, {
__bindgen_bitfield_unit.set(13usize, 1u8, {
let intercept_restore_partition_time: u64 =
unsafe { ::std::mem::transmute(intercept_restore_partition_time) };
intercept_restore_partition_time as u64
});
__bindgen_bitfield_unit.set(14usize, 1u8, {
let intercept_not_present: u64 =
unsafe { ::std::mem::transmute(intercept_not_present) };
intercept_not_present as u64
});
__bindgen_bitfield_unit.set(15usize, 49u8, {
let mbz: u64 = unsafe { ::std::mem::transmute(mbz) };
mbz as u64
});
Expand Down Expand Up @@ -7084,10 +7128,10 @@ pub const hv_partition_property_code_HV_PARTITION_PROPERTY_ISOLATION_STATE:
hv_partition_property_code = 327692;
pub const hv_partition_property_code_HV_PARTITION_PROPERTY_ISOLATION_CONTROL:
hv_partition_property_code = 327693;
pub const hv_partition_property_code_HV_PARTITION_PROPERTY_RDT_L3_COS_INDEX:
pub const hv_partition_property_code_HV_PARTITION_PROPERTY_ALLOCATION_ID:
hv_partition_property_code = 327694;
pub const hv_partition_property_code_HV_PARTITION_PROPERTY_RDT_RMID: hv_partition_property_code =
327695;
pub const hv_partition_property_code_HV_PARTITION_PROPERTY_MONITORING_ID:
hv_partition_property_code = 327695;
pub const hv_partition_property_code_HV_PARTITION_PROPERTY_IMPLEMENTED_PHYSICAL_ADDRESS_BITS:
hv_partition_property_code = 327696;
pub const hv_partition_property_code_HV_PARTITION_PROPERTY_NON_ARCHITECTURAL_CORE_SHARING:
Expand Down Expand Up @@ -21286,6 +21330,48 @@ impl Default for hv_vp_signal_bitset_scheduler_message {
}
#[repr(C, packed)]
#[derive(Debug, Default, Copy, Clone, PartialOrd, Ord, PartialEq, Eq)]
pub struct hv_eventlog_message_payload {
pub type_: __u32,
pub buffer_index: __u32,
}
#[test]
fn bindgen_test_layout_hv_eventlog_message_payload() {
const UNINIT: ::std::mem::MaybeUninit<hv_eventlog_message_payload> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<hv_eventlog_message_payload>(),
8usize,
concat!("Size of: ", stringify!(hv_eventlog_message_payload))
);
assert_eq!(
::std::mem::align_of::<hv_eventlog_message_payload>(),
1usize,
concat!("Alignment of ", stringify!(hv_eventlog_message_payload))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(hv_eventlog_message_payload),
"::",
stringify!(type_)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).buffer_index) as usize - ptr as usize },
4usize,
concat!(
"Offset of field: ",
stringify!(hv_eventlog_message_payload),
"::",
stringify!(buffer_index)
)
);
}
#[repr(C, packed)]
#[derive(Debug, Default, Copy, Clone, PartialOrd, Ord, PartialEq, Eq)]
pub struct hv_vp_signal_pair_scheduler_message {
pub overflow_count: __u32,
pub vp_count: __u8,
Expand Down Expand Up @@ -23947,6 +24033,91 @@ impl Default for mshv_vp_run_registers {
}
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone, PartialOrd, Ord, PartialEq, Eq)]
pub struct mshv_trace_config {
pub mode: __u32,
pub max_buffers_count: __u32,
pub pages_per_buffer: __u32,
pub buffers_threshold: __u32,
pub time_basis: __u32,
pub system_time: __u64,
}
#[test]
fn bindgen_test_layout_mshv_trace_config() {
const UNINIT: ::std::mem::MaybeUninit<mshv_trace_config> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<mshv_trace_config>(),
32usize,
concat!("Size of: ", stringify!(mshv_trace_config))
);
assert_eq!(
::std::mem::align_of::<mshv_trace_config>(),
8usize,
concat!("Alignment of ", stringify!(mshv_trace_config))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).mode) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(mshv_trace_config),
"::",
stringify!(mode)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).max_buffers_count) as usize - ptr as usize },
4usize,
concat!(
"Offset of field: ",
stringify!(mshv_trace_config),
"::",
stringify!(max_buffers_count)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).pages_per_buffer) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(mshv_trace_config),
"::",
stringify!(pages_per_buffer)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).buffers_threshold) as usize - ptr as usize },
12usize,
concat!(
"Offset of field: ",
stringify!(mshv_trace_config),
"::",
stringify!(buffers_threshold)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).time_basis) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(mshv_trace_config),
"::",
stringify!(time_basis)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).system_time) as usize - ptr as usize },
24usize,
concat!(
"Offset of field: ",
stringify!(mshv_trace_config),
"::",
stringify!(system_time)
)
);
}
#[repr(C)]
#[derive(Debug, Default)]
pub struct mshv_modify_gpa_host_access {
pub host_access: __u32,
Expand Down
9 changes: 9 additions & 0 deletions mshv-bindings/src/snp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ type Result<T> = std::result::Result<T, errno::Error>;
pub const GHCB_PROTOCOL_VERSION_MIN: u32 = 1;
pub const GHCB_PROTOCOL_VERSION_MAX: u32 = 2;

pub const SVM_EXITCODE_HV_DOORBELL_PAGE: u32 = 2147483668;
pub const SVM_EXITCODE_SNP_GUEST_REQUEST: u32 = 2147483665;
pub const SVM_EXITCODE_SNP_EXTENDED_GUEST_REQUEST: u32 = 2147483666;
pub const SVM_EXITCODE_SNP_AP_CREATION: u32 = 2147483667;
pub const SVM_NAE_HV_DOORBELL_PAGE_GET_PREFERRED: u32 = 0;
pub const SVM_NAE_HV_DOORBELL_PAGE_SET: u32 = 1;
pub const SVM_NAE_HV_DOORBELL_PAGE_QUERY: u32 = 2;
pub const SVM_NAE_HV_DOORBELL_PAGE_CLEAR: u32 = 3;

pub const GHCB_INFO_BIT_WIDTH: u32 = 12;
pub const GHCB_INFO_MASK: u32 = 4095;
pub const GHCB_DATA_MASK: u64 = 4503599627370495;
Expand Down
Loading