Message ID | 20171123183210.12045-10-julien.grall@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | xen/arm: Stage-2 handling cleanup | expand |
On Thu, 23 Nov 2017, Julien Grall wrote: > The function initrd_load is dealing with IPA but uses gvirt_to_maddr to > do the translation. This is currently working fine because the stage-1 MMU > is disabled. > > Furthermore, the function is implementing its own copy to guest resulting > in code duplication and making more difficult to update the logic in > page-tables (such support for Populate On Demand). > > The new copy_to_guest_phys_flush_dcache could be used here by temporarily > mapping the full initrd in the virtual space. > > Signed-off-by: Julien Grall <julien.grall@linaro.org> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> > --- > xen/arch/arm/domain_build.c | 31 ++++++++----------------------- > 1 file changed, 8 insertions(+), 23 deletions(-) > > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c > index 3f87bf2051..42c2e16ef6 100644 > --- a/xen/arch/arm/domain_build.c > +++ b/xen/arch/arm/domain_build.c > @@ -1966,11 +1966,11 @@ static void initrd_load(struct kernel_info *kinfo) > const struct bootmodule *mod = kinfo->initrd_bootmodule; > paddr_t load_addr = kinfo->initrd_paddr; > paddr_t paddr, len; > - unsigned long offs; > int node; > int res; > __be32 val[2]; > __be32 *cellp; > + void __iomem *initrd; > > if ( !mod || !mod->size ) > return; > @@ -2000,29 +2000,14 @@ static void initrd_load(struct kernel_info *kinfo) > if ( res ) > panic("Cannot fix up \"linux,initrd-end\" property"); > > - for ( offs = 0; offs < len; ) > - { > - uint64_t par; > - paddr_t s, l, ma = 0; > - void *dst; > - > - s = offs & ~PAGE_MASK; > - l = min(PAGE_SIZE - s, len); > - > - par = gvirt_to_maddr(load_addr + offs, &ma, GV2M_WRITE); > - if ( par ) > - { > - panic("Unable to translate guest address"); > - return; > - } > - > - dst = map_domain_page(maddr_to_mfn(ma)); > + initrd = ioremap_wc(paddr, len); > + if ( !initrd ) > + panic("Unable to map the hwdom initrd"); > > - copy_from_paddr(dst + s, paddr + offs, l); > - > - unmap_domain_page(dst); > - offs += l; > - } > + res = copy_to_guest_phys_flush_dcache(kinfo->d, load_addr, > + initrd, len); > + if ( res != 0 ) > + panic("Unable to copy the initrd in the hwdom memory"); > } > > static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo)
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 3f87bf2051..42c2e16ef6 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1966,11 +1966,11 @@ static void initrd_load(struct kernel_info *kinfo) const struct bootmodule *mod = kinfo->initrd_bootmodule; paddr_t load_addr = kinfo->initrd_paddr; paddr_t paddr, len; - unsigned long offs; int node; int res; __be32 val[2]; __be32 *cellp; + void __iomem *initrd; if ( !mod || !mod->size ) return; @@ -2000,29 +2000,14 @@ static void initrd_load(struct kernel_info *kinfo) if ( res ) panic("Cannot fix up \"linux,initrd-end\" property"); - for ( offs = 0; offs < len; ) - { - uint64_t par; - paddr_t s, l, ma = 0; - void *dst; - - s = offs & ~PAGE_MASK; - l = min(PAGE_SIZE - s, len); - - par = gvirt_to_maddr(load_addr + offs, &ma, GV2M_WRITE); - if ( par ) - { - panic("Unable to translate guest address"); - return; - } - - dst = map_domain_page(maddr_to_mfn(ma)); + initrd = ioremap_wc(paddr, len); + if ( !initrd ) + panic("Unable to map the hwdom initrd"); - copy_from_paddr(dst + s, paddr + offs, l); - - unmap_domain_page(dst); - offs += l; - } + res = copy_to_guest_phys_flush_dcache(kinfo->d, load_addr, + initrd, len); + if ( res != 0 ) + panic("Unable to copy the initrd in the hwdom memory"); } static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo)
The function initrd_load is dealing with IPA but uses gvirt_to_maddr to do the translation. This is currently working fine because the stage-1 MMU is disabled. Furthermore, the function is implementing its own copy to guest resulting in code duplication and making more difficult to update the logic in page-tables (such support for Populate On Demand). The new copy_to_guest_phys_flush_dcache could be used here by temporarily mapping the full initrd in the virtual space. Signed-off-by: Julien Grall <julien.grall@linaro.org> --- xen/arch/arm/domain_build.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-)