[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v5 02/15] x86/pv: Use copy_domain_page() to manage domheap pages during initrd relocation
From: Wei Liu <wei.liu2@xxxxxxxxxx> Replace the manual copying logic with a call to `copy_domain_page()` while relocating intird which map and unmap pages accordingly. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> Signed-off-by: Wei Wang <wawei@xxxxxxxxx> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx> Signed-off-by: Elias El Yandouzi <eliasely@xxxxxxxxxx> Signed-off-by: Alejandro Vallejo <alejandro.vallejo@xxxxxxxxx> --- v4->v5: * No changes v3->v4: * Use the count of pages instead of calculating from order for nr_pages initialization v2->v3: * Rename commit title * Rework the for loop copying the pages v1->v2: * Get rid of mfn_to_virt * Don't open code copy_domain_page() Changes since Hongyan's version: * Add missing newline after the variable declaration --- xen/arch/x86/pv/dom0_build.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index f54d1da5c6f4..08a4534d5c19 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -637,17 +637,24 @@ static int __init dom0_construct(struct boot_info *bi, struct domain *d) if ( d->arch.physaddr_bitsize && ((mfn + count - 1) >> (d->arch.physaddr_bitsize - PAGE_SHIFT)) ) { + unsigned int nr_pages = count; + order = get_order_from_pages(count); page = alloc_domheap_pages(d, order, MEMF_no_scrub); if ( !page ) panic("Not enough RAM for domain 0 initrd\n"); + for ( count = -count; order--; ) if ( count & (1UL << order) ) { free_domheap_pages(page, order); page += 1UL << order; + nr_pages -= 1UL << order; } - memcpy(page_to_virt(page), __va(initrd->start), initrd_len); + + for ( ; nr_pages-- ; page++, mfn++ ) + copy_domain_page(page_to_mfn(page), _mfn(mfn)); + /* * The initrd was copied but the initrd variable is reused in the * calculations below. As to not leak the memory used for the -- 2.47.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |