Skip to content

Commit 44cc0e5

Browse files
committed
mshv-ioctls: split get_xcrs
Split the get_xcrs based on VP register page availbility. If VP page is available, get the register using the mapped VP page, otherwise use regular IOCTL. Signed-off-by: Muminul Islam <muislam@microsoft.com>
1 parent 58e8223 commit 44cc0e5

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

mshv-ioctls/src/ioctls/vcpu.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,9 +1271,9 @@ impl VcpuFd {
12711271
Ok(ret_regs)
12721272
}
12731273

1274-
/// X86 specific call that returns the vcpu's current "xcrs".
1274+
/// X86 specific call that returns the vcpu's current "xcrs" using IOCTL
12751275
#[cfg(not(target_arch = "aarch64"))]
1276-
pub fn get_xcrs(&self) -> Result<Xcrs> {
1276+
fn get_xcrs_ioctl(&self) -> Result<Xcrs> {
12771277
let mut reg_assocs: [hv_register_assoc; 1] = [hv_register_assoc {
12781278
name: hv_register_name_HV_X64_REGISTER_XFEM,
12791279
..Default::default()
@@ -1289,6 +1289,17 @@ impl VcpuFd {
12891289

12901290
Ok(ret_regs)
12911291
}
1292+
1293+
/// X86 specific call that returns the vcpu's current "xcrs".
1294+
#[cfg(not(target_arch = "aarch64"))]
1295+
pub fn get_xcrs(&self) -> Result<Xcrs> {
1296+
if self.vp_page.is_some() {
1297+
self.get_xcrs_vp_page()
1298+
} else {
1299+
self.get_xcrs_ioctl()
1300+
}
1301+
}
1302+
12921303
/// X86 specific call to set XCRs
12931304
#[cfg(not(target_arch = "aarch64"))]
12941305
pub fn set_xcrs(&self, xcrs: &Xcrs) -> Result<()> {

0 commit comments

Comments
 (0)