ia64/xen-unstable

changeset 2453:87870eaba49e

bitkeeper revision 1.1159.73.2 (413de7819JSp6BvMAxNzNaHhtLuR3Q)

Tabs -> Spaces and other whitespace cleanup.
author cl349@freefall.cl.cam.ac.uk
date Tue Sep 07 16:53:21 2004 +0000 (2004-09-07)
parents 426891ca6a6f
children 72423979c7cd
files xen/arch/x86/memory.c
line diff
     1.1 --- a/xen/arch/x86/memory.c	Tue Sep 07 16:40:35 2004 +0000
     1.2 +++ b/xen/arch/x86/memory.c	Tue Sep 07 16:53:21 2004 +0000
     1.3 @@ -164,15 +164,8 @@ void arch_init_memory(void)
     1.4  
     1.5      memset(percpu_info, 0, sizeof(percpu_info));
     1.6  
     1.7 -/* XXXX WRITEABLE PAGETABLES SHOULD BE A DOMAIN CREATION-TIME
     1.8 -   DECISION, NOT SOMETHING THAT IS CHANGED ON A RUNNING DOMAIN 
     1.9 -   !!! FIX ME !!!! 
    1.10 - */
    1.11 -
    1.12 -    vm_assist_info[VMASST_TYPE_writable_pagetables].enable =
    1.13 -        NULL;
    1.14 -    vm_assist_info[VMASST_TYPE_writable_pagetables].disable =
    1.15 -        NULL;
    1.16 +    vm_assist_info[VMASST_TYPE_writable_pagetables].enable = NULL;
    1.17 +    vm_assist_info[VMASST_TYPE_writable_pagetables].disable = NULL;
    1.18  
    1.19      for ( mfn = 0; mfn < max_page; mfn++ )
    1.20          frame_table[mfn].count_info |= PGC_always_set;
    1.21 @@ -314,9 +307,9 @@ static int get_page_and_type_from_pagenr
    1.22      if ( unlikely(!get_page_type(page, type)) )
    1.23      {
    1.24  #ifdef VERBOSE
    1.25 -	if ((type & PGT_type_mask) != PGT_l1_page_table)
    1.26 -	    MEM_LOG("Bad page type for pfn %08lx (%08x)", 
    1.27 -		    page_nr, page->u.inuse.type_info);
    1.28 +        if ( (type & PGT_type_mask) != PGT_l1_page_table )
    1.29 +            MEM_LOG("Bad page type for pfn %08lx (%08x)", 
    1.30 +                    page_nr, page->u.inuse.type_info);
    1.31  #endif
    1.32          put_page(page);
    1.33          return 0;
    1.34 @@ -689,7 +682,7 @@ static int mod_l2_entry(l2_pgentry_t *pl
    1.35              return update_l2e(pl2e, ol2e, nl2e);
    1.36  
    1.37          if ( unlikely(!get_page_from_l2e(nl2e, pfn, current, 
    1.38 -					((unsigned long)pl2e & 
    1.39 +                                        ((unsigned long)pl2e & 
    1.40                                           ~PAGE_MASK) >> 2)) )
    1.41              return 0;
    1.42  
    1.43 @@ -796,9 +789,9 @@ int alloc_page_type(struct pfn_info *pag
    1.44      case PGT_ldt_page:
    1.45          return alloc_segdesc_page(page);
    1.46      default:
    1.47 -	printk("Bad type in alloc_page_type %x t=%x c=%x\n", 
    1.48 -	       type, page->u.inuse.type_info,
    1.49 -	       page->count_info);
    1.50 +        printk("Bad type in alloc_page_type %x t=%x c=%x\n", 
    1.51 +               type, page->u.inuse.type_info,
    1.52 +               page->count_info);
    1.53          BUG();
    1.54      }
    1.55  
    1.56 @@ -857,7 +850,7 @@ static int do_extended_command(unsigned 
    1.57          okay = get_page_and_type_from_pagenr(
    1.58              pfn, 
    1.59              ((cmd==MMUEXT_PIN_L2_TABLE) ? 
    1.60 -	     PGT_l2_page_table : (PGT_l1_page_table|PGT_va_mutable)),
    1.61 +             PGT_l2_page_table : (PGT_l1_page_table|PGT_va_mutable)),
    1.62              FOREIGNDOM);
    1.63  
    1.64          if ( unlikely(!okay) )
    1.65 @@ -1493,10 +1486,10 @@ int do_update_va_mapping_otherdomain(uns
    1.66  ptwr_info_t ptwr_info[NR_CPUS] =
    1.67      { [ 0 ... NR_CPUS-1 ] =
    1.68        {
    1.69 -	  .disconnected = ENTRIES_PER_L2_PAGETABLE,
    1.70 -	  .writable_idx = 0,
    1.71 +          .disconnected = ENTRIES_PER_L2_PAGETABLE,
    1.72 +          .writable_idx = 0,
    1.73  #ifdef PTWR_TRACK_DOMAIN
    1.74 -	  .domain = 0,
    1.75 +          .domain = 0,
    1.76  #endif
    1.77        }
    1.78      };
    1.79 @@ -1530,8 +1523,8 @@ void ptwr_reconnect_disconnected(unsigne
    1.80      pl2e = &linear_l2_table[ptwr_info[cpu].disconnected];
    1.81  
    1.82      if (__get_user(pte, writable_pte)) {
    1.83 -	MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte);
    1.84 -	domain_crash();
    1.85 +        MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte);
    1.86 +        domain_crash();
    1.87      }
    1.88      pfn = pte >> PAGE_SHIFT;
    1.89      page = &frame_table[pfn];
    1.90 @@ -1561,9 +1554,9 @@ void ptwr_reconnect_disconnected(unsigne
    1.91          if (unlikely(l1_pgentry_val(ol1e) & _PAGE_PRESENT))
    1.92              put_page_from_l1e(ol1e, current);
    1.93          if (unlikely(!get_page_from_l1e(nl1e, current))) {
    1.94 -	    MEM_LOG("ptwr: Could not re-validate l1 page\n");
    1.95 -	    domain_crash();
    1.96 -	}
    1.97 +            MEM_LOG("ptwr: Could not re-validate l1 page\n");
    1.98 +            domain_crash();
    1.99 +        }
   1.100      }
   1.101      unmap_domain_mem(pl1e);
   1.102      update_l2e(pl2e, *pl2e, nl2e);
   1.103 @@ -1576,15 +1569,15 @@ void ptwr_reconnect_disconnected(unsigne
   1.104      ptwr_info[cpu].disconnected = ENTRIES_PER_L2_PAGETABLE;
   1.105      /* make pt page write protected */
   1.106      if (__get_user(pte, writable_pte)) {
   1.107 -	MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte);
   1.108 -	domain_crash();
   1.109 +        MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte);
   1.110 +        domain_crash();
   1.111      }
   1.112      PTWR_PRINTK(("[A] writable_l1 at %p is %08lx\n",
   1.113                   writable_pte, pte));
   1.114      pte &= ~_PAGE_RW;
   1.115      if (__put_user(pte, writable_pte)) {
   1.116 -	MEM_LOG("ptwr: Could not update pte at %p\n", writable_pte);
   1.117 -	domain_crash();
   1.118 +        MEM_LOG("ptwr: Could not update pte at %p\n", writable_pte);
   1.119 +        domain_crash();
   1.120      }
   1.121      __flush_tlb_one(ptwr_info[cpu].writable_l1);
   1.122      PTWR_PRINTK(("[A] writable_l1 at %p now %08lx\n",
   1.123 @@ -1608,20 +1601,20 @@ void ptwr_flush_inactive(void)
   1.124  #endif
   1.125  #if 0
   1.126      {
   1.127 -	static int maxidx = 0;
   1.128 -	if (ptwr_info[cpu].writable_idx > maxidx) {
   1.129 -	    maxidx = ptwr_info[cpu].writable_idx;
   1.130 -	    printk("maxidx on cpu %d now %d\n", cpu, maxidx);
   1.131 -	}
   1.132 +        static int maxidx = 0;
   1.133 +        if (ptwr_info[cpu].writable_idx > maxidx) {
   1.134 +            maxidx = ptwr_info[cpu].writable_idx;
   1.135 +            printk("maxidx on cpu %d now %d\n", cpu, maxidx);
   1.136 +        }
   1.137      }
   1.138  #endif
   1.139      for (idx = 0; idx < ptwr_info[cpu].writable_idx; idx++) {
   1.140          unsigned long *writable_pte = (unsigned long *)&linear_pg_table
   1.141              [ptwr_info[cpu].writables[idx]>>PAGE_SHIFT];
   1.142          if (__get_user(pte, writable_pte)) {
   1.143 -	    MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte);
   1.144 -	    domain_crash();
   1.145 -	}
   1.146 +            MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte);
   1.147 +            domain_crash();
   1.148 +        }
   1.149          pfn = pte >> PAGE_SHIFT;
   1.150          page = &frame_table[pfn];
   1.151          PTWR_PRINTK(("[I] alloc l1 page %p\n", page));
   1.152 @@ -1636,9 +1629,9 @@ void ptwr_flush_inactive(void)
   1.153              if (unlikely(l1_pgentry_val(ol1e) & _PAGE_PRESENT))
   1.154                  put_page_from_l1e(ol1e, current);
   1.155              if (unlikely(!get_page_from_l1e(nl1e, current))) {
   1.156 -		MEM_LOG("ptwr: Could not re-validate l1 page\n");
   1.157 -		domain_crash();
   1.158 -	    }
   1.159 +                MEM_LOG("ptwr: Could not re-validate l1 page\n");
   1.160 +                domain_crash();
   1.161 +            }
   1.162          }
   1.163          unmap_domain_mem(pl1e);
   1.164  
   1.165 @@ -1647,9 +1640,9 @@ void ptwr_flush_inactive(void)
   1.166                       writable_pte, pte));
   1.167          pte &= ~_PAGE_RW;
   1.168          if (__put_user(pte, writable_pte)) {
   1.169 -	    MEM_LOG("ptwr: Could not update pte at %p\n", writable_pte);
   1.170 -	    domain_crash();
   1.171 -	}
   1.172 +            MEM_LOG("ptwr: Could not update pte at %p\n", writable_pte);
   1.173 +            domain_crash();
   1.174 +        }
   1.175          __flush_tlb_one(ptwr_info[cpu].writables[idx]);
   1.176          PTWR_PRINTK(("[I] writable_l1 at %p now %08lx\n",
   1.177                       writable_pte, pte));
   1.178 @@ -1672,8 +1665,8 @@ int ptwr_do_page_fault(unsigned long add
   1.179  
   1.180      /* Testing for page_present in the L2 avoids lots of unncessary fixups */
   1.181      if ( (l2_pgentry_val(linear_l2_table[addr >> L2_PAGETABLE_SHIFT]) &
   1.182 -      _PAGE_PRESENT) &&
   1.183 -	 (__get_user(pte, (unsigned long *)
   1.184 +          _PAGE_PRESENT) &&
   1.185 +         (__get_user(pte, (unsigned long *)
   1.186                       &linear_pg_table[addr >> PAGE_SHIFT]) == 0) )
   1.187      {
   1.188          pfn = pte >> PAGE_SHIFT;
   1.189 @@ -1698,7 +1691,7 @@ int ptwr_do_page_fault(unsigned long add
   1.190  
   1.191              if ( l2_pgentry_val(*pl2e) >> PAGE_SHIFT != pfn )
   1.192              {
   1.193 -		/* this L1 is not in the current address space */
   1.194 +                /* this L1 is not in the current address space */
   1.195                  l1_pgentry_t *pl1e;
   1.196                  PTWR_PRINTK(("[I] freeing l1 page %p taf %08x/%08x\n", page,
   1.197                               page->u.inuse.type_info,
   1.198 @@ -1753,11 +1746,11 @@ int ptwr_do_page_fault(unsigned long add
   1.199              PTWR_PRINTK(("update %p pte to %08lx\n",
   1.200                           &linear_pg_table[addr>>PAGE_SHIFT], pte));
   1.201              if ( __put_user(pte, (unsigned long *)
   1.202 -			    &linear_pg_table[addr>>PAGE_SHIFT]) ) {
   1.203 -		MEM_LOG("ptwr: Could not update pte at %p\n", (unsigned long *)
   1.204 -			&linear_pg_table[addr>>PAGE_SHIFT]);
   1.205 -		domain_crash();
   1.206 -	    }
   1.207 +                            &linear_pg_table[addr>>PAGE_SHIFT]) ) {
   1.208 +                MEM_LOG("ptwr: Could not update pte at %p\n", (unsigned long *)
   1.209 +                        &linear_pg_table[addr>>PAGE_SHIFT]);
   1.210 +                domain_crash();
   1.211 +            }
   1.212              return 1;
   1.213          }
   1.214      }
   1.215 @@ -1779,9 +1772,9 @@ void ptwr_status(void)
   1.216              [ptwr_info[cpu].writables[i]>>PAGE_SHIFT];
   1.217  
   1.218          if ( __get_user(pte, writable_pte) ) {
   1.219 -	    MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte);
   1.220 -	    domain_crash();
   1.221 -	}
   1.222 +            MEM_LOG("ptwr: Could not read pte at %p\n", writable_pte);
   1.223 +            domain_crash();
   1.224 +        }
   1.225  
   1.226          pfn = pte >> PAGE_SHIFT;
   1.227          page = &frame_table[pfn];
   1.228 @@ -1799,9 +1792,9 @@ void ptwr_status(void)
   1.229      pl2e = &linear_l2_table[ptwr_info[cpu].disconnected];
   1.230  
   1.231      if ( __get_user(pte, (unsigned long *)ptwr_info[cpu].writable_l1) ) {
   1.232 -	MEM_LOG("ptwr: Could not read pte at %p\n", (unsigned long *)
   1.233 -		ptwr_info[cpu].writable_l1);
   1.234 -	domain_crash();
   1.235 +        MEM_LOG("ptwr: Could not read pte at %p\n", (unsigned long *)
   1.236 +                ptwr_info[cpu].writable_l1);
   1.237 +        domain_crash();
   1.238      }
   1.239      pfn = pte >> PAGE_SHIFT;
   1.240      page = &frame_table[pfn];
   1.241 @@ -1824,109 +1817,110 @@ void audit_domain( struct domain *d)
   1.242      int ttot=0, ctot=0;
   1.243      void adjust ( struct pfn_info *page, int dir, int adjtype )
   1.244      {
   1.245 -	int count = page->count_info & PGC_count_mask;
   1.246 +        int count = page->count_info & PGC_count_mask;
   1.247  
   1.248 -	if (adjtype)
   1.249 -	{
   1.250 -	    int tcount = page->u.inuse.type_info & PGT_count_mask;
   1.251 -	    
   1.252 -	    ttot++;
   1.253 +        if ( adjtype )
   1.254 +        {
   1.255 +            int tcount = page->u.inuse.type_info & PGT_count_mask;
   1.256 +            
   1.257 +            ttot++;
   1.258  
   1.259 -	    tcount += dir;
   1.260 +            tcount += dir;
   1.261  
   1.262 -	    if (tcount <0 )
   1.263 -	    {
   1.264 -		printk("Audit %d: type count whent below zero pfn=%x taf=%x otaf=%x\n",
   1.265 -		       d->domain, page-frame_table,
   1.266 -		       page->u.inuse.type_info,
   1.267 -		       page->tlbflush_timestamp);
   1.268 -		return;
   1.269 -	    }
   1.270 -	    
   1.271 -	    page->u.inuse.type_info =
   1.272 -		(page->u.inuse.type_info & ~PGT_count_mask) | tcount;	    
   1.273 -	}
   1.274 +            if ( tcount < 0 )
   1.275 +            {
   1.276 +                printk("Audit %d: type count whent below zero pfn=%x taf=%x otaf=%x\n",
   1.277 +                       d->domain, page-frame_table,
   1.278 +                       page->u.inuse.type_info,
   1.279 +                       page->tlbflush_timestamp);
   1.280 +                return;
   1.281 +            }
   1.282 +            
   1.283 +            page->u.inuse.type_info =
   1.284 +                (page->u.inuse.type_info & ~PGT_count_mask) | tcount;
   1.285 +        }
   1.286  
   1.287 -	ctot++;
   1.288 -	count += dir;
   1.289 -	if (count <0 )
   1.290 -	{
   1.291 -	    printk("Audit %d: general count whent below zero pfn=%x taf=%x otaf=%x\n",
   1.292 -		   d->domain, page-frame_table,
   1.293 -		   page->u.inuse.type_info,
   1.294 -		   page->tlbflush_timestamp);
   1.295 -	    return;
   1.296 -	}
   1.297 -	    
   1.298 -	page->count_info =
   1.299 -	    (page->count_info & ~PGC_count_mask) | count;	    
   1.300 +        ctot++;
   1.301 +        count += dir;
   1.302 +        if ( count < 0 )
   1.303 +        {
   1.304 +            printk("Audit %d: general count whent below zero pfn=%x taf=%x otaf=%x\n",
   1.305 +                   d->domain, page-frame_table,
   1.306 +                   page->u.inuse.type_info,
   1.307 +                   page->tlbflush_timestamp);
   1.308 +            return;
   1.309 +        }
   1.310 +            
   1.311 +        page->count_info =
   1.312 +            (page->count_info & ~PGC_count_mask) | count;            
   1.313  
   1.314      }
   1.315  
   1.316      void scan_for_pfn( struct domain *d, unsigned long xpfn )
   1.317      {
   1.318 -	unsigned long pfn;
   1.319 -	struct list_head *list_ent;
   1.320 -	int i;
   1.321 +        unsigned long pfn;
   1.322 +        struct list_head *list_ent;
   1.323 +        int i;
   1.324  
   1.325          list_ent = d->page_list.next;
   1.326 -	for ( i = 0; (list_ent != &d->page_list); i++ )
   1.327 -	{
   1.328 -	    unsigned long * pt;
   1.329 -	    struct pfn_info *page;
   1.330 -	    pfn = list_entry(list_ent, struct pfn_info, list) - frame_table;
   1.331 -	    page = &frame_table[pfn];
   1.332 -	    
   1.333 -	    if ( (page->u.inuse.type_info & PGT_type_mask) == PGT_l1_page_table ||
   1.334 -		 (page->u.inuse.type_info & PGT_type_mask) == PGT_l2_page_table )
   1.335 -	    {
   1.336 -		pt = map_domain_mem( pfn<<PAGE_SHIFT );
   1.337 +        for ( i = 0; (list_ent != &d->page_list); i++ )
   1.338 +        {
   1.339 +            unsigned long * pt;
   1.340 +            struct pfn_info *page;
   1.341 +            pfn = list_entry(list_ent, struct pfn_info, list) - frame_table;
   1.342 +            page = &frame_table[pfn];
   1.343 +            
   1.344 +            if ( (page->u.inuse.type_info & PGT_type_mask) == PGT_l1_page_table ||
   1.345 +                 (page->u.inuse.type_info & PGT_type_mask) == PGT_l2_page_table )
   1.346 +            {
   1.347 +                pt = map_domain_mem( pfn<<PAGE_SHIFT );
   1.348  
   1.349 -		for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ )
   1.350 -		{
   1.351 -		    if ( pt[i] & _PAGE_PRESENT )
   1.352 -		    {
   1.353 -			unsigned long l1pfn = pt[i]>>PAGE_SHIFT;
   1.354 -			
   1.355 -			if( l1pfn == xpfn )
   1.356 -			{
   1.357 -			    printk("        found dom=%d i=%x pfn=%lx t=%x c=%x\n",
   1.358 -				   d->domain,
   1.359 -				   i,pfn,page->u.inuse.type_info,
   1.360 -				   page->count_info);
   1.361 -			}
   1.362 -		    }
   1.363 -		}
   1.364 +                for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ )
   1.365 +                {
   1.366 +                    if ( pt[i] & _PAGE_PRESENT )
   1.367 +                    {
   1.368 +                        unsigned long l1pfn = pt[i]>>PAGE_SHIFT;
   1.369 +                        
   1.370 +                        if ( l1pfn == xpfn )
   1.371 +                        {
   1.372 +                            printk("        found dom=%d i=%x pfn=%lx t=%x c=%x\n",
   1.373 +                                   d->domain,
   1.374 +                                   i,pfn,page->u.inuse.type_info,
   1.375 +                                   page->count_info);
   1.376 +                        }
   1.377 +                    }
   1.378 +                }
   1.379  
   1.380 -		unmap_domain_mem(pt);	   
   1.381 -	    }
   1.382 +                unmap_domain_mem(pt);           
   1.383 +            }
   1.384  
   1.385 -	    list_ent = frame_table[pfn].list.next;
   1.386 -	}
   1.387 +            list_ent = frame_table[pfn].list.next;
   1.388 +        }
   1.389  
   1.390      }
   1.391  
   1.392      void scan_for_pfn_remote( unsigned long xpfn )
   1.393      {
   1.394 -	struct domain *e;
   1.395 +        struct domain *e;
   1.396  
   1.397 -	for_each_domain ( e )
   1.398 -	{
   1.399 -	    scan_for_pfn( e, xpfn );	    
   1.400 -	}
   1.401 +        for_each_domain ( e )
   1.402 +        {
   1.403 +            scan_for_pfn( e, xpfn );            
   1.404 +        }
   1.405      }   
   1.406  
   1.407      int i;
   1.408      unsigned long pfn;
   1.409      struct list_head *list_ent;
   1.410  
   1.411 -    if(d!=current)domain_pause(d);
   1.412 +    if ( d != current )
   1.413 +        domain_pause(d);
   1.414      synchronise_pagetables(~0UL);
   1.415  
   1.416      printk("pt base=%lx sh_info=%x\n",
   1.417 -	   pagetable_val(d->mm.pagetable)>>PAGE_SHIFT,
   1.418 -	   virt_to_page(d->shared_info)-frame_table);
   1.419 -	   
   1.420 +           pagetable_val(d->mm.pagetable)>>PAGE_SHIFT,
   1.421 +           virt_to_page(d->shared_info)-frame_table);
   1.422 +           
   1.423      spin_lock(&d->page_alloc_lock);
   1.424  
   1.425      /* phase 0 */
   1.426 @@ -1934,42 +1928,42 @@ void audit_domain( struct domain *d)
   1.427      list_ent = d->page_list.next;
   1.428      for ( i = 0; (list_ent != &d->page_list); i++ )
   1.429      {
   1.430 -	struct pfn_info *page;
   1.431 -	pfn = list_entry(list_ent, struct pfn_info, list) - frame_table;       
   1.432 -	page = &frame_table[pfn];
   1.433 +        struct pfn_info *page;
   1.434 +        pfn = list_entry(list_ent, struct pfn_info, list) - frame_table;       
   1.435 +        page = &frame_table[pfn];
   1.436  
   1.437 -	if ( page->u.inuse.domain != d )
   1.438 -	    BUG();
   1.439 +        if ( page->u.inuse.domain != d )
   1.440 +            BUG();
   1.441  
   1.442 -	if ( (page->u.inuse.type_info & PGT_count_mask) >
   1.443 -	     (page->count_info & PGC_count_mask) )
   1.444 -	    printk("taf > caf %x %x pfn=%lx\n",
   1.445 -		   page->u.inuse.type_info, page->count_info, pfn );
   1.446 +        if ( (page->u.inuse.type_info & PGT_count_mask) >
   1.447 +             (page->count_info & PGC_count_mask) )
   1.448 +            printk("taf > caf %x %x pfn=%lx\n",
   1.449 +                   page->u.inuse.type_info, page->count_info, pfn );
   1.450   
   1.451  #if 0   // SYSV shared memory pages plus writeable files
   1.452 -	if ( (page->u.inuse.type_info & PGT_type_mask) == PGT_writable_page && 
   1.453 -	     (page->u.inuse.type_info & PGT_count_mask) > 1 )
   1.454 -	{
   1.455 -	    printk("writeable page with type count >1: pfn=%lx t=%x c=%x\n",
   1.456 -		  pfn,
   1.457 -		  page->u.inuse.type_info,
   1.458 -		  page->count_info );
   1.459 -	    scan_for_pfn_remote(pfn);
   1.460 -	}
   1.461 +        if ( (page->u.inuse.type_info & PGT_type_mask) == PGT_writable_page && 
   1.462 +             (page->u.inuse.type_info & PGT_count_mask) > 1 )
   1.463 +        {
   1.464 +            printk("writeable page with type count >1: pfn=%lx t=%x c=%x\n",
   1.465 +                  pfn,
   1.466 +                  page->u.inuse.type_info,
   1.467 +                  page->count_info );
   1.468 +            scan_for_pfn_remote(pfn);
   1.469 +        }
   1.470  #endif
   1.471 -	if ( (page->u.inuse.type_info & PGT_type_mask) == PGT_none && 
   1.472 -	     (page->u.inuse.type_info & PGT_count_mask) > 1 )
   1.473 -	{
   1.474 -	    printk("normal page with type count >1: pfn=%lx t=%x c=%x\n",
   1.475 -		  pfn,
   1.476 -		  page->u.inuse.type_info,
   1.477 -		  page->count_info );
   1.478 -	}
   1.479 +        if ( (page->u.inuse.type_info & PGT_type_mask) == PGT_none && 
   1.480 +             (page->u.inuse.type_info & PGT_count_mask) > 1 )
   1.481 +        {
   1.482 +            printk("normal page with type count >1: pfn=%lx t=%x c=%x\n",
   1.483 +                  pfn,
   1.484 +                  page->u.inuse.type_info,
   1.485 +                  page->count_info );
   1.486 +        }
   1.487  
   1.488 -	// use tlbflush_timestamp to store original type_info
   1.489 -	page->tlbflush_timestamp = page->u.inuse.type_info;
   1.490 +        // use tlbflush_timestamp to store original type_info
   1.491 +        page->tlbflush_timestamp = page->u.inuse.type_info;
   1.492  
   1.493 -	list_ent = frame_table[pfn].list.next;
   1.494 +        list_ent = frame_table[pfn].list.next;
   1.495      }
   1.496  
   1.497  
   1.498 @@ -1980,118 +1974,118 @@ void audit_domain( struct domain *d)
   1.499      list_ent = d->page_list.next;
   1.500      for ( i = 0; (list_ent != &d->page_list); i++ )
   1.501      {
   1.502 -	unsigned long * pt;
   1.503 -	struct pfn_info *page;
   1.504 -	pfn = list_entry(list_ent, struct pfn_info, list) - frame_table;       
   1.505 -	page = &frame_table[pfn];
   1.506 +        unsigned long * pt;
   1.507 +        struct pfn_info *page;
   1.508 +        pfn = list_entry(list_ent, struct pfn_info, list) - frame_table;       
   1.509 +        page = &frame_table[pfn];
   1.510  
   1.511 -	if ( page->u.inuse.domain != d )
   1.512 -	    BUG();
   1.513 +        if ( page->u.inuse.domain != d )
   1.514 +            BUG();
   1.515  
   1.516 -	switch ( page->u.inuse.type_info & PGT_type_mask )
   1.517 -	{
   1.518 -	case PGT_l2_page_table:
   1.519 +        switch ( page->u.inuse.type_info & PGT_type_mask )
   1.520 +        {
   1.521 +        case PGT_l2_page_table:
   1.522  
   1.523 -	    if ((page->u.inuse.type_info & PGT_validated) != PGT_validated )
   1.524 -		printk("Audit %d: L2 not validated %x\n",
   1.525 -		       d->domain, page->u.inuse.type_info);
   1.526 +            if ( (page->u.inuse.type_info & PGT_validated) != PGT_validated )
   1.527 +                printk("Audit %d: L2 not validated %x\n",
   1.528 +                       d->domain, page->u.inuse.type_info);
   1.529  
   1.530 -	    if ((page->u.inuse.type_info & PGT_pinned) != PGT_pinned )
   1.531 -		printk("Audit %d: L2 not pinned %x\n",
   1.532 -		       d->domain, page->u.inuse.type_info);
   1.533 -	    else
   1.534 -		adjust( page, -1, 1 );
   1.535 -	   
   1.536 -	    pt = map_domain_mem( pfn<<PAGE_SHIFT );
   1.537 +            if ( (page->u.inuse.type_info & PGT_pinned) != PGT_pinned )
   1.538 +                printk("Audit %d: L2 not pinned %x\n",
   1.539 +                       d->domain, page->u.inuse.type_info);
   1.540 +            else
   1.541 +                adjust( page, -1, 1 );
   1.542 +           
   1.543 +            pt = map_domain_mem( pfn<<PAGE_SHIFT );
   1.544  
   1.545 -	    for ( i = 0; i < DOMAIN_ENTRIES_PER_L2_PAGETABLE; i++ )
   1.546 -	    {
   1.547 -		if ( pt[i] & _PAGE_PRESENT )
   1.548 -		{
   1.549 -		    unsigned long l1pfn = pt[i]>>PAGE_SHIFT;
   1.550 -		    struct pfn_info *l1page = &frame_table[l1pfn];
   1.551 +            for ( i = 0; i < DOMAIN_ENTRIES_PER_L2_PAGETABLE; i++ )
   1.552 +            {
   1.553 +                if ( pt[i] & _PAGE_PRESENT )
   1.554 +                {
   1.555 +                    unsigned long l1pfn = pt[i]>>PAGE_SHIFT;
   1.556 +                    struct pfn_info *l1page = &frame_table[l1pfn];
   1.557  
   1.558 -		    if (l1page->u.inuse.domain != d)
   1.559 -		    {
   1.560 -			printk("Skip page belowing to other dom %p\n",
   1.561 -			       l1page->u.inuse.domain);    
   1.562 -			continue;
   1.563 -		    }
   1.564 +                    if ( l1page->u.inuse.domain != d )
   1.565 +                    {
   1.566 +                        printk("Skip page belowing to other dom %p\n",
   1.567 +                               l1page->u.inuse.domain);    
   1.568 +                        continue;
   1.569 +                    }
   1.570  
   1.571 -		    if ((l1page->u.inuse.type_info & PGT_type_mask) !=
   1.572 -			PGT_l1_page_table )
   1.573 -			printk("Audit %d: [%x] Expected L1 t=%x pfn=%lx\n",
   1.574 -			       d->domain, i,
   1.575 -			       l1page->u.inuse.type_info,
   1.576 -			       l1pfn);
   1.577 +                    if ( (l1page->u.inuse.type_info & PGT_type_mask) !=
   1.578 +                         PGT_l1_page_table )
   1.579 +                        printk("Audit %d: [%x] Expected L1 t=%x pfn=%lx\n",
   1.580 +                               d->domain, i,
   1.581 +                               l1page->u.inuse.type_info,
   1.582 +                               l1pfn);
   1.583  
   1.584 -		    adjust( l1page, -1, 1 );
   1.585 -		}
   1.586 -	    }
   1.587 +                    adjust( l1page, -1, 1 );
   1.588 +                }
   1.589 +            }
   1.590  
   1.591 -	    unmap_domain_mem(pt);
   1.592 +            unmap_domain_mem(pt);
   1.593  
   1.594 -	    break;
   1.595 +            break;
   1.596  
   1.597  
   1.598 -	case PGT_l1_page_table:
   1.599 -	    
   1.600 -	    if ((page->u.inuse.type_info & PGT_pinned) == PGT_pinned )
   1.601 -	    {
   1.602 -		//printk("L1 is pinned\n");
   1.603 -		adjust( page, -1, 1 );
   1.604 -	    }
   1.605 +        case PGT_l1_page_table:
   1.606 +            
   1.607 +            if ( (page->u.inuse.type_info & PGT_pinned) == PGT_pinned )
   1.608 +            {
   1.609 +                //printk("L1 is pinned\n");
   1.610 +                adjust( page, -1, 1 );
   1.611 +            }
   1.612  
   1.613 -	    if ((page->u.inuse.type_info & PGT_validated) != PGT_validated )
   1.614 -		printk("Audit %d: L1 not validated %x\n",
   1.615 -		       d->domain, page->u.inuse.type_info);
   1.616 +            if ( (page->u.inuse.type_info & PGT_validated) != PGT_validated )
   1.617 +                printk("Audit %d: L1 not validated %x\n",
   1.618 +                       d->domain, page->u.inuse.type_info);
   1.619  #if 0
   1.620 -	    if ((page->u.inuse.type_info & PGT_pinned) != PGT_pinned )
   1.621 -		printk("Audit %d: L1 not pinned %x\n",
   1.622 -		       d->domain, page->u.inuse.type_info);
   1.623 +            if ( (page->u.inuse.type_info & PGT_pinned) != PGT_pinned )
   1.624 +                printk("Audit %d: L1 not pinned %x\n",
   1.625 +                       d->domain, page->u.inuse.type_info);
   1.626  #endif
   1.627 -	    pt = map_domain_mem( pfn<<PAGE_SHIFT );
   1.628 +            pt = map_domain_mem( pfn<<PAGE_SHIFT );
   1.629  
   1.630 -	    for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ )
   1.631 -	    {
   1.632 -		if ( pt[i] & _PAGE_PRESENT )
   1.633 -		{
   1.634 -		    unsigned long l1pfn = pt[i]>>PAGE_SHIFT;
   1.635 -		    struct pfn_info *l1page = &frame_table[l1pfn];
   1.636 +            for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ )
   1.637 +            {
   1.638 +                if ( pt[i] & _PAGE_PRESENT )
   1.639 +                {
   1.640 +                    unsigned long l1pfn = pt[i]>>PAGE_SHIFT;
   1.641 +                    struct pfn_info *l1page = &frame_table[l1pfn];
   1.642  
   1.643 -		    if ( pt[i] & _PAGE_RW )
   1.644 -		    {
   1.645 +                    if ( pt[i] & _PAGE_RW )
   1.646 +                    {
   1.647  
   1.648 -			if ((l1page->u.inuse.type_info & PGT_type_mask) ==
   1.649 -			    PGT_l1_page_table ||
   1.650 -			    (l1page->u.inuse.type_info & PGT_type_mask) ==
   1.651 -			    PGT_l2_page_table )
   1.652 -			    printk("Audit %d: [%x] Ilegal RW t=%x pfn=%lx\n",
   1.653 -				   d->domain, i,
   1.654 -				   l1page->u.inuse.type_info,
   1.655 -				   l1pfn);
   1.656 +                        if ( (l1page->u.inuse.type_info & PGT_type_mask) ==
   1.657 +                             PGT_l1_page_table ||
   1.658 +                             (l1page->u.inuse.type_info & PGT_type_mask) ==
   1.659 +                             PGT_l2_page_table )
   1.660 +                            printk("Audit %d: [%x] Ilegal RW t=%x pfn=%lx\n",
   1.661 +                                   d->domain, i,
   1.662 +                                   l1page->u.inuse.type_info,
   1.663 +                                   l1pfn);
   1.664  
   1.665 -		    }
   1.666 +                    }
   1.667  
   1.668 -		    if (l1page->u.inuse.domain != d)
   1.669 -		    {
   1.670 -			printk("Skip page belowing to other dom %p\n",
   1.671 -			       l1page->u.inuse.domain);    
   1.672 -			continue;
   1.673 -		    }
   1.674 +                    if ( l1page->u.inuse.domain != d )
   1.675 +                    {
   1.676 +                        printk("Skip page belowing to other dom %p\n",
   1.677 +                               l1page->u.inuse.domain);    
   1.678 +                        continue;
   1.679 +                    }
   1.680  
   1.681 -		    adjust( l1page, -1, 0 );
   1.682 -		}
   1.683 -	    }
   1.684 +                    adjust( l1page, -1, 0 );
   1.685 +                }
   1.686 +            }
   1.687  
   1.688 -	    unmap_domain_mem(pt);
   1.689 +            unmap_domain_mem(pt);
   1.690  
   1.691 -	    break;
   1.692 -	}
   1.693 -	
   1.694 +            break;
   1.695 +        }
   1.696 +        
   1.697  
   1.698  
   1.699 -	list_ent = frame_table[pfn].list.next;
   1.700 +        list_ent = frame_table[pfn].list.next;
   1.701      }
   1.702  
   1.703      /* phase 2 */
   1.704 @@ -2100,38 +2094,38 @@ void audit_domain( struct domain *d)
   1.705      list_ent = d->page_list.next;
   1.706      for ( i = 0; (list_ent != &d->page_list); i++ )
   1.707      {
   1.708 -	struct pfn_info *page;
   1.709 -	pfn = list_entry(list_ent, struct pfn_info, list) - frame_table;
   1.710 -	
   1.711 -	page = &frame_table[pfn];
   1.712 +        struct pfn_info *page;
   1.713 +        pfn = list_entry(list_ent, struct pfn_info, list) - frame_table;
   1.714 +        
   1.715 +        page = &frame_table[pfn];
   1.716  
   1.717  
   1.718 -	switch ( page->u.inuse.type_info & PGT_type_mask)
   1.719 -	{
   1.720 -	case PGT_l1_page_table:
   1.721 -	case PGT_l2_page_table:
   1.722 -	    if ( (page->u.inuse.type_info & PGT_count_mask) != 0 )
   1.723 -	    {
   1.724 -		printk("Audit %d: type count!=0 t=%x ot=%x c=%x pfn=%lx\n",
   1.725 -		       d->domain, page->u.inuse.type_info, 
   1.726 -		       page->tlbflush_timestamp,
   1.727 -		       page->count_info, pfn );
   1.728 -		scan_for_pfn_remote(pfn);
   1.729 -	    }
   1.730 -	default:
   1.731 -	    if ( (page->count_info & PGC_count_mask) != 1 )
   1.732 -	    {
   1.733 -		printk("Audit %d: general count!=1 (c=%x) t=%x ot=%x pfn=%lx\n",
   1.734 -		       d->domain, 
   1.735 -		       page->count_info,
   1.736 -		       page->u.inuse.type_info, 
   1.737 -		       page->tlbflush_timestamp, pfn );
   1.738 -		scan_for_pfn_remote(pfn);
   1.739 -	    }
   1.740 -	    break;
   1.741 -	}
   1.742 +        switch ( page->u.inuse.type_info & PGT_type_mask)
   1.743 +        {
   1.744 +        case PGT_l1_page_table:
   1.745 +        case PGT_l2_page_table:
   1.746 +            if ( (page->u.inuse.type_info & PGT_count_mask) != 0 )
   1.747 +            {
   1.748 +                printk("Audit %d: type count!=0 t=%x ot=%x c=%x pfn=%lx\n",
   1.749 +                       d->domain, page->u.inuse.type_info, 
   1.750 +                       page->tlbflush_timestamp,
   1.751 +                       page->count_info, pfn );
   1.752 +                scan_for_pfn_remote(pfn);
   1.753 +            }
   1.754 +        default:
   1.755 +            if ( (page->count_info & PGC_count_mask) != 1 )
   1.756 +            {
   1.757 +                printk("Audit %d: general count!=1 (c=%x) t=%x ot=%x pfn=%lx\n",
   1.758 +                       d->domain, 
   1.759 +                       page->count_info,
   1.760 +                       page->u.inuse.type_info, 
   1.761 +                       page->tlbflush_timestamp, pfn );
   1.762 +                scan_for_pfn_remote(pfn);
   1.763 +            }
   1.764 +            break;
   1.765 +        }
   1.766  
   1.767 -	list_ent = frame_table[pfn].list.next;
   1.768 +        list_ent = frame_table[pfn].list.next;
   1.769      }
   1.770  
   1.771      /* phase 3 */
   1.772 @@ -2139,65 +2133,65 @@ void audit_domain( struct domain *d)
   1.773      list_ent = d->page_list.next;
   1.774      for ( i = 0; (list_ent != &d->page_list); i++ )
   1.775      {
   1.776 -	unsigned long * pt;
   1.777 -	struct pfn_info *page;
   1.778 -	pfn = list_entry(list_ent, struct pfn_info, list) - frame_table;
   1.779 -	
   1.780 -	page = &frame_table[pfn];
   1.781 +        unsigned long * pt;
   1.782 +        struct pfn_info *page;
   1.783 +        pfn = list_entry(list_ent, struct pfn_info, list) - frame_table;
   1.784 +        
   1.785 +        page = &frame_table[pfn];
   1.786  
   1.787 -	switch ( page->u.inuse.type_info & PGT_type_mask )
   1.788 -	{
   1.789 -	case PGT_l2_page_table:
   1.790 -	    if ((page->u.inuse.type_info & PGT_pinned) == PGT_pinned )
   1.791 -		adjust( page, 1, 1 );	  
   1.792 +        switch ( page->u.inuse.type_info & PGT_type_mask )
   1.793 +        {
   1.794 +        case PGT_l2_page_table:
   1.795 +            if ( (page->u.inuse.type_info & PGT_pinned) == PGT_pinned )
   1.796 +                adjust( page, 1, 1 );          
   1.797  
   1.798 -	    pt = map_domain_mem( pfn<<PAGE_SHIFT );
   1.799 +            pt = map_domain_mem( pfn<<PAGE_SHIFT );
   1.800  
   1.801 -	    for ( i = 0; i < DOMAIN_ENTRIES_PER_L2_PAGETABLE; i++ )
   1.802 -	    {
   1.803 -		if ( pt[i] & _PAGE_PRESENT )
   1.804 -		{
   1.805 -		    unsigned long l1pfn = pt[i]>>PAGE_SHIFT;
   1.806 -		    struct pfn_info *l1page = &frame_table[l1pfn];
   1.807 +            for ( i = 0; i < DOMAIN_ENTRIES_PER_L2_PAGETABLE; i++ )
   1.808 +            {
   1.809 +                if ( pt[i] & _PAGE_PRESENT )
   1.810 +                {
   1.811 +                    unsigned long l1pfn = pt[i]>>PAGE_SHIFT;
   1.812 +                    struct pfn_info *l1page = &frame_table[l1pfn];
   1.813  
   1.814 -		    if ( l1page->u.inuse.domain == d)
   1.815 -			adjust( l1page, 1, 1 );
   1.816 -		}
   1.817 -	    }
   1.818 +                    if ( l1page->u.inuse.domain == d)
   1.819 +                        adjust( l1page, 1, 1 );
   1.820 +                }
   1.821 +            }
   1.822  
   1.823 -	    unmap_domain_mem(pt);
   1.824 -	    break;
   1.825 +            unmap_domain_mem(pt);
   1.826 +            break;
   1.827  
   1.828 -	case PGT_l1_page_table:
   1.829 -	    if ((page->u.inuse.type_info & PGT_pinned) == PGT_pinned )
   1.830 -		adjust( page, 1, 1 );
   1.831 +        case PGT_l1_page_table:
   1.832 +            if ( (page->u.inuse.type_info & PGT_pinned) == PGT_pinned )
   1.833 +                adjust( page, 1, 1 );
   1.834  
   1.835 -	    pt = map_domain_mem( pfn<<PAGE_SHIFT );
   1.836 +            pt = map_domain_mem( pfn<<PAGE_SHIFT );
   1.837  
   1.838 -	    for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ )
   1.839 -	    {
   1.840 -		if ( pt[i] & _PAGE_PRESENT )
   1.841 -		{
   1.842 +            for ( i = 0; i < ENTRIES_PER_L1_PAGETABLE; i++ )
   1.843 +            {
   1.844 +                if ( pt[i] & _PAGE_PRESENT )
   1.845 +                {
   1.846  #if 1
   1.847  
   1.848 -		    unsigned long l1pfn = pt[i]>>PAGE_SHIFT;
   1.849 -		    struct pfn_info *l1page = &frame_table[l1pfn];
   1.850 +                    unsigned long l1pfn = pt[i]>>PAGE_SHIFT;
   1.851 +                    struct pfn_info *l1page = &frame_table[l1pfn];
   1.852  
   1.853 -		    if ( l1page->u.inuse.domain == d)
   1.854 -			adjust( l1page, 1, 0 );
   1.855 +                    if ( l1page->u.inuse.domain == d)
   1.856 +                        adjust( l1page, 1, 0 );
   1.857  #endif
   1.858 -		}
   1.859 -	    }
   1.860 +                }
   1.861 +            }
   1.862  
   1.863 -	    unmap_domain_mem(pt);
   1.864 -	    break;
   1.865 -	}
   1.866 +            unmap_domain_mem(pt);
   1.867 +            break;
   1.868 +        }
   1.869  
   1.870  
   1.871 -	page->tlbflush_timestamp = 0; // put back
   1.872 +        page->tlbflush_timestamp = 0; // put back
   1.873  
   1.874  
   1.875 -	list_ent = frame_table[pfn].list.next;
   1.876 +        list_ent = frame_table[pfn].list.next;
   1.877      }
   1.878  
   1.879      spin_unlock(&d->page_alloc_lock);
   1.880 @@ -2206,24 +2200,24 @@ void audit_domain( struct domain *d)
   1.881  
   1.882      printk("Audit %d: Done. ctot=%d ttot=%d\n",d->domain, ctot, ttot );
   1.883  
   1.884 -    if(d!=current)domain_unpause(d);
   1.885 -
   1.886 +    if ( d != current )
   1.887 +        domain_unpause(d);
   1.888  }
   1.889  
   1.890  
   1.891 -void audit_domains( void )
   1.892 +void audit_domains(void)
   1.893  {
   1.894      struct domain *d;
   1.895  
   1.896      for_each_domain ( d )
   1.897      {
   1.898 -	if ( d->domain > 0 )
   1.899 -	    audit_domain(d);
   1.900 +        if ( d->domain > 0 )
   1.901 +            audit_domain(d);
   1.902      }
   1.903  }
   1.904  
   1.905 -void audit_domains_key (unsigned char key, void *dev_id,
   1.906 -                           struct pt_regs *regs)
   1.907 +void audit_domains_key(unsigned char key, void *dev_id,
   1.908 +                       struct pt_regs *regs)
   1.909  {
   1.910      open_softirq( MEMAUDIT_SOFTIRQ, audit_domains );
   1.911      raise_softirq( MEMAUDIT_SOFTIRQ );