diff --git a/alioth/src/arch/arch.rs b/alioth/src/arch/arch.rs index 85f2d81e..a4f6c31f 100644 --- a/alioth/src/arch/arch.rs +++ b/alioth/src/arch/arch.rs @@ -12,12 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(target_arch = "aarch64")] #[path = "aarch64/aarch64.rs"] -mod aarch64; -#[cfg(target_arch = "x86_64")] +pub mod aarch64; #[path = "x86_64/x86_64.rs"] -mod x86_64; +pub mod x86_64; #[cfg(target_arch = "aarch64")] pub use self::aarch64::*; diff --git a/alioth/src/arch/x86_64/ioapic.rs b/alioth/src/arch/x86_64/ioapic.rs index 9e15bc19..32999f3a 100644 --- a/alioth/src/arch/x86_64/ioapic.rs +++ b/alioth/src/arch/x86_64/ioapic.rs @@ -14,7 +14,7 @@ use bitfield::bitfield; -use crate::arch::intr::DeliveryMode; +use crate::arch::x86_64::intr::DeliveryMode; pub const IOREGSEL: u64 = 0x00; pub const IOWIN: u64 = 0x10; diff --git a/alioth/src/device/device.rs b/alioth/src/device/device.rs index e2c3c9ba..a0608b2e 100644 --- a/alioth/src/device/device.rs +++ b/alioth/src/device/device.rs @@ -25,14 +25,10 @@ pub mod console; #[path = "fw_cfg/fw_cfg.rs"] pub mod fw_cfg; pub mod fw_dbg; -#[cfg(target_arch = "x86_64")] pub mod ioapic; pub mod net; -#[cfg(target_arch = "aarch64")] pub mod pl011; -#[cfg(target_arch = "aarch64")] pub mod pl031; -#[cfg(target_arch = "x86_64")] pub mod serial; #[trace_error] diff --git a/alioth/src/device/fw_cfg/fw_cfg.rs b/alioth/src/device/fw_cfg/fw_cfg.rs index 14ab4543..32a93201 100644 --- a/alioth/src/device/fw_cfg/fw_cfg.rs +++ b/alioth/src/device/fw_cfg/fw_cfg.rs @@ -12,18 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(target_arch = "x86_64")] pub mod acpi; use std::ffi::CString; use std::fmt; use std::fs::File; use std::io::{ErrorKind, Read, Result, Seek, SeekFrom}; -#[cfg(target_arch = "x86_64")] -use std::mem::size_of; -use std::mem::size_of_val; +use std::mem::{size_of, size_of_val}; use std::os::unix::fs::FileExt; -#[cfg(target_arch = "x86_64")] use std::path::Path; use std::sync::Arc; @@ -35,12 +31,10 @@ use serde::{Deserialize, Deserializer}; use serde_aco::Help; use zerocopy::{FromBytes, Immutable, IntoBytes}; -#[cfg(target_arch = "x86_64")] use crate::arch::layout::{ PORT_FW_CFG_DATA, PORT_FW_CFG_DMA_HI, PORT_FW_CFG_DMA_LO, PORT_FW_CFG_SELECTOR, }; use crate::device::{self, MmioDev, Pause}; -#[cfg(target_arch = "x86_64")] use crate::firmware::acpi::AcpiTable; #[cfg(target_arch = "x86_64")] use crate::loader::linux::bootparams::{ @@ -49,11 +43,9 @@ use crate::loader::linux::bootparams::{ use crate::mem; use crate::mem::emulated::{Action, Mmio}; use crate::mem::mapped::RamBus; -#[cfg(target_arch = "x86_64")] use crate::mem::{MemRegionEntry, MemRegionType}; use crate::utils::endian::{Bu16, Bu32, Bu64, Lu16, Lu32, Lu64}; -#[cfg(target_arch = "x86_64")] use self::acpi::create_acpi_loader; pub const SELECTOR_WR: u16 = 1 << 14; @@ -288,7 +280,6 @@ impl FwCfg { self.known_items[FW_CFG_NB_CPUS as usize] = FwCfgContent::Lu16(count.into()); } - #[cfg(target_arch = "x86_64")] pub(crate) fn add_e820(&mut self, mem_regions: &[(u64, MemRegionEntry)]) -> Result<()> { let mut bytes = vec![]; for (addr, region) in mem_regions.iter() { @@ -313,7 +304,6 @@ impl FwCfg { self.add_item(item) } - #[cfg(target_arch = "x86_64")] pub(crate) fn add_acpi(&mut self, acpi_table: AcpiTable) -> Result<()> { let [table_loader, acpi_rsdp, apci_tables] = create_acpi_loader(acpi_table); self.add_item(table_loader)?; @@ -321,7 +311,6 @@ impl FwCfg { self.add_item(apci_tables) } - #[cfg(target_arch = "x86_64")] pub fn add_kernel_data(&mut self, p: &Path) -> Result<()> { let file = File::open(p)?; let mut buffer = vec![0u8; size_of::()]; diff --git a/alioth/src/device/ioapic.rs b/alioth/src/device/ioapic.rs index a7791511..f20feec4 100644 --- a/alioth/src/device/ioapic.rs +++ b/alioth/src/device/ioapic.rs @@ -17,12 +17,12 @@ use parking_lot::Mutex; -use crate::arch::intr::{DestinationMode, MsiAddrLo, MsiData, TriggerMode}; -use crate::arch::ioapic::{ +use crate::arch::x86_64::intr::{DestinationMode, MsiAddrLo, MsiData, TriggerMode}; +use crate::arch::x86_64::ioapic::{ IOAPIC_VER, IOAPICARB, IOAPICID, IOAPICVER, IOREDTBL_BASE, IOREDTBL_MAX, IOREGSEL, IOWIN, NUM_PINS, RedirectEntry, RegId, RegVer, }; -use crate::arch::layout::{APIC_START, IOAPIC_END, IOAPIC_START}; +use crate::arch::x86_64::layout::{APIC_START, IOAPIC_END, IOAPIC_START}; use crate::device::{self, MmioDev, Pause}; use crate::hv::MsiSender; use crate::mem; diff --git a/alioth/src/device/pl011_test.rs b/alioth/src/device/pl011_test.rs index 3b69d85d..de009049 100644 --- a/alioth/src/device/pl011_test.rs +++ b/alioth/src/device/pl011_test.rs @@ -17,14 +17,14 @@ use std::time::{Duration, Instant}; use assert_matches::assert_matches; -use crate::arch::layout::PL011_START; +use crate::arch::aarch64::layout::PL011_START; use crate::device::console::tests::TestConsole; use crate::device::pl011::{ Flag, Interrupt, Pl011, UART_DR, UART_FR, UART_IMSC, UART_MIS, UART_PCELL_ID0, UART_PCELL_ID1, UART_PCELL_ID2, UART_PCELL_ID3, UART_PERIPH_ID0, UART_PERIPH_ID1, UART_PERIPH_ID2, UART_PERIPH_ID3, UART_RIS, }; -use crate::hv::tests::aarch64::TestIrqSender; +use crate::hv::tests::TestIrqSender; use crate::mem::emulated::Mmio; fn fixture_pl011() -> Pl011 { diff --git a/alioth/src/device/pl031_test.rs b/alioth/src/device/pl031_test.rs index d0c3dcaf..d6af8e62 100644 --- a/alioth/src/device/pl031_test.rs +++ b/alioth/src/device/pl031_test.rs @@ -15,7 +15,7 @@ use assert_matches::assert_matches; use chrono::DateTime; -use crate::arch::layout::PL031_START; +use crate::arch::aarch64::layout::PL031_START; use crate::device::clock::tests::TestClock; use crate::device::pl031::{ Pl031, RTC_CR, RTC_DR, RTC_ICR, RTC_IMSC, RTC_LR, RTC_MIS, RTC_MR, RTC_PCELL_ID0, diff --git a/alioth/src/hv/hv.rs b/alioth/src/hv/hv.rs index fb336188..0958e51f 100644 --- a/alioth/src/hv/hv.rs +++ b/alioth/src/hv/hv.rs @@ -25,7 +25,6 @@ use std::arch::x86_64::CpuidResult; use std::collections::HashMap; use std::fmt::Debug; use std::os::fd::AsFd; -#[cfg(not(target_arch = "x86_64"))] use std::sync::Arc; use std::thread::JoinHandle; @@ -225,12 +224,10 @@ pub trait Vcpu { fn tdx_init_mem_region(&self, data: &[u8], gpa: u64, measure: bool) -> Result<()>; } -#[cfg(not(target_arch = "x86_64"))] pub trait IrqSender: Debug + Send + Sync + 'static { fn send(&self) -> Result<(), Error>; } -#[cfg(not(target_arch = "x86_64"))] impl IrqSender for Arc where T: IrqSender, @@ -269,14 +266,6 @@ pub trait IoeventFdRegistry: Debug + Send + Sync + 'static { type IoeventFd: IoeventFd; fn create(&self) -> Result; fn register(&self, fd: &Self::IoeventFd, gpa: u64, len: u8, data: Option) -> Result<()>; - #[cfg(target_arch = "x86_64")] - fn register_port( - &self, - fd: &Self::IoeventFd, - port: u16, - len: u8, - data: Option, - ) -> Result<()>; fn deregister(&self, fd: &Self::IoeventFd) -> Result<()>; } @@ -353,12 +342,10 @@ pub struct VmConfig { pub trait Vm { type Vcpu: Vcpu; type Memory: VmMemory; - #[cfg(not(target_arch = "x86_64"))] type IrqSender: IrqSender + Send + Sync; type MsiSender: MsiSender; type IoeventFdRegistry: IoeventFdRegistry; fn create_vcpu(&self, index: u16, identity: u64) -> Result; - #[cfg(not(target_arch = "x86_64"))] fn create_irq_sender(&self, pin: u8) -> Result; fn create_msi_sender( &self, diff --git a/alioth/src/hv/hv_aarch64_test.rs b/alioth/src/hv/hv_aarch64_test.rs deleted file mode 100644 index f945256a..00000000 --- a/alioth/src/hv/hv_aarch64_test.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2026 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use parking_lot::{Condvar, Mutex}; - -use crate::hv::{IrqSender, Result}; - -#[derive(Debug)] -pub struct TestIrqSender { - pub count: Mutex, - pub condvar: Condvar, -} - -impl TestIrqSender { - pub fn new() -> Self { - Self { - count: Mutex::new(0), - condvar: Condvar::new(), - } - } -} - -impl IrqSender for TestIrqSender { - fn send(&self) -> Result<()> { - let mut count = self.count.lock(); - *count += 1; - self.condvar.notify_one(); - Ok(()) - } -} diff --git a/alioth/src/hv/hv_test.rs b/alioth/src/hv/hv_test.rs index a7cb8b17..e84c9ec4 100644 --- a/alioth/src/hv/hv_test.rs +++ b/alioth/src/hv/hv_test.rs @@ -12,15 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(target_arch = "aarch64")] -#[path = "hv_aarch64_test.rs"] -pub mod aarch64; - use std::os::fd::{AsFd, BorrowedFd}; -use parking_lot::RwLock; +use parking_lot::{Condvar, Mutex, RwLock}; -use crate::hv::{IrqFd, Result}; +use crate::hv::{IrqFd, IrqSender, Result}; #[derive(Debug)] struct TestIrqFdInner { @@ -92,3 +88,27 @@ impl AsFd for TestIrqFd { unreachable!() } } + +#[derive(Debug)] +pub struct TestIrqSender { + pub count: Mutex, + pub condvar: Condvar, +} + +impl TestIrqSender { + pub fn new() -> Self { + Self { + count: Mutex::new(0), + condvar: Condvar::new(), + } + } +} + +impl IrqSender for TestIrqSender { + fn send(&self) -> Result<()> { + let mut count = self.count.lock(); + *count += 1; + self.condvar.notify_one(); + Ok(()) + } +} diff --git a/alioth/src/hv/kvm/vm/vm.rs b/alioth/src/hv/kvm/vm/vm.rs index 1e9f1719..05a4efa3 100644 --- a/alioth/src/hv/kvm/vm/vm.rs +++ b/alioth/src/hv/kvm/vm/vm.rs @@ -31,9 +31,7 @@ use std::sync::Arc; use std::sync::atomic::{AtomicU32, Ordering}; use std::thread::JoinHandle; -#[cfg(not(target_arch = "x86_64"))] -use libc::write; -use libc::{EFD_CLOEXEC, EFD_NONBLOCK, SIGRTMIN, eventfd}; +use libc::{EFD_CLOEXEC, EFD_NONBLOCK, SIGRTMIN, eventfd, write}; use parking_lot::{Mutex, RwLock}; use snafu::ResultExt; @@ -44,13 +42,11 @@ use crate::arch::sev::{SevPolicy, SnpPageType, SnpPolicy}; #[cfg(target_arch = "x86_64")] use crate::arch::tdx::TdAttr; use crate::ffi; -#[cfg(not(target_arch = "x86_64"))] -use crate::hv::IrqSender; use crate::hv::kvm::vcpu::KvmVcpu; use crate::hv::kvm::{KvmError, check_extension, kvm_error}; use crate::hv::{ - Error, IoeventFd, IoeventFdRegistry, IrqFd, Kvm, MemMapOption, MsiSender, Result, Vm, VmConfig, - VmMemory, error, + Error, IoeventFd, IoeventFdRegistry, IrqFd, IrqSender, Kvm, MemMapOption, MsiSender, Result, + Vm, VmConfig, VmMemory, error, }; #[cfg(target_arch = "x86_64")] use crate::sys::kvm::KVM_IRQCHIP_IOAPIC; @@ -289,7 +285,6 @@ impl VmMemory for KvmMemory { Ok(()) } } -#[cfg(not(target_arch = "x86_64"))] #[derive(Debug)] pub struct KvmIrqSender { pin: u8, @@ -297,7 +292,6 @@ pub struct KvmIrqSender { event_fd: OwnedFd, } -#[cfg(not(target_arch = "x86_64"))] impl Drop for KvmIrqSender { fn drop(&mut self) { let pin_flag = 1 << (self.pin as u32); @@ -318,7 +312,6 @@ impl Drop for KvmIrqSender { } } -#[cfg(not(target_arch = "x86_64"))] impl IrqSender for KvmIrqSender { fn send(&self) -> Result<(), Error> { ffi!(unsafe { write(self.event_fd.as_raw_fd(), &1u64 as *const _ as _, 8) }) @@ -591,17 +584,6 @@ impl IoeventFdRegistry for KvmIoeventFdRegistry { Ok(()) } - #[cfg(target_arch = "x86_64")] - fn register_port( - &self, - _fd: &Self::IoeventFd, - _port: u16, - _len: u8, - _data: Option, - ) -> Result<()> { - unimplemented!() - } - fn deregister(&self, fd: &Self::IoeventFd) -> Result<()> { let mut fds = self.vm.ioeventfds.lock(); if let Some(mut request) = fds.remove(&fd.as_fd().as_raw_fd()) { @@ -652,7 +634,6 @@ impl Vm for KvmVm { #[cfg(target_arch = "aarch64")] type GicV3 = aarch64::KvmGicV3; type IoeventFdRegistry = KvmIoeventFdRegistry; - #[cfg(not(target_arch = "x86_64"))] type IrqSender = KvmIrqSender; #[cfg(target_arch = "aarch64")] type Its = aarch64::KvmIts; @@ -680,7 +661,6 @@ impl Vm for KvmVm { } } - #[cfg(not(target_arch = "x86_64"))] fn create_irq_sender(&self, pin: u8) -> Result { let pin_flag = 1 << pin; if self.vm.pin_map.fetch_or(pin_flag, Ordering::AcqRel) & pin_flag == pin_flag { diff --git a/alioth/src/sys/linux/kvm.rs b/alioth/src/sys/linux/kvm.rs index c8104b84..74debad0 100644 --- a/alioth/src/sys/linux/kvm.rs +++ b/alioth/src/sys/linux/kvm.rs @@ -14,17 +14,12 @@ use std::fmt::{Debug, Formatter, Result}; -#[cfg(target_arch = "aarch64")] use bitfield::bitfield; -#[cfg(target_arch = "x86_64")] -use crate::ioctl_writeread_buf; -use crate::sys::ioctl::ioctl_ior; -#[cfg(target_arch = "x86_64")] -use crate::sys::ioctl::ioctl_iowr; +use crate::sys::ioctl::{ioctl_ior, ioctl_iowr}; use crate::{ bitflags, consts, ioctl_none, ioctl_read, ioctl_write_buf, ioctl_write_ptr, ioctl_write_val, - ioctl_writeread, + ioctl_writeread, ioctl_writeread_buf, }; pub const KVMIO: u8 = 0xAE; @@ -41,11 +36,9 @@ consts! { TDX = 5; } } - #[cfg(target_arch = "aarch64")] pub struct KvmVmType(#[allow(dead_code)] pub u64); -#[cfg(target_arch = "x86_64")] pub const KVM_MAX_CPUID_ENTRIES: usize = 256; bitflags! { @@ -55,7 +48,6 @@ bitflags! { } } -#[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Debug, Copy, Clone, Default)] pub struct KvmCpuidEntry2 { @@ -69,7 +61,6 @@ pub struct KvmCpuidEntry2 { pub padding: [u32; 3], } -#[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Debug, Clone)] pub struct KvmCpuid2 { @@ -103,7 +94,6 @@ bitflags! { } } -#[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Debug, Copy, Clone, Default)] pub struct KvmMsrEntry { @@ -112,7 +102,6 @@ pub struct KvmMsrEntry { pub data: u64, } -#[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Debug, Clone)] pub struct KvmMsrs { @@ -121,7 +110,6 @@ pub struct KvmMsrs { pub entries: [KvmMsrEntry; N], } -#[cfg(target_arch = "x86_64")] pub const MAX_IO_MSRS: usize = 256; bitflags! { @@ -173,7 +161,6 @@ pub struct KvmMemoryAttributes { pub flags: u64, } -#[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Debug, Copy, Clone, Default)] pub struct KvmCreateGuestMemfd { @@ -182,7 +169,6 @@ pub struct KvmCreateGuestMemfd { pub reserved: [u64; 6], } -#[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct KvmRegs { @@ -206,7 +192,6 @@ pub struct KvmRegs { pub rflags: u64, } -#[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct KvmSegment { @@ -225,7 +210,6 @@ pub struct KvmSegment { pub padding: u8, } -#[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct KvmDtable { @@ -234,7 +218,6 @@ pub struct KvmDtable { pub padding: [u16; 3], } -#[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct KvmSregs { @@ -258,7 +241,6 @@ pub struct KvmSregs { pub interrupt_bitmap: [u64; 4], } -#[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct KvmSregs2 { @@ -419,7 +401,6 @@ pub struct KvmIrqfd { pub const KVM_IRQ_ROUTING_IRQCHIP: u32 = 1; pub const KVM_IRQ_ROUTING_MSI: u32 = 2; -#[cfg(target_arch = "x86_64")] pub const KVM_IRQCHIP_IOAPIC: u32 = 2; #[derive(Debug, Clone, Copy, Default)] @@ -503,7 +484,6 @@ impl Debug for KvmIrqRouting { bitflags! { #[derive(Default)] pub struct KvmMsiFlag(u32) { - #[cfg(target_arch = "aarch64")] VALID_DEVID = 1 << 0; } } @@ -585,7 +565,6 @@ pub struct KvmEnableCap { pub pad: [u8; 64], } -#[cfg(not(target_arch = "x86_64"))] #[repr(C)] #[derive(Debug, Copy, Clone, Default)] pub struct KvmOneReg { @@ -593,7 +572,6 @@ pub struct KvmOneReg { pub addr: u64, } -#[cfg(target_arch = "aarch64")] #[derive(Debug, Clone, Copy)] #[repr(C)] pub struct KvmCreateDevice { @@ -602,7 +580,6 @@ pub struct KvmCreateDevice { pub flags: u32, } -#[cfg(target_arch = "aarch64")] #[derive(Debug, Clone, Copy, Default)] #[repr(C)] pub struct KvmDeviceAttr { @@ -612,7 +589,6 @@ pub struct KvmDeviceAttr { pub addr: u64, } -#[cfg(target_arch = "aarch64")] consts! { pub struct KvmDevType(u32) { ARM_VGIC_V2 = 5; @@ -621,7 +597,6 @@ consts! { } } -#[cfg(target_arch = "aarch64")] consts! { pub struct KvmDevArmVgicGrp(u32) { ADDR = 0; @@ -634,7 +609,6 @@ consts! { } } -#[cfg(target_arch = "aarch64")] consts! { pub struct KvmVgicAddrType(u64) { DIST_V2 = 0; @@ -646,7 +620,6 @@ consts! { } } -#[cfg(target_arch = "aarch64")] consts! { pub struct KvmDevArmVgicCtrl(u64) { INIT = 0; @@ -657,7 +630,6 @@ consts! { } } -#[cfg(target_arch = "aarch64")] bitfield! { #[derive(Copy, Clone, Default, PartialEq, Eq, Hash)] #[repr(transparent)] @@ -668,7 +640,6 @@ bitfield! { pub index, set_index: 11, 0; } -#[cfg(target_arch = "aarch64")] #[repr(C)] #[derive(Debug, Copy, Clone, Default)] pub struct KvmVcpuInit { @@ -689,7 +660,6 @@ ioctl_none!(kvm_get_api_version, KVMIO, 0x00); ioctl_write_val!(kvm_create_vm, KVMIO, 0x01, KvmVmType); ioctl_write_val!(kvm_check_extension, KVMIO, 0x03, KvmCap); ioctl_none!(kvm_get_vcpu_mmap_size, KVMIO, 0x04); -#[cfg(target_arch = "x86_64")] ioctl_writeread_buf!(kvm_get_supported_cpuid, KVMIO, 0x05, KvmCpuid2); ioctl_write_val!(kvm_create_vcpu, KVMIO, 0x41, u32); @@ -699,9 +669,7 @@ ioctl_write_ptr!( 0x46, KvmUserspaceMemoryRegion ); -#[cfg(target_arch = "x86_64")] ioctl_write_val!(kvm_set_tss_addr, KVMIO, 0x47, u64); -#[cfg(target_arch = "x86_64")] ioctl_write_ptr!(kvm_set_identity_map_addr, KVMIO, 0x48, u64); ioctl_write_ptr!( kvm_set_user_memory_region2, @@ -710,7 +678,6 @@ ioctl_write_ptr!( KvmUserspaceMemoryRegion2 ); -#[cfg(target_arch = "x86_64")] ioctl_none!(kvm_create_irqchip, KVMIO, 0x60); ioctl_write_buf!(kvm_set_gsi_routing, KVMIO, 0x6a, KvmIrqRouting); @@ -718,36 +685,25 @@ ioctl_write_ptr!(kvm_irqfd, KVMIO, 0x76, KvmIrqfd); ioctl_write_ptr!(kvm_ioeventfd, KVMIO, 0x79, KvmIoEventFd); ioctl_none!(kvm_run, KVMIO, 0x80); -#[cfg(target_arch = "x86_64")] ioctl_read!(kvm_get_regs, KVMIO, 0x81, KvmRegs); -#[cfg(target_arch = "x86_64")] ioctl_write_ptr!(kvm_set_regs, KVMIO, 0x82, KvmRegs); -#[cfg(target_arch = "x86_64")] ioctl_read!(kvm_get_sregs, KVMIO, 0x83, KvmSregs); -#[cfg(target_arch = "x86_64")] ioctl_write_ptr!(kvm_set_sregs, KVMIO, 0x84, KvmSregs); -#[cfg(target_arch = "x86_64")] ioctl_write_buf!(kvm_set_msrs, KVMIO, 0x89, KvmMsrs); -#[cfg(target_arch = "x86_64")] ioctl_write_buf!(kvm_set_cpuid2, KVMIO, 0x90, KvmCpuid2); ioctl_write_ptr!(kvm_enable_cap, KVMIO, 0xa3, KvmEnableCap); ioctl_write_ptr!(kvm_signal_msi, KVMIO, 0xa5, KvmMsi); -#[cfg(not(target_arch = "x86_64"))] ioctl_write_ptr!(kvm_get_one_reg, KVMIO, 0xab, KvmOneReg); -#[cfg(not(target_arch = "x86_64"))] ioctl_write_ptr!(kvm_set_one_reg, KVMIO, 0xac, KvmOneReg); ioctl_none!(kvm_kvmclock_ctrl, KVMIO, 0xad); -#[cfg(target_arch = "aarch64")] ioctl_write_ptr!(kvm_arm_vcpu_init, KVMIO, 0xae, KvmVcpuInit); -#[cfg(target_arch = "aarch64")] ioctl_read!(kvm_arm_preferred_target, KVMIO, 0xaf, KvmVcpuInit); -#[cfg(target_arch = "x86_64")] ioctl_writeread!(kvm_memory_encrypt_op, ioctl_iowr::(KVMIO, 0xba)); ioctl_write_ptr!( @@ -762,19 +718,13 @@ ioctl_write_ptr!( KvmEncRegion ); -#[cfg(target_arch = "x86_64")] ioctl_read!(kvm_get_sregs2, KVMIO, 0xcc, KvmSregs2); -#[cfg(target_arch = "x86_64")] ioctl_write_ptr!(kvm_set_sregs2, KVMIO, 0xcd, KvmSregs2); ioctl_write_ptr!(kvm_set_memory_attributes, KVMIO, 0xd2, KvmMemoryAttributes); -#[cfg(target_arch = "x86_64")] ioctl_writeread!(kvm_create_guest_memfd, KVMIO, 0xd4, KvmCreateGuestMemfd); -#[cfg(target_arch = "aarch64")] ioctl_writeread!(kvm_create_device, KVMIO, 0xe0, KvmCreateDevice); -#[cfg(target_arch = "aarch64")] ioctl_write_ptr!(kvm_set_device_attr, KVMIO, 0xe1, KvmDeviceAttr); -#[cfg(target_arch = "aarch64")] ioctl_write_ptr!(kvm_get_device_attr, KVMIO, 0xe2, KvmDeviceAttr); diff --git a/alioth/src/sys/linux/linux.rs b/alioth/src/sys/linux/linux.rs index 67cba0f6..46a9637d 100644 --- a/alioth/src/sys/linux/linux.rs +++ b/alioth/src/sys/linux/linux.rs @@ -15,9 +15,7 @@ pub mod if_tun; pub mod ioctl; pub mod kvm; -#[cfg(target_arch = "x86_64")] pub mod sev; -#[cfg(target_arch = "x86_64")] pub mod tdx; pub mod vfio; pub mod vhost; diff --git a/alioth/src/sys/linux/sev.rs b/alioth/src/sys/linux/sev.rs index c831dd23..dfdc1b54 100644 --- a/alioth/src/sys/linux/sev.rs +++ b/alioth/src/sys/linux/sev.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::arch::sev::{SevPolicy, SevStatus, SnpPageType, SnpPolicy}; +use crate::arch::x86_64::sev::{SevPolicy, SevStatus, SnpPageType, SnpPolicy}; use crate::{consts, ioctl_writeread}; consts! { diff --git a/alioth/src/sys/linux/tdx.rs b/alioth/src/sys/linux/tdx.rs index aedebcfc..476ceaa9 100644 --- a/alioth/src/sys/linux/tdx.rs +++ b/alioth/src/sys/linux/tdx.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::arch::tdx::TdAttr; +use crate::arch::x86_64::tdx::TdAttr; use crate::sys::kvm::{KVM_MAX_CPUID_ENTRIES, KvmCpuid2}; use crate::{bitflags, consts}; diff --git a/alioth/src/utils/utils.rs b/alioth/src/utils/utils.rs index 597ff497..f72adcdd 100644 --- a/alioth/src/utils/utils.rs +++ b/alioth/src/utils/utils.rs @@ -60,7 +60,6 @@ macro_rules! mask_bits { }; } -#[cfg(target_arch = "x86_64")] #[inline] pub fn wrapping_sum<'a, T>(data: T) -> u8 where