Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1961379rdb; Tue, 5 Sep 2023 09:58:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGtpnQwPhMmLCVJHlcg+klKK49qCsZQpNObQDajlgwubN+WWGlUTU70AXXRb6GYTjfqJTca X-Received: by 2002:a17:903:2301:b0:1c2:c60:8388 with SMTP id d1-20020a170903230100b001c20c608388mr15927892plh.6.1693933082079; Tue, 05 Sep 2023 09:58:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693933082; cv=none; d=google.com; s=arc-20160816; b=KgT0YXtawuZr1/+HyE4zqY4kiRYaOk403YrprbdPgcHjmdDzKjPpLBY10CFQPh2RnA po6Nxif0WmfcWwLKECp0x9IGYl2+90lgNykoW9D/TVxPrXqodSi1AgHCNrNYANuxauK/ 2aUe6NUdsbFTrEgTaoSHvUi3vcAuJ5qb2wWEKVn73jMlTEXWReB4kk+oUbUjA24LDkE/ 9csM6Pjr2YsfUE9N3p/DR2ClUi2RId8vo1PScilXohhO/ew3e+Rmfcp15u0ThTcaHA5h aXOUCtKjig6ToRTE5KSMCKX5jn/PSOwqo6XZN5FOSDguRjU5d1F8JtXYHKMqhnpKpRcx Diew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=HQH8m44M6psqM4kegHoGskY+PNSUeIxo5jmtxbPdpGQ=; fh=CZ8D47g5ajU/lYMMT5yJI50pbG977oQ2Qy9mgmfgiEI=; b=gJfKGWQFRSETEikw6z4Wa0yW4HaSv/Vceet/ht8JuXwkMqss5/d+4LPqIR9hawy+Ni PLvfMWx+IHPgz+I6DS034eCvfAzqfh9msybyeOSRJEyvykb7/sl8auTHf88H+/wQycxj JrGRaCRC6Hq1DofnmsgWURwFx/BidlvFHuBp5z2AmnCharBr14eGAyqzNM+rzfn9SaMP 1TgXkG/02wyXB47+IGhiviB46pnANklCZUJ+ELRytuBsH0kOrT04+TUOi3bJu6USxBvD ZCipC6V5lgJn4f0B1YmPFCm9rC16rOooXMqIOaO6NJ1y7mhEUrofdSfo82roM+M2qkHP +RGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kv7-20020a17090328c700b001bdad5c05f7si9181390plb.546.2023.09.05.09.57.48; Tue, 05 Sep 2023 09:58:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241221AbjIEQih (ORCPT + 99 others); Tue, 5 Sep 2023 12:38:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354251AbjIEKV3 (ORCPT ); Tue, 5 Sep 2023 06:21:29 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CD0AA199 for ; Tue, 5 Sep 2023 03:21:25 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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(-) -- 2.34.1