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

Re: [PATCH 4/5] x86/vmx: handle no model-specific LBR presence


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 30 May 2022 18:02:02 +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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=37TxpXbybYBIxNoDM6WFgoDWLtH6YyngDzP+YKk8ZIw=; b=AuBbPfayWRu8xIeK7UShNw5245j6YFo81ZGhJ/5QwVyQuTetpvDT2GX9eHGmuEg72HPjmhqKeLaLV7+0xK5Ph32lwXiwzR0SzVNSi5z70DT4ryBHr1e6a65Y+MfLVuB9igaZS02vxQuco2c8bSwCL4Ww1moKrOaWhnMBpC7zZy9WYUc2X54aYcxtCvNMUCTfQG0F7DC8tlk8IuKENtNdfOmTrgBF9sm7JzunhSTgxqUEXAVZRa7cdjJ7o4+nRCQBn/6P4kFamBHFQof0XCLh3DjpBTmwXUwa24GTDFzp2BSkWZKzObsPuvDcCMeKvbJe8THwlVWJRAiGrOBgjeJfsA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JjmW9b5W8Bg7VSap1gLWdMAPUfsxuMH9Q6W84zCBqedHZsv0UUhhkW61pKeIqdk7J24Iiply1M6VUX96weW5q7dxie/JPr1QuejCNas7j/hywfJDBbLPaztXT8M2kA+ID9sDn7dO6K9a15MdVrR4QbJtH6FrJJm2awP/GCfm797vlYuZgOpKlOWKJGWCEI7JLULRPALbLTeWWdc+mLDLdr2rSoj8MKo2NkPQoA+wngXcAFxRCoOre3kfYxBHqkPl86F+u9XTyolhtk5DrJ7RtE4IDMVCYQS0GwV4GPSW5Y0YXT/p0rBsLs55dSbi87ZvIJGkHAuwwQpGUCzWhRGpQQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 30 May 2022 16:02:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 20.05.2022 15:37, Roger Pau Monne wrote:
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -3007,6 +3007,8 @@ static const struct lbr_info {
>      { MSR_GM_LASTBRANCH_0_FROM_IP,  NUM_MSR_GM_LASTBRANCH_FROM_TO },
>      { MSR_GM_LASTBRANCH_0_TO_IP,    NUM_MSR_GM_LASTBRANCH_FROM_TO },
>      { 0, 0 }
> +}, no_lbr[] = {
> +    {0, 0}
>  };

Instead of introducing this and ...

> @@ -3070,6 +3072,21 @@ static const struct lbr_info *last_branch_msr_get(void)
>          /* Goldmont */
>          case 0x5c: case 0x5f:
>              return gm_lbr;
> +
> +        default:
> +            if ( cpu_has_pdcm )
> +            {
> +                uint64_t cap;
> +
> +                rdmsrl(MSR_IA32_PERF_CAPABILITIES, cap);
> +                if ( (cap & MSR_IA32_PERF_CAP_LBR_FORMAT) == 0x3f )
> +                    /*
> +                     * On processors that do not support model-specific LBRs,
> +                     * PERF_CAPABILITIES.LBR_FMT will have the value 0x3f.
> +                     */
> +                    return no_lbr;

... doing this MSR read every time, can't you store a mask value
once during boot, which you apply to msr_content ...

> @@ -3521,6 +3538,8 @@ static int cf_check vmx_msr_write_intercept(
>                  return X86EMUL_OKAY;
>              }
>  
> +            if ( lbr->count )
> +            {
>              for ( ; lbr->count; lbr++ )
>              {
>                  unsigned int i;

... ahead of the bigger if() enclosing this code (thus also avoiding
the need to re-indent)?

Jan




 


Rackspace

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