Skip to content

Commit 245c54b

Browse files
russell-islamjinankjain
authored andcommitted
mshv-ioctls: property value is 64 bits
Fix get_host_partition_property to return unsigned 64 bits property value. Signed-off-by: Muminul Islam <muislam@microsoft.com>
1 parent ecee0df commit 245c54b

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

mshv-ioctls/src/ioctls/system.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::fs::File;
1212
use std::os::raw::c_char;
1313
use std::os::unix::io::{FromRawFd, RawFd};
1414
use vmm_sys_util::errno;
15-
use vmm_sys_util::ioctl::ioctl_with_ref;
15+
use vmm_sys_util::ioctl::{ioctl_with_mut_ref, ioctl_with_ref};
1616

1717
/// Helper function to populate synthetic features for the partition to create
1818
fn make_synthetic_features_mask() -> u64 {
@@ -163,12 +163,17 @@ impl Mshv {
163163
}
164164

165165
/// Retrieve the host partition property given a property code.
166-
pub fn get_host_partition_property(&self, property_code: u64) -> Result<i32> {
166+
pub fn get_host_partition_property(&self, property_code: u32) -> Result<u64> {
167+
let mut property = mshv_partition_property {
168+
property_code: property_code as u64,
169+
..Default::default()
170+
};
167171
// SAFETY: IOCTL call with the correct types.
168-
let ret =
169-
unsafe { ioctl_with_ref(&self.hv, MSHV_GET_HOST_PARTITION_PROPERTY(), &property_code) };
170-
if ret >= 0 {
171-
Ok(ret)
172+
let ret = unsafe {
173+
ioctl_with_mut_ref(&self.hv, MSHV_GET_HOST_PARTITION_PROPERTY(), &mut property)
174+
};
175+
if ret == 0 {
176+
Ok(property.property_value)
172177
} else {
173178
Err(errno::Error::last().into())
174179
}
@@ -226,7 +231,7 @@ mod tests {
226231
fn test_get_host_ipa_limit() {
227232
let hv = Mshv::new().unwrap();
228233
let host_ipa_limit = hv.get_host_partition_property(
229-
hv_partition_property_code_HV_PARTITION_PROPERTY_PHYSICAL_ADDRESS_WIDTH as u64,
234+
hv_partition_property_code_HV_PARTITION_PROPERTY_PHYSICAL_ADDRESS_WIDTH,
230235
);
231236
assert!(host_ipa_limit.is_ok());
232237
}

mshv-ioctls/src/ioctls/vm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ impl VmFd {
731731
/// For more of the codes, please see the hv_partition_property_code type definitions in the bindings.rs
732732
pub fn get_partition_property(&self, code: u32) -> Result<u64> {
733733
let mut property = mshv_partition_property {
734-
property_code: code,
734+
property_code: code as u64,
735735
..Default::default()
736736
};
737737
// SAFETY: IOCTL with correct types
@@ -762,7 +762,7 @@ impl VmFd {
762762
/// Sets a partion property
763763
pub fn set_partition_property(&self, code: u32, value: u64) -> Result<()> {
764764
let property: mshv_partition_property = mshv_partition_property {
765-
property_code: code,
765+
property_code: code as u64,
766766
property_value: value,
767767
};
768768
// SAFETY: IOCTL with correct types

0 commit comments

Comments
 (0)