ia64/xen-unstable

changeset 8965:8fb4392c1d87

Change shadow_direct_map_init/clean param from vcpu to domain.
Also some cleanups.

Signed-off-by: Xin Li <xin.b.li@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Feb 22 19:23:35 2006 +0100 (2006-02-22)
parents 8946b6dcd49e
children 049929854f7f
files xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/svm/vmcb.c xen/arch/x86/hvm/vmx/vmcs.c xen/arch/x86/hvm/vmx/vmx.c xen/arch/x86/shadow.c xen/arch/x86/shadow32.c xen/arch/x86/shadow_public.c xen/include/asm-x86/shadow.h
line diff
     1.1 --- a/xen/arch/x86/hvm/hvm.c	Wed Feb 22 17:26:39 2006 +0000
     1.2 +++ b/xen/arch/x86/hvm/hvm.c	Wed Feb 22 19:23:35 2006 +0100
     1.3 @@ -190,9 +190,11 @@ void hvm_setup_platform(struct domain* d
     1.4  {
     1.5      struct hvm_domain *platform;
     1.6  
     1.7 -    if (!(HVM_DOMAIN(current) && (current->vcpu_id == 0)))
     1.8 +    if ( !HVM_DOMAIN(current) || (current->vcpu_id != 0) )
     1.9          return;
    1.10  
    1.11 +    shadow_direct_map_init(d);
    1.12 +
    1.13      hvm_map_io_shared_page(d);
    1.14      hvm_get_info(d);
    1.15  
    1.16 @@ -200,7 +202,8 @@ void hvm_setup_platform(struct domain* d
    1.17      pic_init(&platform->vpic, pic_irq_request, &platform->interrupt_request);
    1.18      register_pic_io_hook();
    1.19  
    1.20 -    if ( hvm_apic_support(d) ) {
    1.21 +    if ( hvm_apic_support(d) )
    1.22 +    {
    1.23          spin_lock_init(&d->arch.hvm_domain.round_robin_lock);
    1.24          hvm_vioapic_init(d);
    1.25      }
     2.1 --- a/xen/arch/x86/hvm/svm/svm.c	Wed Feb 22 17:26:39 2006 +0000
     2.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Wed Feb 22 19:23:35 2006 +0100
     2.3 @@ -797,12 +797,13 @@ void svm_relinquish_resources(struct vcp
     2.4      free_host_save_area(v->arch.hvm_svm.host_save_area);
     2.5  #endif
     2.6  
     2.7 -    if (v->vcpu_id == 0) {
     2.8 +    if ( v->vcpu_id == 0 )
     2.9 +    {
    2.10          /* unmap IO shared page */
    2.11          struct domain *d = v->domain;
    2.12 -        if (d->arch.hvm_domain.shared_page_va)
    2.13 +        if ( d->arch.hvm_domain.shared_page_va )
    2.14              unmap_domain_page((void *)d->arch.hvm_domain.shared_page_va);
    2.15 -        shadow_direct_map_clean(v);
    2.16 +        shadow_direct_map_clean(d);
    2.17      }
    2.18  
    2.19      destroy_vmcb(&v->arch.hvm_svm);
     3.1 --- a/xen/arch/x86/hvm/svm/vmcb.c	Wed Feb 22 17:26:39 2006 +0000
     3.2 +++ b/xen/arch/x86/hvm/svm/vmcb.c	Wed Feb 22 19:23:35 2006 +0100
     3.3 @@ -444,8 +444,6 @@ void svm_do_launch(struct vcpu *v)
     3.4          printk("%s: phys_table   = %lx\n", __func__, pt);
     3.5      }
     3.6  
     3.7 -    shadow_direct_map_init(v);
     3.8 -
     3.9      if ( svm_paging_enabled(v) )
    3.10          vmcb->cr3 = pagetable_get_paddr(v->arch.guest_table);
    3.11      else
     4.1 --- a/xen/arch/x86/hvm/vmx/vmcs.c	Wed Feb 22 17:26:39 2006 +0000
     4.2 +++ b/xen/arch/x86/hvm/vmx/vmcs.c	Wed Feb 22 19:23:35 2006 +0100
     4.3 @@ -230,7 +230,6 @@ static void vmx_do_launch(struct vcpu *v
     4.4      error |= __vmwrite(GUEST_TR_BASE, 0);
     4.5      error |= __vmwrite(GUEST_TR_LIMIT, 0xff);
     4.6  
     4.7 -    shadow_direct_map_init(v);
     4.8      __vmwrite(GUEST_CR3, pagetable_get_paddr(v->domain->arch.phys_table));
     4.9      __vmwrite(HOST_CR3, pagetable_get_paddr(v->arch.monitor_table));
    4.10  
     5.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Wed Feb 22 17:26:39 2006 +0000
     5.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Wed Feb 22 19:23:35 2006 +0100
     5.3 @@ -81,14 +81,14 @@ void vmx_final_setup_guest(struct vcpu *
     5.4  void vmx_relinquish_resources(struct vcpu *v)
     5.5  {
     5.6      struct hvm_virpit *vpit;
     5.7 -    
     5.8 +
     5.9      if (v->vcpu_id == 0) {
    5.10          /* unmap IO shared page */
    5.11          struct domain *d = v->domain;
    5.12          if ( d->arch.hvm_domain.shared_page_va )
    5.13              unmap_domain_page_global(
    5.14  	        (void *)d->arch.hvm_domain.shared_page_va);
    5.15 -        shadow_direct_map_clean(v);
    5.16 +        shadow_direct_map_clean(d);
    5.17      }
    5.18  
    5.19      vmx_request_clear_vmcs(v);
     6.1 --- a/xen/arch/x86/shadow.c	Wed Feb 22 17:26:39 2006 +0000
     6.2 +++ b/xen/arch/x86/shadow.c	Wed Feb 22 19:23:35 2006 +0100
     6.3 @@ -3950,11 +3950,11 @@ int shadow_direct_map_fault(unsigned lon
     6.4  
     6.5      __direct_get_l3e(v, vpa, &sl3e);
     6.6  
     6.7 -    if ( !(l3e_get_flags(sl3e) & _PAGE_PRESENT) ) 
     6.8 +    if ( !(l3e_get_flags(sl3e) & _PAGE_PRESENT) )
     6.9      {
    6.10          page = alloc_domheap_page(NULL);
    6.11          if ( !page )
    6.12 -            goto nomem; 
    6.13 +            goto nomem;
    6.14  
    6.15          smfn = page_to_mfn(page);
    6.16          sl3e = l3e_from_pfn(smfn, _PAGE_PRESENT);
    6.17 @@ -3968,11 +3968,11 @@ int shadow_direct_map_fault(unsigned lon
    6.18  
    6.19      __direct_get_l2e(v, vpa, &sl2e);
    6.20  
    6.21 -    if ( !(l2e_get_flags(sl2e) & _PAGE_PRESENT) ) 
    6.22 +    if ( !(l2e_get_flags(sl2e) & _PAGE_PRESENT) )
    6.23      {
    6.24          page = alloc_domheap_page(NULL);
    6.25          if ( !page )
    6.26 -            goto nomem; 
    6.27 +            goto nomem;
    6.28  
    6.29          smfn = page_to_mfn(page);
    6.30          sl2e = l2e_from_pfn(smfn, __PAGE_HYPERVISOR | _PAGE_USER);
    6.31 @@ -3985,11 +3985,11 @@ int shadow_direct_map_fault(unsigned lon
    6.32  
    6.33      __direct_get_l1e(v, vpa, &sl1e);
    6.34  
    6.35 -    if ( !(l1e_get_flags(sl1e) & _PAGE_PRESENT) ) 
    6.36 +    if ( !(l1e_get_flags(sl1e) & _PAGE_PRESENT) )
    6.37      {
    6.38          sl1e = l1e_from_pfn(mfn, __PAGE_HYPERVISOR | _PAGE_USER);
    6.39          __direct_set_l1e(v, vpa, &sl1e);
    6.40 -    } 
    6.41 +    }
    6.42  
    6.43      shadow_unlock(d);
    6.44      return EXCRET_fault_fixed;
    6.45 @@ -3998,7 +3998,7 @@ fail:
    6.46      return 0;
    6.47  
    6.48  nomem:
    6.49 -    shadow_direct_map_clean(v);
    6.50 +    shadow_direct_map_clean(d);
    6.51      domain_crash_synchronous();
    6.52  }
    6.53  #endif
     7.1 --- a/xen/arch/x86/shadow32.c	Wed Feb 22 17:26:39 2006 +0000
     7.2 +++ b/xen/arch/x86/shadow32.c	Wed Feb 22 19:23:35 2006 +0100
     7.3 @@ -1044,7 +1044,7 @@ int shadow_direct_map_fault(unsigned lon
     7.4      }
     7.5  
     7.6      shadow_lock(d);
     7.7 -  
     7.8 +
     7.9     __direct_get_l2e(v, vpa, &sl2e);
    7.10  
    7.11      if ( !(l2e_get_flags(sl2e) & _PAGE_PRESENT) )
    7.12 @@ -1059,7 +1059,7 @@ int shadow_direct_map_fault(unsigned lon
    7.13          sple = (l1_pgentry_t *)map_domain_page(smfn);
    7.14          memset(sple, 0, PAGE_SIZE);
    7.15          __direct_set_l2e(v, vpa, sl2e);
    7.16 -    } 
    7.17 +    }
    7.18  
    7.19      if ( !sple )
    7.20          sple = (l1_pgentry_t *)map_domain_page(l2e_get_pfn(sl2e));
    7.21 @@ -1082,36 +1082,32 @@ fail:
    7.22      return 0;
    7.23  
    7.24  nomem:
    7.25 -    shadow_direct_map_clean(v);
    7.26 +    shadow_direct_map_clean(d);
    7.27      domain_crash_synchronous();
    7.28  }
    7.29  
    7.30  
    7.31 -int shadow_direct_map_init(struct vcpu *v)
    7.32 +int shadow_direct_map_init(struct domain *d)
    7.33  {
    7.34      struct page_info *page;
    7.35      l2_pgentry_t *root;
    7.36  
    7.37      if ( !(page = alloc_domheap_page(NULL)) )
    7.38 -        goto fail;
    7.39 +        return 0;
    7.40  
    7.41      root = map_domain_page(page_to_mfn(page));
    7.42      memset(root, 0, PAGE_SIZE);
    7.43      unmap_domain_page(root);
    7.44  
    7.45 -    v->domain->arch.phys_table = mk_pagetable(page_to_maddr(page));
    7.46 +    d->arch.phys_table = mk_pagetable(page_to_maddr(page));
    7.47  
    7.48      return 1;
    7.49 -
    7.50 -fail:
    7.51 -    return 0;
    7.52  }
    7.53  
    7.54 -void shadow_direct_map_clean(struct vcpu *v)
    7.55 +void shadow_direct_map_clean(struct domain *d)
    7.56  {
    7.57      int i;
    7.58      unsigned long mfn;
    7.59 -    struct domain *d = v->domain;
    7.60      l2_pgentry_t *l2e;
    7.61  
    7.62      mfn =  pagetable_get_pfn(d->arch.phys_table);
    7.63 @@ -1143,7 +1139,7 @@ int __shadow_mode_enable(struct domain *
    7.64  
    7.65      if(!new_modes) /* Nothing to do - return success */
    7.66          return 0; 
    7.67 -        
    7.68 +
    7.69      // can't take anything away by calling this function.
    7.70      ASSERT(!(d->arch.shadow_mode & ~mode));
    7.71  
     8.1 --- a/xen/arch/x86/shadow_public.c	Wed Feb 22 17:26:39 2006 +0000
     8.2 +++ b/xen/arch/x86/shadow_public.c	Wed Feb 22 19:23:35 2006 +0100
     8.3 @@ -36,31 +36,27 @@ static void free_p2m_table(struct vcpu *
     8.4  #define SHADOW_MAX_GUEST32(_encoded) ((L1_PAGETABLE_ENTRIES_32 - 1) - ((_encoded) >> 16))
     8.5  
     8.6  
     8.7 -int shadow_direct_map_init(struct vcpu *v)
     8.8 +int shadow_direct_map_init(struct domain *d)
     8.9  {
    8.10      struct page_info *page;
    8.11      l3_pgentry_t *root;
    8.12  
    8.13      if ( !(page = alloc_domheap_pages(NULL, 0, ALLOC_DOM_DMA)) )
    8.14 -        goto fail;
    8.15 +        return 0;
    8.16  
    8.17      root = map_domain_page(page_to_mfn(page));
    8.18      memset(root, 0, PAGE_SIZE);
    8.19      root[PAE_SHADOW_SELF_ENTRY] = l3e_from_page(page, __PAGE_HYPERVISOR);
    8.20  
    8.21 -    v->domain->arch.phys_table = mk_pagetable(page_to_maddr(page));
    8.22 +    d->arch.phys_table = mk_pagetable(page_to_maddr(page));
    8.23  
    8.24      unmap_domain_page(root);
    8.25      return 1;
    8.26 -
    8.27 -fail:
    8.28 -    return 0;
    8.29  }
    8.30  
    8.31 -void shadow_direct_map_clean(struct vcpu *v)
    8.32 +void shadow_direct_map_clean(struct domain *d)
    8.33  {
    8.34      unsigned long mfn;
    8.35 -    struct domain *d = v->domain;
    8.36      l2_pgentry_t *l2e;
    8.37      l3_pgentry_t *l3e;
    8.38      int i, j;
     9.1 --- a/xen/include/asm-x86/shadow.h	Wed Feb 22 17:26:39 2006 +0000
     9.2 +++ b/xen/include/asm-x86/shadow.h	Wed Feb 22 19:23:35 2006 +0100
     9.3 @@ -115,8 +115,8 @@ do {                                    
     9.4  #define SHADOW_ENCODE_MIN_MAX(_min, _max) ((((GUEST_L1_PAGETABLE_ENTRIES - 1) - (_max)) << 16) | (_min))
     9.5  #define SHADOW_MIN(_encoded) ((_encoded) & ((1u<<16) - 1))
     9.6  #define SHADOW_MAX(_encoded) ((GUEST_L1_PAGETABLE_ENTRIES - 1) - ((_encoded) >> 16))
     9.7 -extern void shadow_direct_map_clean(struct vcpu *v);
     9.8 -extern int shadow_direct_map_init(struct vcpu *v);
     9.9 +extern void shadow_direct_map_clean(struct domain *d);
    9.10 +extern int shadow_direct_map_init(struct domain *d);
    9.11  extern int shadow_direct_map_fault(
    9.12      unsigned long vpa, struct cpu_user_regs *regs);
    9.13  extern void shadow_mode_init(void);