ia64/xen-unstable

changeset 11738:0dc4ae151be2

[LIBXC] Fix ptrace memory-mapping code to map pagetables read-only.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Oct 05 09:30:07 2006 +0100 (2006-10-05)
parents a5a3f48e92c9
children 1a0b58e7b5de 55e53c556f9f
files tools/libxc/xc_ptrace.c
line diff
     1.1 --- a/tools/libxc/xc_ptrace.c	Wed Oct 04 19:00:11 2006 +0100
     1.2 +++ b/tools/libxc/xc_ptrace.c	Thu Oct 05 09:30:07 2006 +0100
     1.3 @@ -251,7 +251,7 @@ map_domain_va_pae(
     1.4      if ( !(l2e & _PAGE_PRESENT) )
     1.5          return NULL;
     1.6      l1p = to_ma(cpu, l2e);
     1.7 -    l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, l1p >> PAGE_SHIFT);
     1.8 +    l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ, l1p >> PAGE_SHIFT);
     1.9      if ( l1 == NULL )
    1.10          return NULL;
    1.11  
    1.12 @@ -281,7 +281,6 @@ map_domain_va_64(
    1.13      uint64_t *l4, *l3, *l2, *l1;
    1.14      static void *v[MAX_VIRT_CPUS];
    1.15  
    1.16 -
    1.17      if ((ctxt[cpu].ctrlreg[4] & 0x20) == 0 ) /* legacy ia32 mode */
    1.18          return map_domain_va_32(xc_handle, cpu, guest_va, perm);
    1.19  
    1.20 @@ -309,7 +308,6 @@ map_domain_va_64(
    1.21      if ( l2 == NULL )
    1.22          return NULL;
    1.23  
    1.24 -    l1 = NULL;
    1.25      l2e = l2[l2_table_offset(va)];
    1.26      munmap(l2, PAGE_SIZE);
    1.27      if ( !(l2e & _PAGE_PRESENT) )
    1.28 @@ -318,11 +316,12 @@ map_domain_va_64(
    1.29      if (l2e & 0x80)  { /* 2M pages */
    1.30          p = to_ma(cpu, (l1p + l1_table_offset(va)) << PAGE_SHIFT);
    1.31      } else { /* 4K pages */
    1.32 -        l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, l1p >> PAGE_SHIFT);
    1.33 +        l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ, l1p >> PAGE_SHIFT);
    1.34          if ( l1 == NULL )
    1.35              return NULL;
    1.36  
    1.37          l1e = l1[l1_table_offset(va)];
    1.38 +        munmap(l1, PAGE_SIZE);
    1.39          if ( !(l1e & _PAGE_PRESENT) )
    1.40              return NULL;
    1.41          p = to_ma(cpu, l1e);
    1.42 @@ -330,8 +329,6 @@ map_domain_va_64(
    1.43      if ( v[cpu] != NULL )
    1.44          munmap(v[cpu], PAGE_SIZE);
    1.45      v[cpu] = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, p >> PAGE_SHIFT);
    1.46 -    if (l1)
    1.47 -        munmap(l1, PAGE_SIZE);
    1.48      if ( v[cpu] == NULL )
    1.49          return NULL;
    1.50