ia64/xen-unstable

view tools/libxc/xc_linux_restore.c @ 2422:2274a0386cc9

bitkeeper revision 1.1159.69.5 (4138e882jA1YaR_OfTfNHe_uT4PDIg)

trivial
author iap10@labyrinth.cl.cam.ac.uk
date Fri Sep 03 21:56:18 2004 +0000 (2004-09-03)
parents 7c3a3f3cf69b
children ac282d5dd9d1 a0d6f6965951 aed97013f9fe
line source
1 /******************************************************************************
2 * xc_linux_restore.c
3 *
4 * Restore the state of a Linux session.
5 *
6 * Copyright (c) 2003, K A Fraser.
7 */
9 #include "xc_private.h"
10 #include <asm-xen/suspend.h>
12 #define MAX_BATCH_SIZE 1024
14 #define DEBUG 0
16 #if DEBUG
17 #define DPRINTF(_f, _a...) printf ( _f , ## _a )
18 #else
19 #define DPRINTF(_f, _a...) ((void)0)
20 #endif
22 static int get_pfn_list(int xc_handle,
23 u32 domain_id,
24 unsigned long *pfn_buf,
25 unsigned long max_pfns)
26 {
27 dom0_op_t op;
28 int ret;
29 op.cmd = DOM0_GETMEMLIST;
30 op.u.getmemlist.domain = (domid_t)domain_id;
31 op.u.getmemlist.max_pfns = max_pfns;
32 op.u.getmemlist.buffer = pfn_buf;
34 if ( mlock(pfn_buf, max_pfns * sizeof(unsigned long)) != 0 )
35 {
36 PERROR("Could not lock pfn list buffer");
37 return -1;
38 }
40 ret = do_dom0_op(xc_handle, &op);
42 (void)munlock(pfn_buf, max_pfns * sizeof(unsigned long));
44 return (ret < 0) ? -1 : op.u.getmemlist.num_pfns;
45 }
47 /** Read the vmconfig string from the state input.
48 * It is stored as a 4-byte count 'n' followed by n bytes.
49 * The config data is stored in a new string in 'ioctxt->vmconfig',
50 * and is null-terminated. The count is stored in 'ioctxt->vmconfig_n'.
51 *
52 * @param ioctxt i/o context
53 * @return 0 on success, non-zero on error.
54 */
55 static int read_vmconfig(XcIOContext *ioctxt)
56 {
57 int err = -1;
59 if ( xcio_read(ioctxt, &ioctxt->vmconfig_n, sizeof(ioctxt->vmconfig_n)) )
60 goto exit;
62 ioctxt->vmconfig = malloc(ioctxt->vmconfig_n + 1);
63 if ( ioctxt->vmconfig == NULL )
64 goto exit;
66 if ( xcio_read(ioctxt, ioctxt->vmconfig, ioctxt->vmconfig_n) )
67 goto exit;
69 ioctxt->vmconfig[ioctxt->vmconfig_n] = '\0';
70 err = 0;
72 exit:
73 if ( err )
74 {
75 if ( ioctxt->vmconfig != NULL )
76 free(ioctxt->vmconfig);
77 ioctxt->vmconfig = NULL;
78 ioctxt->vmconfig_n = 0;
79 }
80 return err;
81 }
83 int xc_linux_restore(int xc_handle, XcIOContext *ioctxt)
84 {
85 dom0_op_t op;
86 int rc = 1, i, n, k;
87 unsigned long mfn, pfn, xpfn;
88 unsigned int prev_pc, this_pc;
89 u32 dom = 0;
90 int verify = 0;
92 /* Number of page frames in use by this Linux session. */
93 unsigned long nr_pfns;
95 /* The new domain's shared-info frame number. */
96 unsigned long shared_info_frame;
97 unsigned char shared_info[PAGE_SIZE]; /* saved contents from file */
99 /* A copy of the CPU context of the guest. */
100 full_execution_context_t ctxt;
102 /* First 16 bytes of the state file must contain 'LinuxGuestRecord'. */
103 char signature[16];
105 /* A copy of the domain's name. */
106 char name[MAX_DOMAIN_NAME];
108 /* A table containg the type of each PFN (/not/ MFN!). */
109 unsigned long *pfn_type = NULL;
111 /* A table of MFNs to map in the current region */
112 unsigned long *region_mfn = NULL;
114 /* A temporary mapping, and a copy, of one frame of guest memory. */
115 unsigned long *ppage = NULL;
117 /* A copy of the pfn-to-mfn table frame list. */
118 unsigned long pfn_to_mfn_frame_list[1024];
120 /* A table mapping each PFN to its new MFN. */
121 unsigned long *pfn_to_mfn_table = NULL;
123 /* used by mapper for updating the domain's copy of the table */
124 unsigned long *live_pfn_to_mfn_table = NULL;
126 /* A temporary mapping of the guest's suspend record. */
127 suspend_record_t *p_srec;
129 char *region_base;
131 mmu_t *mmu = NULL;
133 void *pm_handle = NULL;
135 /* used by debug verify code */
136 unsigned long buf[PAGE_SIZE/sizeof(unsigned long)];
138 if ( mlock(&ctxt, sizeof(ctxt) ) )
139 {
140 /* needed for when we do the build dom0 op,
141 but might as well do early */
142 PERROR("Unable to mlock ctxt");
143 return 1;
144 }
146 /* Start reading the saved-domain record. */
147 if ( xcio_read(ioctxt, signature, 16) ||
148 (memcmp(signature, "LinuxGuestRecord", 16) != 0) )
149 {
150 xcio_error(ioctxt, "Unrecognised state format -- no signature found");
151 goto out;
152 }
154 if ( xcio_read(ioctxt, name, sizeof(name)) ||
155 xcio_read(ioctxt, &nr_pfns, sizeof(unsigned long)) ||
156 xcio_read(ioctxt, pfn_to_mfn_frame_list, PAGE_SIZE) )
157 {
158 xcio_error(ioctxt, "Error reading header");
159 goto out;
160 }
162 if ( read_vmconfig(ioctxt) )
163 {
164 xcio_error(ioctxt, "Error writing vmconfig");
165 goto out;
166 }
168 for ( i = 0; i < MAX_DOMAIN_NAME; i++ )
169 {
170 if ( name[i] == '\0' ) break;
171 if ( name[i] & 0x80 )
172 {
173 xcio_error(ioctxt, "Random characters in domain name");
174 goto out;
175 }
176 }
177 name[MAX_DOMAIN_NAME-1] = '\0';
179 if ( nr_pfns > 1024*1024 )
180 {
181 xcio_error(ioctxt, "Invalid state file -- pfn count out of range");
182 goto out;
183 }
185 /* We want zeroed memory so use calloc rather than malloc. */
186 pfn_to_mfn_table = calloc(1, 4 * nr_pfns);
187 pfn_type = calloc(1, 4 * nr_pfns);
188 region_mfn = calloc(1, 4 * MAX_BATCH_SIZE);
190 if ( (pfn_to_mfn_table == NULL) ||
191 (pfn_type == NULL) ||
192 (region_mfn == NULL) )
193 {
194 errno = ENOMEM;
195 goto out;
196 }
198 if ( mlock(region_mfn, 4 * MAX_BATCH_SIZE ) )
199 {
200 xcio_error(ioctxt, "Could not mlock region_mfn");
201 goto out;
202 }
204 #if 0
205 /* Set the domain's name to that from the restore file */
206 if ( xc_domain_setname( xc_handle, dom, name ) )
207 {
208 xcio_error(ioctxt, "Could not set domain name");
209 goto out;
210 }
212 /* Set the domain's initial memory allocation
213 to that from the restore file */
215 if ( xc_domain_setinitialmem(xc_handle, dom,
216 nr_pfns * (PAGE_SIZE / 1024)) )
217 {
218 xcio_error(ioctxt, "Could not set domain %d initial memory. pfns=%d, %dKB",
219 dom, nr_pfns,nr_pfns * (PAGE_SIZE / 1024));
220 goto out;
221 }
222 #endif
225 /* XXX create domain on CPU=-1 so that in future it auto load ballances by default */
226 if ( xc_domain_create( xc_handle, nr_pfns * (PAGE_SIZE / 1024),
227 "", -1, 1, &dom ) )
228 {
229 xcio_error(ioctxt, "Could not create domain. pfns=%d, %dKB",
230 nr_pfns,nr_pfns * (PAGE_SIZE / 1024));
231 goto out;
232 }
234 ioctxt->domain = dom;
235 printf("Created domain %ld\n",dom);
237 /* Get the domain's shared-info frame. */
238 op.cmd = DOM0_GETDOMAININFO;
239 op.u.getdomaininfo.domain = (domid_t)dom;
240 op.u.getdomaininfo.ctxt = NULL;
241 if ( do_dom0_op(xc_handle, &op) < 0 )
242 {
243 xcio_error(ioctxt, "Could not get information on new domain");
244 goto out;
245 }
246 shared_info_frame = op.u.getdomaininfo.shared_info_frame;
248 if ( (pm_handle = init_pfn_mapper((domid_t)dom)) == NULL )
249 goto out;
251 /* Build the pfn-to-mfn table. We choose MFN ordering returned by Xen. */
252 if ( get_pfn_list(xc_handle, dom, pfn_to_mfn_table, nr_pfns) != nr_pfns )
253 {
254 xcio_error(ioctxt, "Did not read correct number of frame "
255 "numbers for new dom");
256 goto out;
257 }
259 if ( (mmu = init_mmu_updates(xc_handle, dom)) == NULL )
260 {
261 xcio_error(ioctxt, "Could not initialise for MMU updates");
262 goto out;
263 }
265 xcio_info(ioctxt, "Reloading memory pages: 0%%");
267 /*
268 * Now simply read each saved frame into its new machine frame.
269 * We uncanonicalise page tables as we go.
270 */
271 prev_pc = 0;
273 n = 0;
274 while ( 1 )
275 {
276 int j;
277 unsigned long region_pfn_type[MAX_BATCH_SIZE];
279 this_pc = (n * 100) / nr_pfns;
280 if ( (this_pc - prev_pc) >= 5 )
281 {
282 xcio_info(ioctxt, "\b\b\b\b%3d%%", this_pc);
283 prev_pc = this_pc;
284 }
286 if ( xcio_read(ioctxt, &j, sizeof(int)) )
287 {
288 xcio_error(ioctxt, "Error when reading from state file");
289 goto out;
290 }
292 DPRINTF("batch %d\n",j);
294 if ( j == -1 )
295 {
296 verify = 1;
297 printf("Entering page verify mode\n");
298 continue;
299 }
301 if ( j == 0 )
302 break; /* our work here is done */
304 if ( j > MAX_BATCH_SIZE )
305 {
306 xcio_error(ioctxt, "Max batch size exceeded. Giving up.");
307 goto out;
308 }
310 if ( xcio_read(ioctxt, region_pfn_type, j*sizeof(unsigned long)) ) {
311 xcio_error(ioctxt, "Error when reading from state file");
312 goto out;
313 }
315 for ( i = 0; i < j; i++ )
316 {
317 if ( (region_pfn_type[i] & LTAB_MASK) == XTAB)
318 {
319 region_mfn[i] = 0; /* we know map will fail, but don't care */
320 }
321 else
322 {
323 pfn = region_pfn_type[i] & ~LTAB_MASK;
324 region_mfn[i] = pfn_to_mfn_table[pfn];
325 }
326 }
328 if ( (region_base = xc_map_foreign_batch( xc_handle, dom,
329 PROT_WRITE,
330 region_mfn,
331 j )) == 0 )
332 {
333 xcio_error(ioctxt, "map batch failed");
334 goto out;
335 }
337 for ( i = 0; i < j; i++ )
338 {
339 unsigned long *ppage;
341 pfn = region_pfn_type[i] & ~LTAB_MASK;
343 if ( (region_pfn_type[i] & LTAB_MASK) == XTAB) continue;
345 if (pfn>nr_pfns)
346 {
347 xcio_error(ioctxt, "pfn out of range");
348 goto out;
349 }
351 region_pfn_type[i] &= LTAB_MASK;
353 pfn_type[pfn] = region_pfn_type[i];
355 mfn = pfn_to_mfn_table[pfn];
357 if ( verify )
358 ppage = (unsigned long*) buf; /* debug case */
359 else
360 ppage = (unsigned long*) (region_base + i*PAGE_SIZE);
362 if ( xcio_read(ioctxt, ppage, PAGE_SIZE) )
363 {
364 xcio_error(ioctxt, "Error when reading from state file");
365 goto out;
366 }
368 switch( region_pfn_type[i] & LTABTYPE_MASK )
369 {
370 case 0:
371 break;
373 case L1TAB:
374 {
375 for ( k = 0; k < 1024; k++ )
376 {
377 if ( ppage[k] & _PAGE_PRESENT )
378 {
379 xpfn = ppage[k] >> PAGE_SHIFT;
380 if ( xpfn >= nr_pfns )
381 {
382 xcio_error(ioctxt, "Frame number in type %lu page "
383 "table is out of range. i=%d k=%d "
384 "pfn=0x%lx nr_pfns=%lu",
385 region_pfn_type[i]>>28, i,
386 k, xpfn, nr_pfns);
387 goto out;
388 }
390 ppage[k] &= (PAGE_SIZE - 1) &
391 ~(_PAGE_GLOBAL | _PAGE_PAT);
392 ppage[k] |= pfn_to_mfn_table[xpfn] << PAGE_SHIFT;
393 }
394 }
395 }
396 break;
398 case L2TAB:
399 {
400 for ( k = 0;
401 k < (HYPERVISOR_VIRT_START>>L2_PAGETABLE_SHIFT);
402 k++ )
403 {
404 if ( ppage[k] & _PAGE_PRESENT )
405 {
406 xpfn = ppage[k] >> PAGE_SHIFT;
408 if ( xpfn >= nr_pfns )
409 {
410 xcio_error(ioctxt, "Frame number in type %lu page"
411 " table is out of range. i=%d k=%d "
412 "pfn=%lu nr_pfns=%lu",
413 region_pfn_type[i]>>28, i, k,
414 xpfn, nr_pfns);
415 goto out;
416 }
418 ppage[k] &= (PAGE_SIZE - 1) &
419 ~(_PAGE_GLOBAL | _PAGE_PSE);
420 ppage[k] |= pfn_to_mfn_table[xpfn] << PAGE_SHIFT;
421 }
422 }
423 }
424 break;
426 default:
427 xcio_error(ioctxt, "Bogus page type %lx page table is "
428 "out of range. i=%d nr_pfns=%lu",
429 region_pfn_type[i], i, nr_pfns);
430 goto out;
432 } /* end of page type switch statement */
434 if ( verify )
435 {
436 int res = memcmp(buf, (region_base + i*PAGE_SIZE), PAGE_SIZE );
437 if ( res )
438 {
439 int v;
440 printf("************** pfn=%lx type=%lx gotcs=%08lx "
441 "actualcs=%08lx\n", pfn, pfn_type[pfn],
442 csum_page(region_base + i*PAGE_SIZE),
443 csum_page(buf));
444 for ( v = 0; v < 4; v++ )
445 {
446 unsigned long *p = (unsigned long *)
447 (region_base + i*PAGE_SIZE);
448 if ( buf[v] != p[v] )
449 printf(" %d: %08lx %08lx\n",
450 v, buf[v], p[v] );
451 }
452 }
453 }
455 if ( add_mmu_update(xc_handle, mmu,
456 (mfn<<PAGE_SHIFT) | MMU_MACHPHYS_UPDATE, pfn) )
457 {
458 printf("machpys mfn=%ld pfn=%ld\n",mfn,pfn);
459 goto out;
460 }
462 } /* end of 'batch' for loop */
464 munmap( region_base, j*PAGE_SIZE );
465 n+=j; /* crude stats */
466 }
468 DPRINTF("Received all pages\n");
470 /*
471 * Pin page tables. Do this after writing to them as otherwise Xen
472 * will barf when doing the type-checking.
473 */
474 for ( i = 0; i < nr_pfns; i++ )
475 {
476 if ( pfn_type[i] == (L1TAB|LPINTAB) )
477 {
478 if ( add_mmu_update(xc_handle, mmu,
479 (pfn_to_mfn_table[i]<<PAGE_SHIFT) |
480 MMU_EXTENDED_COMMAND,
481 MMUEXT_PIN_L1_TABLE) ) {
482 printf("ERR pin L1 pfn=%lx mfn=%lx\n",
483 (unsigned long)i, pfn_to_mfn_table[i]);
484 goto out;
485 }
486 }
487 else if ( pfn_type[i] == (L2TAB|LPINTAB) )
488 {
489 if ( add_mmu_update(xc_handle, mmu,
490 (pfn_to_mfn_table[i]<<PAGE_SHIFT) |
491 MMU_EXTENDED_COMMAND,
492 MMUEXT_PIN_L2_TABLE) )
493 {
494 printf("ERR pin L2 pfn=%lx mfn=%lx\n",
495 (unsigned long)i, pfn_to_mfn_table[i]);
496 goto out;
497 }
498 }
499 }
501 if ( finish_mmu_updates(xc_handle, mmu) ) goto out;
503 xcio_info(ioctxt, "\b\b\b\b100%%\nMemory reloaded.\n");
505 /* Get the list of PFNs that are not in the psuedo-phys map */
506 {
507 unsigned int count, *pfntab;
508 int rc;
509 if ( xcio_read(ioctxt, &count, sizeof(count)) )
510 {
511 xcio_error(ioctxt, "Error when reading from state file");
512 goto out;
513 }
515 pfntab = malloc( sizeof(unsigned int) * count );
516 if ( !pfntab )
517 {
518 xcio_error(ioctxt, "Out of memory");
519 goto out;
520 }
522 if ( xcio_read(ioctxt, pfntab, sizeof(unsigned int)*count) )
523 {
524 xcio_error(ioctxt, "Error when reading pfntab from state file");
525 goto out;
526 }
528 for(i=0;i<count;i++)
529 {
530 unsigned long pfn = pfntab[i];
531 pfntab[i]=pfn_to_mfn_table[pfn];
532 pfn_to_mfn_table[pfn] = 0x80000001; // not in pmap
533 }
535 if ( count>0 )
536 {
537 if ( (rc = do_dom_mem_op( xc_handle,
538 MEMOP_decrease_reservation,
539 pfntab, count, 0, dom )) <0 )
540 {
541 xcio_error(ioctxt, "Could not decrease reservation : %d",rc);
542 goto out;
543 }
544 else
545 {
546 printf("Decreased reservation by %d pages\n", count);
547 }
548 }
550 }
554 if ( xcio_read(ioctxt, &ctxt, sizeof(ctxt)) ||
555 xcio_read(ioctxt, shared_info, PAGE_SIZE) )
556 {
557 xcio_error(ioctxt, "Error when reading from state file");
558 goto out;
559 }
561 /* Uncanonicalise the suspend-record frame number and poke resume rec. */
562 pfn = ctxt.cpu_ctxt.esi;
563 if ( (pfn >= nr_pfns) || (pfn_type[pfn] != NOTAB) )
564 {
565 xcio_error(ioctxt, "Suspend record frame number is bad");
566 goto out;
567 }
568 ctxt.cpu_ctxt.esi = mfn = pfn_to_mfn_table[pfn];
569 p_srec = map_pfn_writeable(pm_handle, mfn);
570 p_srec->resume_info.nr_pages = nr_pfns;
571 p_srec->resume_info.shared_info = shared_info_frame << PAGE_SHIFT;
572 p_srec->resume_info.flags = 0;
573 unmap_pfn(pm_handle, p_srec);
575 /* Uncanonicalise each GDT frame number. */
576 if ( ctxt.gdt_ents > 8192 )
577 {
578 xcio_error(ioctxt, "GDT entry count out of range");
579 goto out;
580 }
582 for ( i = 0; i < ctxt.gdt_ents; i += 512 )
583 {
584 pfn = ctxt.gdt_frames[i];
585 if ( (pfn >= nr_pfns) || (pfn_type[pfn] != NOTAB) )
586 {
587 xcio_error(ioctxt, "GDT frame number is bad");
588 goto out;
589 }
590 ctxt.gdt_frames[i] = pfn_to_mfn_table[pfn];
591 }
593 /* Uncanonicalise the page table base pointer. */
594 pfn = ctxt.pt_base >> PAGE_SHIFT;
595 if ( (pfn >= nr_pfns) || ((pfn_type[pfn]&LTABTYPE_MASK) != L2TAB) )
596 {
597 printf("PT base is bad. pfn=%lu nr=%lu type=%08lx %08lx\n",
598 pfn, nr_pfns, pfn_type[pfn], (unsigned long)L2TAB);
599 xcio_error(ioctxt, "PT base is bad.");
600 goto out;
601 }
602 ctxt.pt_base = pfn_to_mfn_table[pfn] << PAGE_SHIFT;
605 /* clear any pending events and the selector */
606 memset( &(((shared_info_t *)shared_info)->evtchn_pending[0]),
607 0, sizeof (((shared_info_t *)shared_info)->evtchn_pending)+
608 sizeof(((shared_info_t *)shared_info)->evtchn_pending_sel) );
610 /* Copy saved contents of shared-info page. No checking needed. */
611 ppage = map_pfn_writeable(pm_handle, shared_info_frame);
612 memcpy(ppage, shared_info, sizeof(shared_info_t));
613 unmap_pfn(pm_handle, ppage);
616 /* Uncanonicalise the pfn-to-mfn table frame-number list. */
617 for ( i = 0; i < (nr_pfns+1023)/1024; i++ )
618 {
619 unsigned long pfn, mfn;
621 pfn = pfn_to_mfn_frame_list[i];
622 if ( (pfn >= nr_pfns) || (pfn_type[pfn] != NOTAB) )
623 {
624 xcio_error(ioctxt, "PFN-to-MFN frame number is bad");
625 goto out;
626 }
627 mfn = pfn_to_mfn_table[pfn];
628 pfn_to_mfn_frame_list[i] = mfn;
629 }
631 if ( (live_pfn_to_mfn_table =
632 xc_map_foreign_batch(xc_handle, dom,
633 PROT_WRITE,
634 pfn_to_mfn_frame_list,
635 (nr_pfns+1023)/1024 )) == 0 )
636 {
637 xcio_error(ioctxt, "Couldn't map pfn_to_mfn table");
638 goto out;
639 }
641 memcpy(live_pfn_to_mfn_table, pfn_to_mfn_table,
642 nr_pfns*sizeof(unsigned long) );
644 munmap(live_pfn_to_mfn_table, ((nr_pfns+1023)/1024)*PAGE_SIZE);
646 /*
647 * Safety checking of saved context:
648 * 1. cpu_ctxt is fine, as Xen checks that on context switch.
649 * 2. fpu_ctxt is fine, as it can't hurt Xen.
650 * 3. trap_ctxt needs the code selectors checked.
651 * 4. fast_trap_idx is checked by Xen.
652 * 5. ldt base must be page-aligned, no more than 8192 ents, ...
653 * 6. gdt already done, and further checking is done by Xen.
654 * 7. check that guestos_ss is safe.
655 * 8. pt_base is already done.
656 * 9. debugregs are checked by Xen.
657 * 10. callback code selectors need checking.
658 */
659 for ( i = 0; i < 256; i++ )
660 {
661 ctxt.trap_ctxt[i].vector = i;
662 if ( (ctxt.trap_ctxt[i].cs & 3) == 0 )
663 ctxt.trap_ctxt[i].cs = FLAT_GUESTOS_CS;
664 }
665 if ( (ctxt.guestos_ss & 3) == 0 )
666 ctxt.guestos_ss = FLAT_GUESTOS_DS;
667 if ( (ctxt.event_callback_cs & 3) == 0 )
668 ctxt.event_callback_cs = FLAT_GUESTOS_CS;
669 if ( (ctxt.failsafe_callback_cs & 3) == 0 )
670 ctxt.failsafe_callback_cs = FLAT_GUESTOS_CS;
671 if ( ((ctxt.ldt_base & (PAGE_SIZE - 1)) != 0) ||
672 (ctxt.ldt_ents > 8192) ||
673 (ctxt.ldt_base > HYPERVISOR_VIRT_START) ||
674 ((ctxt.ldt_base + ctxt.ldt_ents*8) > HYPERVISOR_VIRT_START) )
675 {
676 xcio_error(ioctxt, "Bad LDT base or size");
677 goto out;
678 }
680 op.cmd = DOM0_BUILDDOMAIN;
681 op.u.builddomain.domain = (domid_t)dom;
682 op.u.builddomain.ctxt = &ctxt;
683 rc = do_dom0_op(xc_handle, &op);
685 /* don't start the domain as we have console etc to set up */
687 if ( rc == 0 )
688 {
689 /* Success: print the domain id. */
690 xcio_info(ioctxt, "DOM=%lu\n", dom);
691 return 0;
692 }
695 out:
696 if ( (rc != 0) && (dom != 0) )
697 xc_domain_destroy(xc_handle, dom);
698 if ( mmu != NULL )
699 free(mmu);
700 if ( pm_handle != NULL )
701 (void)close_pfn_mapper(pm_handle);
702 if ( pfn_to_mfn_table != NULL )
703 free(pfn_to_mfn_table);
704 if ( pfn_type != NULL )
705 free(pfn_type);
707 if ( rc == 0 )
708 ioctxt->domain = dom;
710 DPRINTF("Restore exit with rc=%d\n",rc);
711 return rc;
712 }