[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Xen-devel][PATCH 02/02] VMX: Add HVM RDTSCP support



Jan, 
        Thanks for reminder. I ever noticed this problem, but I forgot to 
modify the code in that version. 
Attached is the updated one.

Best Regards,
-- Dongxiao

Jan Beulich wrote:
>>>> "Xu, Dongxiao" <dongxiao.xu@xxxxxxxxx> 11.12.09 12:53 >>>
>> Add RDTSCP instruction support for HVM VMX guest.
>> - RDTSCP is introduced in Nehalem processor on Intel platform. Like
>> RDTSC, RDTSCP will return the TSC value, besides, it will return the
>> low 32bit of TSC_AUX MSR. Currently Linux kernel will write (node_id
>> << 12 | process_id) into that MSR, so that when guest execs RDTSCP,
>> it will also get processor information. - This instruction is
>> supported for HVM only when the hardware has this capability
>> (indicated by cpuid). 
> 
> This
> 
>> --- a/xen/arch/x86/hvm/vmx/vmx.c     Tue Dec 08 14:14:27 2009 +0000
>> +++ b/xen/arch/x86/hvm/vmx/vmx.c     Fri Dec 11 19:10:53 2009 +0800
>> @@ -138,7 +138,7 @@ static DEFINE_PER_CPU(struct vmx_msr_sta
>> 
>> static u32 msr_index[VMX_MSR_COUNT] =
>> {
>> -    MSR_LSTAR, MSR_STAR, MSR_SYSCALL_MASK
>> +    MSR_LSTAR, MSR_STAR, MSR_SYSCALL_MASK, MSR_TSC_AUX };
>> 
>> static void vmx_save_host_msrs(void)
>> @@ -146,8 +146,11 @@ static void vmx_save_host_msrs(void)
>>     struct vmx_msr_state *host_msr_state =
>> &this_cpu(host_msr_state);     int i; 
>> 
>> -    for ( i = 0; i < VMX_MSR_COUNT; i++ )
>> +    for ( i = 0; i < VMX_MSR_COUNT - 1; i++ )
>>         rdmsrl(msr_index[i], host_msr_state->msrs[i]); +
>> +    if ( cpu_has_rdtscp )
>> +        rdmsrl(MSR_TSC_AUX,
>> host_msr_state->msrs[VMX_INDEX_MSR_TSC_AUX]); } 
>> 
>> #define WRITE_MSR(address)                                          
>> \ 
> 
> seems to be calling for future problems - if anyone adds an element to
> msr_index[] before MSR_TSC_AUX, the logic will silently break. A
> BUILD_BUG_ON() and a comment would be the minimum thing to add
> in my opinion.
> 
> Jan

Attachment: 02-add-hvm-rdtscp-support.patch
Description: 02-add-hvm-rdtscp-support.patch

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.