From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F349834B1B6 for ; Thu, 19 Feb 2026 15:03:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771513438; cv=none; b=MYJ9zslAbRqv1avgyKlu2BHmKIZwOOa01ml2NJXHba1AfbTrJvlIxcmm6YUQfVnzdH3gGmGtTniwKaiLyeWhqj5w5U/mtitcZh9ulYPxD5WjPAC1Mh0EcwtDEp04d26+DQGUTfp91GfTewG36YPosX3ChHLwdx1yGdp49JE1vBE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771513438; c=relaxed/simple; bh=d6JjcNAg2Oni2j0Cc2qz7M5pf9n0QU8xi4fMnLP4/vc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=qMs5HkGzUjFkuYZwks/iTFv3J/sR3hem/ErKDvQhKCgsQefNXa97sl34PvWy0spTu2XxJ00o4Nlt0joQjbwX77Glfs/Ch26l5QJpwaSNBXuQi7WbcGTKndUWgeLTBAeKvsZjy6cHeHpD+VK+zZtSg0fH18pDXuTKFZfhKj90Xps= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--vdonnefort.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=G0d3Omze; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--vdonnefort.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="G0d3Omze" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4836abfc742so7366845e9.0 for ; Thu, 19 Feb 2026 07:03:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771513435; x=1772118235; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=s8Aoqn8UeoyisKs5heWso8axoywS653i0/sfLBOPKoY=; b=G0d3OmzeN5tC1DdUoZIkCtsx5G2Y7mEwbtAmMuODVvcqVwFnqGjoMLPmJDFLmbZzd9 rJCUQtMWvLZLHsD6ETBX2YGjQOLYt3b+zwceTLIt9uIqlo7vN8u+Bc5RQyoDYB/TprRg xuX0I5u14Hn/GlBrvxuVLc4MD9kzMmf2DKD/pix6+X7JmL3H9rkGHqPH8JdWRuLqyM50 88VeYQLckhb3FPZmHxbfYvD8j7PBfvgpP8HVLSw9mXQNsn3SetI0osOoRvJi/RewUBNM sxHuEnUg9ag+2nCyf2Agbi3b1nXfj3zNBjP+gQuIvx8O7jVEx3ee2Nt3IkpvBG8XUhDH s+7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771513435; x=1772118235; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=s8Aoqn8UeoyisKs5heWso8axoywS653i0/sfLBOPKoY=; b=sbDriGlsUnDEGD0nC7n7NJM+5YZ0klSIaq+ZlqCTw81jFc6hhclHeLe9076dQneavF JgAnbM9i7hhO73tvITkwHUDrJLDEFnRTWiDaA/mY3bSzSa4z4GtpkOjTNg1WZmAr5991 yLqy/6QQdWmvEoL8vs5FPOTwxpj1xWiN4H0XLqF3EaH8eqXSxX/QRT7OMbRsc+/v7mtv lDbqXCS01tJTjY7WNyWdNvAT5nnD/yNW/auIdXyhLo0SAqKuYBsTvQnlrCSDrrstiR9O WExsoG8GOdDpOjGQm5akjA8h9oiuu9APuCotSw8Ou8zpKXQpCoKRhP304A2ipVfCAPfg jbRg== X-Forwarded-Encrypted: i=1; AJvYcCUG0o+aksgD3UmNBdGZ7eILrebLPBV2MC6Ma9zD3m+2Sn38/Lt8wKkApVn6ahS4BRrxNQHxG6MObkDtt9FDlA/vH/A=@vger.kernel.org X-Gm-Message-State: AOJu0YwtKvQy96kAlmK1gzkUwFaCugzhDJTCGmVKJZmx19UHjzZlfsyp U3t2TQur40kP4MPW/sR4WJjswP2hW6Ab+A0C/cYKkkUUQTxpgZSjDdZodVKMX+1j+Q53JDSieWx WG0Vi1z9BW2VR5+SBm9isaQ== X-Received: from wmcn19.prod.google.com ([2002:a05:600c:c0d3:b0:483:6ff0:11a0]) (user=vdonnefort job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:314c:b0:477:54f9:6ac2 with SMTP id 5b1f17b1804b1-48379b318f6mr273945815e9.0.1771513434848; Thu, 19 Feb 2026 07:03:54 -0800 (PST) Date: Thu, 19 Feb 2026 15:03:03 +0000 In-Reply-To: <20260219150307.14538-1-vdonnefort@google.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260219150307.14538-1-vdonnefort@google.com> X-Mailer: git-send-email 2.53.0.335.g19a08e0c02-goog Message-ID: <20260219150307.14538-27-vdonnefort@google.com> Subject: [PATCH v12 26/30] KVM: arm64: Add trace reset to the nVHE/pKVM hyp From: Vincent Donnefort 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 Content-Type: text/plain; charset="UTF-8" Make the hypervisor reset either the whole tracing buffer or a specific ring-buffer, on remotes/hypervisor/trace or per_cpu//trace write access. Signed-off-by: Vincent Donnefort 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.335.g19a08e0c02-goog