From patchwork Fri May 20 13:37:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12856848 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0C4EC4332F for ; Fri, 20 May 2022 13:38:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.334160.558175 (Exim 4.92) (envelope-from ) id 1ns2pf-0005wm-29; Fri, 20 May 2022 13:38:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 334160.558175; Fri, 20 May 2022 13:38:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ns2pe-0005wV-UY; Fri, 20 May 2022 13:38:18 +0000 Received: by outflank-mailman (input) for mailman id 334160; Fri, 20 May 2022 13:38:17 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ns2pd-00056k-80 for xen-devel@lists.xenproject.org; Fri, 20 May 2022 13:38:17 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 19efacff-d842-11ec-bd2c-47488cf2e6aa; Fri, 20 May 2022 15:38:15 +0200 (CEST) Received: from mail-bn7nam10lp2109.outbound.protection.outlook.com (HELO NAM10-BN7-obe.outbound.protection.outlook.com) ([104.47.70.109]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 20 May 2022 09:38:14 -0400 Received: from DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) by SA2PR03MB5755.namprd03.prod.outlook.com (2603:10b6:806:111::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.14; Fri, 20 May 2022 13:38:13 +0000 Received: from DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::5df3:95ce:4dfd:134e]) by DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::5df3:95ce:4dfd:134e%5]) with mapi id 15.20.5273.018; Fri, 20 May 2022 13:38:13 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 19efacff-d842-11ec-bd2c-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1653053895; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=J60n5jqdMwAAtpUd0Sb/CZ3lcfzBgmMhxbvEASQztDY=; b=FkDBc4HdQSZtbwzDE5HyrsU7/IeODNJYkrqzToymaBT6EWDqzVDNfuP3 R3BqWJju3CHcL6zaiUVmPMSa5W/FIs6qootsH6gwLtESx+XafjgRBduVj vkW3ldggMkRTPApBqGt4qh6IBjD8NV4wdjzbOqVpV1GxLemK4Gsbr5goa 4=; X-IronPort-RemoteIP: 104.47.70.109 X-IronPort-MID: 71650041 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:Uu/+oqI+0vddXpeqFE+RpZQlxSXFcZb7ZxGr2PjKsXjdYENS1zdTn 2IfWWqGbPnbZGSjf4wjbou1oEkG6MLdxtYwSldl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Ii3rqpsL0ABggDdBauI5fehzFr2I9odBVys twri2knqsSKSmFsDX25tDOWR0vvFGzu2AenekaiGEaeZcCaYVWsZcU8CpuYds99RrBmcEa+d RVfYHhDK48SyLYU5mZhBgj/DWUZAV8Iv/cKXJy+PB80FBt7QVEJgUjtYkid0w7heMAoql/lp r525tT5cFzp7ctHMRA7cc6MLyK4z/2MGTx2Fz7GyWVKIg3f1TwlrXQ3JIZoMmXRb1g9upBpH 2GaiITiVIP X-IronPort-AV: E=Sophos;i="5.91,239,1647316800"; d="scan'208";a="71650041" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bbJGrKihM0r4M17xmkPV/SEIjd4FyOAbocPk/LZPF9gHqy1NxUb5jtNw0KJVJBDx4zXrhv4eFT8RTDQmuwLmUYxJlemWrHtSwK5Y9WbQbQQYhWFgpzHRods8Vvwlw8iufCmze8xGzjJP4f8VqYk1oZkjbkQFEfEmieFcVxXnIqG/oGv/mSA/z96cq9t3gco2fhXWH4BP4NHFy+kc2oKjXbcj8uQos78kdkdUCYE9ZmRaNa7pjDrRVb7DdDpVjzbBzF1raMZeZq4PKLrW8qnbDvoGLm6H8oHBXKbWSO/8gVlDD0XoSE99SDiwy/BZ391362M7NkNfhNmpmrWmCdtGfg== 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=jb7AH61H+rViXQ6rYuunouCojzr47RKHvH4ITvQrb1M=; b=HnlQwv8ZZv6kYAuzvlJZeerFwrr+8R7vunmu/W2yq8numw3HTuWujb7ip5Jf3xijku+ON08BHKMViRO124ZHuFSqa6HJhG8v1bvKueHi08tJIAtUrtHSq/FmHkfv5Gok6KcYtUf1ezLmMlPe9JeTmh8C+Zbf/NZ07ALxUXQgQGRhwGyMHPwMVQaOdtvFYE2h3TroIbBMqlLtDzQLy1s9gxoLANEy2Nalb+2hiwGuhjGBm0EXtQbn1MXewTi777y2ykFMqt+ZpIv7B1bW2uI3Zx3msxHhq04A0IB19Gb1g3Uyo5Wg7Fn5j/d1J1gLzTRZQe0hi0zepsvtJxyaIjvAjg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jb7AH61H+rViXQ6rYuunouCojzr47RKHvH4ITvQrb1M=; b=oXOgOcc9nxATnQSwCWHGdbHypyIm2jzuVBO5wuPbdyXjycxiU5Rs3G83cHQn+ggNxfI+TdGLSw4As4joJJlK6W18YXBUW9+9faV4rJHYJ3jB5O+h62puiigw6Gjc1mBbolV6rTZGUynZQrZTMcHIzU+IGZnOgXaY3OioWEI6uVY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH 3/5] x86/perf: expose LBR format in PERF_CAPABILITIES Date: Fri, 20 May 2022 15:37:44 +0200 Message-Id: <20220520133746.66142-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220520133746.66142-1-roger.pau@citrix.com> References: <20220520133746.66142-1-roger.pau@citrix.com> X-ClientProxiedBy: LO4P123CA0401.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:189::10) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0dbe4ca5-8e86-4749-6211-08da3a65fc79 X-MS-TrafficTypeDiagnostic: SA2PR03MB5755:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D5ZuQ5twQWWZI6Q5yKWXfz/vbSX7YRKS+g7H9K4ZZUeo7QJxpD33/2qkJ6GN1uVz/x20DsmnM4XTSp+REPlR2/zgDz4Oqw62hQOfq8Eup/ftnWK5oUVZ6nN6p0tuwHfJnGOc8CDsHvrN4Mw1ywgFggYWPK/M0y5AEDUKIosUXntsSSlWl7MAWq7077/JZ/wg259K/VTZPOde6wlnE1fvbdz5iyb1Hx0ryuvBSpiF3Iixge7wlAULKO3709/HfO2+lmxEjN7uRtNgV6Uv0GtyzVrZY0kbdXDPXTNYIy3fmgmbeJI53u1tUybB241bC1wqyBnN0Dq9LVpnr68jBHkaA8fwNa7KOgOPJNoQc/YjTZH9eguuf0ujah1VcKaThf758FeFCXQmj1ZxqdyQE9uOvYFugn+NWDXSE7AKL874xUI25HH7W18CVuzzfNiOy2AQG/9MMKqAf/WDATPS/C6eI6isY5HbMTgPpj3AJzRalRgzLZSSlcC0Kcjk7aytHxh/3Nt2AcWEmI+GhAFjq1zgmySpKC/JTP8F967wGugz8qwSdtQpKampdlobqAPSgRsSA0FVQjYFClfetWXdcrNwRT7AT069QEq/oRa0y2Op1YsDGLLCZUzCmZpxaWxDBNDHeP9gSPqYxgcxpXrKp5HatQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(54906003)(316002)(6916009)(86362001)(66556008)(66476007)(66946007)(8676002)(4326008)(6486002)(83380400001)(6512007)(26005)(2906002)(6506007)(508600001)(1076003)(38100700002)(2616005)(82960400001)(6666004)(36756003)(5660300002)(8936002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Skaskp0iN/gkclKTNcjBu2oLAUZ/?= =?utf-8?q?DsNR2mNrzuZ1k+1RLrjBMr35GVHBxCgZYNabGBR9FheT6Szt+SZ7gYmQbmHPYoESR?= =?utf-8?q?074VetVO3h9tp6J50N2/eAAQmDaZgsfc6AuoJcX7FvHWHuLJvdYsABK2JSDVcVsQC?= =?utf-8?q?m8jjqOcNIzAl0jneljaiwH77/DIWcJI5q6uALQb977oBnLagYQX7t/g7V43gYEiuP?= =?utf-8?q?ZPEJmYGXg07232Ej7fZel1PdDvTkzgJ6tf/VcAlLH/D1SH8Gmzq/XjhxmjgCMhTO9?= =?utf-8?q?gtmUifAjKIrhInk30f7FeQ5rio1BSQmKDZ6DWsMDl0zy6jTPr6HTzFgrXAZx46+Z7?= =?utf-8?q?wNiu279XZRuKc6E4DSFtUbLDjfacosRQj9P6jLFw6khTLUyGWiTBXWco2DHvc7yR7?= =?utf-8?q?3nd/QxrzcBdn7kRnjEv9nlnHi36ow6bXQZ/0j/CDtSNdNETN2u8fzIchVpDpOK8mW?= =?utf-8?q?33pnKlCzeIhes9Xtgc8ctbJN0mKha4XYF9n9ALq1hbCH82tba+8jRHAGL/onn9UgF?= =?utf-8?q?nbJ28LBRVCUpspdfFPhTA56pZoNhEAiIlaEas/kAQsvzqvRQUaL2zcleZp3cnzYY8?= =?utf-8?q?Mupi/s94M5VpHScpAi5U6sAS9viw+eYB36YRxPGBBG9reFDhqMs2fzxP4PoC+BAJX?= =?utf-8?q?TMn/CsBP2xnoO13rUXC2pDbKW8PhatvOaeoDHqG7iWvUwcsi/yl3D1QI9rAbtbAop?= =?utf-8?q?VsH0smH3hxcg0DHSXA7ZrBntQeb1n4GfVgVJ2vVBVnN1t/q9PznRBKRaCTU42dgIc?= =?utf-8?q?FZVT1kP5OnNHaaiIFdJIh1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z3r0m0Pzn9nRzTTP9uyiU98kg=3D?= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0dbe4ca5-8e86-4749-6211-08da3a65fc79 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2022 13:38:12.9830 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kNNpOi8NGp+F6DbdhXUz9umrfUEqhjwPO481hSocSpS9zT1+5uyiJnsT+wBtHgnaloUewubdGK2Cx83rPEbupA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR03MB5755 Allow exposing the PDCM bit in CPUID for HVM guests if present on the platform, which in turn allows exposing PERF_CAPABILITIES. Limit the information exposed in PERF_CAPABILITIES to the LBR format only. This is helpful as hardware without model-specific LBRs set format to 0x3f in order to notify the feature is not present. Signed-off-by: Roger Pau Monné --- Seeing as we have never exposed PDCM in CPUID I wonder whether there's something that I'm missing that makes exposing PERF_CAPABILITIES LBR format not as trivial as it looks. --- xen/arch/x86/msr.c | 9 +++++++++ xen/include/public/arch-x86/cpufeatureset.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c index 01a15857b7..423a795d1d 100644 --- a/xen/arch/x86/msr.c +++ b/xen/arch/x86/msr.c @@ -316,6 +316,15 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val) *val = 0; break; + case MSR_IA32_PERF_CAPABILITIES: + if ( !cp->basic.pdcm ) + goto gp_fault; + + /* Only report LBR format. */ + rdmsrl(MSR_IA32_PERF_CAPABILITIES, *val); + *val &= MSR_IA32_PERF_CAP_LBR_FORMAT; + break; + case MSR_X2APIC_FIRST ... MSR_X2APIC_LAST: if ( !is_hvm_domain(d) || v != curr ) goto gp_fault; diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h index cd6409f9f3..5fdaec43c5 100644 --- a/xen/include/public/arch-x86/cpufeatureset.h +++ b/xen/include/public/arch-x86/cpufeatureset.h @@ -135,7 +135,7 @@ XEN_CPUFEATURE(SSSE3, 1*32+ 9) /*A Supplemental Streaming SIMD Extensio XEN_CPUFEATURE(FMA, 1*32+12) /*A Fused Multiply Add */ XEN_CPUFEATURE(CX16, 1*32+13) /*A CMPXCHG16B */ XEN_CPUFEATURE(XTPR, 1*32+14) /* Send Task Priority Messages */ -XEN_CPUFEATURE(PDCM, 1*32+15) /* Perf/Debug Capability MSR */ +XEN_CPUFEATURE(PDCM, 1*32+15) /*S Perf/Debug Capability MSR */ XEN_CPUFEATURE(PCID, 1*32+17) /*H Process Context ID */ XEN_CPUFEATURE(DCA, 1*32+18) /* Direct Cache Access */ XEN_CPUFEATURE(SSE4_1, 1*32+19) /*A Streaming SIMD Extensions 4.1 */