Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: arm64: Add trace reset to the nVHE/pKVM hyp

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>
Link: https://patch.msgid.link/20260309162516.2623589-27-vdonnefort@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>

authored by

Vincent Donnefort and committed by
Marc Zyngier
2194d317 b2288891

+29 -1
+1
arch/arm64/include/asm/kvm_asm.h
··· 94 94 __KVM_HOST_SMCCC_FUNC___tracing_enable, 95 95 __KVM_HOST_SMCCC_FUNC___tracing_swap_reader, 96 96 __KVM_HOST_SMCCC_FUNC___tracing_update_clock, 97 + __KVM_HOST_SMCCC_FUNC___tracing_reset, 97 98 }; 98 99 99 100 #define DECLARE_KVM_VHE_SYM(sym) extern char sym[]
+2
arch/arm64/kvm/hyp/include/nvhe/trace.h
··· 12 12 int __tracing_enable(bool enable); 13 13 int __tracing_swap_reader(unsigned int cpu); 14 14 void __tracing_update_clock(u32 mult, u32 shift, u64 epoch_ns, u64 epoch_cyc); 15 + int __tracing_reset(unsigned int cpu); 15 16 #else 16 17 static inline void *tracing_reserve_entry(unsigned long length) { return NULL; } 17 18 static inline void tracing_commit_entry(void) { } ··· 22 21 static inline int __tracing_enable(bool enable) { return -ENODEV; } 23 22 static inline int __tracing_swap_reader(unsigned int cpu) { return -ENODEV; } 24 23 static inline void __tracing_update_clock(u32 mult, u32 shift, u64 epoch_ns, u64 epoch_cyc) { } 24 + static inline int __tracing_reset(unsigned int cpu) { return -ENODEV; } 25 25 #endif 26 26 #endif
+8
arch/arm64/kvm/hyp/nvhe/hyp-main.c
··· 625 625 __tracing_update_clock(mult, shift, epoch_ns, epoch_cyc); 626 626 } 627 627 628 + static void handle___tracing_reset(struct kvm_cpu_context *host_ctxt) 629 + { 630 + DECLARE_REG(unsigned int, cpu, host_ctxt, 1); 631 + 632 + cpu_reg(host_ctxt, 1) = __tracing_reset(cpu); 633 + } 634 + 628 635 typedef void (*hcall_t)(struct kvm_cpu_context *); 629 636 630 637 #define HANDLE_FUNC(x) [__KVM_HOST_SMCCC_FUNC_##x] = (hcall_t)handle_##x ··· 678 671 HANDLE_FUNC(__tracing_enable), 679 672 HANDLE_FUNC(__tracing_swap_reader), 680 673 HANDLE_FUNC(__tracing_update_clock), 674 + HANDLE_FUNC(__tracing_reset), 681 675 }; 682 676 683 677 static void handle_host_hcall(struct kvm_cpu_context *host_ctxt)
+17
arch/arm64/kvm/hyp/nvhe/trace.c
··· 287 287 /* ...we can now override the old one and swap. */ 288 288 trace_clock_update(mult, shift, epoch_ns, epoch_cyc); 289 289 } 290 + 291 + int __tracing_reset(unsigned int cpu) 292 + { 293 + int ret = -ENODEV; 294 + 295 + if (cpu >= hyp_nr_cpus) 296 + return -EINVAL; 297 + 298 + hyp_spin_lock(&trace_buffer.lock); 299 + 300 + if (hyp_trace_buffer_loaded(&trace_buffer)) 301 + ret = simple_ring_buffer_reset(per_cpu_ptr(trace_buffer.simple_rbs, cpu)); 302 + 303 + hyp_spin_unlock(&trace_buffer.lock); 304 + 305 + return ret; 306 + }
+1 -1
arch/arm64/kvm/hyp_trace.c
··· 313 313 314 314 static int hyp_trace_reset(unsigned int cpu, void *priv) 315 315 { 316 - return 0; 316 + return kvm_call_hyp_nvhe(__tracing_reset, cpu); 317 317 } 318 318 319 319 static int hyp_trace_enable_event(unsigned short id, bool enable, void *priv)