ia64/xen-unstable

changeset 12278:a174f9787014

[HVM][SVM] Turn off long mode (EFER.LMA) when CR0.PG==0.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Nov 07 10:19:20 2006 +0000 (2006-11-07)
parents d745f1420d5b
children cb8eeadd8eae
files xen/arch/x86/hvm/svm/svm.c xen/include/asm-x86/hvm/svm/vmcb.h
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/svm.c	Tue Nov 07 10:18:50 2006 +0000
     1.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Tue Nov 07 10:19:20 2006 +0000
     1.3 @@ -264,6 +264,11 @@ static int svm_pae_enabled(struct vcpu *
     1.4      return (cr4 & X86_CR4_PAE);
     1.5  }
     1.6  
     1.7 +static int svm_long_mode_enabled(struct vcpu *v)
     1.8 +{
     1.9 +    return test_bit(SVM_CPU_STATE_LMA_ENABLED, &v->arch.hvm_svm.cpu_state);
    1.10 +}
    1.11 +
    1.12  #define IS_CANO_ADDRESS(add) 1
    1.13  
    1.14  static inline int long_mode_do_msr_read(struct cpu_user_regs *regs)
    1.15 @@ -369,7 +374,7 @@ static inline int long_mode_do_msr_write
    1.16  
    1.17      case MSR_FS_BASE:
    1.18      case MSR_GS_BASE:
    1.19 -        if (!(SVM_LONG_GUEST(vc)))
    1.20 +        if ( !svm_long_mode_enabled(vc) )
    1.21              domain_crash_synchronous();
    1.22  
    1.23          if (!IS_CANO_ADDRESS(msr_content))
    1.24 @@ -682,11 +687,6 @@ static void svm_load_cpu_guest_regs(
    1.25      svm_load_cpu_user_regs(v, regs);
    1.26  }
    1.27  
    1.28 -int svm_long_mode_enabled(struct vcpu *v)
    1.29 -{
    1.30 -    return SVM_LONG_GUEST(v);
    1.31 -}
    1.32 -
    1.33  static void arch_svm_do_launch(struct vcpu *v) 
    1.34  {
    1.35      svm_do_launch(v);
    1.36 @@ -1487,9 +1487,8 @@ static int svm_set_cr0(unsigned long val
    1.37          {
    1.38              /* Here the PAE is should to be opened */
    1.39              HVM_DBG_LOG(DBG_LEVEL_1, "Enable the Long mode\n");
    1.40 -            set_bit(SVM_CPU_STATE_LMA_ENABLED,
    1.41 -                    &v->arch.hvm_svm.cpu_state);
    1.42 -            vmcb->efer |= (EFER_LMA | EFER_LME);
    1.43 +            set_bit(SVM_CPU_STATE_LMA_ENABLED, &v->arch.hvm_svm.cpu_state);
    1.44 +            vmcb->efer |= EFER_LMA;
    1.45          }
    1.46  #endif  /* __x86_64__ */
    1.47  
    1.48 @@ -1530,6 +1529,11 @@ static int svm_set_cr0(unsigned long val
    1.49      }
    1.50      else if ( (value & (X86_CR0_PE | X86_CR0_PG)) == X86_CR0_PE )
    1.51      {
    1.52 +        if ( svm_long_mode_enabled(v) )
    1.53 +        {
    1.54 +            vmcb->efer &= ~EFER_LMA;
    1.55 +            clear_bit(SVM_CPU_STATE_LMA_ENABLED, &v->arch.hvm_svm.cpu_state);
    1.56 +        }
    1.57          /* we should take care of this kind of situation */
    1.58          shadow_update_paging_modes(v);
    1.59          vmcb->cr3 = v->arch.hvm_vcpu.hw_cr3;
     2.1 --- a/xen/include/asm-x86/hvm/svm/vmcb.h	Tue Nov 07 10:18:50 2006 +0000
     2.2 +++ b/xen/include/asm-x86/hvm/svm/vmcb.h	Tue Nov 07 10:19:20 2006 +0000
     2.3 @@ -310,10 +310,6 @@ enum {
     2.4      SVM_CPU_STATE_LMA_ENABLED,
     2.5      SVM_CPU_STATE_ASSIST_ENABLED,
     2.6  };  
     2.7 -    
     2.8 -#define SVM_LONG_GUEST(ed)    \
     2.9 -  (test_bit(SVM_CPU_STATE_LMA_ENABLED, &ed->arch.hvm_svm.cpu_state))
    2.10 -
    2.11  
    2.12  /* 
    2.13   * Attribute for segment selector. This is a copy of bit 40:47 & 52:55 of the