Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1435213rdb; Mon, 4 Sep 2023 14:06:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHHvaoSMMy0uIycvPzRVxkxcULG+YgL8FH9EIEXKAq8N6zLSgZaSE1hh0h6ciqa5XFPiNK X-Received: by 2002:a05:6a00:1893:b0:68c:42:d3dd with SMTP id x19-20020a056a00189300b0068c0042d3ddmr11746421pfh.27.1693861599869; Mon, 04 Sep 2023 14:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693861599; cv=none; d=google.com; s=arc-20160816; b=I7FZx9e4YLoHyn6mcdc+i3jjS3hadOpYBctD2Bt/LELOHCwK4g7uvQdEf+7qNWc9mm u1xXJebNzItyIsA7Dc1t3SjnIGOpt1MY3K0lDMkEzB30U5d+avOMh1anTHGSmQxpvuTz zOSft4rE4QtwHOCVsSwsBbSY9Z6iSPCA8iw9T2JIFP7IOAGLiQ5KoFDqFea2xYqXQRsh dM5aJSzgE718Yl1q9XBE0XOgx7OJAsZvXMj3xDr5mj4bok17JVLaF3OViVfN2dFNozau Uw+nLq0oROeRd7pyEUpGphiTZR/Q4eRfHy2G8H6g9wSOo/abe6Eoka82TqKNkW9NcX5P jVyw== 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=VaJVRGV4wLmfz5EaIF/pPYMi9NEuHnnLrYVq8tFSMj0=; fh=CZ8D47g5ajU/lYMMT5yJI50pbG977oQ2Qy9mgmfgiEI=; b=GqWAGCA1cE0ONZnl6TNB10C4gp7ab370f1X4LodZFgNG1akqBF5bnCVmQ6hJv6Bj16 2W9q2bPTBH1IEi9LEIqgUSolr6SKOOZb8LX1NOa5sZwlzyVvORl2i7E2QCcF7UcoPdsM 6/nwMWX2vM6VLm/7z70mWC5LMG/6OioZY0XWkN8veU+yQzXBd+8iy7Nst/9iI2c/Dijk IRulm5RD6QQyIBsZJb6rDH+kECaoec3UufvfzAQS448pKr1ZfZAB2A/xMvVc336uIFFj PkB1EDFYjQHGUeDfhny/KMnkjJAvYCFa9PEss45erWQtJ5uMXi6FoYsDATSe/IkG1x+B ue1A== 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 f14-20020a056a00228e00b0068a412a90e9si8506556pfe.97.2023.09.04.14.06.26; Mon, 04 Sep 2023 14:06:39 -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 S1350277AbjIDOH1 (ORCPT + 99 others); Mon, 4 Sep 2023 10:07:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235306AbjIDOH0 (ORCPT ); Mon, 4 Sep 2023 10:07:26 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4A5A2CDB for ; Mon, 4 Sep 2023 07:07:23 -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 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 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]. 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(-) -- 2.34.1