fix(x86): use IOMMU only when needed for passthrough

This commit is contained in:
Alex Zenla
2024-06-20 17:46:16 -07:00
parent 02b97cff6d
commit a71375e4ad
4 changed files with 9 additions and 5 deletions

View File

@ -261,7 +261,7 @@ impl<I: BootImageLoader, P: BootSetupPlatform> BootSetup<I, P> {
#[async_trait::async_trait] #[async_trait::async_trait]
pub trait BootSetupPlatform: Clone { pub trait BootSetupPlatform: Clone {
fn create_domain(&self) -> CreateDomain; fn create_domain(&self, needs_passthrough: bool) -> CreateDomain;
fn page_size(&self) -> u64; fn page_size(&self) -> u64;
fn page_shift(&self) -> u64; fn page_shift(&self) -> u64;
fn needs_early_kernel(&self) -> bool; fn needs_early_kernel(&self) -> bool;

View File

@ -150,7 +150,7 @@ impl<P: BootSetupPlatform> XenClient<P> {
} }
pub async fn create(&self, config: &DomainConfig) -> Result<CreatedDomain> { pub async fn create(&self, config: &DomainConfig) -> Result<CreatedDomain> {
let mut domain = self.platform.create_domain(); let mut domain = self.platform.create_domain(!config.pcis.is_empty());
domain.max_vcpus = config.max_vcpus; domain.max_vcpus = config.max_vcpus;
let domid = self.call.create_domain(domain).await?; let domid = self.call.create_domain(domain).await?;
match self.init(domid, &domain, config).await { match self.init(domid, &domain, config).await {

View File

@ -16,7 +16,7 @@ impl UnsupportedPlatform {
#[async_trait::async_trait] #[async_trait::async_trait]
impl BootSetupPlatform for UnsupportedPlatform { impl BootSetupPlatform for UnsupportedPlatform {
fn create_domain(&self) -> CreateDomain { fn create_domain(&self, _: bool) -> CreateDomain {
panic!("unsupported platform") panic!("unsupported platform")
} }

View File

@ -434,9 +434,13 @@ impl X86PvPlatform {
#[async_trait::async_trait] #[async_trait::async_trait]
impl BootSetupPlatform for X86PvPlatform { impl BootSetupPlatform for X86PvPlatform {
fn create_domain(&self) -> CreateDomain { fn create_domain(&self, needs_passthrough: bool) -> CreateDomain {
CreateDomain { CreateDomain {
flags: XEN_DOMCTL_CDF_IOMMU, flags: if needs_passthrough {
XEN_DOMCTL_CDF_IOMMU
} else {
0
},
..Default::default() ..Default::default()
} }
} }