ia64/xen-unstable

changeset 15197:acee9e2c6f8b

Clean up map_domain_page().
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu May 24 11:33:39 2007 +0100 (2007-05-24)
parents 12a12637af46
children 2623444e6d33
files xen/arch/x86/hvm/vlapic.c xen/arch/x86/mm/shadow/multi.c xen/arch/x86/x86_32/domain_page.c xen/include/asm-x86/hap.h
line diff
     1.1 --- a/xen/arch/x86/hvm/vlapic.c	Thu May 24 10:50:07 2007 +0100
     1.2 +++ b/xen/arch/x86/hvm/vlapic.c	Thu May 24 11:33:39 2007 +0100
     1.3 @@ -918,16 +918,16 @@ int vlapic_init(struct vcpu *v)
     1.4      vlapic->regs_page = alloc_domheap_page(NULL);
     1.5      if ( vlapic->regs_page == NULL )
     1.6      {
     1.7 -        dprintk(XENLOG_ERR, "malloc vlapic regs_page error for vcpu %x\n",
     1.8 -                v->vcpu_id);
     1.9 +        dprintk(XENLOG_ERR, "alloc vlapic regs error: %d/%d\n",
    1.10 +                v->domain->domain_id, v->vcpu_id);
    1.11          return -ENOMEM;
    1.12      }
    1.13  
    1.14      vlapic->regs = map_domain_page_global(page_to_mfn(vlapic->regs_page));
    1.15      if ( vlapic->regs == NULL )
    1.16      {
    1.17 -        dprintk(XENLOG_ERR, "malloc vlapic regs error for vcpu %x\n",
    1.18 -                v->vcpu_id);
    1.19 +        dprintk(XENLOG_ERR, "map vlapic regs error: %d/%d\n",
    1.20 +                v->domain->domain_id, v->vcpu_id);
    1.21  	return -ENOMEM;
    1.22      }
    1.23  
    1.24 @@ -935,7 +935,8 @@ int vlapic_init(struct vcpu *v)
    1.25  
    1.26      vlapic_reset(vlapic);
    1.27  
    1.28 -    vlapic->hw.apic_base_msr = MSR_IA32_APICBASE_ENABLE | APIC_DEFAULT_PHYS_BASE;
    1.29 +    vlapic->hw.apic_base_msr = (MSR_IA32_APICBASE_ENABLE |
    1.30 +                                APIC_DEFAULT_PHYS_BASE);
    1.31      if ( v->vcpu_id == 0 )
    1.32          vlapic->hw.apic_base_msr |= MSR_IA32_APICBASE_BSP;
    1.33  
     2.1 --- a/xen/arch/x86/mm/shadow/multi.c	Thu May 24 10:50:07 2007 +0100
     2.2 +++ b/xen/arch/x86/mm/shadow/multi.c	Thu May 24 11:33:39 2007 +0100
     2.3 @@ -3487,6 +3487,7 @@ sh_update_cr3(struct vcpu *v, int do_loc
     2.4          v->arch.paging.shadow.guest_vtable = sh_map_domain_page_global(gmfn);
     2.5          /* PAGING_LEVELS==4 implies 64-bit, which means that
     2.6           * map_domain_page_global can't fail */
     2.7 +        BUG_ON(v->arch.paging.shadow.guest_vtable == NULL);
     2.8      }
     2.9      else
    2.10          v->arch.paging.shadow.guest_vtable = __linear_l4_table;
    2.11 @@ -3519,7 +3520,7 @@ sh_update_cr3(struct vcpu *v, int do_loc
    2.12          v->arch.paging.shadow.guest_vtable = sh_map_domain_page_global(gmfn);
    2.13          /* Does this really need map_domain_page_global?  Handle the
    2.14           * error properly if so. */
    2.15 -        ASSERT( v->arch.paging.shadow.guest_vtable );
    2.16 +        BUG_ON(v->arch.paging.shadow.guest_vtable == NULL); /* XXX */
    2.17      }
    2.18      else
    2.19          v->arch.paging.shadow.guest_vtable = __linear_l2_table;
     3.1 --- a/xen/arch/x86/x86_32/domain_page.c	Thu May 24 10:50:07 2007 +0100
     3.2 +++ b/xen/arch/x86/x86_32/domain_page.c	Thu May 24 11:33:39 2007 +0100
     3.3 @@ -98,7 +98,7 @@ void *map_domain_page(unsigned long mfn)
     3.4          cache->tlbflush_timestamp = tlbflush_current_time();
     3.5  
     3.6          idx = find_first_zero_bit(cache->inuse, MAPCACHE_ENTRIES);
     3.7 -        ASSERT(idx < MAPCACHE_ENTRIES);
     3.8 +        BUG_ON(idx >= MAPCACHE_ENTRIES);
     3.9      }
    3.10  
    3.11      set_bit(idx, cache->inuse);
    3.12 @@ -218,25 +218,21 @@ void *map_domain_page_global(unsigned lo
    3.13  
    3.14          idx = find_first_zero_bit(inuse, GLOBALMAP_BITS);
    3.15          va = IOREMAP_VIRT_START + (idx << PAGE_SHIFT);
    3.16 -        if ( va >= FIXADDR_START )
    3.17 +        if ( unlikely(va >= FIXADDR_START) )
    3.18          {
    3.19 -            va = 0;
    3.20 -            goto fail;
    3.21 +            spin_unlock(&globalmap_lock);
    3.22 +            return NULL;
    3.23          }
    3.24      }
    3.25  
    3.26      set_bit(idx, inuse);
    3.27      inuse_cursor = idx + 1;
    3.28  
    3.29 -  fail:
    3.30      spin_unlock(&globalmap_lock);
    3.31  
    3.32 -    if ( likely(va != 0) )
    3.33 -    {
    3.34 -	pl2e = virt_to_xen_l2e(va);
    3.35 -	pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(va);
    3.36 -	l1e_write(pl1e, l1e_from_pfn(mfn, __PAGE_HYPERVISOR));
    3.37 -    }
    3.38 +    pl2e = virt_to_xen_l2e(va);
    3.39 +    pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(va);
    3.40 +    l1e_write(pl1e, l1e_from_pfn(mfn, __PAGE_HYPERVISOR));
    3.41  
    3.42      return (void *)va;
    3.43  }
     4.1 --- a/xen/include/asm-x86/hap.h	Thu May 24 10:50:07 2007 +0100
     4.2 +++ b/xen/include/asm-x86/hap.h	Thu May 24 11:33:39 2007 +0100
     4.3 @@ -48,18 +48,6 @@ hap_unmap_domain_page(void *p)
     4.4      unmap_domain_page(p);
     4.5  }
     4.6  
     4.7 -static inline void *
     4.8 -hap_map_domain_page_global(mfn_t mfn)
     4.9 -{
    4.10 -    return map_domain_page_global(mfn_x(mfn));
    4.11 -}
    4.12 -
    4.13 -static inline void 
    4.14 -hap_unmap_domain_page_global(void *p) 
    4.15 -{
    4.16 -    unmap_domain_page_global(p);
    4.17 -}
    4.18 -
    4.19  /************************************************/
    4.20  /*           locking for hap code               */
    4.21  /************************************************/