debuggers.hg

changeset 20695:976d679b04fb

HVM RDTSCP fixes
- Put the guest rdtscp cpuid logic in xc_cpuid_x86.c.
- MSR_TSC_AUX's high 32bit is reserved, so only write the low 32bit.

Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Dec 16 12:23:21 2009 +0000 (2009-12-16)
parents 91ec06817632
children b543acc1aaad
files tools/libxc/xc_cpuid_x86.c xen/arch/x86/hvm/vmx/vmx.c
line diff
     1.1 --- a/tools/libxc/xc_cpuid_x86.c	Wed Dec 16 12:21:43 2009 +0000
     1.2 +++ b/tools/libxc/xc_cpuid_x86.c	Wed Dec 16 12:23:21 2009 +0000
     1.3 @@ -136,7 +136,8 @@ static void intel_xc_cpuid_policy(
     1.4          regs[2] &= (is_64bit ? bitmaskof(X86_FEATURE_LAHF_LM) : 0);
     1.5          regs[3] &= ((is_pae ? bitmaskof(X86_FEATURE_NX) : 0) |
     1.6                      (is_64bit ? bitmaskof(X86_FEATURE_LM) : 0) |
     1.7 -                    (is_64bit ? bitmaskof(X86_FEATURE_SYSCALL) : 0));
     1.8 +                    (is_64bit ? bitmaskof(X86_FEATURE_SYSCALL) : 0) |
     1.9 +                    (is_64bit ? bitmaskof(X86_FEATURE_RDTSCP) : 0));
    1.10          break;
    1.11      }
    1.12  
     2.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Wed Dec 16 12:21:43 2009 +0000
     2.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Wed Dec 16 12:23:21 2009 +0000
     2.3 @@ -292,7 +292,7 @@ static enum handler_return long_mode_do_
     2.4          {
     2.5              struct vmx_msr_state *guest_state = &v->arch.hvm_vmx.msr_state;
     2.6              guest_state->msrs[VMX_INDEX_MSR_TSC_AUX] = msr_content;
     2.7 -            wrmsrl(MSR_TSC_AUX, msr_content);
     2.8 +            wrmsrl(MSR_TSC_AUX, (uint32_t)msr_content);
     2.9          }
    2.10          else
    2.11          {
    2.12 @@ -333,7 +333,8 @@ static void vmx_restore_host_msrs(void)
    2.13      }
    2.14  
    2.15      if ( cpu_has_rdtscp )
    2.16 -        wrmsrl(MSR_TSC_AUX, host_msr_state->msrs[VMX_INDEX_MSR_TSC_AUX]);
    2.17 +        wrmsrl(MSR_TSC_AUX,
    2.18 +               (uint32_t)host_msr_state->msrs[VMX_INDEX_MSR_TSC_AUX]);
    2.19  }
    2.20  
    2.21  static void vmx_save_guest_msrs(struct vcpu *v)
    2.22 @@ -383,7 +384,8 @@ static void vmx_restore_guest_msrs(struc
    2.23      }
    2.24  
    2.25      if ( cpu_has_rdtscp )
    2.26 -        wrmsrl(MSR_TSC_AUX, guest_msr_state->msrs[VMX_INDEX_MSR_TSC_AUX]);
    2.27 +        wrmsrl(MSR_TSC_AUX,
    2.28 +               (uint32_t)guest_msr_state->msrs[VMX_INDEX_MSR_TSC_AUX]);
    2.29  }
    2.30  
    2.31  #else  /* __i386__ */
    2.32 @@ -627,6 +629,8 @@ static void vmx_save_cpu_state(struct vc
    2.33      data->msr_syscall_mask = guest_state->msrs[VMX_INDEX_MSR_SYSCALL_MASK];
    2.34      if ( cpu_has_rdtscp )
    2.35          data->msr_tsc_aux = guest_state->msrs[VMX_INDEX_MSR_TSC_AUX];
    2.36 +    else
    2.37 +        data->msr_tsc_aux = 0;
    2.38  #endif
    2.39  
    2.40      data->tsc = hvm_get_guest_tsc(v);
    2.41 @@ -647,6 +651,8 @@ static void vmx_load_cpu_state(struct vc
    2.42      v->arch.hvm_vmx.shadow_gs = data->shadow_gs;
    2.43      if ( cpu_has_rdtscp )
    2.44          guest_state->msrs[VMX_INDEX_MSR_TSC_AUX] = data->msr_tsc_aux;
    2.45 +    else
    2.46 +        guest_state->msrs[VMX_INDEX_MSR_TSC_AUX] = 0;
    2.47  #endif
    2.48  
    2.49      hvm_set_guest_tsc(v, data->tsc);
    2.50 @@ -1563,13 +1569,6 @@ static void vmx_cpuid_intercept(
    2.51              else
    2.52                  *edx &= ~(bitmaskof(X86_FEATURE_SYSCALL));
    2.53  
    2.54 -#ifdef __x86_64__
    2.55 -            if ( cpu_has_rdtscp )
    2.56 -                *edx |= bitmaskof(X86_FEATURE_RDTSCP);
    2.57 -            else
    2.58 -                *edx &= ~(bitmaskof(X86_FEATURE_RDTSCP));
    2.59 -#endif
    2.60 -
    2.61              break;
    2.62      }
    2.63