Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1284864lqt; Fri, 7 Jun 2024 13:32:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWFnFrFUzX8Kft/dvN13xi2fcN67MfpNVxUSPVjXqErUhOKk2lns6EVhl66mAcM/gStyUm8S0Qsk5xjVbOUecbUbEWEA6tct4wf3ktD1A== X-Google-Smtp-Source: AGHT+IFg+7ZHRQPcEMAgRte1tvqRQBiklYSd+s4IQwv3MFlMcw+Cjad7rLywgBD2M1bqT1287+mP X-Received: by 2002:a50:ab5b:0:b0:57a:79c2:e9d7 with SMTP id 4fb4d7f45d1cf-57c50989d4amr2048411a12.27.1717792329980; Fri, 07 Jun 2024 13:32:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717792329; cv=pass; d=google.com; s=arc-20160816; b=cvj5nqU5k6PPCuroV7toFKv5Th+JNINTWfnVTqxfiFeATjuNStaBZe/6HvnE5ydMV2 4lEr4NqKtGvtEsGzWv/iCIEOqx4tD9tdUP91x88S+cJaMMMsUy7KO1uTtar8B/yQ5bo7 voEGuopVqScdf660wRn1C8i5R1yu9iRIFHWX1fz51Izdi1lZwCTxS4gAF8BpKYJsXW+Z lUIZh5j3aprNHBYcFve4HGIqIzPU8t97lizoD8P60h2d0uM5EQk6hP6bfso22HibaWX4 JhvwBJQU+kAvVsCmhypvJubL6INd0BW6fvNuYmLzn/+vqZT0gOgCzuH5s2V2ycv9Ebns WJyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:from :dkim-signature; bh=6DW1OaAy7XNtbLBjtuRQ/i65TivcvHt1w6xX9VG+TSo=; fh=7MWtQIrhu8/8z5W30BSUbJmbB5Xoil/A+Q0kLnK8lig=; b=tFXT7ailm59KSV2WuoTiJQZGa/RVX7rc/lTiCMqVXRTDxYclQPppLe/sQjx8i7ePaD ZVYFtu3dj47ps7eYWCRK3iiRRqg6uaUDFzbxZJpAzjAuYC6CO2OfDpcA6kMiWg/M0vM9 Kxiu7pu5qYCqRsUWnKlYvoy8FqD7DN+OS9bUJ2y6l5pacJkx4/wecVwiybyaQtOFruMw ho930xv4C5Br0W1nPLbYZwpeR8KzhUby+orqVrsEGEdYG5T2d0xSeljWclAu/XeiHAsJ QNiHanUWxrl7dQXPQNEnbxM+mEV8gbJPC0Ss/XsQV5MiQud+eKFTkYoXRKsz+KBriDpz kBgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i0S21Kci; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206713-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206713-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae23135dsi2071250a12.449.2024.06.07.13.32.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 13:32:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206713-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i0S21Kci; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206713-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206713-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B25941F23708 for ; Fri, 7 Jun 2024 20:32:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6900D14F9E6; Fri, 7 Jun 2024 20:32:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i0S21Kci" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B026819; Fri, 7 Jun 2024 20:32:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717792323; cv=none; b=KnsleeFEiVjW72vZHRFg3V2yiLkkpkSL4AAEP8PsB8FwC4zqSMtgDwKix7z8D/MCDcYa3jY1OjpdpYCj05yhpVH+pFsRBr16opqjdruiuK7saeL/4TkFui7BHUiexnN8DHOVG/xONoLsb7pRxgLQ2MptquHvUVytIX4/EXFcjM4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717792323; c=relaxed/simple; bh=X4B1La1z1pxjkZPYe8MXZt4HnbUKOeGUnGDR7svXFnY=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=ZdONmihoFc7Q/Tt3kJNlhhG6UFLXwsK+a/naKSC9TALg1ipGNUL4dmrZOuklxptNsPdrlOxS6DNJsAK7E0rEtkosEO6hqa8ZFy+aXbWM2v/ROfGw7f89eN+Ak6oZS0T1/qPLAgTU5A0gCsOEgMguVFQuoUSCK7Q5UVQFWRTYeWs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i0S21Kci; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9ACFC2BBFC; Fri, 7 Jun 2024 20:32:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717792323; bh=X4B1La1z1pxjkZPYe8MXZt4HnbUKOeGUnGDR7svXFnY=; h=From:Subject:Date:To:Cc:From; b=i0S21KciwE9FHfuVZmGF6pWg2iaggajBlMr1gDX7jHhHbqi61mw6qJcRclL5w3U4K tAiWVDL9hgNZ8/Wz9/M7BJq4rZimfXFUYF48bC33grP4XEjUeOf/E2VIEa4YjaP3Zi gj7bVQE/F6uiqdYJ0MqatakrSQODbpxtMty4PPvaFh8CpGqvBC2DHuNK1NR4dSEQvc ynm6cSIbdI72F3E3o7C4sO6eoFXPyKAda9GbbsMYc6NLdVCW3B0uO+PM8cqD4lnrXf iTSqGMr9a8wNwaHCrb563J57HcqWeRTx5dGe2SdWOqZVh04HPnbDLlJxDgmgf1aW6h gW4RfM6XmkDng== From: "Rob Herring (Arm)" Subject: [PATCH 0/9] arm64: Add support for Armv9.4 PMU fixed instruction counter Date: Fri, 07 Jun 2024 14:31:25 -0600 Message-Id: <20240607-arm-pmu-3-9-icntr-v1-0-c7bd2dceff3b@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAB1uY2YC/x3MPQqAMAxA4atIZgOx9f8q4iA2agarpCqCeHeL4 ze890BgFQ7QJg8oXxJk8xFZmsC4DH5mFBcNhkxOJVU46Ir7eqLFBmX0hyLltiqcc0S1gdjtypP c/7Pr3/cDRyd5VGMAAAA= To: Russell King , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Will Deacon , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, kvmarm@lists.linux.dev X-Mailer: b4 0.14-dev This series adds support for the optional fixed instruction counter added in Armv9.4 PMU. Most of the series is a refactoring to remove the index to counter number conversion which dates back to the Armv7 PMU driver. Removing it is necessary in order to support more than 32 counters without a bunch of conditional code further complicating the conversion. Patches 1-2 move the 32-bit Arm PMU drivers into drivers/perf/ and drop non-DT probe support. These can be taken first if there's no comments on them. Patch 3 changes struct arm_pmu.num_events to a bitmap of events, and updates all the users. This removes the index to counter conversion on the PMUv3 and Armv7 drivers. Patch 4 updates various register accessors to use 64-bit values matching the register size. Patches 5-6 update KVM PMU register accesses to use shared accessors from asm/arm_pmuv3.h. Patches 7-8 rework KVM and perf PMU defines for counter indexes and number of counters. Patch 9 finally adds support for the fixed instruction counter. I tested this on FVP with VHE host and a guest. I tested the Armv7 PMU changes with QEMU. Signed-off-by: Rob Herring (Arm) --- Rob Herring (Arm) (9): perf/arm: Move 32-bit PMU drivers to drivers/perf/ perf: arm_v6/7_pmu: Drop non-DT probe support perf: arm_pmu: Remove event index to counter remapping perf: arm_pmuv3: Prepare for more than 32 counters KVM: arm64: pmu: Use arm_pmuv3.h register accessors KVM: arm64: pmu: Use generated define for PMSELR_EL0.SEL access arm64: perf/kvm: Use a common PMU cycle counter define KVM: arm64: Refine PMU defines for number of counters perf: arm_pmuv3: Add support for Armv9.4 PMU instruction counter arch/arm/include/asm/arm_pmuv3.h | 23 ++++ arch/arm/kernel/Makefile | 2 - arch/arm64/include/asm/arm_pmuv3.h | 56 ++++++++- arch/arm64/include/asm/kvm_host.h | 8 +- arch/arm64/include/asm/sysreg.h | 1 - arch/arm64/kvm/pmu-emul.c | 14 +-- arch/arm64/kvm/pmu.c | 88 ++++--------- arch/arm64/kvm/sys_regs.c | 11 +- arch/arm64/tools/sysreg | 30 +++++ drivers/perf/Kconfig | 12 ++ drivers/perf/Makefile | 3 + drivers/perf/arm_pmu.c | 11 +- drivers/perf/arm_pmuv3.c | 138 ++++++++++----------- .../perf_event_v6.c => drivers/perf/arm_v6_pmu.c | 26 +--- .../perf_event_v7.c => drivers/perf/arm_v7_pmu.c | 90 +++++--------- .../perf/arm_xscale_pmu.c | 15 +-- include/kvm/arm_pmu.h | 8 +- include/linux/perf/arm_pmu.h | 10 +- include/linux/perf/arm_pmuv3.h | 7 +- 19 files changed, 289 insertions(+), 264 deletions(-) --- base-commit: 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0 change-id: 20240607-arm-pmu-3-9-icntr-04375ddd0082 Best regards, -- Rob Herring (Arm)