direct-io.hg

changeset 1875:f44c755b90ea

bitkeeper revision 1.1119 (41001bd4uSgdikWNjQh6HN1GC4celA)

only validate changes entries
author cl349@freefall.cl.cam.ac.uk
date Thu Jul 22 19:56:04 2004 +0000 (2004-07-22)
parents 24a435d26a6b
children 2a0b8a9e1e5e
files xen/arch/x86/memory.c
line diff
     1.1 --- a/xen/arch/x86/memory.c	Thu Jul 22 17:55:10 2004 +0000
     1.2 +++ b/xen/arch/x86/memory.c	Thu Jul 22 19:56:04 2004 +0000
     1.3 @@ -1227,10 +1227,12 @@ int do_update_va_mapping_otherdomain(uns
     1.4  /*  */
     1.5  unsigned long ptwr_disconnected[NR_CPUS] __cacheline_aligned =
     1.6  	{ [ 0 ... NR_CPUS-1 ] = ENTRIES_PER_L2_PAGETABLE };
     1.7 +static l1_pgentry_t ptwr_disconnected_page[NR_CPUS][ENTRIES_PER_L1_PAGETABLE] __cacheline_aligned;
     1.8  static unsigned long *ptwr_writable_l1[NR_CPUS] __cacheline_aligned;
     1.9  #define	PTWR_NR_WRITABLES 4
    1.10  static unsigned long *ptwr_writables[NR_CPUS][PTWR_NR_WRITABLES] __cacheline_aligned;
    1.11  int ptwr_writable_idx[NR_CPUS] __cacheline_aligned = { 0, };
    1.12 +static l1_pgentry_t ptwr_writable_page[NR_CPUS][PTWR_NR_WRITABLES][ENTRIES_PER_L1_PAGETABLE] __cacheline_aligned;
    1.13  #ifdef TRACK_PTWR_DOMAIN
    1.14  domid_t ptwr_domain[NR_CPUS] = { 0, };
    1.15  #endif
    1.16 @@ -1268,6 +1270,29 @@ void ptwr_reconnect_disconnected(unsigne
    1.17                  frame_table[pfn].type_and_flags,
    1.18                  frame_table[pfn].count_and_flags,
    1.19                  frame_table[pfn].u.domain->domain);
    1.20 +#if 1
    1.21 +    {
    1.22 +        l2_pgentry_t nl2e = mk_l2_pgentry((l2_pgentry_val(*pl2e) & ~0x800) |
    1.23 +                                          _PAGE_PRESENT);
    1.24 +        l1_pgentry_t *pl1e;
    1.25 +        int i;
    1.26 +
    1.27 +        pl1e = map_domain_mem(l2_pgentry_to_pagenr(nl2e) << PAGE_SHIFT);
    1.28 +        for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ ) {
    1.29 +            if (l1_pgentry_val(pl1e[i]) != l1_pgentry_val(ptwr_disconnected_page[cpu][i])) {
    1.30 +#if 0
    1.31 +                printk("%03x: %08lx != %08lx\n", i, l1_pgentry_val(pl1e[i]),
    1.32 +                       l1_pgentry_val(ptwr_disconnected_page[cpu][i]));
    1.33 +#endif
    1.34 +                put_page_from_l1e(ptwr_disconnected_page[cpu][i]);
    1.35 +                if (unlikely(!get_page_from_l1e(pl1e[i])))
    1.36 +                    BUG();
    1.37 +            }
    1.38 +        }
    1.39 +        unmap_domain_mem(pl1e);
    1.40 +        update_l2e(pl2e, *pl2e, nl2e);
    1.41 +    }
    1.42 +#else
    1.43      if (!mod_l2_entry(pl2e, mk_l2_pgentry((l2_pgentry_val(*pl2e) & ~0x800) |
    1.44                                            _PAGE_PRESENT),
    1.45                        l1_pgentry_val(linear_pg_table[(unsigned long)pl2e >>
    1.46 @@ -1289,6 +1314,7 @@ void ptwr_reconnect_disconnected(unsigne
    1.47  
    1.48          BUG();
    1.49      }
    1.50 +#endif
    1.51      if (page->count_and_flags & PGC_guest_pinned) {
    1.52          if ((page->type_and_flags & PGT_count_mask) != 1)
    1.53              BUG();
    1.54 @@ -1315,7 +1341,7 @@ void ptwr_flush_inactive(void)
    1.55  {
    1.56      unsigned long pte, pfn;
    1.57      struct pfn_info *page;
    1.58 -    int i;
    1.59 +    int idx;
    1.60      int cpu = smp_processor_id();
    1.61  
    1.62  #ifdef TRACK_PTWR_DOMAIN
    1.63 @@ -1323,25 +1349,47 @@ void ptwr_flush_inactive(void)
    1.64          printk("ptwr_flush_inactive domain mismatch %d != %d\n",
    1.65                 ptwr_domain[cpu], get_current()->domain);
    1.66  #endif
    1.67 -    for (i = 0; i < ptwr_writable_idx[cpu]; i++) {
    1.68 -        if (__get_user(pte, ptwr_writables[cpu][i]))
    1.69 +    for (idx = 0; idx < ptwr_writable_idx[cpu]; idx++) {
    1.70 +        if (__get_user(pte, ptwr_writables[cpu][idx]))
    1.71              BUG();
    1.72          pfn = pte >> PAGE_SHIFT;
    1.73          page = &frame_table[pfn];
    1.74          PTWR_PRINTK("alloc l1 page %p\n", page);
    1.75 +#if 0
    1.76          if (!get_page_type(page, PGT_l1_page_table))
    1.77              BUG();
    1.78 +#else
    1.79 +        {
    1.80 +            l1_pgentry_t *pl1e;
    1.81 +            int i;
    1.82 +
    1.83 +            pl1e = map_domain_mem(pfn << PAGE_SHIFT);
    1.84 +            for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ ) {
    1.85 +                if (l1_pgentry_val(pl1e[i]) !=
    1.86 +                    l1_pgentry_val(ptwr_writable_page[cpu][idx][i])) {
    1.87 +#if 0
    1.88 +                    printk("%03x: %08lx != %08lx\n", i, l1_pgentry_val(pl1e[i]),
    1.89 +                           l1_pgentry_val(ptwr_writable_page[cpu][idx][i]));
    1.90 +#endif
    1.91 +                    put_page_from_l1e(ptwr_writable_page[cpu][idx][i]);
    1.92 +                    if (unlikely(!get_page_from_l1e(pl1e[i])))
    1.93 +                        BUG();
    1.94 +                }
    1.95 +            }
    1.96 +            unmap_domain_mem(pl1e);
    1.97 +        }
    1.98 +#endif
    1.99          if (page->count_and_flags & PGC_guest_pinned) {
   1.100              if ((page->type_and_flags & PGT_count_mask) != 1)
   1.101                  BUG();
   1.102              page->type_and_flags++;
   1.103          }
   1.104          /* make pt page writable */
   1.105 -        PTWR_PRINTK("writable_l1 at %p is %08lx\n", ptwr_writables[cpu][i], pte);
   1.106 +        PTWR_PRINTK("writable_l1 at %p is %08lx\n", ptwr_writables[cpu][idx], pte);
   1.107          pte &= ~_PAGE_RW;
   1.108 -        if (__put_user(pte, ptwr_writables[cpu][i]))
   1.109 +        if (__put_user(pte, ptwr_writables[cpu][idx]))
   1.110              BUG();
   1.111 -        PTWR_PRINTK("writable_l1 at %p now %08lx\n", ptwr_writables[cpu][i], pte);
   1.112 +        PTWR_PRINTK("writable_l1 at %p now %08lx\n", ptwr_writables[cpu][idx], pte);
   1.113      }
   1.114      ptwr_writable_idx[cpu] = 0;
   1.115  }
   1.116 @@ -1388,16 +1436,27 @@ int ptwr_do_page_fault(unsigned long add
   1.117                  page->type_and_flags--;
   1.118              }
   1.119              if (l2_pgentry_val(*pl2e) >> PAGE_SHIFT != pfn) {
   1.120 +                l1_pgentry_t *pl1e;
   1.121                  PTWR_PRINTK("freeing l1 page %p taf %08x/%08x\n", page,
   1.122                              page->type_and_flags, page->count_and_flags);
   1.123                  if (ptwr_writable_idx[cpu] == PTWR_NR_WRITABLES)
   1.124                      ptwr_flush_inactive();
   1.125 -                ptwr_writables[cpu][ptwr_writable_idx[cpu]++] = (unsigned long *)
   1.126 +                ptwr_writables[cpu][ptwr_writable_idx[cpu]] = (unsigned long *)
   1.127                      &linear_pg_table[addr>>PAGE_SHIFT];
   1.128                  if ((page->type_and_flags & PGT_count_mask) != 1)
   1.129                      BUG();
   1.130 +#if 0
   1.131                  put_page_type(page);
   1.132 +#else
   1.133 +                pl1e = map_domain_mem(pfn << PAGE_SHIFT);
   1.134 +                memcpy(&ptwr_writable_page[cpu][ptwr_writable_idx[cpu]][0],
   1.135 +                       pl1e, ENTRIES_PER_L1_PAGETABLE * sizeof(l1_pgentry_t));
   1.136 +                unmap_domain_mem(pl1e);
   1.137 +#endif
   1.138 +                ptwr_writable_idx[cpu]++;
   1.139              } else {
   1.140 +                l2_pgentry_t nl2e;
   1.141 +                l1_pgentry_t *pl1e;
   1.142                  if (ptwr_disconnected[cpu] != ENTRIES_PER_L2_PAGETABLE)
   1.143                      ptwr_reconnect_disconnected(addr);
   1.144                  PTWR_PRINTK("    pl2e %p l2e %08lx pfn %08lx taf %08x/%08x/%u\n",
   1.145 @@ -1408,12 +1467,17 @@ int ptwr_do_page_fault(unsigned long add
   1.146                              frame_table[pfn].type_and_flags,
   1.147                              frame_table[pfn].count_and_flags, frame_table[pfn].u.domain->domain);
   1.148                  /* disconnect l1 page */
   1.149 -                mod_l2_entry(pl2e, mk_l2_pgentry((l2_pgentry_val(*pl2e) &
   1.150 -                                                  ~_PAGE_PRESENT) | 0x800),
   1.151 +                nl2e = mk_l2_pgentry((l2_pgentry_val(*pl2e) &
   1.152 +                                      ~_PAGE_PRESENT) | 0x800);
   1.153 +#if 0
   1.154 +                mod_l2_entry(pl2e, nl2e,
   1.155                               l1_pgentry_val(linear_pg_table
   1.156                                              [(unsigned long)pl2e
   1.157                                               >> PAGE_SHIFT]) >>
   1.158                               PAGE_SHIFT);
   1.159 +#else
   1.160 +                update_l2e(pl2e, *pl2e, nl2e);
   1.161 +#endif
   1.162                  ptwr_disconnected[cpu] = (page->type_and_flags & PGT_va_mask) >>
   1.163                      PGT_va_shift;
   1.164                  PTWR_PRINTK("now pl2e %p l2e %08lx              taf %08x/%08x/%u\n",
   1.165 @@ -1422,6 +1486,10 @@ int ptwr_do_page_fault(unsigned long add
   1.166                         frame_table[pfn].count_and_flags, frame_table[pfn].u.domain->domain);
   1.167                  ptwr_writable_l1[cpu] = (unsigned long *)
   1.168                      &linear_pg_table[addr>>PAGE_SHIFT];
   1.169 +                pl1e = map_domain_mem(l2_pgentry_to_pagenr(nl2e) << PAGE_SHIFT);
   1.170 +                memcpy(&ptwr_disconnected_page[cpu][0], pl1e,
   1.171 +                       ENTRIES_PER_L1_PAGETABLE * sizeof(l1_pgentry_t));
   1.172 +                unmap_domain_mem(pl1e);
   1.173              }
   1.174              /* make pt page writable */
   1.175              pte |= _PAGE_RW;