From: Vincent Donnefort <vdonnefort@google.com>
To: rostedt@goodmis.org, mhiramat@kernel.org,
mathieu.desnoyers@efficios.com,
linux-trace-kernel@vger.kernel.org, maz@kernel.org,
oliver.upton@linux.dev, joey.gouly@arm.com,
suzuki.poulose@arm.com, yuzenghui@huawei.com
Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
jstultz@google.com, qperret@google.com, will@kernel.org,
aneesh.kumar@kernel.org, kernel-team@android.com,
linux-kernel@vger.kernel.org,
Vincent Donnefort <vdonnefort@google.com>
Subject: [PATCH v13 26/32] KVM: arm64: Add trace reset to the nVHE/pKVM hyp
Date: Fri, 6 Mar 2026 14:35:30 +0000 [thread overview]
Message-ID: <20260306143536.339777-27-vdonnefort@google.com> (raw)
In-Reply-To: <20260306143536.339777-1-vdonnefort@google.com>
Make the hypervisor reset either the whole tracing buffer or a specific
ring-buffer, on remotes/hypervisor/trace or per_cpu/<cpu>/trace write
access.
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h
index 9c4fe3bfbfff..66abf77cf371 100644
--- a/arch/arm64/include/asm/kvm_asm.h
+++ b/arch/arm64/include/asm/kvm_asm.h
@@ -94,6 +94,7 @@ enum __kvm_host_smccc_func {
__KVM_HOST_SMCCC_FUNC___tracing_enable,
__KVM_HOST_SMCCC_FUNC___tracing_swap_reader,
__KVM_HOST_SMCCC_FUNC___tracing_update_clock,
+ __KVM_HOST_SMCCC_FUNC___tracing_reset,
};
#define DECLARE_KVM_VHE_SYM(sym) extern char sym[]
diff --git a/arch/arm64/kvm/hyp/include/nvhe/trace.h b/arch/arm64/kvm/hyp/include/nvhe/trace.h
index fd641e1b1c23..44912869d184 100644
--- a/arch/arm64/kvm/hyp/include/nvhe/trace.h
+++ b/arch/arm64/kvm/hyp/include/nvhe/trace.h
@@ -12,6 +12,7 @@ void __tracing_unload(void);
int __tracing_enable(bool enable);
int __tracing_swap_reader(unsigned int cpu);
void __tracing_update_clock(u32 mult, u32 shift, u64 epoch_ns, u64 epoch_cyc);
+int __tracing_reset(unsigned int cpu);
#else
static inline void *tracing_reserve_entry(unsigned long length) { return NULL; }
static inline void tracing_commit_entry(void) { }
@@ -21,5 +22,6 @@ static inline void __tracing_unload(void) { }
static inline int __tracing_enable(bool enable) { return -ENODEV; }
static inline int __tracing_swap_reader(unsigned int cpu) { return -ENODEV; }
static inline void __tracing_update_clock(u32 mult, u32 shift, u64 epoch_ns, u64 epoch_cyc) { }
+static inline int __tracing_reset(unsigned int cpu) { return -ENODEV; }
#endif
#endif
diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
index 02d5271199d5..9b05f0c87586 100644
--- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
+++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
@@ -625,6 +625,13 @@ static void handle___tracing_update_clock(struct kvm_cpu_context *host_ctxt)
__tracing_update_clock(mult, shift, epoch_ns, epoch_cyc);
}
+static void handle___tracing_reset(struct kvm_cpu_context *host_ctxt)
+{
+ DECLARE_REG(unsigned int, cpu, host_ctxt, 1);
+
+ cpu_reg(host_ctxt, 1) = __tracing_reset(cpu);
+}
+
typedef void (*hcall_t)(struct kvm_cpu_context *);
#define HANDLE_FUNC(x) [__KVM_HOST_SMCCC_FUNC_##x] = (hcall_t)handle_##x
@@ -671,6 +678,7 @@ static const hcall_t host_hcall[] = {
HANDLE_FUNC(__tracing_enable),
HANDLE_FUNC(__tracing_swap_reader),
HANDLE_FUNC(__tracing_update_clock),
+ HANDLE_FUNC(__tracing_reset),
};
static void handle_host_hcall(struct kvm_cpu_context *host_ctxt)
diff --git a/arch/arm64/kvm/hyp/nvhe/trace.c b/arch/arm64/kvm/hyp/nvhe/trace.c
index 2c8e6f49d7de..a6ca27b18e15 100644
--- a/arch/arm64/kvm/hyp/nvhe/trace.c
+++ b/arch/arm64/kvm/hyp/nvhe/trace.c
@@ -287,3 +287,20 @@ void __tracing_update_clock(u32 mult, u32 shift, u64 epoch_ns, u64 epoch_cyc)
/* ...we can now override the old one and swap. */
trace_clock_update(mult, shift, epoch_ns, epoch_cyc);
}
+
+int __tracing_reset(unsigned int cpu)
+{
+ int ret = -ENODEV;
+
+ if (cpu >= hyp_nr_cpus)
+ return -EINVAL;
+
+ hyp_spin_lock(&trace_buffer.lock);
+
+ if (hyp_trace_buffer_loaded(&trace_buffer))
+ ret = simple_ring_buffer_reset(per_cpu_ptr(trace_buffer.simple_rbs, cpu));
+
+ hyp_spin_unlock(&trace_buffer.lock);
+
+ return ret;
+}
diff --git a/arch/arm64/kvm/hyp_trace.c b/arch/arm64/kvm/hyp_trace.c
index 1e5fc27f0e9d..09bc192e3514 100644
--- a/arch/arm64/kvm/hyp_trace.c
+++ b/arch/arm64/kvm/hyp_trace.c
@@ -313,7 +313,7 @@ static int hyp_trace_swap_reader_page(unsigned int cpu, void *priv)
static int hyp_trace_reset(unsigned int cpu, void *priv)
{
- return 0;
+ return kvm_call_hyp_nvhe(__tracing_reset, cpu);
}
static int hyp_trace_enable_event(unsigned short id, bool enable, void *priv)
--
2.53.0.473.g4a7958ca14-goog
next prev parent reply other threads:[~2026-03-06 14:36 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 14:35 [PATCH v13 00/32] Tracefs support for pKVM Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 01/32] ring-buffer: Add page statistics to the meta-page Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 02/32] ring-buffer: Store bpage pointers into subbuf_ids Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 03/32] ring-buffer: Introduce ring-buffer remotes Vincent Donnefort
2026-03-06 16:37 ` Markus Elfring
2026-03-11 15:23 ` Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 04/32] ring-buffer: Add non-consuming read for " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 05/32] tracing: Introduce trace remotes Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 06/32] tracing: Add reset to " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 07/32] tracing: Add non-consuming read " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 08/32] tracing: Add init callback " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 09/32] tracing: Add events " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 10/32] tracing: Add events/ root files " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 11/32] tracing: Add helpers to create trace remote events Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 12/32] ring-buffer: Export buffer_data_page and macros Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 13/32] tracing: Introduce simple_ring_buffer Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 14/32] tracing: Add a trace remote module for testing Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 15/32] tracing: selftests: Add trace remote tests Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 16/32] Documentation: tracing: Add tracing remotes Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 17/32] tracing: load/unload page callbacks for simple_ring_buffer Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 18/32] tracing: Check for undefined symbols in simple_ring_buffer Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 19/32] KVM: arm64: Add PKVM_DISABLE_STAGE2_ON_PANIC Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 20/32] KVM: arm64: Add clock support to nVHE/pKVM hyp Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 21/32] KVM: arm64: Initialise hyp_nr_cpus for nVHE hyp Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 22/32] KVM: arm64: Support unaligned fixmap in the pKVM hyp Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 23/32] KVM: arm64: Add tracing capability for the nVHE/pKVM hyp Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 24/32] KVM: arm64: Add trace remote " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 25/32] KVM: arm64: Sync boot clock with " Vincent Donnefort
2026-03-06 14:35 ` Vincent Donnefort [this message]
2026-03-06 14:35 ` [PATCH v13 27/32] KVM: arm64: Add event support to the nVHE/pKVM hyp and trace remote Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 28/32] KVM: arm64: Add hyp_enter/hyp_exit events to nVHE/pKVM hyp Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 29/32] KVM: arm64: Add selftest event support " Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 30/32] tracing: selftests: Add hypervisor trace remote tests Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 31/32] fixup! tracing: Add a trace remote module for testing Vincent Donnefort
2026-03-06 14:35 ` [PATCH v13 32/32] " Vincent Donnefort
2026-03-09 1:45 ` [PATCH v13 00/32] Tracefs support for pKVM Steven Rostedt
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=20260306143536.339777-27-vdonnefort@google.com \
--to=vdonnefort@google.com \
--cc=aneesh.kumar@kernel.org \
--cc=joey.gouly@arm.com \
--cc=jstultz@google.com \
--cc=kernel-team@android.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=maz@kernel.org \
--cc=mhiramat@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=qperret@google.com \
--cc=rostedt@goodmis.org \
--cc=suzuki.poulose@arm.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