Skip to content

Commit 58e8223

Browse files
committed
mshv-ioctls: add an API to get xcrs
Add a private API to get extended register using VP register page. Signed-off-by: Muminul Islam <muislam@microsoft.com>
1 parent b64539c commit 58e8223

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

mshv-ioctls/src/ioctls/vcpu.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,22 @@ impl VcpuFd {
12551255
self.set_reg(&reg_assocs)?;
12561256
Ok(())
12571257
}
1258+
1259+
/// X86 specific call that returns the vcpu's current "xcrs" using VP register page
1260+
/// This is a private API for internal use, not publicly available
1261+
#[cfg(not(target_arch = "aarch64"))]
1262+
fn get_xcrs_vp_page(&self) -> Result<Xcrs> {
1263+
let vp_reg_page = self.get_vp_reg_page().unwrap().0;
1264+
// SAFETY: access union fields
1265+
let ret_regs = unsafe {
1266+
Xcrs {
1267+
xcr0: (*vp_reg_page).xfem,
1268+
}
1269+
};
1270+
1271+
Ok(ret_regs)
1272+
}
1273+
12581274
/// X86 specific call that returns the vcpu's current "xcrs".
12591275
#[cfg(not(target_arch = "aarch64"))]
12601276
pub fn get_xcrs(&self) -> Result<Xcrs> {

0 commit comments

Comments
 (0)