From: James Clark <james.clark@linaro.org>
To: maz@kernel.org, kvmarm@lists.linux.dev, oliver.upton@linux.dev,
suzuki.poulose@arm.com, coresight@lists.linaro.org
Cc: James Clark <james.clark@linaro.org>,
Joey Gouly <joey.gouly@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Mike Leach <mike.leach@linaro.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Mark Rutland <mark.rutland@arm.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Mark Brown <broonie@kernel.org>,
James Morse <james.morse@arm.com>,
Shiqi Liu <shiqiliu@hust.edu.cn>, Fuad Tabba <tabba@google.com>,
"Rob Herring (Arm)" <robh@kernel.org>,
Raghavendra Rao Ananta <rananta@google.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v10 09/10] KVM: arm64: Support trace filtering for guests
Date: Tue, 7 Jan 2025 11:32:46 +0000 [thread overview]
Message-ID: <20250107113252.260631-10-james.clark@linaro.org> (raw)
In-Reply-To: <20250107113252.260631-1-james.clark@linaro.org>
For nVHE, switch the filter value in and out if the Coresight driver
asks for it. This will support filters for guests when sinks other than
TRBE are used.
For VHE, just write the filter directly to TRFCR_EL1 where trace can be
used even with TRBE sinks.
Signed-off-by: James Clark <james.clark@linaro.org>
---
arch/arm64/include/asm/kvm_host.h | 2 ++
arch/arm64/kvm/debug.c | 18 ++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index b244ec44bd3a..1284f4c2da27 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -1388,6 +1388,7 @@ void kvm_clr_pmu_events(u64 clr);
bool kvm_set_pmuserenr(u64 val);
void kvm_enable_trbe(void);
void kvm_disable_trbe(void);
+void kvm_tracing_set_el1_configuration(u64 trfcr_while_in_guest);
#else
static inline void kvm_set_pmu_events(u64 set, struct perf_event_attr *attr) {}
static inline void kvm_clr_pmu_events(u64 clr) {}
@@ -1397,6 +1398,7 @@ static inline bool kvm_set_pmuserenr(u64 val)
}
static inline void kvm_enable_trbe(void) {}
static inline void kvm_disable_trbe(void) {}
+static inline void kvm_tracing_set_el1_configuration(u64 trfcr_while_in_guest) {}
#endif
void kvm_vcpu_load_vhe(struct kvm_vcpu *vcpu);
diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c
index e1ac3d2a65be..22815a40d2ee 100644
--- a/arch/arm64/kvm/debug.c
+++ b/arch/arm64/kvm/debug.c
@@ -339,3 +339,21 @@ void kvm_disable_trbe(void)
host_data_clear_flag(TRBE_ENABLED);
}
EXPORT_SYMBOL_GPL(kvm_disable_trbe);
+
+void kvm_tracing_set_el1_configuration(u64 trfcr_while_in_guest)
+{
+ if (is_protected_kvm_enabled() || WARN_ON_ONCE(preemptible()))
+ return;
+
+ if (has_vhe()) {
+ write_sysreg_s(trfcr_while_in_guest, SYS_TRFCR_EL12);
+ return;
+ }
+
+ *host_data_ptr(trfcr_while_in_guest) = trfcr_while_in_guest;
+ if (read_sysreg_s(SYS_TRFCR_EL1) != trfcr_while_in_guest)
+ host_data_set_flag(EL1_TRACING_CONFIGURED);
+ else
+ host_data_clear_flag(EL1_TRACING_CONFIGURED);
+}
+EXPORT_SYMBOL_GPL(kvm_tracing_set_el1_configuration);
--
2.34.1
next prev parent reply other threads:[~2025-01-07 11:35 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 11:32 [PATCH v10 00/10] kvm/coresight: Support exclude guest and exclude host James Clark
2025-01-07 11:32 ` [PATCH v10 01/10] KVM: arm64: Drop MDSCR_EL1_DEBUG_MASK James Clark
2025-01-07 11:32 ` [PATCH v10 02/10] KVM: arm64: Get rid of __kvm_get_mdcr_el2() and related warts James Clark
2025-01-07 11:32 ` [PATCH v10 03/10] KVM: arm64: Track presence of SPE/TRBE in kvm_host_data instead of vCPU James Clark
2025-01-07 11:32 ` [PATCH v10 04/10] arm64/sysreg: Add a comment that the sysreg file should be sorted James Clark
2025-01-12 12:49 ` Marc Zyngier
2025-01-13 15:43 ` James Clark
2025-01-13 16:49 ` Marc Zyngier
2025-01-13 17:02 ` Mark Brown
2025-01-14 18:16 ` Rob Herring
2025-01-14 19:45 ` Mark Brown
2025-01-15 10:43 ` James Clark
2025-01-15 13:00 ` Mark Brown
2025-01-07 11:32 ` [PATCH v10 05/10] tools: arm64: Update sysreg.h header files James Clark
2025-01-07 11:32 ` [PATCH v10 06/10] arm64/sysreg/tools: Move TRFCR definitions to sysreg James Clark
2025-01-12 12:58 ` Marc Zyngier
2025-01-12 13:58 ` Marc Zyngier
2025-01-13 16:29 ` James Clark
2025-01-07 11:32 ` [PATCH v10 07/10] coresight: trbe: Remove redundant disable call James Clark
2025-01-07 11:32 ` [PATCH v10 08/10] KVM: arm64: coresight: Give TRBE enabled state to KVM James Clark
2025-01-07 11:32 ` James Clark [this message]
2025-01-07 11:32 ` [PATCH v10 10/10] coresight: Pass guest TRFCR value " James Clark
2025-01-12 14:02 ` (subset) [PATCH v10 00/10] kvm/coresight: Support exclude guest and exclude host Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250107113252.260631-10-james.clark@linaro.org \
--to=james.clark@linaro.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=anshuman.khandual@arm.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=coresight@lists.linaro.org \
--cc=james.morse@arm.com \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=mike.leach@linaro.org \
--cc=oliver.upton@linux.dev \
--cc=rananta@google.com \
--cc=robh@kernel.org \
--cc=shiqiliu@hust.edu.cn \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®