ia64/xen-unstable

changeset 9063:79a93530121b

Fix SVM cr0 handling.

Signed-off-by: Tom Woller <thomas.woller@amd.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Feb 28 10:14:32 2006 +0100 (2006-02-28)
parents 933d0d70378f
children 034af52f0df7
files xen/arch/x86/hvm/svm/svm.c
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/svm.c	Tue Feb 28 10:14:10 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Tue Feb 28 10:14:32 2006 +0100
     1.3 @@ -1363,13 +1363,13 @@ static void svm_io_instruction(struct vc
     1.4      }
     1.5  }
     1.6  
     1.7 -
     1.8  static int svm_set_cr0(unsigned long value)
     1.9  {
    1.10      struct vcpu *v = current;
    1.11      unsigned long mfn;
    1.12      int paging_enabled;
    1.13      struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
    1.14 +    unsigned long crn;
    1.15  
    1.16      ASSERT(vmcb);
    1.17  
    1.18 @@ -1414,14 +1414,7 @@ static int svm_set_cr0(unsigned long val
    1.19              HVM_DBG_LOG(DBG_LEVEL_1, "Enable the Long mode\n");
    1.20              set_bit(SVM_CPU_STATE_LMA_ENABLED,
    1.21                      &v->arch.hvm_svm.cpu_state);
    1.22 -#if 0
    1.23 -            __vmread(VM_ENTRY_CONTROLS, &vm_entry_value);
    1.24 -            vm_entry_value |= VM_ENTRY_CONTROLS_IA32E_MODE;
    1.25 -            __vmwrite(VM_ENTRY_CONTROLS, vm_entry_value);
    1.26 -#else
    1.27 -	    printk("Cannot yet set SVM_CPU_STATE_LMA_ENABLED\n");
    1.28 -	    domain_crash_synchronous();
    1.29 -#endif
    1.30 +            vmcb->efer |= (EFER_LMA | EFER_LME);
    1.31  
    1.32  #if CONFIG_PAGING_LEVELS >= 4 
    1.33              if (!shadow_set_guest_paging_levels(v->domain, 4)) 
    1.34 @@ -1432,8 +1425,9 @@ static int svm_set_cr0(unsigned long val
    1.35  #endif
    1.36          }
    1.37          else
    1.38 +#endif  /* __x86_64__ */
    1.39          {
    1.40 -#if CONFIG_PAGING_LEVELS >= 4
    1.41 +#if CONFIG_PAGING_LEVELS >= 3
    1.42              if (!shadow_set_guest_paging_levels(v->domain, 2))
    1.43              {
    1.44                  printk("Unsupported guest paging levels\n");
    1.45 @@ -1442,30 +1436,15 @@ static int svm_set_cr0(unsigned long val
    1.46  #endif
    1.47          }
    1.48  
    1.49 -#if 0
    1.50 -        unsigned long crn;
    1.51 -
    1.52          /* update CR4's PAE if needed */
    1.53 -        __vmread(GUEST_CR4, &crn);
    1.54 +        crn = vmcb->cr4;
    1.55          if ((!(crn & X86_CR4_PAE)) 
    1.56                  && test_bit(SVM_CPU_STATE_PAE_ENABLED, 
    1.57                      &v->arch.hvm_svm.cpu_state))
    1.58          {
    1.59              HVM_DBG_LOG(DBG_LEVEL_1, "enable PAE on cr4\n");
    1.60 -            __vmwrite(GUEST_CR4, crn | X86_CR4_PAE);
    1.61 +            vmcb->cr4 |= X86_CR4_PAE;
    1.62          }
    1.63 -#else
    1.64 -	printk("Cannot yet set SVM_CPU_STATE_PAE_ENABLED\n");
    1.65 -	domain_crash_synchronous(); 
    1.66 -#endif
    1.67 -#elif defined(__i386__)
    1.68 -	{
    1.69 -            unsigned long old_base_mfn;
    1.70 -            old_base_mfn = pagetable_get_pfn(v->arch.guest_table);
    1.71 -            if (old_base_mfn)
    1.72 -                put_page(mfn_to_page(old_base_mfn));
    1.73 -	}
    1.74 -#endif
    1.75  
    1.76          /* Now arch.guest_table points to machine physical. */
    1.77          v->arch.guest_table = mk_pagetable((u64)mfn << PAGE_SHIFT);
    1.78 @@ -1500,7 +1479,6 @@ static int svm_set_cr0(unsigned long val
    1.79      return 1;
    1.80  }
    1.81  
    1.82 -
    1.83  /*
    1.84   * Read from control registers. CR0 and CR4 are read from the shadow.
    1.85   */