Message ID | 20250306220343.203047-3-jason.andryuk@amd.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | ARM split hardware and control domains | expand |
On Thu, 6 Mar 2025, Jason Andryuk wrote: > Factor out construct_hwdom() from construct_dom0(). This will be > re-used by the dom0less code when building a domain with the hardware > capability. > > iommu_hwdom_init(d) is moved into construct_hwdom() which moves it after > kernel_probe(). kernel_probe() doesn't seem to depend on its setting. > > Signed-off-by: Jason Andryuk <jason.andryuk@amd.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> > --- > xen/arch/arm/domain_build.c | 28 ++++++++++++++++--------- > xen/arch/arm/include/asm/domain_build.h | 1 + > 2 files changed, 19 insertions(+), 10 deletions(-) > > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c > index 6784ee6f6d..d676422496 100644 > --- a/xen/arch/arm/domain_build.c > +++ b/xen/arch/arm/domain_build.c > @@ -2296,8 +2296,6 @@ static int __init construct_dom0(struct domain *d) > dom0_mem = MB(512); > } > > - iommu_hwdom_init(d); > - > d->max_pages = dom0_mem >> PAGE_SHIFT; > > kinfo.unassigned_mem = dom0_mem; > @@ -2307,17 +2305,27 @@ static int __init construct_dom0(struct domain *d) > if ( rc < 0 ) > return rc; > > + return construct_hwdom(&kinfo); > +} > + > +int __init construct_hwdom(struct kernel_info *kinfo) > +{ > + struct domain *d = kinfo->d; > + int rc; > + > + iommu_hwdom_init(d); > + > #ifdef CONFIG_ARM_64 > /* type must be set before allocate_memory */ > - d->arch.type = kinfo.type; > + d->arch.type = kinfo->type; > #endif > - find_gnttab_region(d, &kinfo); > + find_gnttab_region(d, kinfo); > if ( is_domain_direct_mapped(d) ) > - allocate_memory_11(d, &kinfo); > + allocate_memory_11(d, kinfo); > else > - allocate_memory(d, &kinfo); > + allocate_memory(d, kinfo); > > - rc = process_shm_chosen(d, &kinfo); > + rc = process_shm_chosen(d, kinfo); > if ( rc < 0 ) > return rc; > > @@ -2332,7 +2340,7 @@ static int __init construct_dom0(struct domain *d) > > if ( acpi_disabled ) > { > - rc = prepare_dtb_hwdom(d, &kinfo); > + rc = prepare_dtb_hwdom(d, kinfo); > if ( rc < 0 ) > return rc; > #ifdef CONFIG_HAS_PCI > @@ -2340,12 +2348,12 @@ static int __init construct_dom0(struct domain *d) > #endif > } > else > - rc = prepare_acpi(d, &kinfo); > + rc = prepare_acpi(d, kinfo); > > if ( rc < 0 ) > return rc; > > - return construct_domain(d, &kinfo); > + return construct_domain(d, kinfo); > } > > void __init create_dom0(void) > diff --git a/xen/arch/arm/include/asm/domain_build.h b/xen/arch/arm/include/asm/domain_build.h > index 5d77af2e8b..134290853c 100644 > --- a/xen/arch/arm/include/asm/domain_build.h > +++ b/xen/arch/arm/include/asm/domain_build.h > @@ -13,6 +13,7 @@ bool allocate_bank_memory(struct kernel_info *kinfo, gfn_t sgfn, > paddr_t tot_size); > void allocate_memory(struct domain *d, struct kernel_info *kinfo); > int construct_domain(struct domain *d, struct kernel_info *kinfo); > +int construct_hwdom(struct kernel_info *kinfo); > int domain_fdt_begin_node(void *fdt, const char *name, uint64_t unit); > int make_chosen_node(const struct kernel_info *kinfo); > int make_cpus_node(const struct domain *d, void *fdt); > -- > 2.48.1 >
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 6784ee6f6d..d676422496 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2296,8 +2296,6 @@ static int __init construct_dom0(struct domain *d) dom0_mem = MB(512); } - iommu_hwdom_init(d); - d->max_pages = dom0_mem >> PAGE_SHIFT; kinfo.unassigned_mem = dom0_mem; @@ -2307,17 +2305,27 @@ static int __init construct_dom0(struct domain *d) if ( rc < 0 ) return rc; + return construct_hwdom(&kinfo); +} + +int __init construct_hwdom(struct kernel_info *kinfo) +{ + struct domain *d = kinfo->d; + int rc; + + iommu_hwdom_init(d); + #ifdef CONFIG_ARM_64 /* type must be set before allocate_memory */ - d->arch.type = kinfo.type; + d->arch.type = kinfo->type; #endif - find_gnttab_region(d, &kinfo); + find_gnttab_region(d, kinfo); if ( is_domain_direct_mapped(d) ) - allocate_memory_11(d, &kinfo); + allocate_memory_11(d, kinfo); else - allocate_memory(d, &kinfo); + allocate_memory(d, kinfo); - rc = process_shm_chosen(d, &kinfo); + rc = process_shm_chosen(d, kinfo); if ( rc < 0 ) return rc; @@ -2332,7 +2340,7 @@ static int __init construct_dom0(struct domain *d) if ( acpi_disabled ) { - rc = prepare_dtb_hwdom(d, &kinfo); + rc = prepare_dtb_hwdom(d, kinfo); if ( rc < 0 ) return rc; #ifdef CONFIG_HAS_PCI @@ -2340,12 +2348,12 @@ static int __init construct_dom0(struct domain *d) #endif } else - rc = prepare_acpi(d, &kinfo); + rc = prepare_acpi(d, kinfo); if ( rc < 0 ) return rc; - return construct_domain(d, &kinfo); + return construct_domain(d, kinfo); } void __init create_dom0(void) diff --git a/xen/arch/arm/include/asm/domain_build.h b/xen/arch/arm/include/asm/domain_build.h index 5d77af2e8b..134290853c 100644 --- a/xen/arch/arm/include/asm/domain_build.h +++ b/xen/arch/arm/include/asm/domain_build.h @@ -13,6 +13,7 @@ bool allocate_bank_memory(struct kernel_info *kinfo, gfn_t sgfn, paddr_t tot_size); void allocate_memory(struct domain *d, struct kernel_info *kinfo); int construct_domain(struct domain *d, struct kernel_info *kinfo); +int construct_hwdom(struct kernel_info *kinfo); int domain_fdt_begin_node(void *fdt, const char *name, uint64_t unit); int make_chosen_node(const struct kernel_info *kinfo); int make_cpus_node(const struct domain *d, void *fdt);
Factor out construct_hwdom() from construct_dom0(). This will be re-used by the dom0less code when building a domain with the hardware capability. iommu_hwdom_init(d) is moved into construct_hwdom() which moves it after kernel_probe(). kernel_probe() doesn't seem to depend on its setting. Signed-off-by: Jason Andryuk <jason.andryuk@amd.com> --- xen/arch/arm/domain_build.c | 28 ++++++++++++++++--------- xen/arch/arm/include/asm/domain_build.h | 1 + 2 files changed, 19 insertions(+), 10 deletions(-)