diff --git a/crates/runtime/src/lib.rs b/crates/runtime/src/lib.rs index 6523f32..9fc81d3 100644 --- a/crates/runtime/src/lib.rs +++ b/crates/runtime/src/lib.rs @@ -7,7 +7,7 @@ use log::error; use loopdev::LoopControl; use tokio::sync::Semaphore; use uuid::Uuid; -use xenclient::{x86pv::X86PvPlatform, XenClient}; +use xenclient::XenClient; use xenstore::{XsdClient, XsdInterface}; use self::{ @@ -21,7 +21,11 @@ pub mod channel; pub mod ip; pub mod launch; -type RuntimePlatform = X86PvPlatform; +#[cfg(target_arch = "x86_64")] +type RuntimePlatform = xenclient::x86pv::X86PvPlatform; + +#[cfg(not(target_arch = "x86_64"))] +type RuntimePlatform = xenclient::unsupported::UnsupportedPlatform; pub struct GuestLoopInfo { pub device: String, diff --git a/crates/xen/xencall/src/sys.rs b/crates/xen/xencall/src/sys.rs index 23b5752..fe0628b 100644 --- a/crates/xen/xencall/src/sys.rs +++ b/crates/xen/xencall/src/sys.rs @@ -270,7 +270,6 @@ impl Default for CreateDomain { CreateDomain { ssidref: SECINITSID_DOMU, handle: Uuid::new_v4().into_bytes(), - #[cfg(target_arch = "x86_64")] flags: 0, iommu_opts: 0, max_vcpus: 1, @@ -453,8 +452,8 @@ impl Default for VcpuGuestContextFpuCtx { #[repr(C)] #[derive(Copy, Clone, Debug, Default)] -#[cfg(target_arch = "x86_64")] -pub struct CpuUserRegs { +#[allow(non_camel_case_types)] +pub struct x8664CpuUserRegs { pub r15: u64, pub r14: u64, pub r13: u64, @@ -493,7 +492,6 @@ pub struct CpuUserRegs { #[repr(C)] #[derive(Copy, Clone, Debug, Default)] -#[cfg(target_arch = "x86_64")] pub struct TrapInfo { pub vector: u8, pub flags: u8, @@ -507,7 +505,7 @@ pub struct TrapInfo { pub struct x8664VcpuGuestContext { pub fpu_ctx: VcpuGuestContextFpuCtx, pub flags: u64, - pub user_regs: CpuUserRegs, + pub user_regs: x8664CpuUserRegs, pub trap_ctx: [TrapInfo; 256], pub ldt_base: u64, pub ldt_ents: u64, @@ -602,7 +600,7 @@ pub struct Arm64CpuUserRegs { #[derive(Copy, Clone, Debug, Default)] pub struct Arm64VcpuGuestContext { pub flags: u32, - pub user_regs: CpuUserRegs, + pub user_regs: x8664CpuUserRegs, pub sctlr: u64, pub ttbcr: u64, pub ttbr0: u64, diff --git a/crates/xen/xenclient/src/boot.rs b/crates/xen/xenclient/src/boot.rs index 6c846b2..376eb00 100644 --- a/crates/xen/xenclient/src/boot.rs +++ b/crates/xen/xenclient/src/boot.rs @@ -71,7 +71,6 @@ impl BootDomain { pfn: self.pfn_alloc_end, addr: 0, size, - #[cfg(target_arch = "x86_64")] pages, }; diff --git a/crates/xen/xenclient/src/lib.rs b/crates/xen/xenclient/src/lib.rs index 438c81c..820fce0 100644 --- a/crates/xen/xenclient/src/lib.rs +++ b/crates/xen/xenclient/src/lib.rs @@ -27,6 +27,9 @@ use xenstore::{ }; pub mod pci; + +pub mod unsupported; +#[cfg(target_arch = "x86_64")] pub mod x86pv; #[derive(Clone)] diff --git a/crates/xen/xenclient/src/unsupported.rs b/crates/xen/xenclient/src/unsupported.rs new file mode 100644 index 0000000..35b0806 --- /dev/null +++ b/crates/xen/xenclient/src/unsupported.rs @@ -0,0 +1,86 @@ +use xencall::sys::CreateDomain; + +use crate::{ + boot::{BootDomain, BootSetupPlatform, DomainSegment}, + error::Result, +}; + +#[derive(Default, Clone)] +pub struct UnsupportedPlatform; + +impl UnsupportedPlatform { + pub fn new() -> Self { + Self {} + } +} + +#[async_trait::async_trait] +impl BootSetupPlatform for UnsupportedPlatform { + fn create_domain(&self) -> CreateDomain { + panic!("unsupported platform") + } + + fn page_size(&self) -> u64 { + panic!("unsupported platform") + } + + fn page_shift(&self) -> u64 { + panic!("unsupported platform") + } + + fn needs_early_kernel(&self) -> bool { + panic!("unsupported platform") + } + + fn hvm(&self) -> bool { + panic!("unsupported platform") + } + + async fn initialize_early(&mut self, _: &mut BootDomain) -> Result<()> { + panic!("unsupported platform") + } + + async fn initialize_memory(&mut self, _: &mut BootDomain) -> Result<()> { + panic!("unsupported platform") + } + + async fn alloc_p2m_segment(&mut self, _: &mut BootDomain) -> Result> { + panic!("unsupported platform") + } + + async fn alloc_page_tables(&mut self, _: &mut BootDomain) -> Result> { + panic!("unsupported platform") + } + + async fn setup_page_tables(&mut self, _: &mut BootDomain) -> Result<()> { + panic!("unsupported platform") + } + + async fn setup_hypercall_page(&mut self, _: &mut BootDomain) -> Result<()> { + panic!("unsupported platform") + } + + async fn alloc_magic_pages(&mut self, _: &mut BootDomain) -> Result<()> { + panic!("unsupported platform") + } + + async fn setup_shared_info(&mut self, _: &mut BootDomain, _: u64) -> Result<()> { + panic!("unsupported platform") + } + + async fn setup_start_info(&mut self, _: &mut BootDomain, _: u64) -> Result<()> { + panic!("unsupported platform") + } + + async fn bootlate(&mut self, _: &mut BootDomain) -> Result<()> { + panic!("unsupported platform") + } + + async fn vcpu(&mut self, _: &mut BootDomain) -> Result<()> { + panic!("unsupported platform") + } + + async fn gnttab_seed(&mut self, _: &mut BootDomain) -> Result<()> { + panic!("unsupported platform") + } +}