Skip to content

Commit e71e511

Browse files
anirudhrbrussell-islam
authored andcommitted
mshv-bindings: add bindings for arm64 reset intercepts
Add bindings for arm64 reset intercept message Signed-off-by: Anirudh Rayabharam <[email protected]>
1 parent 7728080 commit e71e511

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

hv-headers/hvgdk_mini.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ enum hv_message_type {
322322
HVMSG_X64_HALT = 0x80010007,
323323
HVMSG_X64_INTERRUPTION_DELIVERABLE = 0x80010008,
324324
HVMSG_X64_SIPI_INTERCEPT = 0x80010009,
325+
HVMSG_ARM64_RESET_INTERCEPT = 0x8001000C,
325326
HVMSG_X64_SEV_VMGEXIT_INTERCEPT = 0x80010013,
326327
};
327328

hv-headers/hvhdk.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,22 @@ struct hv_arm64_memory_intercept_message {
10861086
__u64 syndrome;
10871087
} __packed;
10881088

1089+
enum hv_arm64_reset_type
1090+
{
1091+
HV_ARM64_RESET_TYPE_POWER_OFF = 0,
1092+
HV_ARM64_RESET_TYPE_REBOOT,
1093+
HV_ARM64_RESET_TYPE_SYSTEM_RESET2,
1094+
HV_ARM64_RESET_TYPE_HIBERNATE,
1095+
HV_ARM64_RESET_TYPE_MAX
1096+
};
1097+
1098+
struct hv_arm64_reset_intercept_message
1099+
{
1100+
struct hv_arm64_intercept_message_header header;
1101+
__u32 reset_type;
1102+
__u32 reset_code;
1103+
};
1104+
10891105
#endif /* __aarch64__ */
10901106

10911107
struct hv_input_translate_virtual_address {

mshv-bindings/src/arm64/bindings.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,6 +1916,7 @@ pub const hv_message_type_HVMSG_X64_IOMMU_PRQ: hv_message_type = 2147549190;
19161916
pub const hv_message_type_HVMSG_X64_HALT: hv_message_type = 2147549191;
19171917
pub const hv_message_type_HVMSG_X64_INTERRUPTION_DELIVERABLE: hv_message_type = 2147549192;
19181918
pub const hv_message_type_HVMSG_X64_SIPI_INTERCEPT: hv_message_type = 2147549193;
1919+
pub const hv_message_type_HVMSG_ARM64_RESET_INTERCEPT: hv_message_type = 2147549196;
19191920
pub const hv_message_type_HVMSG_X64_SEV_VMGEXIT_INTERCEPT: hv_message_type = 2147549203;
19201921
pub type hv_message_type = ::std::os::raw::c_uint;
19211922
#[repr(C)]
@@ -10816,6 +10817,41 @@ impl Default for hv_arm64_memory_intercept_message {
1081610817
}
1081710818
}
1081810819
}
10820+
pub const hv_arm64_reset_type_HV_ARM64_RESET_TYPE_POWER_OFF: hv_arm64_reset_type = 0;
10821+
pub const hv_arm64_reset_type_HV_ARM64_RESET_TYPE_REBOOT: hv_arm64_reset_type = 1;
10822+
pub const hv_arm64_reset_type_HV_ARM64_RESET_TYPE_SYSTEM_RESET2: hv_arm64_reset_type = 2;
10823+
pub const hv_arm64_reset_type_HV_ARM64_RESET_TYPE_HIBERNATE: hv_arm64_reset_type = 3;
10824+
pub const hv_arm64_reset_type_HV_ARM64_RESET_TYPE_MAX: hv_arm64_reset_type = 4;
10825+
pub type hv_arm64_reset_type = ::std::os::raw::c_uint;
10826+
#[repr(C)]
10827+
#[derive(Copy, Clone)]
10828+
pub struct hv_arm64_reset_intercept_message {
10829+
pub header: hv_arm64_intercept_message_header,
10830+
pub reset_type: __u32,
10831+
pub reset_code: __u32,
10832+
}
10833+
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
10834+
const _: () = {
10835+
["Size of hv_arm64_reset_intercept_message"]
10836+
[::std::mem::size_of::<hv_arm64_reset_intercept_message>() - 32usize];
10837+
["Alignment of hv_arm64_reset_intercept_message"]
10838+
[::std::mem::align_of::<hv_arm64_reset_intercept_message>() - 4usize];
10839+
["Offset of field: hv_arm64_reset_intercept_message::header"]
10840+
[::std::mem::offset_of!(hv_arm64_reset_intercept_message, header) - 0usize];
10841+
["Offset of field: hv_arm64_reset_intercept_message::reset_type"]
10842+
[::std::mem::offset_of!(hv_arm64_reset_intercept_message, reset_type) - 24usize];
10843+
["Offset of field: hv_arm64_reset_intercept_message::reset_code"]
10844+
[::std::mem::offset_of!(hv_arm64_reset_intercept_message, reset_code) - 28usize];
10845+
};
10846+
impl Default for hv_arm64_reset_intercept_message {
10847+
fn default() -> Self {
10848+
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
10849+
unsafe {
10850+
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
10851+
s.assume_init()
10852+
}
10853+
}
10854+
}
1081910855
#[repr(C, packed)]
1082010856
#[derive(Debug, Default, Copy, Clone, PartialOrd, Ord, PartialEq, Eq)]
1082110857
pub struct hv_input_translate_virtual_address {

mshv-bindings/src/arm64/unmarshal.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,17 @@ impl hv_message {
2121
unsafe { std::ptr::read_unaligned(std::ptr::addr_of!(self.u.payload) as *const _) };
2222
Ok(ret)
2323
}
24+
25+
#[inline]
26+
pub fn to_reset_intercept_msg(&self) -> Result<hv_arm64_reset_intercept_message> {
27+
if self.header.message_type != hv_message_type_HVMSG_ARM64_RESET_INTERCEPT {
28+
return Err(errno::Error::new(libc::EINVAL));
29+
}
30+
31+
// SAFETY: The payload is guaranteed to be of type `hv_arm64_reset_intercept_message`
32+
// because we ensured the message type above.
33+
let ret =
34+
unsafe { std::ptr::read_unaligned(std::ptr::addr_of!(self.u.payload) as *const _) };
35+
Ok(ret)
36+
}
2437
}

0 commit comments

Comments
 (0)