From patchwork Mon Sep 4 14:07:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13374059 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 82A1AC71153 for ; Mon, 4 Sep 2023 14:07:58 +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=kaDpVTfp4un+9qu93Lfy0v1YWCqhuPIJVgNvb1JsR5Y=; b=kPKQFmeBwQtexH smOyksT4nu4o4J3cM3no+Xdc4TF2luN4sHZZ9QXPHvaxEHv5twE2gIxZO/Qh/yq5ewzIn6zAe7c79 BxxfHpSO8KTrnnDG340UCoxXJmDEycWsuZIor8p353rhl9aCbx9ugiQrOg87O9+dzA6E6TMOyltpy u/BvHD5Z5vkri4NgCCeCw1puQq/KEopG/4Nb3iJV7SfErMSQqZ/KxwPpSA2d7b7oOrVupjU8Gq+UC 45LqfENQ3qoT8PGsVeu+EF0RFC1ewl4ZKhAjBQarH7k1BHkccCnAI4vQAzUcc424AUgJ7+qY7iQPF dDRrrJcKB1nYRGFC+P2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdAEp-004EPr-0b; Mon, 04 Sep 2023 14:07:35 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdAEk-004EOT-33 for linux-arm-kernel@lists.infradead.org; Mon, 04 Sep 2023 14:07: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 039A11474; Mon, 4 Sep 2023 07:08:01 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7D2353F766; Mon, 4 Sep 2023 07:07:15 -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 v2 0/2] coresight: Allow guests to be traced when FEAT_TRF and VHE are present Date: Mon, 4 Sep 2023 15:07:01 +0100 Message-Id: <20230904140705.1620708-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-20230904_070731_031979_93005FFF X-CRM114-Status: GOOD ( 15.89 ) 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]. With nVHE the behaviour 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 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 | 40 +++++++++++++++ .../coresight/coresight-etm4x-core.c | 51 ++++++++++++++++--- drivers/hwtracing/coresight/coresight-etm4x.h | 2 +- drivers/hwtracing/coresight/coresight-priv.h | 3 ++ 5 files changed, 89 insertions(+), 19 deletions(-)