From mboxrd@z Thu Jan 1 00:00:00 1970 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 4C64DC4345F for ; Fri, 12 Apr 2024 09:22:55 +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:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:CC:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=RgzGPZFAvnOjgwZhX2BKzX3lMon4jji/bqGNyNM3/ww=; b=FjPbh+EucCbHVG9YGpC/nHIWMR GrwPgm1bQ2e8b7mhNMUR9GCJ8byKhCDMhhSxaxnVioG0JRi9EU47y6XXlmJlzC7AZXDiT1dkvZU0g ZonQIKrCKY4V0k9xPD85F4HPvFJNbeYu7tRiSHzBX0gx/yiCHp2ndC5MATShntsJWQwd/QNAHNNLP zh491ckSdKG6HyaVai0XloFqZDTFW1kwIIPJk04O+WAEM+oLqxp+caLTbX04ymTuj54msGyp56Q08 c6BQ/T7P/xSROnzVzTUkHbxp1/Ksn+3cfHqQG+RFGCZYIs6rjl4Cubv86dstb7v3OmgbVBzr0JNx5 MLyI2+ew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvD7L-0000000GQNC-24b5; Fri, 12 Apr 2024 09:22:43 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvD7H-0000000GQKC-20JX for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 09:22:41 +0000 Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4VG9xk4LL0z1RC78; Fri, 12 Apr 2024 17:19:38 +0800 (CST) Received: from kwepemd200014.china.huawei.com (unknown [7.221.188.8]) by mail.maildlp.com (Postfix) with ESMTPS id 87F3A140156; Fri, 12 Apr 2024 17:22:32 +0800 (CST) Received: from [10.67.121.177] (10.67.121.177) by kwepemd200014.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Fri, 12 Apr 2024 17:22:31 +0800 CC: , , , , , , , , , , , , Subject: Re: [PATCH v2 3/3] perf: arm_spe: Enable the profiling of EL0&1 translation regime To: Will Deacon References: <20231130074609.58668-1-yangyicong@huawei.com> <20231130074609.58668-4-yangyicong@huawei.com> <20240411142829.GA26681@willie-the-truck> From: Yicong Yang Message-ID: Date: Fri, 12 Apr 2024 17:22:28 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <20240411142829.GA26681@willie-the-truck> X-Originating-IP: [10.67.121.177] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemd200014.china.huawei.com (7.221.188.8) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_022239_887679_92519C92 X-CRM114-Status: GOOD ( 19.30 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2024/4/11 22:28, Will Deacon wrote: > On Thu, Nov 30, 2023 at 03:46:09PM +0800, Yicong Yang wrote: >> From: Yicong Yang >> >> On a VHE enabled host, the PMSCR_EL1 will be redirect to PMSCR_EL2 >> and we're actually enabling E0SPE and E2SPE in the driver. This means >> the data from EL0&1 translation regime of a VM will not be profiled. >> So this patch tries to add the support of profiling EL0 and EL1 of >> a VM. Users can filter data of different exception level by using >> the perf's exclude_* attributes. The exclude_* decision is referred >> to Documentation/arch/arm64/perf.rst and the implementation of >> arm_pmuv3. >> >> Signed-off-by: Yicong Yang >> --- >> drivers/perf/arm_spe_pmu.c | 37 ++++++++++++++++++++++++++++++------- >> 1 file changed, 30 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c >> index 09570d4d63cd..a647d625f359 100644 >> --- a/drivers/perf/arm_spe_pmu.c >> +++ b/drivers/perf/arm_spe_pmu.c >> @@ -316,21 +316,44 @@ static u64 arm_spe_event_to_pmscr(struct perf_event *event) >> static void arm_spe_pmu_set_pmscr(struct perf_event *event) >> { >> struct perf_event_attr *attr = &event->attr; >> - u64 reg = 0; >> + u64 pmscr_el1, pmscr_el12; >> >> - reg = arm_spe_event_to_pmscr(event); >> - if (!attr->exclude_user) >> - reg |= PMSCR_EL1x_E0SPE; >> + pmscr_el1 = pmscr_el12 = arm_spe_event_to_pmscr(event); >> + >> + /* >> + * Map the exclude_* descision to ELx according to >> + * Documentation/arch/arm64/perf.rst. >> + */ >> + if (is_kernel_in_hyp_mode()) { >> + if (!attr->exclude_kernel && !attr->exclude_host) >> + pmscr_el1 |= PMSCR_EL1x_E1SPE; >> >> - if (!attr->exclude_kernel) >> - reg |= PMSCR_EL1x_E1SPE; >> + if (!attr->exclude_kernel && !attr->exclude_guest) >> + pmscr_el12 |= PMSCR_EL1x_E1SPE; >> + >> + if (!attr->exclude_user && !attr->exclude_host) { >> + pmscr_el1 |= PMSCR_EL1x_E0SPE; >> + pmscr_el12 |= PMSCR_EL1x_E0SPE; >> + } > > Hmm, I don't understand this part. Doesn't this mean that setting > 'exclude_host' to true will also exclude userspace (EL0) profiling for > the guest? > I may misunderstand 'exclude_host' in the doc. Yes we won't include EL0 here in the driver but we should handle it on guest enter/exit, which is missed in this patch. Will see how to handle it properly on guest enter/exit and respin a v3. Thanks. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel