From patchwork Wed Nov 22 08:45:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yicong Yang X-Patchwork-Id: 13464239 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 8338CC072A2 for ; Wed, 22 Nov 2023 08:49:56 +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=2RQfOcgL4DGpZvJJRbVPetWpnK3vRM+UszPZFlaYmEg=; b=pxFjsZCL1YyNg9 GOjqTQEVQ3zaH4Fd4swg9gM4SxJU3i9AfSQEgvD8c5g3ehPDWuwGBtv0g5obnvsklJ+AumA8mBz8O 0wObpuY8djoTzQ5IQK2Efuq5/2t02YU3scKvHe7NbljTU+wTUxGuP8Y3fKcug9W+WiaEX+GP6KXop 5jxM8QRJvYHkM9F1P63Ddf6GiheulsgjzxPpv5ZS2JnLOojjHdzcOJQSvS9JjLfALgy49QnxTmhZC rN4IUjQ3jbKJTJmT/x6w7Zf7UqpbztqUivCeAdCmKcva2DC7YSD6z+6gwDw+BbgFsMS/ihiYrZS8D N+HWcCna/reQaiustazg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5ivK-0016RF-11; Wed, 22 Nov 2023 08:49:30 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5ivG-0016Pk-0K for linux-arm-kernel@lists.infradead.org; Wed, 22 Nov 2023 08:49:28 +0000 Received: from canpemm500009.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SZvwH301Dz1P8lP; Wed, 22 Nov 2023 16:45:51 +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; Wed, 22 Nov 2023 16:49:19 +0800 From: Yicong Yang To: , , , , , , CC: , , , , , Subject: [PATCH 0/3] Enable the profiling of EL0&1 translation regime of ARM SPE Date: Wed, 22 Nov 2023 16:45:59 +0800 Message-ID: <20231122084602.53914-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: dggems704-chm.china.huawei.com (10.3.19.181) 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-20231122_004926_324161_74605C24 X-CRM114-Status: GOOD ( 10.64 ) 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 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(-)