From patchwork Tue Sep 5 10:21:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13374413 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 E6501C83F3E for ; Tue, 5 Sep 2023 10:22:03 +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=QR+KxP3jjc06U727gNim7mxvWljBiMzs2vy93imoRrM=; b=llN2p1SPcS8aDi /OAZ/7+06Rhqawpw+phx0Hl6TnBP7xvPL5s1R6UE+u1iU8ZpGGEe6mG9wpvk+KjBRr+6cNai9i83Z PgDKxhZ1Md1TJNh690R+T5wx7W3VB5lmPfdzD0L/vA1yv60f6rGK7ZF3gNcoRlDzWbr9qxQ0K06Oh XHol+OsuUbzv75F25VUhPvhh4v+PHzNGk3/Gx8hIjC8RtL9ZcfwzdIq6tZ6/XWlA3BqYPIyWLUkvF 5UUzJZcCgr5jdkNNdWCiSBfnR3ohRfD+UBzqmjSjCDyBYZa6K6BZLNTGwru9MAuvJPUp1ag0e9Wyd YOVKmJFfDOAYOSFmNkqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdTBd-005hek-1k; Tue, 05 Sep 2023 10:21:33 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdTBa-005hcg-2R for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 10:21:32 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7D70411FB; Tue, 5 Sep 2023 03:22:03 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1B4373F738; Tue, 5 Sep 2023 03:21:22 -0700 (PDT) From: James Clark To: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, broonie@kernel.org Cc: maz@kernel.org, James Clark , Catalin Marinas , Will Deacon , Suzuki K Poulose , Mike Leach , Leo Yan , Alexander Shishkin , James Morse , Kristina Martsenko , Anshuman Khandual , Rob Herring , Jintack Lim , Joey Gouly , linux-kernel@vger.kernel.org Subject: [PATCH v3 0/2] coresight: Allow guests to be traced when FEAT_TRF and VHE are present Date: Tue, 5 Sep 2023 11:21:13 +0100 Message-Id: <20230905102117.2011094-1-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230905_032130_862395_13491FA3 X-CRM114-Status: GOOD ( 15.53 ) 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 FEAT_TRF is a Coresight feature that allows trace capture to be completely filtered at different exception levels, unlike the existing TRCVICTLR controls which may still emit target addresses of branches, even if the following trace is filtered. Without FEAT_TRF, it was possible to start a trace session on a host and also collect trace from the guest as TRCVICTLR was never programmed to exclude guests (and it could still emit target addresses even if it was). Now when FEAT_TRF is present, because we don't write to TRFCR_EL1, guest trace will be completely disabled. This change fixes this issue, and also adds the ability to control it with the Perf exclude_host and exclude_guest flags. The first commit moves the register to sysreg because I add the EL12 version in the second commit. The test results have some single spurious EL2 addresses, but I don't think this is an issue with this patchset because it happens in the host-userspace case which maintains the existing programming of TRFCR. It's likely an issue with the model but I will follow it up separately. The corresponding change for nVHE is here [1]. The nVHE behaviour is is reversed, currently guest trace is always generated because the host already writes to TRFCR_EL1. This is the same both with and without FEAT_TRF. [1]: https://lore.kernel.org/kvmarm/20230804101317.460697-1-james.clark@arm.com/ --- Changes since v2: * E0TRE -> E0HTRE in TRFCR_EL2 to match Arm ARM * Add missing USE_TRFCR_EL1_TS enum value Changes since v1: * Split new sysreg definitions into TRFCR_EL2 and TRFCR_ELx so that TRFCR_ELx doesn't include CX which TRFCR_EL1 doesn't have. * Mask out TS and CX before writing to TRFCR_EL1 because it doesn't have CX and TS has no effect. * Expand cover letter James Clark (2): arm64/sysreg: Move TRFCR definitions to sysreg coresight: Allow guests to be traced when FEAT_TRF and VHE are present arch/arm64/include/asm/sysreg.h | 12 ----- arch/arm64/tools/sysreg | 41 +++++++++++++++ .../coresight/coresight-etm4x-core.c | 51 ++++++++++++++++--- drivers/hwtracing/coresight/coresight-etm4x.h | 2 +- drivers/hwtracing/coresight/coresight-priv.h | 3 ++ 5 files changed, 90 insertions(+), 19 deletions(-)