ia64/xen-unstable

changeset 1877:853d916ceb18

bitkeeper revision 1.1121 (41002fa0_p8P33pqa96kysY0roIzBA)

g/c old code and cleanup
author cl349@freefall.cl.cam.ac.uk
date Thu Jul 22 21:20:32 2004 +0000 (2004-07-22)
parents 2a0b8a9e1e5e
children ce3ac2fde5dd
files xen/arch/x86/memory.c
line diff
     1.1 --- a/xen/arch/x86/memory.c	Thu Jul 22 19:57:47 2004 +0000
     1.2 +++ b/xen/arch/x86/memory.c	Thu Jul 22 21:20:32 2004 +0000
     1.3 @@ -1245,8 +1245,10 @@ void ptwr_reconnect_disconnected(unsigne
     1.4      unsigned long pte;
     1.5      unsigned long pfn;
     1.6      struct pfn_info *page;
     1.7 -    l2_pgentry_t *pl2e;
     1.8 +    l2_pgentry_t *pl2e, nl2e;
     1.9 +    l1_pgentry_t *pl1e;
    1.10      int cpu = smp_processor_id();
    1.11 +    int i;
    1.12  
    1.13  #ifdef TRACK_PTWR_DOMAIN
    1.14      if (ptwr_domain[cpu] != get_current()->domain)
    1.15 @@ -1270,51 +1272,24 @@ void ptwr_reconnect_disconnected(unsigne
    1.16                  frame_table[pfn].type_and_flags,
    1.17                  frame_table[pfn].count_and_flags,
    1.18                  frame_table[pfn].u.domain->domain);
    1.19 -#if 1
    1.20 -    {
    1.21 -        l2_pgentry_t nl2e = mk_l2_pgentry((l2_pgentry_val(*pl2e) & ~0x800) |
    1.22 -                                          _PAGE_PRESENT);
    1.23 -        l1_pgentry_t *pl1e;
    1.24 -        int i;
    1.25  
    1.26 -        pl1e = map_domain_mem(l2_pgentry_to_pagenr(nl2e) << PAGE_SHIFT);
    1.27 -        for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ ) {
    1.28 -            if (l1_pgentry_val(pl1e[i]) != l1_pgentry_val(ptwr_disconnected_page[cpu][i])) {
    1.29 +    nl2e = mk_l2_pgentry((l2_pgentry_val(*pl2e) & ~0x800) |
    1.30 +                         _PAGE_PRESENT);
    1.31 +    pl1e = map_domain_mem(l2_pgentry_to_pagenr(nl2e) << PAGE_SHIFT);
    1.32 +    for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ ) {
    1.33 +        if (l1_pgentry_val(pl1e[i]) != l1_pgentry_val(ptwr_disconnected_page[cpu][i])) {
    1.34  #if 0
    1.35 -                printk("%03x: %08lx != %08lx\n", i, l1_pgentry_val(pl1e[i]),
    1.36 -                       l1_pgentry_val(ptwr_disconnected_page[cpu][i]));
    1.37 +            printk("%03x: %08lx != %08lx\n", i, l1_pgentry_val(pl1e[i]),
    1.38 +                   l1_pgentry_val(ptwr_disconnected_page[cpu][i]));
    1.39  #endif
    1.40 -                put_page_from_l1e(ptwr_disconnected_page[cpu][i]);
    1.41 -                if (unlikely(!get_page_from_l1e(pl1e[i])))
    1.42 -                    BUG();
    1.43 -            }
    1.44 +            put_page_from_l1e(ptwr_disconnected_page[cpu][i]);
    1.45 +            if (unlikely(!get_page_from_l1e(pl1e[i])))
    1.46 +                BUG();
    1.47          }
    1.48 -        unmap_domain_mem(pl1e);
    1.49 -        update_l2e(pl2e, *pl2e, nl2e);
    1.50      }
    1.51 -#else
    1.52 -    if (!mod_l2_entry(pl2e, mk_l2_pgentry((l2_pgentry_val(*pl2e) & ~0x800) |
    1.53 -                                          _PAGE_PRESENT),
    1.54 -                      l1_pgentry_val(linear_pg_table[(unsigned long)pl2e >>
    1.55 -                                                     PAGE_SHIFT]) >> PAGE_SHIFT)) {
    1.56 -        l2_pgentry_t nl2e = mk_l2_pgentry((l2_pgentry_val(*pl2e) & ~0x800) |
    1.57 -                                          _PAGE_PRESENT);
    1.58 -        l1_pgentry_t *pl1e;
    1.59 -        int i;
    1.60 +    unmap_domain_mem(pl1e);
    1.61 +    update_l2e(pl2e, *pl2e, nl2e);
    1.62  
    1.63 -        printk("ptrw mod_l2_entry failed on %p: %08lx -> %08lx\n", pl2e,
    1.64 -               l2_pgentry_val(*pl2e), l2_pgentry_val(nl2e));
    1.65 -        pl1e = map_domain_mem(l2_pgentry_to_pagenr(nl2e) << PAGE_SHIFT);
    1.66 -        for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ ) {
    1.67 -            printk("%03x: %08lx ", i, l1_pgentry_val(pl1e[i]));
    1.68 -            if (i % 4 == 3)
    1.69 -                printk("\n");
    1.70 -        }
    1.71 -        unmap_domain_mem(pl1e);
    1.72 -
    1.73 -        BUG();
    1.74 -    }
    1.75 -#endif
    1.76      if (page->count_and_flags & PGC_guest_pinned) {
    1.77          if ((page->type_and_flags & PGT_count_mask) != 1)
    1.78              BUG();
    1.79 @@ -1323,7 +1298,8 @@ void ptwr_reconnect_disconnected(unsigne
    1.80      PTWR_PRINTK("now pl2e %p l2e %08lx              taf %08x/%08x/%u\n", pl2e,
    1.81                  l2_pgentry_val(*pl2e),
    1.82                  frame_table[pfn].type_and_flags,
    1.83 -                frame_table[pfn].count_and_flags, frame_table[pfn].u.domain->domain);
    1.84 +                frame_table[pfn].count_and_flags,
    1.85 +                frame_table[pfn].u.domain->domain);
    1.86      ptwr_disconnected[cpu] = ENTRIES_PER_L2_PAGETABLE;
    1.87      /* make pt page write protected */
    1.88      if (__get_user(pte, ptwr_writable_l1[cpu]))
    1.89 @@ -1341,8 +1317,9 @@ void ptwr_flush_inactive(void)
    1.90  {
    1.91      unsigned long pte, pfn;
    1.92      struct pfn_info *page;
    1.93 -    int idx;
    1.94 +    l1_pgentry_t *pl1e;
    1.95      int cpu = smp_processor_id();
    1.96 +    int i, idx;
    1.97  
    1.98  #ifdef TRACK_PTWR_DOMAIN
    1.99      if (ptwr_domain[cpu] != get_current()->domain)
   1.100 @@ -1355,41 +1332,35 @@ void ptwr_flush_inactive(void)
   1.101          pfn = pte >> PAGE_SHIFT;
   1.102          page = &frame_table[pfn];
   1.103          PTWR_PRINTK("alloc l1 page %p\n", page);
   1.104 -#if 0
   1.105 -        if (!get_page_type(page, PGT_l1_page_table))
   1.106 -            BUG();
   1.107 -#else
   1.108 -        {
   1.109 -            l1_pgentry_t *pl1e;
   1.110 -            int i;
   1.111  
   1.112 -            pl1e = map_domain_mem(pfn << PAGE_SHIFT);
   1.113 -            for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ ) {
   1.114 -                if (l1_pgentry_val(pl1e[i]) !=
   1.115 -                    l1_pgentry_val(ptwr_writable_page[cpu][idx][i])) {
   1.116 +        pl1e = map_domain_mem(pfn << PAGE_SHIFT);
   1.117 +        for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ ) {
   1.118 +            if (l1_pgentry_val(pl1e[i]) !=
   1.119 +                l1_pgentry_val(ptwr_writable_page[cpu][idx][i])) {
   1.120  #if 0
   1.121 -                    printk("%03x: %08lx != %08lx\n", i, l1_pgentry_val(pl1e[i]),
   1.122 -                           l1_pgentry_val(ptwr_writable_page[cpu][idx][i]));
   1.123 +                printk("%03x: %08lx != %08lx\n", i, l1_pgentry_val(pl1e[i]),
   1.124 +                       l1_pgentry_val(ptwr_writable_page[cpu][idx][i]));
   1.125  #endif
   1.126 -                    put_page_from_l1e(ptwr_writable_page[cpu][idx][i]);
   1.127 -                    if (unlikely(!get_page_from_l1e(pl1e[i])))
   1.128 -                        BUG();
   1.129 -                }
   1.130 +                put_page_from_l1e(ptwr_writable_page[cpu][idx][i]);
   1.131 +                if (unlikely(!get_page_from_l1e(pl1e[i])))
   1.132 +                    BUG();
   1.133              }
   1.134 -            unmap_domain_mem(pl1e);
   1.135          }
   1.136 -#endif
   1.137 +        unmap_domain_mem(pl1e);
   1.138 +
   1.139          if (page->count_and_flags & PGC_guest_pinned) {
   1.140              if ((page->type_and_flags & PGT_count_mask) != 1)
   1.141                  BUG();
   1.142              page->type_and_flags++;
   1.143          }
   1.144          /* make pt page writable */
   1.145 -        PTWR_PRINTK("writable_l1 at %p is %08lx\n", ptwr_writables[cpu][idx], pte);
   1.146 +        PTWR_PRINTK("writable_l1 at %p is %08lx\n", ptwr_writables[cpu][idx],
   1.147 +                    pte);
   1.148          pte &= ~_PAGE_RW;
   1.149          if (__put_user(pte, ptwr_writables[cpu][idx]))
   1.150              BUG();
   1.151 -        PTWR_PRINTK("writable_l1 at %p now %08lx\n", ptwr_writables[cpu][idx], pte);
   1.152 +        PTWR_PRINTK("writable_l1 at %p now %08lx\n", ptwr_writables[cpu][idx],
   1.153 +                    pte);
   1.154      }
   1.155      ptwr_writable_idx[cpu] = 0;
   1.156  }
   1.157 @@ -1445,14 +1416,12 @@ int ptwr_do_page_fault(unsigned long add
   1.158                      &linear_pg_table[addr>>PAGE_SHIFT];
   1.159                  if ((page->type_and_flags & PGT_count_mask) != 1)
   1.160                      BUG();
   1.161 -#if 0
   1.162 -                put_page_type(page);
   1.163 -#else
   1.164 +
   1.165                  pl1e = map_domain_mem(pfn << PAGE_SHIFT);
   1.166                  memcpy(&ptwr_writable_page[cpu][ptwr_writable_idx[cpu]][0],
   1.167                         pl1e, ENTRIES_PER_L1_PAGETABLE * sizeof(l1_pgentry_t));
   1.168                  unmap_domain_mem(pl1e);
   1.169 -#endif
   1.170 +
   1.171                  ptwr_writable_idx[cpu]++;
   1.172              } else {
   1.173                  l2_pgentry_t nl2e;
   1.174 @@ -1465,28 +1434,24 @@ int ptwr_do_page_fault(unsigned long add
   1.175                                                             >> PAGE_SHIFT]) >>
   1.176                              PAGE_SHIFT,
   1.177                              frame_table[pfn].type_and_flags,
   1.178 -                            frame_table[pfn].count_and_flags, frame_table[pfn].u.domain->domain);
   1.179 +                            frame_table[pfn].count_and_flags,
   1.180 +                            frame_table[pfn].u.domain->domain);
   1.181                  /* disconnect l1 page */
   1.182                  nl2e = mk_l2_pgentry((l2_pgentry_val(*pl2e) &
   1.183                                        ~_PAGE_PRESENT) | 0x800);
   1.184 -#if 0
   1.185 -                mod_l2_entry(pl2e, nl2e,
   1.186 -                             l1_pgentry_val(linear_pg_table
   1.187 -                                            [(unsigned long)pl2e
   1.188 -                                             >> PAGE_SHIFT]) >>
   1.189 -                             PAGE_SHIFT);
   1.190 -#else
   1.191                  update_l2e(pl2e, *pl2e, nl2e);
   1.192 -#endif
   1.193 -                ptwr_disconnected[cpu] = (page->type_and_flags & PGT_va_mask) >>
   1.194 -                    PGT_va_shift;
   1.195 +
   1.196 +                ptwr_disconnected[cpu] = (page->type_and_flags & PGT_va_mask)
   1.197 +                    >> PGT_va_shift;
   1.198                  PTWR_PRINTK("now pl2e %p l2e %08lx              taf %08x/%08x/%u\n",
   1.199 -                       pl2e, l2_pgentry_val(*pl2e),
   1.200 -                       frame_table[pfn].type_and_flags,
   1.201 -                       frame_table[pfn].count_and_flags, frame_table[pfn].u.domain->domain);
   1.202 +                            pl2e, l2_pgentry_val(*pl2e),
   1.203 +                            frame_table[pfn].type_and_flags,
   1.204 +                            frame_table[pfn].count_and_flags,
   1.205 +                            frame_table[pfn].u.domain->domain);
   1.206                  ptwr_writable_l1[cpu] = (unsigned long *)
   1.207                      &linear_pg_table[addr>>PAGE_SHIFT];
   1.208 -                pl1e = map_domain_mem(l2_pgentry_to_pagenr(nl2e) << PAGE_SHIFT);
   1.209 +                pl1e = map_domain_mem(l2_pgentry_to_pagenr(nl2e) <<
   1.210 +                                      PAGE_SHIFT);
   1.211                  memcpy(&ptwr_disconnected_page[cpu][0], pl1e,
   1.212                         ENTRIES_PER_L1_PAGETABLE * sizeof(l1_pgentry_t));
   1.213                  unmap_domain_mem(pl1e);