direct-io.hg

changeset 14675:b0b20a09d253

hvm svm: Some code cleanups.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Fri Mar 30 19:02:40 2007 +0100 (2007-03-30)
parents 2b715386b4cf
children c1578c694b39 fc9e2f7920c9
files xen/arch/x86/hvm/svm/svm.c xen/arch/x86/mm/paging.c
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/svm.c	Fri Mar 30 18:42:49 2007 +0100
     1.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Fri Mar 30 19:02:40 2007 +0100
     1.3 @@ -70,7 +70,6 @@ u64 root_vmcb_pa[NR_CPUS] __read_mostly;
     1.4  
     1.5  /* hardware assisted paging bits */
     1.6  extern int opt_hap_enabled;
     1.7 -extern int hap_capable_system;
     1.8  
     1.9  static inline void svm_inject_exception(struct vcpu *v, int trap, 
    1.10                                          int ev, int error_code)
    1.11 @@ -920,16 +919,13 @@ void svm_npt_detect(void)
    1.12  {
    1.13      u32 eax, ebx, ecx, edx;
    1.14  
    1.15 -    /* check CPUID for nested paging support */
    1.16 +    /* Check CPUID for nested paging support. */
    1.17      cpuid(0x8000000A, &eax, &ebx, &ecx, &edx);
    1.18 -    if ( edx & 0x01 ) /* nested paging */
    1.19 +
    1.20 +    if ( !(edx & 1) && opt_hap_enabled )
    1.21      {
    1.22 -        hap_capable_system = 1;
    1.23 -    }
    1.24 -    else if ( opt_hap_enabled )
    1.25 -    {
    1.26 -        printk(" nested paging is not supported by this CPU.\n");
    1.27 -        hap_capable_system = 0; /* no nested paging, we disable flag. */
    1.28 +        printk("SVM: Nested paging is not supported by this CPU.\n");
    1.29 +        opt_hap_enabled = 0;
    1.30      }
    1.31  }
    1.32  
    1.33 @@ -944,7 +940,7 @@ int start_svm(void)
    1.34      ecx = cpuid_ecx(0x80000001);
    1.35      boot_cpu_data.x86_capability[5] = ecx;
    1.36      
    1.37 -    if (!(test_bit(X86_FEATURE_SVME, &boot_cpu_data.x86_capability)))
    1.38 +    if ( !(test_bit(X86_FEATURE_SVME, &boot_cpu_data.x86_capability)) )
    1.39          return 0;
    1.40  
    1.41      /* check whether SVM feature is disabled in BIOS */
    1.42 @@ -955,13 +951,13 @@ int start_svm(void)
    1.43          return 0;
    1.44      }
    1.45  
    1.46 -    if ( (hsa[cpu] == NULL) && ((hsa[cpu] = alloc_host_save_area()) == NULL) )
    1.47 +    if ( ((hsa[cpu] = alloc_host_save_area()) == NULL) ||
    1.48 +         ((root_vmcb[cpu] = alloc_vmcb()) == NULL) )
    1.49          return 0;
    1.50 -    
    1.51 +
    1.52      rdmsr(MSR_EFER, eax, edx);
    1.53      eax |= EFER_SVME;
    1.54      wrmsr(MSR_EFER, eax, edx);
    1.55 -    printk("AMD SVM Extension is enabled for cpu %d.\n", cpu );
    1.56  
    1.57      svm_npt_detect();
    1.58  
    1.59 @@ -970,12 +966,9 @@ int start_svm(void)
    1.60      phys_hsa_lo = (u32) phys_hsa;
    1.61      phys_hsa_hi = (u32) (phys_hsa >> 32);    
    1.62      wrmsr(MSR_K8_VM_HSAVE_PA, phys_hsa_lo, phys_hsa_hi);
    1.63 +
    1.64 +    root_vmcb_pa[cpu] = virt_to_maddr(root_vmcb[cpu]);
    1.65    
    1.66 -    if ( (root_vmcb[cpu] == NULL) &&
    1.67 -         ((root_vmcb[cpu] = alloc_vmcb()) == NULL) )
    1.68 -        return 0;
    1.69 -    root_vmcb_pa[cpu] = virt_to_maddr(root_vmcb[cpu]);
    1.70 -
    1.71      if ( cpu != 0 )
    1.72          return 1;
    1.73  
     2.1 --- a/xen/arch/x86/mm/paging.c	Fri Mar 30 18:42:49 2007 +0100
     2.2 +++ b/xen/arch/x86/mm/paging.c	Fri Mar 30 19:02:40 2007 +0100
     2.3 @@ -27,9 +27,8 @@
     2.4  #include <asm/hap.h>
     2.5  
     2.6  /* Xen command-line option to enable hardware-assisted paging */
     2.7 -int opt_hap_enabled = 0; 
     2.8 +int opt_hap_enabled;
     2.9  boolean_param("hap", opt_hap_enabled);
    2.10 -int hap_capable_system = 0;
    2.11  
    2.12  /* Printouts */
    2.13  #define PAGING_PRINTK(_f, _a...)                                     \
    2.14 @@ -49,14 +48,14 @@ void paging_domain_init(struct domain *d
    2.15      p2m_init(d);
    2.16      shadow_domain_init(d);
    2.17  
    2.18 -    if ( opt_hap_enabled && hap_capable_system && is_hvm_domain(d) )
    2.19 +    if ( opt_hap_enabled && is_hvm_domain(d) )
    2.20          hap_domain_init(d);
    2.21  }
    2.22  
    2.23  /* vcpu paging struct initialization goes here */
    2.24  void paging_vcpu_init(struct vcpu *v)
    2.25  {
    2.26 -    if ( opt_hap_enabled && hap_capable_system && is_hvm_vcpu(v) )
    2.27 +    if ( opt_hap_enabled && is_hvm_vcpu(v) )
    2.28          hap_vcpu_init(v);
    2.29      else
    2.30          shadow_vcpu_init(v);
    2.31 @@ -67,7 +66,7 @@ int paging_domctl(struct domain *d, xen_
    2.32                    XEN_GUEST_HANDLE(void) u_domctl)
    2.33  {
    2.34      /* Here, dispatch domctl to the appropriate paging code */
    2.35 -    if ( opt_hap_enabled && hap_capable_system && is_hvm_domain(d) )
    2.36 +    if ( opt_hap_enabled && is_hvm_domain(d) )
    2.37          return hap_domctl(d, sc, u_domctl);
    2.38      else
    2.39          return shadow_domctl(d, sc, u_domctl);
    2.40 @@ -76,7 +75,7 @@ int paging_domctl(struct domain *d, xen_
    2.41  /* Call when destroying a domain */
    2.42  void paging_teardown(struct domain *d)
    2.43  {
    2.44 -    if ( opt_hap_enabled && hap_capable_system && is_hvm_domain(d) )
    2.45 +    if ( opt_hap_enabled && is_hvm_domain(d) )
    2.46          hap_teardown(d);
    2.47      else
    2.48          shadow_teardown(d);
    2.49 @@ -85,7 +84,7 @@ void paging_teardown(struct domain *d)
    2.50  /* Call once all of the references to the domain have gone away */
    2.51  void paging_final_teardown(struct domain *d)
    2.52  {
    2.53 -    if ( opt_hap_enabled && hap_capable_system && is_hvm_domain(d) )
    2.54 +    if ( opt_hap_enabled && is_hvm_domain(d) )
    2.55          hap_final_teardown(d);
    2.56      else
    2.57          shadow_final_teardown(d);
    2.58 @@ -95,7 +94,7 @@ void paging_final_teardown(struct domain
    2.59   * creation. */
    2.60  int paging_enable(struct domain *d, u32 mode)
    2.61  {
    2.62 -    if ( opt_hap_enabled && hap_capable_system && is_hvm_domain(d) )
    2.63 +    if ( opt_hap_enabled && is_hvm_domain(d) )
    2.64          return hap_enable(d, mode | PG_HAP_enable);
    2.65      else
    2.66          return shadow_enable(d, mode | PG_SH_enable);