diff -r a0561bcf9333 tools/libxc/xc_domain_restore.c --- a/tools/libxc/xc_domain_restore.c Wed Jun 11 16:38:02 2008 +0100 +++ b/tools/libxc/xc_domain_restore.c Sat Jun 14 00:57:11 2008 +0800 @@ -684,6 +684,8 @@ int xc_domain_restore(int xc_handle, int if ( hvm ) { uint32_t rec_len; + uint64_t ident_pt; + uint32_t *ident_pt_start; /* Set HVM-specific parameters */ if ( read_exact(io_fd, magic_pfns, sizeof(magic_pfns)) ) @@ -717,6 +719,28 @@ int xc_domain_restore(int xc_handle, int goto out; } *store_mfn = magic_pfns[2]; + + /* Read the address of the identity map for EPT guest */ + if ( read_exact(io_fd, &ident_pt, sizeof(uint64_t)) ) + { + ERROR("error read the address of the identity map for EPT guest"); + goto out; + } + + if ( (ident_pt_start = xc_map_foreign_range( + xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE, + ident_pt >> PAGE_SHIFT)) == NULL ) + { + ERROR("cannot get the identity map for EPT guest"); + goto out; + } + + for ( i = 0; i < PAGE_SIZE / sizeof(*ident_pt_start); i++ ) + ident_pt_start[i] = (i << 22) | _PAGE_PRESENT | _PAGE_RW | + _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_PSE; + munmap(ident_pt_start , PAGE_SIZE); + + xc_set_hvm_param(xc_handle, dom, HVM_PARAM_IDENT_PT, ident_pt); /* Read HVM context */ if ( read_exact(io_fd, &rec_len, sizeof(uint32_t)) ) diff -r a0561bcf9333 tools/libxc/xc_domain_save.c --- a/tools/libxc/xc_domain_save.c Wed Jun 11 16:38:02 2008 +0100 +++ b/tools/libxc/xc_domain_save.c Sat Jun 14 00:55:10 2008 +0800 @@ -1440,6 +1440,7 @@ int xc_domain_save(int xc_handle, int io if ( hvm ) { uint32_t rec_size; + uint64_t ident_pt; /* Save magic-page locations. */ memset(magic_pfns, 0, sizeof(magic_pfns)); @@ -1449,9 +1450,20 @@ int xc_domain_save(int xc_handle, int io (unsigned long *)&magic_pfns[1]); xc_get_hvm_param(xc_handle, dom, HVM_PARAM_STORE_PFN, (unsigned long *)&magic_pfns[2]); + if ( write_exact(io_fd, magic_pfns, sizeof(magic_pfns)) ) { PERROR("Error when writing to state file (7)"); + goto out; + } + + /* Get the address of indentity map for EPT guest */ + xc_get_hvm_param(xc_handle, dom, HVM_PARAM_IDENT_PT, + (unsigned long *)&ident_pt); + + if ( write_exact(io_fd, &ident_pt, sizeof(ident_pt)) ) + { + PERROR("Error when writing the ident_pt for EPT guest"); goto out; }