WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: Jan Beulich <JBeulich@xxxxxxxxxx>
Subject: RE: [Xen-devel][PATCH 02/02] VMX: Add HVM RDTSCP support
From: "Xu, Dongxiao" <dongxiao.xu@xxxxxxxxx>
Date: Fri, 11 Dec 2009 21:10:45 +0800
Accept-language: en-US
Acceptlanguage: en-US
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Delivery-date: Fri, 11 Dec 2009 05:11:17 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4B224B6402000078000253AC@xxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <EADF0A36011179459010BDF5142A457501D13FE7E9@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> <4B224B6402000078000253AC@xxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: Acp6XuJVgCM9AtBxQ7WH6MFNAIAd2AABB2WA
Thread-topic: [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