From patchwork Thu Nov 30 07:46:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yicong Yang X-Patchwork-Id: 13474128 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 07EC7C4167B for ; Thu, 30 Nov 2023 07:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=CpMuofrVpa4j51rJUieFVhN70r24jqc0bPwadX8/MgI=; b=jQh9bHSSJA8j7E cgCE4+EfJdvFYGNpz3NCWlTRAY/p9TMiguSdLDntyiBCt74Si0Ks16H82n3A+lTUIJqt3rz3uMBFT FIY13mQw9nRah6JCR070yYTccxHa8Aijtuqz4Huz1ZvHit8183e6gdZjEBuLTk5paGWepncAhcQWs iRPPPebGp4/ewUscDQjF5g6tj0JstEN2xe021TEG2fBW1DIm3MWymSCzuNY/fdV7G+Hmez9tsK/wg KOC+36gaH/LvMezzPeMLQTCHz99JSLZIEYk2HniruHRWykgvzlnQgkYxOpxxwAMgcR/QuwUumd0NL 0+MlFVbioPGv/BgrubZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8bny-00A8DT-0C; Thu, 30 Nov 2023 07:49:50 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8bnn-00A88B-1p for linux-arm-kernel@lists.infradead.org; Thu, 30 Nov 2023 07:49:41 +0000 Received: from canpemm500009.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SgpGl4yzXzWhpy; Thu, 30 Nov 2023 15:48:47 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 30 Nov 2023 15:49:32 +0800 From: Yicong Yang To: , , , , , , CC: , , , , , Subject: [PATCH v2 0/3] Enable the profiling of EL0&1 translation regime of ARM SPE Date: Thu, 30 Nov 2023 15:46:06 +0800 Message-ID: <20231130074609.58668-1-yangyicong@huawei.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 X-Originating-IP: [10.50.165.33] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_234939_789783_E961D007 X-CRM114-Status: GOOD ( 11.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Yicong Yang When using the SPE, it's noticed the operation of a VM is not profiled at all on a VHE enabled host. This is because the driver's using PMSCR_EL1.{E1SPE, E0SPE} to enable the profiling. On a VHE enabled host, we're actually setting the PMSCR_EL2.{E2SPE, E0SPE}. This will enable the profiling of EL2 and EL0 in a EL2&0 translation regime. However the VM is using a EL1&0 translation regime, so it's not profiled. We can enable the profiling of EL1&0 translation regime by setting PMSCR_EL12.{E1SPE, E0SPE} from EL2. This patch adds the support to this by: - Add the sysreg definition of PMSCR_EL12 - Factor the code to allow extension - Enable the profiling of EL1&0 and complete perf's exclude_* option Tests have been done on VHE and non-VHE host with `perf record -e {arm_spe_0//}:u|k|h|G|h` and results shows as expected. The sample from El0 in the VM will be like (generated by `perf report -D`): . 000003b8: b0 48 eb 12 ab ff ff 00 80 PC 0xffffab12eb48 el0 ns=1 . 000003c1: 99 07 00 LAT 7 ISSUE . 000003c4: 98 08 00 LAT 8 TOT . 000003c7: 62 42 00 00 00 EV RETIRED NOT-TAKEN . 000003cc: 4a 01 B COND . 000003ce: 00 00 PAD . 000003d0: b1 4c eb 12 ab ff ff 00 80 TGT 0xffffab12eb4c el0 ns=1 . 000003d9: 00 00 00 PAD . 000003dc: 64 50 01 00 00 CONTEXT 0x150 el1 . 000003e1: 65 3c 11 00 00 CONTEXT 0x113c el2 . 000003e6: 00 00 00 00 00 PAD . 000003eb: 71 aa aa 00 fd 06 00 00 00 TS 30014483114 Change since v1: - Add tag by Mark and ordered PMSCR_EL12 by address as suggested. By now at least PMSCR_EL12 keeps order among its *_EL12 siblings in sysreg. Link: https://lore.kernel.org/linux-arm-kernel/20231122084602.53914-1-yangyicong@huawei.com/ Yicong Yang (3): arm64/sysreg: Add PMSCR_EL12 and factor out the common fields perf: arm_spe: Factor out PMSCR set/clear operations perf: arm_spe: Enable the profiling of EL0&1 translation regime arch/arm64/tools/sysreg | 10 ++++- drivers/perf/arm_spe_pmu.c | 76 ++++++++++++++++++++++++++++---------- 2 files changed, 65 insertions(+), 21 deletions(-)