From nobody Fri May 10 11:34:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1687283212; cv=none; d=zohomail.com; s=zohoarc; b=Ol6RVemq3duLEpQd9CAJIZzCLbIqEquv2Xk2H+BKqXpYKfjAzj+JTM8ilISMIHMHq7iRgK04qZyTNRiyG5+w2IT5EZVffWUnezpf2I+aMMyy6/3Z3yakiQZXKlxtfxUiP1neDnBW0ls/zYeWISYmKlLnlkYls9vpv2er9xkfOgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687283212; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=O2JU8pRvxThG2B/gs9b8T1ixwic4EVk4bYV3kOoNzCA=; b=lJ3E2P1SCobfVwPY+wcJ2F77laYh94btglMHyMKquRjpDT1NCzeNsyUi7jfWjTOJ8I9SLXSYwSLTKQZtnekpGWzJ59m/5eFNnPuqRAbB5jHhixjyCDSM0r2/Y3QIOcJXxoWQt/rgaRIuEkKVryMmXyfAYXBYVVq9xvaaU6ZGoNE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1687283212064882.3390241639028; Tue, 20 Jun 2023 10:46:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.552161.862077 (Exim 4.92) (envelope-from ) id 1qBfQi-0008Fx-G2; Tue, 20 Jun 2023 17:46:12 +0000 Received: by outflank-mailman (output) from mailman id 552161.862077; Tue, 20 Jun 2023 17:46:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qBfQi-0008Fq-Cj; Tue, 20 Jun 2023 17:46:12 +0000 Received: by outflank-mailman (input) for mailman id 552161; Tue, 20 Jun 2023 17:46:11 +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 1qBfQg-0008Fk-UV for xen-devel@lists.xenproject.org; Tue, 20 Jun 2023 17:46:11 +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 5537f468-0f92-11ee-b234-6b7b168915f2; Tue, 20 Jun 2023 19:46:08 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 5537f468-0f92-11ee-b234-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1687283167; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=rGnvM14ixfWPA7glURMM/F1hOUiXveqgD8w1TAFs4DI=; b=AyJk/65X4gV99IxoYa+pnLBDbvcEq1ljq+fkwzH9HD3PmE/DWZ4eKw9v SuuJLUu/55SnkQrD8ZXuZdSZqh2n8+o6wmwxMjhGi9tRtXAXlf8u2mGUV spP1DcG8wi/QRq+6iRrO6y3K0t/0LwJJOLrU/YpkNxObVNBKbkgm0hJJu Y=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 112833466 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:O2A/Z6wc0iIfSE8Z5ol6t+c2xirEfRIJ4+MujC+fZmUNrF6WrkVSy mVJDW2ObPnZa2X9c9h3PYmw8UoDusCExoVgGVQ4rSAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjP3OHfykTrafYEidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw/zF8EsHUMja4mtC5QRgP6gT5jcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KWpx9 tggFQ1QUiiGosuzzIP8du9lutt2eaEHPKtH0p1h5TTQDPJgSpHfWaTao9Rf2V/chOgXQ6yYP ZBAL2MyMlKZOUYn1lQ/UfrSmM+BgHXlfiIeg1WSvactuEDYzRBr0airO93QEjCPbZwMxBbD/ T6YoQwVBDlHG4Gx6GqV2Uj1odbMoRr7WKQwFZ2Ro6sCbFq7mTVIVUx+uUGAiem0jAuyVsxSL 2QQ+zEytu4i+UqzVN7/Uhak5nmesXY0efBdDuk74wGl0bfP7kCSAW1sZiFFQMwrsokxXzNC6 7OSt4q3X3o16uTTEC/DsO7O9lteJBT5M0cJWiwgdTY4vuXbpaQaix7+CeplGZKq24id9S7L/ 9yakMQvr+xN3ZFRh//hpAuvbyGE/caQEFNsjunDdif8t14iOtb4D2C9wQKDhcusOrp1WbVoU JIsv8GFpN4DApiW/MBmaLVcRer5jxpp3dC1vLKOI3XC3273k5JbVdoMiAyS3W8wWir+RRfnY VXIpSRa74JJMX2hYMdfOtzhVJ17nPWwRYm5CJg4i+aihLArKWdrGwk0PyatM53FyhBwwcnTx 7/GGSpTMZrqIfs+l2fnLwvs+bQq2jo/1QvuqWPTlnyaPU6lTCfNE98taQLeBt3VGYvY+G05B f4DbZrVo/ieOcWiChTqHXk7dwFWdyRrW86nwyGVH8baSjdb9KgaI6e56dscl0ZNxsy5Ss+gE qmBZ3Jl IronPort-HdrOrdr: A9a23:ZhdMOqAVWYwBO5/lHemW55DYdb4zR+YMi2TDgXoBLiC9Ffbo9P xG/c566faasl0ssR0b8+xoW5PgfZq/z/FICNIqTNOftWDd0QOVxedZgLcKqAePJ8SRzIJgPQ gLSdkZNDVdZ2IK7/oTQWODYrMd/OU= X-Talos-CUID: 9a23:MdlciG8J0+skREz0Qh+Vv0UrGeQdT0CA8E/VBma9BVcudLucdUDFrQ== X-Talos-MUID: 9a23:DcpC+wYyG+cUfeBT6hCxqhAyJOxSuoOXC3w0kZUgmcikHHkl X-IronPort-AV: E=Sophos;i="6.00,257,1681185600"; d="scan'208";a="112833466" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH] x86/vpmu: Simplify is_pmc_quirk Date: Tue, 20 Jun 2023 18:45:56 +0100 Message-ID: <20230620174556.3898824-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1687283214220100001 This should be static, and there's no need for a separate (non-init, even) function to perform a simple equality test. Drop the is_ prefix which is gramatically questionable, and make it __ro_after_init. Leave a TODO, because the behaviour is definitely wrong to be applied to ~a= ll modern Intel CPUs, and has been raised on xen-devel previously without conclusion. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu --- xen/arch/x86/cpu/vpmu_intel.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/cpu/vpmu_intel.c b/xen/arch/x86/cpu/vpmu_intel.c index 35e350578b84..0291481da22e 100644 --- a/xen/arch/x86/cpu/vpmu_intel.c +++ b/xen/arch/x86/cpu/vpmu_intel.c @@ -91,22 +91,14 @@ static const unsigned int regs_off =3D * 1 (or another value !=3D 0) into it. * There exist no errata and the real cause of this behaviour is unknown. */ -bool_t __read_mostly is_pmc_quirk; - -static void check_pmc_quirk(void) -{ - if ( current_cpu_data.x86 =3D=3D 6 ) - is_pmc_quirk =3D 1; - else - is_pmc_quirk =3D 0; =20 -} +static bool __ro_after_init pmc_quirk; =20 static void handle_pmc_quirk(u64 msr_content) { int i; u64 val; =20 - if ( !is_pmc_quirk ) + if ( !pmc_quirk ) return; =20 val =3D msr_content; @@ -791,8 +783,9 @@ static int cf_check core2_vpmu_do_interrupt(struct cpu_= user_regs *regs) rdmsrl(MSR_CORE_PERF_GLOBAL_STATUS, msr_content); if ( msr_content ) { - if ( is_pmc_quirk ) + if ( pmc_quirk ) handle_pmc_quirk(msr_content); + core2_vpmu_cxt->global_status |=3D msr_content; msr_content &=3D ~global_ovf_ctrl_mask; wrmsrl(MSR_CORE_PERF_GLOBAL_OVF_CTRL, msr_content); @@ -967,7 +960,8 @@ const struct arch_vpmu_ops *__init core2_vpmu_init(void) sizeof(uint64_t) * fixed_pmc_cnt + sizeof(struct xen_pmu_cntr_pair) * arch_pmc_cnt; =20 - check_pmc_quirk(); + /* TODO: This is surely wrong. */ + pmc_quirk =3D current_cpu_data.x86 =3D=3D 6; =20 if ( sizeof(struct xen_pmu_data) + sizeof(uint64_t) * fixed_pmc_cnt + sizeof(struct xen_pmu_cntr_pair) * arch_pmc_cnt > PAGE_SIZE ) --=20 2.30.2