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

Re: [PATCH v2 3/7] x86/vmx: add IPT cpu feature


  • To: Michał Leszczyński <michal.leszczynski@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 22 Jun 2020 10:31:18 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=25ytYj9uCGoj+ojl69tAQKmC4JucJCp9GoThbB8TDmk=; b=jWb7S5WLybFNLzo3oIUrmZajuP264eQARRH1jiEESM5C5CHW1zQTEoVAVVoKRtZ/ZMjkfAqEIHD/NB+e5kAlupRYviwtojiNBWZe2KpeXgmgozW5Lg4KsLUp1bhdxEEtZ/tmdVCZPLU4ZeMwHzjYyFlJjdyE+jTD9Hl7Vo5FrbUB9+tGEkIHH6o88QfMGl4K/SLrWWzuWG4Xf9kI/48MQ+i6jClOUeIgExl+b2naz4pYBPfRgdYN9VENJDgt0/qdRuCyDzMsug2IivaO7D3u3oz6enQOMVnzyvmIn8O0a6Unzk4xIw1/L535cwy9Hvef0hERn+UjY2qousGU58Tagw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TDgYWfQE2km+PJgZcpWkrua+galLBdruqY10D0Yf8q+zvCoz5Hy7Itg7BHb2CK02iWBV0cAeTbJQucrR6GgEMq2nkInhebA0LYlPTDWcYLrBEZ+Kt7hk+aYXski56buQznYSaKeEkE8TohFbC1ImRJNIFo540kGQiGpAsUWJdrwzI+P6UIbK1mj2lTtT5FXeOL2m3FYvvIanBq0sBbpP63uf4qmtX/eG3KlJhwpnR0aAtpDwC7gvirCnnO/PFUiyOa97gQKagiyKNz5jFYJNbP4FIw7JkEByy/WfeBqhDYP7WT/tONCtDn5xEkg/G4xvGHj4i44NxXpvNXzkibnlBw==
  • Authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=suse.com;
  • Cc: Kevin Tian <kevin.tian@xxxxxxxxx>, "Kang, Luwei" <luwei.kang@xxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Tamas K Lengyel <tamas.k.lengyel@xxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 22 Jun 2020 08:31:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 22.06.2020 04:49, Michał Leszczyński wrote:
> ----- 19 cze 2020 o 15:44, Roger Pau Monné roger.pau@xxxxxxxxxx napisał(a):
> 
>> On Fri, Jun 19, 2020 at 01:40:21AM +0200, Michał Leszczyński wrote:
>>> Check if Intel Processor Trace feature is supported by current
>>> processor. Define hvm_ipt_supported function.
>>>
>>> Signed-off-by: Michal Leszczynski <michal.leszczynski@xxxxxxx>
>>> ---
>>
>> We usually keep a shirt list of the changes between versions, so it's
>> easier for the reviewers to know what changed. As an example:
>>
>> https://lore.kernel.org/xen-devel/20200613184132.11880-1-julien@xxxxxxx/
>>
>>>  xen/arch/x86/hvm/vmx/vmcs.c                 | 4 ++++
>>>  xen/include/asm-x86/cpufeature.h            | 1 +
>>>  xen/include/asm-x86/hvm/hvm.h               | 9 +++++++++
>>>  xen/include/asm-x86/hvm/vmx/vmcs.h          | 1 +
>>>  xen/include/public/arch-x86/cpufeatureset.h | 1 +
>>>  5 files changed, 16 insertions(+)
>>>
>>> diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
>>> index ca94c2bedc..8466ccb912 100644
>>> --- a/xen/arch/x86/hvm/vmx/vmcs.c
>>> +++ b/xen/arch/x86/hvm/vmx/vmcs.c
>>> @@ -315,6 +315,10 @@ static int vmx_init_vmcs_config(void)
>>>          if ( opt_ept_pml )
>>>              opt |= SECONDARY_EXEC_ENABLE_PML;
>>>  
>>> +        /* Check whether IPT is supported in VMX operation */
>>> +        hvm_funcs.pt_supported = cpu_has_ipt &&
>>> +            ( _vmx_misc_cap & VMX_MISC_PT_SUPPORTED );
>>
>> By the placement of this chunk you are tying IPT support to the
>> secondary exec availability, but I don't think that's required?
>>
>> Ie: You should move the read of misc_cap to the top-level of the
>> function and perform the VMX_MISC_PT_SUPPORTED check there also.
>>
>> Note that space inside parentheses is only required for conditions of
>> 'if', 'for' and those kind of statements, here it's not required, so
>> this should be:
>>
>>    hvm_funcs.pt_supported = cpu_has_ipt &&
>>                             (_vmx_misc_cap & VMX_MISC_PT_SUPPORTED);
>>
>> I also think this should look like:
>>
>>    if ( !smp_processor_id() )
>>      hvm_funcs.pt_supported = cpu_has_ipt &&
>>                                 (_vmx_misc_cap & VMX_MISC_PT_SUPPORTED);
>>    else if ( hvm_funcs.pt_supported &&
>>              !(_vmx_misc_cap & VMX_MISC_PT_SUPPORTED) )
>>    {
>>        printk("VMX: IPT capabilities fatally differ between CPU%u and 
>> CPU0\n",
>>               smp_processor_id());
>>        return -EINVAL;
>>    }
>>
>>
>> So that you can detect mismatches between CPUs.
> 
> 
> I'm afraid this snippet doesn't work. All CPUs read hvm_funcs.pt_supported as 
> 0 even when it was set to 1 for CPU=0. I'm not sure if this is some 
> multithreading issue or there is a separate hvm_funcs for each CPU?

hvm_funcs will be set from start_vmx()'s return value, i.e. vmx_function_table.
Therefore at least prior to start_vmx() completing you need to fiddle with
vmx_function_table, not hvm_funcs. And in the code here, where for APs you
only read the value, you could easily use the former uniformly, I think.

Jan



 


Rackspace

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