Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop arm and x86 32-bit architecture support #289

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added

- [[#289](https://github.com/rust-vmm/kvm-ioctls/pull/289)]: Drop `x86` and `arm` support.
- [[#275](https://github.com/rust-vmm/kvm-ioctls/pull/275)]: Introduce `riscv64` ioctls.

### Changed
Expand Down
45 changes: 17 additions & 28 deletions src/cap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,40 +41,29 @@ pub enum Cap {
Iommu = KVM_CAP_IOMMU,
DestroyMemoryRegionWorks = KVM_CAP_DESTROY_MEMORY_REGION_WORKS,
UserNmi = KVM_CAP_USER_NMI,
#[cfg(any(
target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64",
target_arch = "s390x"
))]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64", target_arch = "s390x"))]
SetGuestDebug = KVM_CAP_SET_GUEST_DEBUG,
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
ReinjectControl = KVM_CAP_REINJECT_CONTROL,
IrqRouting = KVM_CAP_IRQ_ROUTING,
IrqInjectStatus = KVM_CAP_IRQ_INJECT_STATUS,
AssignDevIrq = KVM_CAP_ASSIGN_DEV_IRQ,
JoinMemoryRegionsWorks = KVM_CAP_JOIN_MEMORY_REGIONS_WORKS,
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
Mce = KVM_CAP_MCE,
Irqfd = KVM_CAP_IRQFD,
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
Pit2 = KVM_CAP_PIT2,
SetBootCpuId = KVM_CAP_SET_BOOT_CPU_ID,
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
PitState2 = KVM_CAP_PIT_STATE2,
Ioeventfd = KVM_CAP_IOEVENTFD,
SetIdentityMapAddr = KVM_CAP_SET_IDENTITY_MAP_ADDR,
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
XenHvm = KVM_CAP_XEN_HVM,
AdjustClock = KVM_CAP_ADJUST_CLOCK,
InternalErrorData = KVM_CAP_INTERNAL_ERROR_DATA,
#[cfg(any(
target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64"
))]
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
VcpuEvents = KVM_CAP_VCPU_EVENTS,
S390Psw = KVM_CAP_S390_PSW,
PpcSegstate = KVM_CAP_PPC_SEGSTATE,
Expand All @@ -84,15 +73,15 @@ pub enum Cap {
PciSegment = KVM_CAP_PCI_SEGMENT,
PpcPairedSingles = KVM_CAP_PPC_PAIRED_SINGLES,
IntrShadow = KVM_CAP_INTR_SHADOW,
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
Debugregs = KVM_CAP_DEBUGREGS,
X86RobustSinglestep = KVM_CAP_X86_ROBUST_SINGLESTEP,
PpcOsi = KVM_CAP_PPC_OSI,
PpcUnsetIrq = KVM_CAP_PPC_UNSET_IRQ,
EnableCap = KVM_CAP_ENABLE_CAP,
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
Xsave = KVM_CAP_XSAVE,
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
Xcrs = KVM_CAP_XCRS,
PpcGetPvinfo = KVM_CAP_PPC_GET_PVINFO,
PpcIrqLevel = KVM_CAP_PPC_IRQ_LEVEL,
Expand Down Expand Up @@ -145,9 +134,9 @@ pub enum Cap {
PpcEnableHcall = KVM_CAP_PPC_ENABLE_HCALL,
CheckExtensionVm = KVM_CAP_CHECK_EXTENSION_VM,
S390UserSigp = KVM_CAP_S390_USER_SIGP,
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
X86Smm = KVM_CAP_X86_SMM,
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
SplitIrqchip = KVM_CAP_SPLIT_IRQCHIP,
ArmPmuV3 = KVM_CAP_ARM_PMU_V3,
ImmediateExit = KVM_CAP_IMMEDIATE_EXIT,
Expand All @@ -161,14 +150,14 @@ pub enum Cap {
CoalescedPio = KVM_CAP_COALESCED_PIO,
#[cfg(target_arch = "aarch64")]
ArmSve = KVM_CAP_ARM_SVE,
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
#[cfg(target_arch = "aarch64")]
ArmPtrAuthAddress = KVM_CAP_ARM_PTRAUTH_ADDRESS,
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
#[cfg(target_arch = "aarch64")]
ArmPtrAuthGeneric = KVM_CAP_ARM_PTRAUTH_GENERIC,
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
X86UserSpaceMsr = KVM_CAP_X86_USER_SPACE_MSR,
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
ExitHypercall = KVM_CAP_EXIT_HYPERCALL,
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
MemoryFaultInfo = KVM_CAP_MEMORY_FAULT_INFO,
}
4 changes: 2 additions & 2 deletions src/ioctls/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ mod tests {
#![allow(clippy::undocumented_unsafe_blocks)]
use super::*;
use crate::ioctls::system::Kvm;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
use kvm_bindings::{
kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V3, kvm_device_type_KVM_DEV_TYPE_VFIO,
KVM_DEV_VFIO_GROUP, KVM_DEV_VFIO_GROUP_ADD,
Expand All @@ -213,7 +213,7 @@ mod tests {
use kvm_bindings::KVM_CREATE_DEVICE_TEST;

#[test]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
fn test_create_device() {
let kvm = Kvm::new().unwrap();
let vm = kvm.create_vm().unwrap();
Expand Down
32 changes: 16 additions & 16 deletions src/ioctls/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ use crate::ioctls::Result;
use crate::kvm_ioctls::*;
#[cfg(target_arch = "aarch64")]
use kvm_bindings::KVM_VM_TYPE_ARM_IPA_SIZE_MASK;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
use kvm_bindings::{CpuId, MsrList, Msrs, KVM_MAX_CPUID_ENTRIES, KVM_MAX_MSR_ENTRIES};
use vmm_sys_util::errno;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
use vmm_sys_util::ioctl::ioctl_with_mut_ptr;
use vmm_sys_util::ioctl::{ioctl, ioctl_with_val};

Expand Down Expand Up @@ -352,7 +352,7 @@ impl Kvm {
}
}

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
fn get_cpuid(&self, kind: u64, num_entries: usize) -> Result<CpuId> {
if num_entries > KVM_MAX_CPUID_ENTRIES {
// Returns the same error the underlying `ioctl` would have sent.
Expand Down Expand Up @@ -395,7 +395,7 @@ impl Kvm {
/// let cpuid_entries = cpuid.as_mut_slice();
/// assert!(cpuid_entries.len() <= KVM_MAX_CPUID_ENTRIES);
/// ```
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
pub fn get_emulated_cpuid(&self, num_entries: usize) -> Result<CpuId> {
self.get_cpuid(KVM_GET_EMULATED_CPUID(), num_entries)
}
Expand Down Expand Up @@ -424,7 +424,7 @@ impl Kvm {
/// let cpuid_entries = cpuid.as_mut_slice();
/// assert!(cpuid_entries.len() <= KVM_MAX_CPUID_ENTRIES);
/// ```
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
pub fn get_supported_cpuid(&self, num_entries: usize) -> Result<CpuId> {
self.get_cpuid(KVM_GET_SUPPORTED_CPUID(), num_entries)
}
Expand All @@ -441,7 +441,7 @@ impl Kvm {
/// let kvm = Kvm::new().unwrap();
/// let msr_index_list = kvm.get_msr_index_list().unwrap();
/// ```
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
pub fn get_msr_index_list(&self) -> Result<MsrList> {
let mut msr_list =
MsrList::new(KVM_MAX_MSR_ENTRIES).map_err(|_| errno::Error::new(libc::ENOMEM))?;
Expand Down Expand Up @@ -477,7 +477,7 @@ impl Kvm {
/// let kvm = Kvm::new().unwrap();
/// let msr_feature_index_list = kvm.get_msr_feature_index_list().unwrap();
/// ```
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
pub fn get_msr_feature_index_list(&self) -> Result<MsrList> {
let mut msr_list =
MsrList::new(KVM_MAX_MSR_ENTRIES).map_err(|_| errno::Error::new(libc::ENOMEM))?;
Expand Down Expand Up @@ -531,7 +531,7 @@ impl Kvm {
/// .unwrap();
/// let ret = kvm.get_msrs(&mut msrs).unwrap();
/// ```
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
pub fn get_msrs(&self, msrs: &mut Msrs) -> Result<usize> {
// SAFETY: Here we trust the kernel not to read past the end of the kvm_msrs struct.
let ret = unsafe { ioctl_with_mut_ptr(self, KVM_GET_MSRS(), msrs.as_mut_fam_struct_ptr()) };
Expand Down Expand Up @@ -731,7 +731,7 @@ mod tests {
use super::*;
use libc::{fcntl, FD_CLOEXEC, F_GETFD};
use std::os::fd::IntoRawFd;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
use vmm_sys_util::fam::FamStruct;

#[test]
Expand Down Expand Up @@ -867,7 +867,7 @@ mod tests {
}
}

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
#[test]
fn test_get_supported_cpuid() {
let kvm = Kvm::new().unwrap();
Expand All @@ -882,7 +882,7 @@ mod tests {
}

#[test]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
fn test_get_emulated_cpuid() {
let kvm = Kvm::new().unwrap();
let mut cpuid = kvm.get_emulated_cpuid(KVM_MAX_CPUID_ENTRIES).unwrap();
Expand All @@ -895,7 +895,7 @@ mod tests {
cpuid_err.unwrap_err();
}

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
#[test]
fn test_cpuid_clone() {
let kvm = Kvm::new().unwrap();
Expand All @@ -910,23 +910,23 @@ mod tests {
}

#[test]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
fn get_msr_index_list() {
let kvm = Kvm::new().unwrap();
let msr_list = kvm.get_msr_index_list().unwrap();
assert!(msr_list.as_slice().len() >= 2);
}

#[test]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
fn get_msr_feature_index_list() {
let kvm = Kvm::new().unwrap();
let msr_feature_index_list = kvm.get_msr_feature_index_list().unwrap();
assert!(!msr_feature_index_list.as_slice().is_empty());
}

#[test]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
fn get_msrs() {
use kvm_bindings::kvm_msr_entry;

Expand Down Expand Up @@ -961,7 +961,7 @@ mod tests {
);
assert_eq!(faulty_kvm.get_nr_vcpus(), 4);
assert_eq!(faulty_kvm.get_nr_memslots(), 32);
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[cfg(target_arch = "x86_64")]
{
assert_eq!(
faulty_kvm.get_emulated_cpuid(4).err().unwrap().errno(),
Expand Down
Loading