xen/arm: kernel: Rework kernel_zimage_load to use the generic copy helper

The function kernel_zimage 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 kernel in the virtual space.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
Julien Grall authored and Stefano Stabellini committed 2017-12-12 12:11:29 -08:00
1 parent 5302bd490b
commit d8972aa964
3 files changed
+15 -21

No files matched your search

+1
View File
@@ -2135,6 +2135,7 @@ int construct_dom0(struct domain *d)
d->max_pages = ~0U;
kinfo.unassigned_mem = dom0_mem;
kinfo.d = d;
rc = kernel_probe(&kinfo);
if ( rc < 0 )
+12 -21
View File
@@ -15,6 +15,8 @@
#include <xen/gunzip.h>
#include <xen/vmap.h>
#include <asm/guest_access.h>
#include "kernel.h"
#define UIMAGE_MAGIC 0x27051956
@@ -157,7 +159,8 @@ static void kernel_zimage_load(struct kernel_info *info)
paddr_t load_addr = kernel_zimage_place(info);
paddr_t paddr = info->zimage.kernel_addr;
paddr_t len = info->zimage.len;
unsigned long offs;
void *kernel;
int rc;
info->entry = load_addr;
@@ -165,29 +168,17 @@ static void kernel_zimage_load(struct kernel_info *info)
printk("Loading zImage from %"PRIpaddr" to %"PRIpaddr"-%"PRIpaddr"\n",
paddr, load_addr, load_addr + len);
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);
kernel = ioremap_wc(paddr, len);
if ( !kernel )
panic("Unable to map the hwdom kernel");
par = gvirt_to_maddr(load_addr + offs, &ma, GV2M_WRITE);
if ( par )
{
panic("Unable to map translate guest address");
return;
}
rc = copy_to_guest_phys_flush_dcache(info->d, load_addr,
kernel, len);
if ( rc != 0 )
panic("Unable to copy the kernel in the hwdom memory");
dst = map_domain_page(maddr_to_mfn(ma));
copy_from_paddr(dst + s, paddr + offs, l);
unmap_domain_page(dst);
offs += l;
}
iounmap(kernel);
}
/*
+2
View File
@@ -15,6 +15,8 @@ struct kernel_info {
enum domain_type type;
#endif
struct domain *d;
void *fdt; /* flat device tree */
paddr_t unassigned_mem; /* RAM not (yet) assigned to a bank */
struct meminfo mem;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.