From 852c5cea72e07706be1e778f6cdd03c8026ee966 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Fri, 27 Feb 2004 15:19:27 +0000 Subject: bitkeeper revision 1.755 (403f5fffwYqT6Gw88yRJHe04lMgpjg) Many files: Further cleanups to the Xen pagetable interface. --- tools/xc/lib/xc_linux_restore.c | 71 ++++++++--------------------------------- 1 file changed, 14 insertions(+), 57 deletions(-) (limited to 'tools/xc/lib/xc_linux_restore.c') diff --git a/tools/xc/lib/xc_linux_restore.c b/tools/xc/lib/xc_linux_restore.c index 74e7641bed..3b00a81011 100644 --- a/tools/xc/lib/xc_linux_restore.c +++ b/tools/xc/lib/xc_linux_restore.c @@ -43,56 +43,6 @@ static int get_pfn_list(int xc_handle, return (ret < 0) ? -1 : op.u.getmemlist.num_pfns; } -#define MAX_MMU_UPDATES 1024 - -static int flush_mmu_updates(int xc_handle, - mmu_update_t *mmu_updates, - int *mmu_update_idx) -{ - int err = 0; - privcmd_hypercall_t hypercall; - - if ( *mmu_update_idx == 0 ) - return 0; - - hypercall.op = __HYPERVISOR_mmu_update; - hypercall.arg[0] = (unsigned long)mmu_updates; - hypercall.arg[1] = (unsigned long)*mmu_update_idx; - - if ( mlock(mmu_updates, sizeof(mmu_updates)) != 0 ) - { - PERROR("Could not lock pagetable update array"); - err = 1; - goto out; - } - - if ( do_xen_hypercall(xc_handle, &hypercall) < 0 ) - { - ERROR("Failure when submitting mmu updates"); - err = 1; - } - - *mmu_update_idx = 0; - - (void)munlock(mmu_updates, sizeof(mmu_updates)); - - out: - return err; -} - -static int add_mmu_update(int xc_handle, - mmu_update_t *mmu_updates, - int *mmu_update_idx, - unsigned long ptr, - unsigned long val) -{ - mmu_updates[*mmu_update_idx].ptr = ptr; - mmu_updates[*mmu_update_idx].val = val; - if ( ++*mmu_update_idx == MAX_MMU_UPDATES ) - return flush_mmu_updates(xc_handle, mmu_updates, mmu_update_idx); - return 0; -} - static int checked_read(gzFile fd, void *buf, size_t count) { int rc; @@ -147,8 +97,7 @@ int xc_linux_restore(int xc_handle, int fd; gzFile gfd; - mmu_update_t mmu_updates[MAX_MMU_UPDATES]; - int mmu_update_idx = 0; + mmu_t *mmu = NULL; int pm_handle = -1; @@ -252,6 +201,12 @@ int xc_linux_restore(int xc_handle, goto out; } + if ( (mmu = init_mmu_updates(xc_handle, dom)) == NULL ) + { + ERROR("Could not initialise for MMU updates"); + goto out; + } + verbose_printf("Reloading memory pages: 0%%"); /* @@ -323,7 +278,7 @@ int xc_linux_restore(int xc_handle, unmap_pfn(pm_handle, ppage); - if ( add_mmu_update(xc_handle, mmu_updates, &mmu_update_idx, + if ( add_mmu_update(xc_handle, mmu, (mfn<