• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #if !defined(__ARM64_KVM_HYPEVENTS_H_) || defined(HYP_EVENT_MULTI_READ)
4 #define __ARM64_KVM_HYPEVENTS_H_
5 
6 #ifdef __KVM_NVHE_HYPERVISOR__
7 #include <nvhe/trace.h>
8 #endif
9 
10 /*
11  * Hypervisor events definitions.
12  */
13 
14 #ifdef CONFIG_PKVM_FTRACE
15 HYP_EVENT(func,
16 	HE_PROTO(unsigned long ip, unsigned long parent),
17 	HE_STRUCT(
18 		he_field(unsigned long, ip)
19 		he_field(unsigned long, parent)
20 	),
21 	HE_ASSIGN(
22 		__entry->ip = ip;
23 		__entry->parent = parent;
24 	),
25 	HE_PRINTK("    %ps <- %ps", (void *)__entry->ip, (void *)__entry->parent)
26 );
27 
28 HYP_EVENT(func_ret,
29 	HE_PROTO(unsigned long ip),
30 	HE_STRUCT(
31 		he_field(unsigned long, ip)
32 	),
33 	HE_ASSIGN(
34 		__entry->ip = ip;
35 	),
36 	HE_PRINTK("%ps", (void *)__entry->ip)
37 );
38 #endif
39 
40 HYP_EVENT(hyp_enter,
41 	HE_PROTO(void),
42 	HE_STRUCT(
43 	),
44 	HE_ASSIGN(
45 	),
46 	HE_PRINTK(" ")
47 );
48 
49 HYP_EVENT(hyp_exit,
50 	HE_PROTO(void),
51 	HE_STRUCT(
52 	),
53 	HE_ASSIGN(
54 	),
55 	HE_PRINTK(" ")
56 );
57 
58 HYP_EVENT(host_hcall,
59 	HE_PROTO(unsigned int id, u8 invalid),
60 	HE_STRUCT(
61 		he_field(unsigned int, id)
62 		he_field(u8, invalid)
63 	),
64 	HE_ASSIGN(
65 		__entry->id = id;
66 		__entry->invalid = invalid;
67 	),
68 	HE_PRINTK("id=%u invalid=%u",
69 		  __entry->id, __entry->invalid)
70 );
71 
72 HYP_EVENT(host_smc,
73 	HE_PROTO(u64 id, u8 forwarded),
74 	HE_STRUCT(
75 		he_field(u64, id)
76 		he_field(u8, forwarded)
77 	),
78 	HE_ASSIGN(
79 		__entry->id = id;
80 		__entry->forwarded = forwarded;
81 	),
82 	HE_PRINTK("id=%llu forwarded=%u",
83 		  __entry->id, __entry->forwarded)
84 );
85 
86 
87 HYP_EVENT(host_mem_abort,
88 	HE_PROTO(u64 esr, u64 addr),
89 	HE_STRUCT(
90 		he_field(u64, esr)
91 		he_field(u64, addr)
92 	),
93 	HE_ASSIGN(
94 		__entry->esr = esr;
95 		__entry->addr = addr;
96 	),
97 	HE_PRINTK("esr=0x%llx addr=0x%llx",
98 		  __entry->esr, __entry->addr)
99 );
100 
101 HYP_EVENT(__hyp_printk,
102 	HE_PROTO(u8 fmt_id, u64 a, u64 b, u64 c, u64 d),
103 	HE_STRUCT(
104 		he_field(u8, fmt_id)
105 		he_field(u64, a)
106 		he_field(u64, b)
107 		he_field(u64, c)
108 		he_field(u64, d)
109 	),
110 	HE_ASSIGN(
111 		__entry->fmt_id = fmt_id;
112 		__entry->a = a;
113 		__entry->b = b;
114 		__entry->c = c;
115 		__entry->d = d;
116 	),
117 	HE_PRINTK_UNKNOWN_FMT(hyp_printk_fmt_from_id(__entry->fmt_id),
118 		__entry->a, __entry->b, __entry->c, __entry->d)
119 );
120 
121 HYP_EVENT(psci_mem_protect,
122 	HE_PROTO(u64 count, u64 was),
123 	HE_STRUCT(
124 		he_field(u64, count)
125 		he_field(u64, was)
126 	),
127 	HE_ASSIGN(
128 		__entry->count = count;
129 		__entry->was = was;
130 	),
131 	HE_PRINTK("count=%llu was=%llu", __entry->count, __entry->was)
132 );
133 
134 HYP_EVENT(vcpu_illegal_trap,
135 	HE_PROTO(u64 esr),
136 	HE_STRUCT(
137 		he_field(u64, esr)
138 	),
139 	HE_ASSIGN(
140 		__entry->esr = esr;
141 	),
142 	HE_PRINTK("esr_el2=%llx", __entry->esr)
143 );
144 
145 #ifdef CONFIG_PKVM_SELFTESTS
146 HYP_EVENT(selftest,
147 	  HE_PROTO(void),
148 	  HE_STRUCT(),
149 	  HE_ASSIGN(),
150 	  HE_PRINTK(" ")
151 );
152 #endif
153 
154 HYP_EVENT(iommu_idmap,
155 	HE_PROTO(u64 from, u64 to, int prot),
156 	HE_STRUCT(
157 		he_field(u64, from)
158 		he_field(u64, to)
159 		he_field(int, prot)
160 	),
161 	HE_ASSIGN(
162 		__entry->from = from;
163 		__entry->to = to;
164 		__entry->prot = prot;
165 	),
166 	HE_PRINTK("from=0x%llx to=0x%llx prot=0x%x", __entry->from, __entry->to, __entry->prot)
167 );
168 
169 HYP_EVENT(iommu_idmap_complete,
170 	HE_PROTO(bool map),
171 	HE_STRUCT(
172 		he_field(bool, map)
173 	),
174 	HE_ASSIGN(
175 		__entry->map = map;
176 	),
177 	HE_PRINTK("map=%d", __entry->map)
178 );
179 #endif /* __ARM64_KVM_HYPEVENTS_H_ */
180