ia64/xen-unstable

changeset 15604:23dab4b05455

hap: Fix for coding style.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Jul 17 09:22:41 2007 +0100 (2007-07-17)
parents d99903a98ad0
children 9559ba7c80f9
files xen/arch/x86/mm/hap/hap.c xen/arch/x86/mm/hap/support.c xen/include/asm-x86/hap.h
line diff
     1.1 --- a/xen/arch/x86/mm/hap/hap.c	Mon Jul 16 14:28:54 2007 +0100
     1.2 +++ b/xen/arch/x86/mm/hap/hap.c	Tue Jul 17 09:22:41 2007 +0100
     1.3 @@ -133,21 +133,21 @@ struct page_info * hap_alloc_p2m_page(st
     1.4      */
     1.5      if ( d->arch.paging.hap.p2m_pages == 0 ) 
     1.6      {
     1.7 -	pg = alloc_domheap_pages(NULL, 0, MEMF_bits(32));
     1.8 -	d->arch.paging.hap.p2m_pages += 1;
     1.9 +        pg = alloc_domheap_pages(NULL, 0, MEMF_bits(32));
    1.10 +        d->arch.paging.hap.p2m_pages += 1;
    1.11      }
    1.12      else
    1.13  #endif
    1.14      {
    1.15 -	pg = mfn_to_page(hap_alloc(d));
    1.16 -	
    1.17 -	d->arch.paging.hap.p2m_pages += 1;
    1.18 -	d->arch.paging.hap.total_pages -= 1;
    1.19 -    }	
    1.20 +        pg = mfn_to_page(hap_alloc(d));
    1.21 +        d->arch.paging.hap.p2m_pages += 1;
    1.22 +        d->arch.paging.hap.total_pages -= 1;
    1.23 +    }
    1.24  
    1.25 -    if ( pg == NULL ) {
    1.26 -	hap_unlock(d);
    1.27 -	return NULL;
    1.28 +    if ( pg == NULL )
    1.29 +    {
    1.30 +        hap_unlock(d);
    1.31 +        return NULL;
    1.32      }   
    1.33  
    1.34      hap_unlock(d);
    1.35 @@ -166,17 +166,16 @@ void hap_free_p2m_page(struct domain *d,
    1.36  {
    1.37      ASSERT(page_get_owner(pg) == d);
    1.38      /* Should have just the one ref we gave it in alloc_p2m_page() */
    1.39 -    if ( (pg->count_info & PGC_count_mask) != 1 ) {
    1.40 +    if ( (pg->count_info & PGC_count_mask) != 1 )
    1.41          HAP_ERROR("Odd p2m page count c=%#x t=%"PRtype_info"\n",
    1.42                    pg->count_info, pg->u.inuse.type_info);
    1.43 -    }
    1.44      pg->count_info = 0;
    1.45      /* Free should not decrement domain's total allocation, since 
    1.46       * these pages were allocated without an owner. */
    1.47      page_set_owner(pg, NULL); 
    1.48      free_domheap_pages(pg, 0);
    1.49      d->arch.paging.hap.p2m_pages--;
    1.50 -    ASSERT( d->arch.paging.hap.p2m_pages >= 0 );
    1.51 +    ASSERT(d->arch.paging.hap.p2m_pages >= 0);
    1.52  }
    1.53  
    1.54  /* Return the size of the pool, rounded up to the nearest MB */
    1.55 @@ -185,7 +184,6 @@ hap_get_allocation(struct domain *d)
    1.56  {
    1.57      unsigned int pg = d->arch.paging.hap.total_pages;
    1.58  
    1.59 -    HERE_I_AM;
    1.60      return ((pg >> (20 - PAGE_SHIFT))
    1.61              + ((pg & ((1 << (20 - PAGE_SHIFT)) - 1)) ? 1 : 0));
    1.62  }
    1.63 @@ -199,11 +197,14 @@ hap_set_allocation(struct domain *d, uns
    1.64  
    1.65      ASSERT(hap_locked_by_me(d));
    1.66  
    1.67 -    while ( d->arch.paging.hap.total_pages != pages ) {
    1.68 -        if ( d->arch.paging.hap.total_pages < pages ) {
    1.69 +    while ( d->arch.paging.hap.total_pages != pages )
    1.70 +    {
    1.71 +        if ( d->arch.paging.hap.total_pages < pages )
    1.72 +        {
    1.73              /* Need to allocate more memory from domheap */
    1.74              sp = alloc_domheap_pages(NULL, 0, 0);
    1.75 -            if ( sp == NULL ) {
    1.76 +            if ( sp == NULL )
    1.77 +            {
    1.78                  HAP_PRINTK("failed to allocate hap pages.\n");
    1.79                  return -ENOMEM;
    1.80              }
    1.81 @@ -211,7 +212,8 @@ hap_set_allocation(struct domain *d, uns
    1.82              d->arch.paging.hap.total_pages += 1;
    1.83              list_add_tail(&sp->list, &d->arch.paging.hap.freelists);
    1.84          }
    1.85 -        else if ( d->arch.paging.hap.total_pages > pages ) {
    1.86 +        else if ( d->arch.paging.hap.total_pages > pages )
    1.87 +        {
    1.88              /* Need to return memory to domheap */
    1.89              ASSERT(!list_empty(&d->arch.paging.hap.freelists));
    1.90              sp = list_entry(d->arch.paging.hap.freelists.next,
    1.91 @@ -224,7 +226,8 @@ hap_set_allocation(struct domain *d, uns
    1.92          }
    1.93          
    1.94          /* Check to see if we need to yield and try again */
    1.95 -        if ( preempted && hypercall_preempt_check() ) {
    1.96 +        if ( preempted && hypercall_preempt_check() )
    1.97 +        {
    1.98              *preempted = 1;
    1.99              return 0;
   1.100          }
   1.101 @@ -285,8 +288,8 @@ void hap_install_xen_entries_in_l2h(stru
   1.102      for ( i = 0; i < PDPT_L2_ENTRIES; i++ )
   1.103          sl2e[l2_table_offset(PERDOMAIN_VIRT_START) + i] =
   1.104              l2e_from_pfn(
   1.105 -                         mfn_x(page_to_mfn(virt_to_page(d->arch.mm_perdomain_pt) + i)),
   1.106 -                         __PAGE_HYPERVISOR);
   1.107 +                mfn_x(page_to_mfn(virt_to_page(d->arch.mm_perdomain_pt) + i)),
   1.108 +                __PAGE_HYPERVISOR);
   1.109      
   1.110      for ( i = 0; i < HAP_L3_PAGETABLE_ENTRIES; i++ )
   1.111          sl2e[l2_table_offset(LINEAR_PT_VIRT_START) + i] =
   1.112 @@ -434,22 +437,23 @@ int hap_enable(struct domain *d, u32 mod
   1.113      unsigned int old_pages;
   1.114      int rv = 0;
   1.115  
   1.116 -    HERE_I_AM;
   1.117 -
   1.118      domain_pause(d);
   1.119      /* error check */
   1.120 -    if ( (d == current->domain) ) {
   1.121 +    if ( (d == current->domain) )
   1.122 +    {
   1.123          rv = -EINVAL;
   1.124          goto out;
   1.125      }
   1.126  
   1.127      old_pages = d->arch.paging.hap.total_pages;
   1.128 -    if ( old_pages == 0 ) {
   1.129 +    if ( old_pages == 0 )
   1.130 +    {
   1.131          unsigned int r;
   1.132          hap_lock(d);
   1.133          r = hap_set_allocation(d, 256, NULL);
   1.134          hap_unlock(d);
   1.135 -        if ( r != 0 ) {
   1.136 +        if ( r != 0 )
   1.137 +        {
   1.138              hap_set_allocation(d, 0, NULL);
   1.139              rv = -ENOMEM;
   1.140              goto out;
   1.141 @@ -457,7 +461,8 @@ int hap_enable(struct domain *d, u32 mod
   1.142      }
   1.143  
   1.144      /* allocate P2m table */
   1.145 -    if ( mode & PG_translate ) {
   1.146 +    if ( mode & PG_translate )
   1.147 +    {
   1.148          rv = p2m_alloc_table(d, hap_alloc_p2m_page, hap_free_p2m_page);
   1.149          if ( rv != 0 )
   1.150              goto out;
   1.151 @@ -472,20 +477,17 @@ int hap_enable(struct domain *d, u32 mod
   1.152  
   1.153  void hap_final_teardown(struct domain *d)
   1.154  {
   1.155 -    HERE_I_AM;
   1.156 -
   1.157      if ( d->arch.paging.hap.total_pages != 0 )
   1.158          hap_teardown(d);
   1.159  
   1.160      p2m_teardown(d);
   1.161 -    ASSERT( d->arch.paging.hap.p2m_pages == 0 );
   1.162 +    ASSERT(d->arch.paging.hap.p2m_pages == 0);
   1.163  }
   1.164  
   1.165  void hap_teardown(struct domain *d)
   1.166  {
   1.167      struct vcpu *v;
   1.168      mfn_t mfn;
   1.169 -    HERE_I_AM;
   1.170  
   1.171      ASSERT(d->is_dying);
   1.172      ASSERT(d != current->domain);
   1.173 @@ -493,10 +495,13 @@ void hap_teardown(struct domain *d)
   1.174      if ( !hap_locked_by_me(d) )
   1.175          hap_lock(d); /* Keep various asserts happy */
   1.176  
   1.177 -    if ( paging_mode_enabled(d) ) {
   1.178 +    if ( paging_mode_enabled(d) )
   1.179 +    {
   1.180          /* release the monitor table held by each vcpu */
   1.181 -        for_each_vcpu(d, v) {
   1.182 -            if ( v->arch.paging.mode && paging_mode_external(d) ) {
   1.183 +        for_each_vcpu ( d, v )
   1.184 +        {
   1.185 +            if ( v->arch.paging.mode && paging_mode_external(d) )
   1.186 +            {
   1.187                  mfn = pagetable_get_mfn(v->arch.monitor_table);
   1.188                  if ( mfn_valid(mfn) && (mfn_x(mfn) != 0) )
   1.189                      hap_destroy_monitor_table(v, mfn);
   1.190 @@ -505,7 +510,8 @@ void hap_teardown(struct domain *d)
   1.191          }
   1.192      }
   1.193  
   1.194 -    if ( d->arch.paging.hap.total_pages != 0 ) {
   1.195 +    if ( d->arch.paging.hap.total_pages != 0 )
   1.196 +    {
   1.197          HAP_PRINTK("teardown of domain %u starts."
   1.198                        "  pages total = %u, free = %u, p2m=%u\n",
   1.199                        d->domain_id,
   1.200 @@ -531,9 +537,8 @@ int hap_domctl(struct domain *d, xen_dom
   1.201  {
   1.202      int rc, preempted = 0;
   1.203  
   1.204 -    HERE_I_AM;
   1.205 -
   1.206 -    switch ( sc->op ) {
   1.207 +    switch ( sc->op )
   1.208 +    {
   1.209      case XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION:
   1.210          hap_lock(d);
   1.211          rc = hap_set_allocation(d, sc->mb << (20 - PAGE_SHIFT), &preempted);
   1.212 @@ -599,8 +604,6 @@ void hap_update_paging_modes(struct vcpu
   1.213  {
   1.214      struct domain *d;
   1.215  
   1.216 -    HERE_I_AM;
   1.217 -
   1.218      d = v->domain;
   1.219      hap_lock(d);
   1.220  
   1.221 @@ -608,7 +611,8 @@ void hap_update_paging_modes(struct vcpu
   1.222       * guest's paging mode. So, make sure the shadow registers (CR0, CR4, EFER)
   1.223       * reflect guest's status correctly.
   1.224       */
   1.225 -    if ( hvm_paging_enabled(v) ) {
   1.226 +    if ( hvm_paging_enabled(v) )
   1.227 +    {
   1.228          if ( hvm_long_mode_enabled(v) )
   1.229              v->arch.paging.mode = &hap_paging_long_mode;
   1.230          else if ( hvm_pae_enabled(v) )
   1.231 @@ -616,13 +620,15 @@ void hap_update_paging_modes(struct vcpu
   1.232          else
   1.233              v->arch.paging.mode = &hap_paging_protected_mode;
   1.234      }
   1.235 -    else {
   1.236 +    else
   1.237 +    {
   1.238          v->arch.paging.mode = &hap_paging_real_mode;
   1.239      }
   1.240  
   1.241      v->arch.paging.translate_enabled = !!hvm_paging_enabled(v);
   1.242  
   1.243 -    if ( pagetable_is_null(v->arch.monitor_table) ) {
   1.244 +    if ( pagetable_is_null(v->arch.monitor_table) )
   1.245 +    {
   1.246          mfn_t mmfn = hap_make_monitor_table(v);
   1.247          v->arch.monitor_table = pagetable_from_mfn(mmfn);
   1.248          make_cr3(v, mfn_x(mmfn));
   1.249 @@ -647,23 +653,25 @@ static void p2m_install_entry_in_monitor
   1.250      index = ((unsigned long)l3e & ~PAGE_MASK) / sizeof(l3_pgentry_t);
   1.251      ASSERT(index < MACHPHYS_MBYTES>>1);
   1.252      
   1.253 -    for_each_vcpu(d, v) {
   1.254 -	if ( pagetable_get_pfn(v->arch.monitor_table) == 0 ) 
   1.255 -	    continue;
   1.256 +    for_each_vcpu ( d, v )
   1.257 +    {
   1.258 +        if ( pagetable_get_pfn(v->arch.monitor_table) == 0 ) 
   1.259 +            continue;
   1.260  
   1.261 -	ASSERT(paging_mode_external(v->domain));
   1.262 +        ASSERT(paging_mode_external(v->domain));
   1.263  
   1.264          if ( v == current ) /* OK to use linear map of monitor_table */
   1.265 -	    ml2e = __linear_l2_table + l2_linear_offset(RO_MPT_VIRT_START);
   1.266 +            ml2e = __linear_l2_table + l2_linear_offset(RO_MPT_VIRT_START);
   1.267          else {
   1.268 -	    l3_pgentry_t *ml3e;
   1.269 -            ml3e = hap_map_domain_page(pagetable_get_mfn(v->arch.monitor_table));
   1.270 -	    ASSERT(l3e_get_flags(ml3e[3]) & _PAGE_PRESENT);
   1.271 +            l3_pgentry_t *ml3e;
   1.272 +            ml3e = hap_map_domain_page(
   1.273 +                pagetable_get_mfn(v->arch.monitor_table));
   1.274 +            ASSERT(l3e_get_flags(ml3e[3]) & _PAGE_PRESENT);
   1.275              ml2e = hap_map_domain_page(_mfn(l3e_get_pfn(ml3e[3])));
   1.276              ml2e += l2_table_offset(RO_MPT_VIRT_START);
   1.277 -	    hap_unmap_domain_page(ml3e);
   1.278 +            hap_unmap_domain_page(ml3e);
   1.279          }
   1.280 -	ml2e[index] = l2e_from_pfn(l3e_get_pfn(*l3e), __PAGE_HYPERVISOR);
   1.281 +        ml2e[index] = l2e_from_pfn(l3e_get_pfn(*l3e), __PAGE_HYPERVISOR);
   1.282          if ( v != current )
   1.283              hap_unmap_domain_page(ml2e);
   1.284      }
   1.285 @@ -680,9 +688,9 @@ hap_write_p2m_entry(struct vcpu *v, unsi
   1.286  #if CONFIG_PAGING_LEVELS == 3
   1.287      /* install P2M in monitor table for PAE Xen */
   1.288      if ( level == 3 ) 
   1.289 -	/* We have written to the p2m l3: need to sync the per-vcpu
   1.290 +        /* We have written to the p2m l3: need to sync the per-vcpu
   1.291           * copies of it in the monitor tables */
   1.292 -	p2m_install_entry_in_monitors(v->domain, (l3_pgentry_t *)p);
   1.293 +        p2m_install_entry_in_monitors(v->domain, (l3_pgentry_t *)p);
   1.294  #endif
   1.295      
   1.296      hap_unlock(v->domain);
     2.1 --- a/xen/arch/x86/mm/hap/support.c	Mon Jul 16 14:28:54 2007 +0100
     2.2 +++ b/xen/arch/x86/mm/hap/support.c	Tue Jul 17 09:22:41 2007 +0100
     2.3 @@ -43,7 +43,6 @@
     2.4   */
     2.5  unsigned long hap_gva_to_gfn_real_mode(struct vcpu *v, unsigned long gva)
     2.6  {
     2.7 -    HERE_I_AM;
     2.8      return ((paddr_t)gva >> PAGE_SHIFT);
     2.9  }
    2.10  
    2.11 @@ -61,12 +60,12 @@ unsigned long hap_gva_to_gfn_protected_m
    2.12      l2_pgentry_32_t *l2e; /* guest page entry size is 32-bit */
    2.13      l1_pgentry_32_t *l1e;
    2.14  
    2.15 -    HERE_I_AM;
    2.16 -
    2.17      gpfn = (gcr3 >> PAGE_SHIFT);
    2.18 -    for ( lev = mode; lev >= 1; lev-- ) {
    2.19 -        mfn = get_mfn_from_gpfn( gpfn );
    2.20 -        if ( mfn == INVALID_MFN ) {
    2.21 +    for ( lev = mode; lev >= 1; lev-- )
    2.22 +    {
    2.23 +        mfn = get_mfn_from_gpfn(gpfn);
    2.24 +        if ( mfn == INVALID_MFN )
    2.25 +        {
    2.26              HAP_PRINTK("bad pfn=0x%lx from gva=0x%lx at lev%d\n", gpfn, gva, 
    2.27                         lev);
    2.28              success = 0;
    2.29 @@ -74,18 +73,22 @@ unsigned long hap_gva_to_gfn_protected_m
    2.30          }
    2.31          index = (gva >> PT_SHIFT[mode][lev]) & (PT_ENTRIES[mode][lev]-1);
    2.32  
    2.33 -        if ( lev == 2 ) {
    2.34 -            l2e = map_domain_page( mfn );
    2.35 +        if ( lev == 2 )
    2.36 +        {
    2.37 +            l2e = map_domain_page(mfn);
    2.38              HAP_PRINTK("l2 page table entry is %ulx at index = %d\n", 
    2.39                         l2e[index].l2, index);
    2.40 -            if ( !(l2e_get_flags_32(l2e[index]) & _PAGE_PRESENT) ) {
    2.41 +            if ( !(l2e_get_flags_32(l2e[index]) & _PAGE_PRESENT) )
    2.42 +            {
    2.43                  HAP_PRINTK("Level 2 entry not present at index = %d\n", index);
    2.44                  success = 0;
    2.45              }
    2.46  
    2.47 -            if ( l2e_get_flags_32(l2e[index]) & _PAGE_PSE ) { /* handle PSE */
    2.48 +            if ( l2e_get_flags_32(l2e[index]) & _PAGE_PSE )
    2.49 +            {
    2.50                  HAP_PRINTK("guest page table is PSE\n");
    2.51 -                if ( l2e_get_intpte(l2e[index]) & 0x001FE000UL ) { /*[13:20] */
    2.52 +                if ( l2e_get_intpte(l2e[index]) & 0x001FE000UL ) /*[13:20] */
    2.53 +                {
    2.54                      printk("guest physical memory size is too large!\n");
    2.55                      domain_crash(v->domain);
    2.56                  }
    2.57 @@ -94,23 +97,24 @@ unsigned long hap_gva_to_gfn_protected_m
    2.58                  unmap_domain_page(l2e);
    2.59                  break; /* last level page table, return from here */
    2.60              }
    2.61 -            else {
    2.62 -                gpfn = l2e_get_pfn( l2e[index] );
    2.63 -            }
    2.64 +
    2.65 +            gpfn = l2e_get_pfn(l2e[index]);
    2.66              unmap_domain_page(l2e);
    2.67          }
    2.68  
    2.69 -        if ( lev == 1 ) {
    2.70 -            l1e = map_domain_page( mfn );
    2.71 +        if ( lev == 1 )
    2.72 +        {
    2.73 +            l1e = map_domain_page(mfn);
    2.74              HAP_PRINTK("l1 page table entry is %ulx at index = %d\n", 
    2.75                         l1e[index].l1, index);
    2.76 -            if ( !(l1e_get_flags_32(l1e[index]) & _PAGE_PRESENT) ) {
    2.77 +            if ( !(l1e_get_flags_32(l1e[index]) & _PAGE_PRESENT) )
    2.78 +            {
    2.79                  HAP_PRINTK("Level 1 entry not present at index = %d\n", index);
    2.80                  success = 0;
    2.81              }
    2.82 -            gpfn = l1e_get_pfn( l1e[index] );
    2.83 +            gpfn = l1e_get_pfn(l1e[index]);
    2.84              gpa = (l1e_get_intpte(l1e[index]) & PHYSICAL_PAGE_4K_MASK) + 
    2.85 -                (gva & ~PHYSICAL_PAGE_4K_MASK);	    
    2.86 +                (gva & ~PHYSICAL_PAGE_4K_MASK);    
    2.87              unmap_domain_page(l1e);
    2.88          }
    2.89  
    2.90 @@ -120,10 +124,7 @@ unsigned long hap_gva_to_gfn_protected_m
    2.91  
    2.92      HAP_PRINTK("success = %d, gva = %lx, gpa = %lx\n", success, gva, gpa);
    2.93  
    2.94 -    if ( !success ) /* error happened */
    2.95 -        return INVALID_GFN;
    2.96 -    else
    2.97 -        return ((paddr_t)gpa >> PAGE_SHIFT);
    2.98 +    return (!success ? INVALID_GFN : ((paddr_t)gpa >> PAGE_SHIFT));
    2.99  }
   2.100  
   2.101  
   2.102 @@ -144,12 +145,12 @@ unsigned long hap_gva_to_gfn_pae_mode(st
   2.103      l2_pgentry_t *l2e;
   2.104      l3_pgentry_t *l3e;
   2.105      
   2.106 -    HERE_I_AM;
   2.107 -
   2.108      gpfn = (gcr3 >> PAGE_SHIFT);
   2.109 -    for ( lev = mode; lev >= 1; lev-- ) {
   2.110 -        mfn = get_mfn_from_gpfn( gpfn );
   2.111 -        if ( mfn == INVALID_MFN ) {
   2.112 +    for ( lev = mode; lev >= 1; lev-- )
   2.113 +    {
   2.114 +        mfn = get_mfn_from_gpfn(gpfn);
   2.115 +        if ( mfn == INVALID_MFN )
   2.116 +        {
   2.117              HAP_PRINTK("bad pfn=0x%lx from gva=0x%lx at lev%d\n", gpfn, gva, 
   2.118                         lev);
   2.119              success = 0;
   2.120 @@ -157,44 +158,50 @@ unsigned long hap_gva_to_gfn_pae_mode(st
   2.121          }
   2.122          index = (gva >> PT_SHIFT[mode][lev]) & (PT_ENTRIES[mode][lev]-1);
   2.123  
   2.124 -        if ( lev == 3 ) {
   2.125 -            l3e = map_domain_page( mfn );
   2.126 -            index += ( ((gcr3 >> 5 ) & 127 ) * 4 );
   2.127 -            if ( !(l3e_get_flags(l3e[index]) & _PAGE_PRESENT) ) {
   2.128 +        if ( lev == 3 )
   2.129 +        {
   2.130 +            l3e = map_domain_page(mfn);
   2.131 +            index += ((gcr3 >> 5) & 127) * 4;
   2.132 +            if ( !(l3e_get_flags(l3e[index]) & _PAGE_PRESENT) )
   2.133 +            {
   2.134                  HAP_PRINTK("Level 3 entry not present at index = %d\n", index);
   2.135                  success = 0;
   2.136              }
   2.137 -            gpfn = l3e_get_pfn( l3e[index] );
   2.138 +            gpfn = l3e_get_pfn(l3e[index]);
   2.139              unmap_domain_page(l3e);
   2.140          }
   2.141  
   2.142 -        if ( lev == 2 ) {
   2.143 -            l2e = map_domain_page( mfn );
   2.144 -            if ( !(l2e_get_flags(l2e[index]) & _PAGE_PRESENT) ) {
   2.145 +        if ( lev == 2 )
   2.146 +        {
   2.147 +            l2e = map_domain_page(mfn);
   2.148 +            if ( !(l2e_get_flags(l2e[index]) & _PAGE_PRESENT) )
   2.149 +            {
   2.150                  HAP_PRINTK("Level 2 entry not present at index = %d\n", index);
   2.151                  success = 0;
   2.152              }
   2.153  
   2.154 -            if ( l2e_get_flags(l2e[index]) & _PAGE_PSE ) { /* handle PSE */
   2.155 +            if ( l2e_get_flags(l2e[index]) & _PAGE_PSE )
   2.156 +            {
   2.157                  HAP_PRINTK("guest page table is PSE\n");
   2.158                  gpa = (l2e_get_intpte(l2e[index]) & PHYSICAL_PAGE_2M_MASK) + 
   2.159                      (gva & ~PHYSICAL_PAGE_2M_MASK);
   2.160                  unmap_domain_page(l2e);
   2.161                  break; /* last level page table, jump out from here */
   2.162              }
   2.163 -            else { 
   2.164 -                gpfn = l2e_get_pfn(l2e[index]);
   2.165 -            }
   2.166 +
   2.167 +            gpfn = l2e_get_pfn(l2e[index]);
   2.168              unmap_domain_page(l2e);
   2.169          }
   2.170  
   2.171 -        if ( lev == 1 ) {
   2.172 -            l1e = map_domain_page( mfn );
   2.173 -            if ( !(l1e_get_flags(l1e[index]) & _PAGE_PRESENT) ) {
   2.174 +        if ( lev == 1 )
   2.175 +        {
   2.176 +            l1e = map_domain_page(mfn);
   2.177 +            if ( !(l1e_get_flags(l1e[index]) & _PAGE_PRESENT) )
   2.178 +            {
   2.179                  HAP_PRINTK("Level 1 entry not present at index = %d\n", index);
   2.180                  success = 0;
   2.181              }
   2.182 -            gpfn = l1e_get_pfn( l1e[index] );
   2.183 +            gpfn = l1e_get_pfn(l1e[index]);
   2.184              gpa = (l1e_get_intpte(l1e[index]) & PHYSICAL_PAGE_4K_MASK) + 
   2.185                  (gva & ~PHYSICAL_PAGE_4K_MASK);
   2.186              unmap_domain_page(l1e);
   2.187 @@ -207,12 +214,8 @@ unsigned long hap_gva_to_gfn_pae_mode(st
   2.188      gpa &= ~PAGE_NX_BIT; /* clear NX bit of guest physical address */
   2.189      HAP_PRINTK("success = %d, gva = %lx, gpa = %lx\n", success, gva, gpa);
   2.190  
   2.191 -    if ( !success )
   2.192 -        return INVALID_GFN;
   2.193 -    else
   2.194 -        return ((paddr_t)gpa >> PAGE_SHIFT);
   2.195 +    return (!success ? INVALID_GFN : ((paddr_t)gpa >> PAGE_SHIFT));
   2.196  #else
   2.197 -    HERE_I_AM;
   2.198      printk("guest paging level (3) is greater than host paging level!\n");
   2.199      domain_crash(v->domain);
   2.200      return INVALID_GFN;
   2.201 @@ -220,7 +223,6 @@ unsigned long hap_gva_to_gfn_pae_mode(st
   2.202  }
   2.203  
   2.204  
   2.205 -
   2.206  /* Translate guest virtual address to guest physical address. Specifically
   2.207   * for long mode guest. 
   2.208   */
   2.209 @@ -238,12 +240,12 @@ unsigned long hap_gva_to_gfn_long_mode(s
   2.210      l2_pgentry_t *l2e;
   2.211      l1_pgentry_t *l1e;
   2.212  
   2.213 -    HERE_I_AM;
   2.214 -
   2.215      gpfn = (gcr3 >> PAGE_SHIFT);
   2.216 -    for ( lev = mode; lev >= 1; lev-- ) {
   2.217 -        mfn = get_mfn_from_gpfn( gpfn );
   2.218 -        if ( mfn == INVALID_MFN ) {
   2.219 +    for ( lev = mode; lev >= 1; lev-- )
   2.220 +    {
   2.221 +        mfn = get_mfn_from_gpfn(gpfn);
   2.222 +        if ( mfn == INVALID_MFN )
   2.223 +        {
   2.224              HAP_PRINTK("bad pfn=0x%lx from gva=0x%lx at lev%d\n", gpfn, gva, 
   2.225                         lev);
   2.226              success = 0;
   2.227 @@ -251,53 +253,61 @@ unsigned long hap_gva_to_gfn_long_mode(s
   2.228          }
   2.229          index = (gva >> PT_SHIFT[mode][lev]) & (PT_ENTRIES[mode][lev]-1);
   2.230  
   2.231 -        if ( lev == 4 ) {
   2.232 -            l4e = map_domain_page( mfn );
   2.233 -            if ( !(l4e_get_flags(l4e[index]) & _PAGE_PRESENT) ) {
   2.234 +        if ( lev == 4 )
   2.235 +        {
   2.236 +            l4e = map_domain_page(mfn);
   2.237 +            if ( !(l4e_get_flags(l4e[index]) & _PAGE_PRESENT) )
   2.238 +            {
   2.239                  HAP_PRINTK("Level 4 entry not present at index = %d\n", index);
   2.240                  success = 0;
   2.241              }
   2.242 -            gpfn = l4e_get_pfn( l4e[index] );
   2.243 +            gpfn = l4e_get_pfn(l4e[index]);
   2.244              unmap_domain_page(l4e);
   2.245          }
   2.246  
   2.247 -        if ( lev == 3 ) {
   2.248 -            l3e = map_domain_page( mfn );
   2.249 -            if ( !(l3e_get_flags(l3e[index]) & _PAGE_PRESENT) ) {
   2.250 +        if ( lev == 3 )
   2.251 +        {
   2.252 +            l3e = map_domain_page(mfn);
   2.253 +            if ( !(l3e_get_flags(l3e[index]) & _PAGE_PRESENT) )
   2.254 +            {
   2.255                  HAP_PRINTK("Level 3 entry not present at index = %d\n", index);
   2.256                  success = 0;
   2.257              }
   2.258 -            gpfn = l3e_get_pfn( l3e[index] );
   2.259 +            gpfn = l3e_get_pfn(l3e[index]);
   2.260              unmap_domain_page(l3e);
   2.261          }
   2.262  
   2.263 -        if ( lev == 2 ) {
   2.264 -            l2e = map_domain_page( mfn );
   2.265 -            if ( !(l2e_get_flags(l2e[index]) & _PAGE_PRESENT) ) {
   2.266 +        if ( lev == 2 )
   2.267 +        {
   2.268 +            l2e = map_domain_page(mfn);
   2.269 +            if ( !(l2e_get_flags(l2e[index]) & _PAGE_PRESENT) )
   2.270 +            {
   2.271                  HAP_PRINTK("Level 2 entry not present at index = %d\n", index);
   2.272                  success = 0;
   2.273              }
   2.274  
   2.275 -            if ( l2e_get_flags(l2e[index]) & _PAGE_PSE ) { /* handle PSE */
   2.276 +            if ( l2e_get_flags(l2e[index]) & _PAGE_PSE )
   2.277 +            {
   2.278                  HAP_PRINTK("guest page table is PSE\n");
   2.279                  gpa = (l2e_get_intpte(l2e[index]) & PHYSICAL_ADDR_2M_MASK_LM) 
   2.280                      + (gva & ~PHYSICAL_PAGE_2M_MASK);
   2.281                  unmap_domain_page(l2e);
   2.282                  break; /* last level page table, jump out from here */
   2.283              }
   2.284 -            else { 
   2.285 -                gpfn = l2e_get_pfn(l2e[index]);
   2.286 -            }
   2.287 +
   2.288 +            gpfn = l2e_get_pfn(l2e[index]);
   2.289              unmap_domain_page(l2e);
   2.290          }
   2.291  
   2.292 -        if ( lev == 1 ) {
   2.293 -            l1e = map_domain_page( mfn );
   2.294 -            if ( !(l1e_get_flags(l1e[index]) & _PAGE_PRESENT) ) {
   2.295 +        if ( lev == 1 )
   2.296 +        {
   2.297 +            l1e = map_domain_page(mfn);
   2.298 +            if ( !(l1e_get_flags(l1e[index]) & _PAGE_PRESENT) )
   2.299 +            {
   2.300                  HAP_PRINTK("Level 1 entry not present at index = %d\n", index);
   2.301                  success = 0;
   2.302              }
   2.303 -            gpfn = l1e_get_pfn( l1e[index] );
   2.304 +            gpfn = l1e_get_pfn(l1e[index]);
   2.305              gpa = (l1e_get_intpte(l1e[index]) & PHYSICAL_ADDR_4K_MASK_LM) + 
   2.306                  (gva & ~PHYSICAL_PAGE_4K_MASK);
   2.307              unmap_domain_page(l1e);
   2.308 @@ -310,12 +320,8 @@ unsigned long hap_gva_to_gfn_long_mode(s
   2.309      gpa &= ~PAGE_NX_BIT; /* clear NX bit of guest physical address */
   2.310      HAP_PRINTK("success = %d, gva = %lx, gpa = %lx\n", success, gva, gpa);
   2.311  
   2.312 -    if ( !success )
   2.313 -        return INVALID_GFN;
   2.314 -    else
   2.315 -        return ((paddr_t)gpa >> PAGE_SHIFT);
   2.316 +    return (!success ? INVALID_GFN : ((paddr_t)gpa >> PAGE_SHIFT));
   2.317  #else
   2.318 -    HERE_I_AM;
   2.319      printk("guest paging level (4) is greater than host paging level!\n");
   2.320      domain_crash(v->domain);
   2.321      return INVALID_GFN;
     3.1 --- a/xen/include/asm-x86/hap.h	Mon Jul 16 14:28:54 2007 +0100
     3.2 +++ b/xen/include/asm-x86/hap.h	Tue Jul 17 09:22:41 2007 +0100
     3.3 @@ -26,8 +26,6 @@
     3.4  #ifndef _XEN_HAP_H
     3.5  #define _XEN_HAP_H
     3.6  
     3.7 -#define HERE_I_AM                                                     \
     3.8 -    debugtrace_printk("HERE I AM: %s %s %d\n", __func__, __FILE__, __LINE__)
     3.9  #define HAP_PRINTK(_f, _a...)                                         \
    3.10      debugtrace_printk("hap: %s(): " _f, __func__, ##_a)
    3.11  #define HAP_ERROR(_f, _a...)                                          \
    3.12 @@ -98,6 +96,7 @@ extern struct paging_mode hap_paging_rea
    3.13  extern struct paging_mode hap_paging_protected_mode;
    3.14  extern struct paging_mode hap_paging_pae_mode;
    3.15  extern struct paging_mode hap_paging_long_mode;
    3.16 +
    3.17  #endif /* XEN_HAP_H */
    3.18  
    3.19  /*