diff options
author | Matt Delco <delco@chromium.org> | 2020-02-25 18:01:05 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-05 19:01:24 +0000 |
commit | d2a862b41f07d387926f0b984c56dc838003102c (patch) | |
tree | f7f03c7c31673efc0b29cc4bf74804f638dac172 /kvm_sys | |
parent | b9f4c9bca30e65eacfb055951fa994ad5127a8f0 (diff) | |
download | crosvm-d2a862b41f07d387926f0b984c56dc838003102c.tar crosvm-d2a862b41f07d387926f0b984c56dc838003102c.tar.gz crosvm-d2a862b41f07d387926f0b984c56dc838003102c.tar.bz2 crosvm-d2a862b41f07d387926f0b984c56dc838003102c.tar.lz crosvm-d2a862b41f07d387926f0b984c56dc838003102c.tar.xz crosvm-d2a862b41f07d387926f0b984c56dc838003102c.tar.zst crosvm-d2a862b41f07d387926f0b984c56dc838003102c.zip |
crosvm: add handling for hyperv exits
When features for Hyper-V are enabled there's a another type of exit that can be triggered. This change attempts to add support for those types of exits. BUG=b:150151095 TEST=ran build_test Change-Id: I3131a2c8d9c610576ac177dbfe82f78e8d5dbfb1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2073254 Reviewed-by: Matt Delco <delco@chromium.org> Tested-by: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Matt Delco <delco@chromium.org> Auto-Submit: Matt Delco <delco@chromium.org>
Diffstat (limited to 'kvm_sys')
-rw-r--r-- | kvm_sys/src/aarch64/bindings.rs | 172 | ||||
-rw-r--r-- | kvm_sys/src/lib.rs | 3 | ||||
-rw-r--r-- | kvm_sys/src/x86/bindings.rs | 173 |
3 files changed, 344 insertions, 4 deletions
diff --git a/kvm_sys/src/aarch64/bindings.rs b/kvm_sys/src/aarch64/bindings.rs index 7be9e0d..084fc13 100644 --- a/kvm_sys/src/aarch64/bindings.rs +++ b/kvm_sys/src/aarch64/bindings.rs @@ -274,11 +274,14 @@ pub const KVM_EXIT_EPR: ::std::os::raw::c_uint = 23; pub const KVM_EXIT_SYSTEM_EVENT: ::std::os::raw::c_uint = 24; pub const KVM_EXIT_S390_STSI: ::std::os::raw::c_uint = 25; pub const KVM_EXIT_IOAPIC_EOI: ::std::os::raw::c_uint = 26; +pub const KVM_EXIT_HYPERV: ::std::os::raw::c_uint = 27; pub const KVM_INTERNAL_ERROR_EMULATION: ::std::os::raw::c_uint = 1; pub const KVM_INTERNAL_ERROR_SIMUL_EX: ::std::os::raw::c_uint = 2; pub const KVM_INTERNAL_ERROR_DELIVERY_EV: ::std::os::raw::c_uint = 3; pub const KVM_EXIT_IO_IN: ::std::os::raw::c_uint = 0; pub const KVM_EXIT_IO_OUT: ::std::os::raw::c_uint = 1; +pub const KVM_EXIT_HYPERV_SYNIC: ::std::os::raw::c_uint = 1; +pub const KVM_EXIT_HYPERV_HCALL: ::std::os::raw::c_uint = 2; pub const KVM_S390_RESET_POR: ::std::os::raw::c_uint = 1; pub const KVM_S390_RESET_CLEAR: ::std::os::raw::c_uint = 2; pub const KVM_S390_RESET_SUBSYSTEM: ::std::os::raw::c_uint = 4; @@ -1694,6 +1697,7 @@ pub union kvm_run__bindgen_ty_1 { pub system_event: kvm_run__bindgen_ty_1__bindgen_ty_17, pub s390_stsi: kvm_run__bindgen_ty_1__bindgen_ty_18, pub eoi: kvm_run__bindgen_ty_1__bindgen_ty_19, + pub hyperv: kvm_hyperv_exit, pub padding: [::std::os::raw::c_char; 256usize], _bindgen_union_align: [u64; 32usize], } @@ -2833,6 +2837,174 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_19() { ) ); } +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_hyperv_exit { + pub type_: __u32, + pub pad: __u32, + pub u: kvm_hyperv_exit__bindgen_ty_1, +} +#[test] +fn bindgen_test_layout_kvm_hyperv_exit() { + assert_eq!( + ::std::mem::size_of::<kvm_hyperv_exit>(), + 40usize, + concat!("Size of: ", stringify!(kvm_hyperv_exit)) + ); + assert_eq!( + ::std::mem::align_of::<kvm_hyperv_exit>(), + 8usize, + concat!("Alignment of ", stringify!(kvm_hyperv_exit)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<kvm_hyperv_exit>())).u as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit), + "::", + stringify!(u) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_hyperv_exit__bindgen_ty_1 { + pub synic: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1, + pub hcall: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2, +} +#[test] +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<kvm_hyperv_exit__bindgen_ty_1>(), + 32usize, + concat!("Size of: ", stringify!(kvm_hyperv_exit__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<kvm_hyperv_exit__bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(kvm_hyperv_exit__bindgen_ty_1)) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1 { + pub msr: __u32, + pub pad: __u32, + pub control: __u64, + pub evt_page: __u64, + pub msg_page: __u64, +} +#[test] +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1>(), + 32usize, + concat!( + "Size of: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1>(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1>())).control + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(control) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1>())).evt_page + as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(evt_page) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1>())).msg_page + as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(msg_page) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2 { + pub input: __u64, + pub result: __u64, + pub params: [__u64; 2], +} +#[test] +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2() { + assert_eq!( + ::std::mem::size_of::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2>(), + 32usize, + concat!( + "Size of: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + ::std::mem::align_of::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2>(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2>())).result + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(result) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2>())).params + as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(params) + ) + ); +} #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1() { assert_eq!( diff --git a/kvm_sys/src/lib.rs b/kvm_sys/src/lib.rs index 4c0324d..8f27690 100644 --- a/kvm_sys/src/lib.rs +++ b/kvm_sys/src/lib.rs @@ -8,9 +8,6 @@ use sys_util::{ioctl_io_nr, ioctl_ior_nr, ioctl_iow_nr, ioctl_iowr_nr}; -// Somehow this one gets missed by bindgen -pub const KVM_EXIT_IO_OUT: ::std::os::raw::c_uint = 1; - // Each of the below modules defines ioctls specific to their platform. #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] diff --git a/kvm_sys/src/x86/bindings.rs b/kvm_sys/src/x86/bindings.rs index 5991d17..7236611 100644 --- a/kvm_sys/src/x86/bindings.rs +++ b/kvm_sys/src/x86/bindings.rs @@ -251,11 +251,14 @@ pub const KVM_EXIT_EPR: ::std::os::raw::c_uint = 23; pub const KVM_EXIT_SYSTEM_EVENT: ::std::os::raw::c_uint = 24; pub const KVM_EXIT_S390_STSI: ::std::os::raw::c_uint = 25; pub const KVM_EXIT_IOAPIC_EOI: ::std::os::raw::c_uint = 26; +pub const KVM_EXIT_HYPERV: ::std::os::raw::c_uint = 27; pub const KVM_INTERNAL_ERROR_EMULATION: ::std::os::raw::c_uint = 1; pub const KVM_INTERNAL_ERROR_SIMUL_EX: ::std::os::raw::c_uint = 2; pub const KVM_INTERNAL_ERROR_DELIVERY_EV: ::std::os::raw::c_uint = 3; pub const KVM_EXIT_IO_IN: ::std::os::raw::c_uint = 0; pub const KVM_EXIT_IO_OUT: ::std::os::raw::c_uint = 1; +pub const KVM_EXIT_HYPERV_SYNIC: ::std::os::raw::c_uint = 1; +pub const KVM_EXIT_HYPERV_HCALL: ::std::os::raw::c_uint = 2; pub const KVM_S390_RESET_POR: ::std::os::raw::c_uint = 1; pub const KVM_S390_RESET_CLEAR: ::std::os::raw::c_uint = 2; pub const KVM_S390_RESET_SUBSYSTEM: ::std::os::raw::c_uint = 4; @@ -4084,6 +4087,7 @@ pub union kvm_run__bindgen_ty_1 { pub system_event: kvm_run__bindgen_ty_1__bindgen_ty_17, pub s390_stsi: kvm_run__bindgen_ty_1__bindgen_ty_18, pub eoi: kvm_run__bindgen_ty_1__bindgen_ty_19, + pub hyperv: kvm_hyperv_exit, pub padding: [::std::os::raw::c_char; 256usize], _bindgen_union_align: [u64; 32usize], } @@ -5223,7 +5227,174 @@ fn bindgen_test_layout_kvm_run__bindgen_ty_1__bindgen_ty_19() { ) ); } - +#[repr(C)] +#[derive(Copy, Clone)] +pub struct kvm_hyperv_exit { + pub type_: __u32, + pub pad: __u32, + pub u: kvm_hyperv_exit__bindgen_ty_1, +} +#[test] +fn bindgen_test_layout_kvm_hyperv_exit() { + assert_eq!( + ::std::mem::size_of::<kvm_hyperv_exit>(), + 40usize, + concat!("Size of: ", stringify!(kvm_hyperv_exit)) + ); + assert_eq!( + ::std::mem::align_of::<kvm_hyperv_exit>(), + 8usize, + concat!("Alignment of ", stringify!(kvm_hyperv_exit)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<kvm_hyperv_exit>())).u as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit), + "::", + stringify!(u) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union kvm_hyperv_exit__bindgen_ty_1 { + pub synic: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1, + pub hcall: kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2, +} +#[test] +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<kvm_hyperv_exit__bindgen_ty_1>(), + 32usize, + concat!("Size of: ", stringify!(kvm_hyperv_exit__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<kvm_hyperv_exit__bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(kvm_hyperv_exit__bindgen_ty_1)) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1 { + pub msr: __u32, + pub pad: __u32, + pub control: __u64, + pub evt_page: __u64, + pub msg_page: __u64, +} +#[test] +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::std::mem::size_of::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1>(), + 32usize, + concat!( + "Size of: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1>(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1>())).control + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(control) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1>())).evt_page + as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(evt_page) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1>())).msg_page + as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(msg_page) + ) + ); +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2 { + pub input: __u64, + pub result: __u64, + pub params: [__u64; 2], +} +#[test] +fn bindgen_test_layout_kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2() { + assert_eq!( + ::std::mem::size_of::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2>(), + 32usize, + concat!( + "Size of: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + ::std::mem::align_of::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2>(), + 8usize, + concat!( + "Alignment of ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2>())).result + as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(result) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::<kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2>())).params + as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(kvm_hyperv_exit__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(params) + ) + ); +} #[test] fn bindgen_test_layout_kvm_run__bindgen_ty_1() { assert_eq!( |