Path: blob/master/arch/arm64/kvm/hyp/include/nvhe/trace.h
171056 views
/* SPDX-License-Identifier: GPL-2.0-only */1#ifndef __ARM64_KVM_HYP_NVHE_TRACE_H2#define __ARM64_KVM_HYP_NVHE_TRACE_H34#include <linux/trace_remote_event.h>56#include <asm/kvm_hyptrace.h>78static inline pid_t __tracing_get_vcpu_pid(struct kvm_cpu_context *host_ctxt)9{10struct kvm_vcpu *vcpu;1112if (!host_ctxt)13host_ctxt = host_data_ptr(host_ctxt);1415vcpu = host_ctxt->__hyp_running_vcpu;1617return vcpu ? vcpu->arch.pid : 0;18}1920#define HE_PROTO(__args...) __args21#define HE_ASSIGN(__args...) __args22#define HE_STRUCT RE_STRUCT23#define he_field re_field2425#ifdef CONFIG_NVHE_EL2_TRACING2627#define HYP_EVENT(__name, __proto, __struct, __assign, __printk) \28REMOTE_EVENT_FORMAT(__name, __struct); \29extern struct hyp_event_id hyp_event_id_##__name; \30static __always_inline void trace_##__name(__proto) \31{ \32struct remote_event_format_##__name *__entry; \33size_t length = sizeof(*__entry); \34\35if (!atomic_read(&hyp_event_id_##__name.enabled)) \36return; \37__entry = tracing_reserve_entry(length); \38if (!__entry) \39return; \40__entry->hdr.id = hyp_event_id_##__name.id; \41__assign \42tracing_commit_entry(); \43}4445void *tracing_reserve_entry(unsigned long length);46void tracing_commit_entry(void);4748int __tracing_load(unsigned long desc_va, size_t desc_size);49void __tracing_unload(void);50int __tracing_enable(bool enable);51int __tracing_swap_reader(unsigned int cpu);52void __tracing_update_clock(u32 mult, u32 shift, u64 epoch_ns, u64 epoch_cyc);53int __tracing_reset(unsigned int cpu);54int __tracing_enable_event(unsigned short id, bool enable);55#else56static inline void *tracing_reserve_entry(unsigned long length) { return NULL; }57static inline void tracing_commit_entry(void) { }58#define HYP_EVENT(__name, __proto, __struct, __assign, __printk) \59static inline void trace_##__name(__proto) {}6061static inline int __tracing_load(unsigned long desc_va, size_t desc_size) { return -ENODEV; }62static inline void __tracing_unload(void) { }63static inline int __tracing_enable(bool enable) { return -ENODEV; }64static inline int __tracing_swap_reader(unsigned int cpu) { return -ENODEV; }65static inline void __tracing_update_clock(u32 mult, u32 shift, u64 epoch_ns, u64 epoch_cyc) { }66static inline int __tracing_reset(unsigned int cpu) { return -ENODEV; }67static inline int __tracing_enable_event(unsigned short id, bool enable) { return -ENODEV; }68#endif69#endif707172