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

Re: [PATCH 1/3] x86/vPMU: convert vendor hook invocations to altcall


  • To: Andrew Cooper <amc96@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 1 Dec 2021 08:32:40 +0100
  • 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+fO/+E6zcJdufR+r2Lb6bLprlrGmHwIxNFjibVMxTh8=; b=GWCOIOpI7JsW84IuybZK0dc0gCd5qssin07GnQMG2Mm1/SrBQJeb8NJB0VRvUER1y36KsNBnugk1EZ1L2zIeiF3g/hRjaHHMgPE0PvvIfrgKn8DTiGRa8b7+Yc6B26Y4ZQ0rx23V5FPwpEL19mfROAF6LUWxuW13cjgdtwr+HUdHBLdbPLQIaebq5ahx2F0SVblwW1R6H3pVeB7zqDRI+GczfMCW1saEkQuh/MySRLPsI4PRtksCPh5r/htEvR+vgtqJxRM4mFH+dXk+R5LfURIce9sEKTI8PHLcEG5DQ2VY/VyoC9jjuN5OEDIOA008QKq+Z2Q9a95UyrkuJ3akDQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SbHaYFRqQZJy+UxtdYUx/jWFald2SaQyZAwLNHHNTurd5JhAYsgsmvKLb/VVIEbE+kDUa7e0bsf8kgaxmaMk30Vmhz2SGXNjoVdlZ63nY+rtwlYjXDQBzA2E5aRivtV1VMq1tne0LjqiTfSDwAuWG/6ODkAw9bRGkJtIDKd5PArdaWmiHGVERzrKwvcXm5jDXzqaHLbOnzlXuw9Xxy6cMRpERrDYugPssARhHSvymBYfvYYdRX18HvtGIHwu6QTegWAhQ97QiAN/XR0gohSfsVaG2YNaRx2J8tAm/Y6oorGYtmrWre4QV1jp+Esp8M2SwvQdxGOcYzIqo+C4fzxsIg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 01 Dec 2021 07:33:04 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 30.11.2021 21:56, Andrew Cooper wrote:
> On 29/11/2021 09:10, Jan Beulich wrote:
>> @@ -133,14 +133,13 @@ int vpmu_do_msr(unsigned int msr, uint64
>>           goto nop;
>>  
>>      vpmu = vcpu_vpmu(curr);
>> -    ops = vpmu->arch_vpmu_ops;
>> -    if ( !ops )
>> +    if ( !vpmu_is_set(vpmu, VPMU_INITIALIZED) )
>>          goto nop;
>>  
>> -    if ( is_write && ops->do_wrmsr )
>> -        ret = ops->do_wrmsr(msr, *msr_content, supported);
>> -    else if ( !is_write && ops->do_rdmsr )
>> -        ret = ops->do_rdmsr(msr, msr_content);
>> +    if ( is_write && vpmu_ops.do_wrmsr )
>> +        ret = alternative_call(vpmu_ops.do_wrmsr, msr, *msr_content, 
>> supported);
>> +    else if ( !is_write && vpmu_ops.do_rdmsr )
>> +        ret = alternative_call(vpmu_ops.do_rdmsr, msr, msr_content);
> 
> Elsewhere, you've dropped the function pointer NULL checks.  Why not here?

No, I'm not dropping any function pointer checks here; all I drop is
checks of the ops pointer being NULL. These checks all get dropped in
patch 3.

>> --- a/xen/include/asm-x86/vpmu.h
>> +++ b/xen/include/asm-x86/vpmu.h
>> @@ -61,25 +61,25 @@ struct vpmu_struct {
>>      u32 hw_lapic_lvtpc;
>>      void *context;      /* May be shared with PV guest */
>>      void *priv_context; /* hypervisor-only */
>> -    const struct arch_vpmu_ops *arch_vpmu_ops;
>>      struct xen_pmu_data *xenpmu_data;
>>      spinlock_t vpmu_lock;
>>  };
>>  
>>  /* VPMU states */
>> -#define VPMU_CONTEXT_ALLOCATED              0x1
>> -#define VPMU_CONTEXT_LOADED                 0x2
>> -#define VPMU_RUNNING                        0x4
>> -#define VPMU_CONTEXT_SAVE                   0x8   /* Force context save */
>> -#define VPMU_FROZEN                         0x10  /* Stop counters while 
>> VCPU is not running */
>> -#define VPMU_PASSIVE_DOMAIN_ALLOCATED       0x20
>> +#define VPMU_INITIALIZED                    0x1
>> +#define VPMU_CONTEXT_ALLOCATED              0x2
>> +#define VPMU_CONTEXT_LOADED                 0x4
>> +#define VPMU_RUNNING                        0x8
>> +#define VPMU_CONTEXT_SAVE                   0x10  /* Force context save */
>> +#define VPMU_FROZEN                         0x20  /* Stop counters while 
>> VCPU is not running */
>> +#define VPMU_PASSIVE_DOMAIN_ALLOCATED       0x40
>>  /* PV(H) guests: VPMU registers are accessed by guest from shared page */
>> -#define VPMU_CACHED                         0x40
>> -#define VPMU_AVAILABLE                      0x80
>> +#define VPMU_CACHED                         0x80
>> +#define VPMU_AVAILABLE                      0x100
>>  
>>  /* Intel-specific VPMU features */
>> -#define VPMU_CPU_HAS_DS                     0x100 /* Has Debug Store */
>> -#define VPMU_CPU_HAS_BTS                    0x200 /* Has Branch Trace Store 
>> */
>> +#define VPMU_CPU_HAS_DS                     0x1000 /* Has Debug Store */
>> +#define VPMU_CPU_HAS_BTS                    0x2000 /* Has Branch Trace 
>> Store */
> 
> Seeing as you're shuffling each of these, how about adding some leading
> 0's for alignment?

Fine with me; I did consider it at the time of writing the patch,
but decided that such a change of non-mandatory style may not be
justified here (or even in general), as there are also downsides
to such padding: Once adding a constant with more significant
digits, all pre-existing ones need touching to insert yet another
zero.

Jan




 


Rackspace

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