kvm_sys: Move KVM_PVIOMMU_SET_CONFIG to lib.rs

Replace the ioctl definition using a magic number with the appropriate
macro call. Note that this commit also limits the availability of the
constant to AArch64 Android, the only builds using it as per the cfg
attributes of KvmVfioPviommu::ioctl_kvm_pviommu_set_config().

TEST=m crosvm # in AOSP, then validated the constant using decompilation

Change-Id: I6099a69419c5c562b0c5ce5b27ac3f24b73c9244
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5750141
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Pierre-Clément Tosi <ptosi@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Pierre-Clément Tosi 2024-07-29 15:42:40 +01:00 committed by crosvm LUCI
parent 3e44794a86
commit 20eee9bace
3 changed files with 6 additions and 3 deletions

View file

@ -39,8 +39,7 @@ pub struct kvm_vfio_iommu_config {
pub device_fd: i32,
pub sid_idx: u32,
pub vsid: u32,
}
pub const KVM_PVIOMMU_SET_CONFIG: i32 = 0xc00cae01u32 as i32;"
}"
X86_64_EXTRAS="
// This is how zerocopy's author deal with bindings for __BindgenBitfieldUnit<Storage>, see:

View file

@ -38,7 +38,6 @@ pub struct kvm_vfio_iommu_config {
pub sid_idx: u32,
pub vsid: u32,
}
pub const KVM_PVIOMMU_SET_CONFIG: i32 = 0xc00cae01u32 as i32;
#[repr(C)]
#[derive(Default)]

View file

@ -69,6 +69,8 @@ pub mod aarch64 {
pub mod bindings;
use base::ioctl_ior_nr;
use base::ioctl_iow_nr;
#[cfg(target_os = "android")]
use base::ioctl_iowr_nr;
pub use bindings::*;
ioctl_iow_nr!(KVM_ARM_SET_DEVICE_ADDR, KVMIO, 0xab, kvm_arm_device_addr);
@ -80,6 +82,9 @@ pub mod aarch64 {
0xb5,
kvm_arm_counter_offset
);
#[cfg(target_os = "android")]
ioctl_iowr_nr!(KVM_PVIOMMU_SET_CONFIG, KVMIO, 0x1, kvm_vfio_iommu_config);
}
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
pub use crate::aarch64::*;