fix(xen): arm64 is currently unsupported, treat it as such at runtime

This commit is contained in:
Alex Zenla
2024-06-20 17:15:37 -07:00
parent 089c9cbff9
commit 11a34d4834
5 changed files with 99 additions and 9 deletions

View File

@ -7,7 +7,7 @@ use log::error;
use loopdev::LoopControl; use loopdev::LoopControl;
use tokio::sync::Semaphore; use tokio::sync::Semaphore;
use uuid::Uuid; use uuid::Uuid;
use xenclient::{x86pv::X86PvPlatform, XenClient}; use xenclient::XenClient;
use xenstore::{XsdClient, XsdInterface}; use xenstore::{XsdClient, XsdInterface};
use self::{ use self::{
@ -21,7 +21,11 @@ pub mod channel;
pub mod ip; pub mod ip;
pub mod launch; 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 struct GuestLoopInfo {
pub device: String, pub device: String,

View File

@ -270,7 +270,6 @@ impl Default for CreateDomain {
CreateDomain { CreateDomain {
ssidref: SECINITSID_DOMU, ssidref: SECINITSID_DOMU,
handle: Uuid::new_v4().into_bytes(), handle: Uuid::new_v4().into_bytes(),
#[cfg(target_arch = "x86_64")]
flags: 0, flags: 0,
iommu_opts: 0, iommu_opts: 0,
max_vcpus: 1, max_vcpus: 1,
@ -453,8 +452,8 @@ impl Default for VcpuGuestContextFpuCtx {
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug, Default)] #[derive(Copy, Clone, Debug, Default)]
#[cfg(target_arch = "x86_64")] #[allow(non_camel_case_types)]
pub struct CpuUserRegs { pub struct x8664CpuUserRegs {
pub r15: u64, pub r15: u64,
pub r14: u64, pub r14: u64,
pub r13: u64, pub r13: u64,
@ -493,7 +492,6 @@ pub struct CpuUserRegs {
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug, Default)] #[derive(Copy, Clone, Debug, Default)]
#[cfg(target_arch = "x86_64")]
pub struct TrapInfo { pub struct TrapInfo {
pub vector: u8, pub vector: u8,
pub flags: u8, pub flags: u8,
@ -507,7 +505,7 @@ pub struct TrapInfo {
pub struct x8664VcpuGuestContext { pub struct x8664VcpuGuestContext {
pub fpu_ctx: VcpuGuestContextFpuCtx, pub fpu_ctx: VcpuGuestContextFpuCtx,
pub flags: u64, pub flags: u64,
pub user_regs: CpuUserRegs, pub user_regs: x8664CpuUserRegs,
pub trap_ctx: [TrapInfo; 256], pub trap_ctx: [TrapInfo; 256],
pub ldt_base: u64, pub ldt_base: u64,
pub ldt_ents: u64, pub ldt_ents: u64,
@ -602,7 +600,7 @@ pub struct Arm64CpuUserRegs {
#[derive(Copy, Clone, Debug, Default)] #[derive(Copy, Clone, Debug, Default)]
pub struct Arm64VcpuGuestContext { pub struct Arm64VcpuGuestContext {
pub flags: u32, pub flags: u32,
pub user_regs: CpuUserRegs, pub user_regs: x8664CpuUserRegs,
pub sctlr: u64, pub sctlr: u64,
pub ttbcr: u64, pub ttbcr: u64,
pub ttbr0: u64, pub ttbr0: u64,

View File

@ -71,7 +71,6 @@ impl BootDomain {
pfn: self.pfn_alloc_end, pfn: self.pfn_alloc_end,
addr: 0, addr: 0,
size, size,
#[cfg(target_arch = "x86_64")]
pages, pages,
}; };

View File

@ -27,6 +27,9 @@ use xenstore::{
}; };
pub mod pci; pub mod pci;
pub mod unsupported;
#[cfg(target_arch = "x86_64")]
pub mod x86pv; pub mod x86pv;
#[derive(Clone)] #[derive(Clone)]

View File

@ -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<Option<DomainSegment>> {
panic!("unsupported platform")
}
async fn alloc_page_tables(&mut self, _: &mut BootDomain) -> Result<Option<DomainSegment>> {
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")
}
}