Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/arm64/kvm/hyp/include/nvhe/trace.h
171056 views
1
/* SPDX-License-Identifier: GPL-2.0-only */
2
#ifndef __ARM64_KVM_HYP_NVHE_TRACE_H
3
#define __ARM64_KVM_HYP_NVHE_TRACE_H
4
5
#include <linux/trace_remote_event.h>
6
7
#include <asm/kvm_hyptrace.h>
8
9
static inline pid_t __tracing_get_vcpu_pid(struct kvm_cpu_context *host_ctxt)
10
{
11
struct kvm_vcpu *vcpu;
12
13
if (!host_ctxt)
14
host_ctxt = host_data_ptr(host_ctxt);
15
16
vcpu = host_ctxt->__hyp_running_vcpu;
17
18
return vcpu ? vcpu->arch.pid : 0;
19
}
20
21
#define HE_PROTO(__args...) __args
22
#define HE_ASSIGN(__args...) __args
23
#define HE_STRUCT RE_STRUCT
24
#define he_field re_field
25
26
#ifdef CONFIG_NVHE_EL2_TRACING
27
28
#define HYP_EVENT(__name, __proto, __struct, __assign, __printk) \
29
REMOTE_EVENT_FORMAT(__name, __struct); \
30
extern struct hyp_event_id hyp_event_id_##__name; \
31
static __always_inline void trace_##__name(__proto) \
32
{ \
33
struct remote_event_format_##__name *__entry; \
34
size_t length = sizeof(*__entry); \
35
\
36
if (!atomic_read(&hyp_event_id_##__name.enabled)) \
37
return; \
38
__entry = tracing_reserve_entry(length); \
39
if (!__entry) \
40
return; \
41
__entry->hdr.id = hyp_event_id_##__name.id; \
42
__assign \
43
tracing_commit_entry(); \
44
}
45
46
void *tracing_reserve_entry(unsigned long length);
47
void tracing_commit_entry(void);
48
49
int __tracing_load(unsigned long desc_va, size_t desc_size);
50
void __tracing_unload(void);
51
int __tracing_enable(bool enable);
52
int __tracing_swap_reader(unsigned int cpu);
53
void __tracing_update_clock(u32 mult, u32 shift, u64 epoch_ns, u64 epoch_cyc);
54
int __tracing_reset(unsigned int cpu);
55
int __tracing_enable_event(unsigned short id, bool enable);
56
#else
57
static inline void *tracing_reserve_entry(unsigned long length) { return NULL; }
58
static inline void tracing_commit_entry(void) { }
59
#define HYP_EVENT(__name, __proto, __struct, __assign, __printk) \
60
static inline void trace_##__name(__proto) {}
61
62
static inline int __tracing_load(unsigned long desc_va, size_t desc_size) { return -ENODEV; }
63
static inline void __tracing_unload(void) { }
64
static inline int __tracing_enable(bool enable) { return -ENODEV; }
65
static inline int __tracing_swap_reader(unsigned int cpu) { return -ENODEV; }
66
static inline void __tracing_update_clock(u32 mult, u32 shift, u64 epoch_ns, u64 epoch_cyc) { }
67
static inline int __tracing_reset(unsigned int cpu) { return -ENODEV; }
68
static inline int __tracing_enable_event(unsigned short id, bool enable) { return -ENODEV; }
69
#endif
70
#endif
71
72