1*1b4c136bSAlex Bennée /*
2*1b4c136bSAlex Bennée * Copyright (C) 2023, Pierrick Bouvier <pierrick.bouvier@linaro.org>
3*1b4c136bSAlex Bennée *
4*1b4c136bSAlex Bennée * Demonstrates and tests usage of inline ops.
5*1b4c136bSAlex Bennée *
6*1b4c136bSAlex Bennée * License: GNU GPL, version 2 or later.
7*1b4c136bSAlex Bennée * See the COPYING file in the top-level directory.
8*1b4c136bSAlex Bennée */
9*1b4c136bSAlex Bennée
10*1b4c136bSAlex Bennée #include <glib.h>
11*1b4c136bSAlex Bennée #include <stdint.h>
12*1b4c136bSAlex Bennée #include <stdio.h>
13*1b4c136bSAlex Bennée
14*1b4c136bSAlex Bennée #include <qemu-plugin.h>
15*1b4c136bSAlex Bennée
16*1b4c136bSAlex Bennée typedef struct {
17*1b4c136bSAlex Bennée uint64_t count_tb;
18*1b4c136bSAlex Bennée uint64_t count_tb_inline;
19*1b4c136bSAlex Bennée uint64_t count_insn;
20*1b4c136bSAlex Bennée uint64_t count_insn_inline;
21*1b4c136bSAlex Bennée uint64_t count_mem;
22*1b4c136bSAlex Bennée uint64_t count_mem_inline;
23*1b4c136bSAlex Bennée uint64_t tb_cond_num_trigger;
24*1b4c136bSAlex Bennée uint64_t tb_cond_track_count;
25*1b4c136bSAlex Bennée uint64_t insn_cond_num_trigger;
26*1b4c136bSAlex Bennée uint64_t insn_cond_track_count;
27*1b4c136bSAlex Bennée } CPUCount;
28*1b4c136bSAlex Bennée
29*1b4c136bSAlex Bennée static const uint64_t cond_trigger_limit = 100;
30*1b4c136bSAlex Bennée
31*1b4c136bSAlex Bennée typedef struct {
32*1b4c136bSAlex Bennée uint64_t data_insn;
33*1b4c136bSAlex Bennée uint64_t data_tb;
34*1b4c136bSAlex Bennée uint64_t data_mem;
35*1b4c136bSAlex Bennée } CPUData;
36*1b4c136bSAlex Bennée
37*1b4c136bSAlex Bennée static struct qemu_plugin_scoreboard *counts;
38*1b4c136bSAlex Bennée static qemu_plugin_u64 count_tb;
39*1b4c136bSAlex Bennée static qemu_plugin_u64 count_tb_inline;
40*1b4c136bSAlex Bennée static qemu_plugin_u64 count_insn;
41*1b4c136bSAlex Bennée static qemu_plugin_u64 count_insn_inline;
42*1b4c136bSAlex Bennée static qemu_plugin_u64 count_mem;
43*1b4c136bSAlex Bennée static qemu_plugin_u64 count_mem_inline;
44*1b4c136bSAlex Bennée static qemu_plugin_u64 tb_cond_num_trigger;
45*1b4c136bSAlex Bennée static qemu_plugin_u64 tb_cond_track_count;
46*1b4c136bSAlex Bennée static qemu_plugin_u64 insn_cond_num_trigger;
47*1b4c136bSAlex Bennée static qemu_plugin_u64 insn_cond_track_count;
48*1b4c136bSAlex Bennée static struct qemu_plugin_scoreboard *data;
49*1b4c136bSAlex Bennée static qemu_plugin_u64 data_insn;
50*1b4c136bSAlex Bennée static qemu_plugin_u64 data_tb;
51*1b4c136bSAlex Bennée static qemu_plugin_u64 data_mem;
52*1b4c136bSAlex Bennée
53*1b4c136bSAlex Bennée static uint64_t global_count_tb;
54*1b4c136bSAlex Bennée static uint64_t global_count_insn;
55*1b4c136bSAlex Bennée static uint64_t global_count_mem;
56*1b4c136bSAlex Bennée static unsigned int max_cpu_index;
57*1b4c136bSAlex Bennée static GMutex tb_lock;
58*1b4c136bSAlex Bennée static GMutex insn_lock;
59*1b4c136bSAlex Bennée static GMutex mem_lock;
60*1b4c136bSAlex Bennée
61*1b4c136bSAlex Bennée QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
62*1b4c136bSAlex Bennée
stats_insn(void)63*1b4c136bSAlex Bennée static void stats_insn(void)
64*1b4c136bSAlex Bennée {
65*1b4c136bSAlex Bennée const uint64_t expected = global_count_insn;
66*1b4c136bSAlex Bennée const uint64_t per_vcpu = qemu_plugin_u64_sum(count_insn);
67*1b4c136bSAlex Bennée const uint64_t inl_per_vcpu =
68*1b4c136bSAlex Bennée qemu_plugin_u64_sum(count_insn_inline);
69*1b4c136bSAlex Bennée const uint64_t cond_num_trigger =
70*1b4c136bSAlex Bennée qemu_plugin_u64_sum(insn_cond_num_trigger);
71*1b4c136bSAlex Bennée const uint64_t cond_track_left = qemu_plugin_u64_sum(insn_cond_track_count);
72*1b4c136bSAlex Bennée const uint64_t conditional =
73*1b4c136bSAlex Bennée cond_num_trigger * cond_trigger_limit + cond_track_left;
74*1b4c136bSAlex Bennée g_autoptr(GString) stats = g_string_new("");
75*1b4c136bSAlex Bennée g_string_append_printf(stats, "insn: %" PRIu64 "\n", expected);
76*1b4c136bSAlex Bennée g_string_append_printf(stats, "insn: %" PRIu64 " (per vcpu)\n", per_vcpu);
77*1b4c136bSAlex Bennée g_string_append_printf(stats, "insn: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu);
78*1b4c136bSAlex Bennée g_string_append_printf(stats, "insn: %" PRIu64 " (cond cb)\n", conditional);
79*1b4c136bSAlex Bennée qemu_plugin_outs(stats->str);
80*1b4c136bSAlex Bennée g_assert(expected > 0);
81*1b4c136bSAlex Bennée g_assert(per_vcpu == expected);
82*1b4c136bSAlex Bennée g_assert(inl_per_vcpu == expected);
83*1b4c136bSAlex Bennée g_assert(conditional == expected);
84*1b4c136bSAlex Bennée }
85*1b4c136bSAlex Bennée
stats_tb(void)86*1b4c136bSAlex Bennée static void stats_tb(void)
87*1b4c136bSAlex Bennée {
88*1b4c136bSAlex Bennée const uint64_t expected = global_count_tb;
89*1b4c136bSAlex Bennée const uint64_t per_vcpu = qemu_plugin_u64_sum(count_tb);
90*1b4c136bSAlex Bennée const uint64_t inl_per_vcpu =
91*1b4c136bSAlex Bennée qemu_plugin_u64_sum(count_tb_inline);
92*1b4c136bSAlex Bennée const uint64_t cond_num_trigger = qemu_plugin_u64_sum(tb_cond_num_trigger);
93*1b4c136bSAlex Bennée const uint64_t cond_track_left = qemu_plugin_u64_sum(tb_cond_track_count);
94*1b4c136bSAlex Bennée const uint64_t conditional =
95*1b4c136bSAlex Bennée cond_num_trigger * cond_trigger_limit + cond_track_left;
96*1b4c136bSAlex Bennée g_autoptr(GString) stats = g_string_new("");
97*1b4c136bSAlex Bennée g_string_append_printf(stats, "tb: %" PRIu64 "\n", expected);
98*1b4c136bSAlex Bennée g_string_append_printf(stats, "tb: %" PRIu64 " (per vcpu)\n", per_vcpu);
99*1b4c136bSAlex Bennée g_string_append_printf(stats, "tb: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu);
100*1b4c136bSAlex Bennée g_string_append_printf(stats, "tb: %" PRIu64 " (conditional cb)\n", conditional);
101*1b4c136bSAlex Bennée qemu_plugin_outs(stats->str);
102*1b4c136bSAlex Bennée g_assert(expected > 0);
103*1b4c136bSAlex Bennée g_assert(per_vcpu == expected);
104*1b4c136bSAlex Bennée g_assert(inl_per_vcpu == expected);
105*1b4c136bSAlex Bennée g_assert(conditional == expected);
106*1b4c136bSAlex Bennée }
107*1b4c136bSAlex Bennée
stats_mem(void)108*1b4c136bSAlex Bennée static void stats_mem(void)
109*1b4c136bSAlex Bennée {
110*1b4c136bSAlex Bennée const uint64_t expected = global_count_mem;
111*1b4c136bSAlex Bennée const uint64_t per_vcpu = qemu_plugin_u64_sum(count_mem);
112*1b4c136bSAlex Bennée const uint64_t inl_per_vcpu =
113*1b4c136bSAlex Bennée qemu_plugin_u64_sum(count_mem_inline);
114*1b4c136bSAlex Bennée g_autoptr(GString) stats = g_string_new("");
115*1b4c136bSAlex Bennée g_string_append_printf(stats, "mem: %" PRIu64 "\n", expected);
116*1b4c136bSAlex Bennée g_string_append_printf(stats, "mem: %" PRIu64 " (per vcpu)\n", per_vcpu);
117*1b4c136bSAlex Bennée g_string_append_printf(stats, "mem: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu);
118*1b4c136bSAlex Bennée qemu_plugin_outs(stats->str);
119*1b4c136bSAlex Bennée g_assert(expected > 0);
120*1b4c136bSAlex Bennée g_assert(per_vcpu == expected);
121*1b4c136bSAlex Bennée g_assert(inl_per_vcpu == expected);
122*1b4c136bSAlex Bennée }
123*1b4c136bSAlex Bennée
plugin_exit(qemu_plugin_id_t id,void * udata)124*1b4c136bSAlex Bennée static void plugin_exit(qemu_plugin_id_t id, void *udata)
125*1b4c136bSAlex Bennée {
126*1b4c136bSAlex Bennée const unsigned int num_cpus = qemu_plugin_num_vcpus();
127*1b4c136bSAlex Bennée g_autoptr(GString) stats = g_string_new("");
128*1b4c136bSAlex Bennée g_assert(num_cpus == max_cpu_index + 1);
129*1b4c136bSAlex Bennée
130*1b4c136bSAlex Bennée for (int i = 0; i < num_cpus ; ++i) {
131*1b4c136bSAlex Bennée const uint64_t tb = qemu_plugin_u64_get(count_tb, i);
132*1b4c136bSAlex Bennée const uint64_t tb_inline = qemu_plugin_u64_get(count_tb_inline, i);
133*1b4c136bSAlex Bennée const uint64_t insn = qemu_plugin_u64_get(count_insn, i);
134*1b4c136bSAlex Bennée const uint64_t insn_inline = qemu_plugin_u64_get(count_insn_inline, i);
135*1b4c136bSAlex Bennée const uint64_t mem = qemu_plugin_u64_get(count_mem, i);
136*1b4c136bSAlex Bennée const uint64_t mem_inline = qemu_plugin_u64_get(count_mem_inline, i);
137*1b4c136bSAlex Bennée const uint64_t tb_cond_trigger =
138*1b4c136bSAlex Bennée qemu_plugin_u64_get(tb_cond_num_trigger, i);
139*1b4c136bSAlex Bennée const uint64_t tb_cond_left =
140*1b4c136bSAlex Bennée qemu_plugin_u64_get(tb_cond_track_count, i);
141*1b4c136bSAlex Bennée const uint64_t insn_cond_trigger =
142*1b4c136bSAlex Bennée qemu_plugin_u64_get(insn_cond_num_trigger, i);
143*1b4c136bSAlex Bennée const uint64_t insn_cond_left =
144*1b4c136bSAlex Bennée qemu_plugin_u64_get(insn_cond_track_count, i);
145*1b4c136bSAlex Bennée g_string_printf(stats, "cpu %d: tb (%" PRIu64 ", %" PRIu64
146*1b4c136bSAlex Bennée ", %" PRIu64 " * %" PRIu64 " + %" PRIu64
147*1b4c136bSAlex Bennée ") | "
148*1b4c136bSAlex Bennée "insn (%" PRIu64 ", %" PRIu64
149*1b4c136bSAlex Bennée ", %" PRIu64 " * %" PRIu64 " + %" PRIu64
150*1b4c136bSAlex Bennée ") | "
151*1b4c136bSAlex Bennée "mem (%" PRIu64 ", %" PRIu64 ")"
152*1b4c136bSAlex Bennée "\n",
153*1b4c136bSAlex Bennée i,
154*1b4c136bSAlex Bennée tb, tb_inline,
155*1b4c136bSAlex Bennée tb_cond_trigger, cond_trigger_limit, tb_cond_left,
156*1b4c136bSAlex Bennée insn, insn_inline,
157*1b4c136bSAlex Bennée insn_cond_trigger, cond_trigger_limit, insn_cond_left,
158*1b4c136bSAlex Bennée mem, mem_inline);
159*1b4c136bSAlex Bennée qemu_plugin_outs(stats->str);
160*1b4c136bSAlex Bennée g_assert(tb == tb_inline);
161*1b4c136bSAlex Bennée g_assert(insn == insn_inline);
162*1b4c136bSAlex Bennée g_assert(mem == mem_inline);
163*1b4c136bSAlex Bennée g_assert(tb_cond_trigger == tb / cond_trigger_limit);
164*1b4c136bSAlex Bennée g_assert(tb_cond_left == tb % cond_trigger_limit);
165*1b4c136bSAlex Bennée g_assert(insn_cond_trigger == insn / cond_trigger_limit);
166*1b4c136bSAlex Bennée g_assert(insn_cond_left == insn % cond_trigger_limit);
167*1b4c136bSAlex Bennée }
168*1b4c136bSAlex Bennée
169*1b4c136bSAlex Bennée stats_tb();
170*1b4c136bSAlex Bennée stats_insn();
171*1b4c136bSAlex Bennée stats_mem();
172*1b4c136bSAlex Bennée
173*1b4c136bSAlex Bennée qemu_plugin_scoreboard_free(counts);
174*1b4c136bSAlex Bennée qemu_plugin_scoreboard_free(data);
175*1b4c136bSAlex Bennée }
176*1b4c136bSAlex Bennée
vcpu_tb_exec(unsigned int cpu_index,void * udata)177*1b4c136bSAlex Bennée static void vcpu_tb_exec(unsigned int cpu_index, void *udata)
178*1b4c136bSAlex Bennée {
179*1b4c136bSAlex Bennée qemu_plugin_u64_add(count_tb, cpu_index, 1);
180*1b4c136bSAlex Bennée g_assert(qemu_plugin_u64_get(data_tb, cpu_index) == (uintptr_t) udata);
181*1b4c136bSAlex Bennée g_mutex_lock(&tb_lock);
182*1b4c136bSAlex Bennée max_cpu_index = MAX(max_cpu_index, cpu_index);
183*1b4c136bSAlex Bennée global_count_tb++;
184*1b4c136bSAlex Bennée g_mutex_unlock(&tb_lock);
185*1b4c136bSAlex Bennée }
186*1b4c136bSAlex Bennée
vcpu_tb_cond_exec(unsigned int cpu_index,void * udata)187*1b4c136bSAlex Bennée static void vcpu_tb_cond_exec(unsigned int cpu_index, void *udata)
188*1b4c136bSAlex Bennée {
189*1b4c136bSAlex Bennée g_assert(qemu_plugin_u64_get(tb_cond_track_count, cpu_index) ==
190*1b4c136bSAlex Bennée cond_trigger_limit);
191*1b4c136bSAlex Bennée g_assert(qemu_plugin_u64_get(data_tb, cpu_index) == (uintptr_t) udata);
192*1b4c136bSAlex Bennée qemu_plugin_u64_set(tb_cond_track_count, cpu_index, 0);
193*1b4c136bSAlex Bennée qemu_plugin_u64_add(tb_cond_num_trigger, cpu_index, 1);
194*1b4c136bSAlex Bennée }
195*1b4c136bSAlex Bennée
vcpu_insn_cond_exec(unsigned int cpu_index,void * udata)196*1b4c136bSAlex Bennée static void vcpu_insn_cond_exec(unsigned int cpu_index, void *udata)
197*1b4c136bSAlex Bennée {
198*1b4c136bSAlex Bennée g_assert(qemu_plugin_u64_get(insn_cond_track_count, cpu_index) ==
199*1b4c136bSAlex Bennée cond_trigger_limit);
200*1b4c136bSAlex Bennée g_assert(qemu_plugin_u64_get(data_insn, cpu_index) == (uintptr_t) udata);
201*1b4c136bSAlex Bennée qemu_plugin_u64_set(insn_cond_track_count, cpu_index, 0);
202*1b4c136bSAlex Bennée qemu_plugin_u64_add(insn_cond_num_trigger, cpu_index, 1);
203*1b4c136bSAlex Bennée }
204*1b4c136bSAlex Bennée
vcpu_insn_exec(unsigned int cpu_index,void * udata)205*1b4c136bSAlex Bennée static void vcpu_insn_exec(unsigned int cpu_index, void *udata)
206*1b4c136bSAlex Bennée {
207*1b4c136bSAlex Bennée qemu_plugin_u64_add(count_insn, cpu_index, 1);
208*1b4c136bSAlex Bennée g_assert(qemu_plugin_u64_get(data_insn, cpu_index) == (uintptr_t) udata);
209*1b4c136bSAlex Bennée g_mutex_lock(&insn_lock);
210*1b4c136bSAlex Bennée global_count_insn++;
211*1b4c136bSAlex Bennée g_mutex_unlock(&insn_lock);
212*1b4c136bSAlex Bennée }
213*1b4c136bSAlex Bennée
vcpu_mem_access(unsigned int cpu_index,qemu_plugin_meminfo_t info,uint64_t vaddr,void * udata)214*1b4c136bSAlex Bennée static void vcpu_mem_access(unsigned int cpu_index,
215*1b4c136bSAlex Bennée qemu_plugin_meminfo_t info,
216*1b4c136bSAlex Bennée uint64_t vaddr,
217*1b4c136bSAlex Bennée void *udata)
218*1b4c136bSAlex Bennée {
219*1b4c136bSAlex Bennée qemu_plugin_u64_add(count_mem, cpu_index, 1);
220*1b4c136bSAlex Bennée g_assert(qemu_plugin_u64_get(data_mem, cpu_index) == (uintptr_t) udata);
221*1b4c136bSAlex Bennée g_mutex_lock(&mem_lock);
222*1b4c136bSAlex Bennée global_count_mem++;
223*1b4c136bSAlex Bennée g_mutex_unlock(&mem_lock);
224*1b4c136bSAlex Bennée }
225*1b4c136bSAlex Bennée
vcpu_tb_trans(qemu_plugin_id_t id,struct qemu_plugin_tb * tb)226*1b4c136bSAlex Bennée static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
227*1b4c136bSAlex Bennée {
228*1b4c136bSAlex Bennée void *tb_store = tb;
229*1b4c136bSAlex Bennée qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu(
230*1b4c136bSAlex Bennée tb, QEMU_PLUGIN_INLINE_STORE_U64, data_tb, (uintptr_t) tb_store);
231*1b4c136bSAlex Bennée qemu_plugin_register_vcpu_tb_exec_cb(
232*1b4c136bSAlex Bennée tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, tb_store);
233*1b4c136bSAlex Bennée qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu(
234*1b4c136bSAlex Bennée tb, QEMU_PLUGIN_INLINE_ADD_U64, count_tb_inline, 1);
235*1b4c136bSAlex Bennée
236*1b4c136bSAlex Bennée qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu(
237*1b4c136bSAlex Bennée tb, QEMU_PLUGIN_INLINE_ADD_U64, tb_cond_track_count, 1);
238*1b4c136bSAlex Bennée qemu_plugin_register_vcpu_tb_exec_cond_cb(
239*1b4c136bSAlex Bennée tb, vcpu_tb_cond_exec, QEMU_PLUGIN_CB_NO_REGS,
240*1b4c136bSAlex Bennée QEMU_PLUGIN_COND_EQ, tb_cond_track_count, cond_trigger_limit, tb_store);
241*1b4c136bSAlex Bennée
242*1b4c136bSAlex Bennée for (int idx = 0; idx < qemu_plugin_tb_n_insns(tb); ++idx) {
243*1b4c136bSAlex Bennée struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, idx);
244*1b4c136bSAlex Bennée void *insn_store = insn;
245*1b4c136bSAlex Bennée void *mem_store = (char *)insn_store + 0xff;
246*1b4c136bSAlex Bennée
247*1b4c136bSAlex Bennée qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(
248*1b4c136bSAlex Bennée insn, QEMU_PLUGIN_INLINE_STORE_U64, data_insn,
249*1b4c136bSAlex Bennée (uintptr_t) insn_store);
250*1b4c136bSAlex Bennée qemu_plugin_register_vcpu_insn_exec_cb(
251*1b4c136bSAlex Bennée insn, vcpu_insn_exec, QEMU_PLUGIN_CB_NO_REGS, insn_store);
252*1b4c136bSAlex Bennée qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(
253*1b4c136bSAlex Bennée insn, QEMU_PLUGIN_INLINE_ADD_U64, count_insn_inline, 1);
254*1b4c136bSAlex Bennée
255*1b4c136bSAlex Bennée qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(
256*1b4c136bSAlex Bennée insn, QEMU_PLUGIN_INLINE_ADD_U64, insn_cond_track_count, 1);
257*1b4c136bSAlex Bennée qemu_plugin_register_vcpu_insn_exec_cond_cb(
258*1b4c136bSAlex Bennée insn, vcpu_insn_cond_exec, QEMU_PLUGIN_CB_NO_REGS,
259*1b4c136bSAlex Bennée QEMU_PLUGIN_COND_EQ, insn_cond_track_count, cond_trigger_limit,
260*1b4c136bSAlex Bennée insn_store);
261*1b4c136bSAlex Bennée
262*1b4c136bSAlex Bennée qemu_plugin_register_vcpu_mem_inline_per_vcpu(
263*1b4c136bSAlex Bennée insn, QEMU_PLUGIN_MEM_RW,
264*1b4c136bSAlex Bennée QEMU_PLUGIN_INLINE_STORE_U64,
265*1b4c136bSAlex Bennée data_mem, (uintptr_t) mem_store);
266*1b4c136bSAlex Bennée qemu_plugin_register_vcpu_mem_cb(insn, &vcpu_mem_access,
267*1b4c136bSAlex Bennée QEMU_PLUGIN_CB_NO_REGS,
268*1b4c136bSAlex Bennée QEMU_PLUGIN_MEM_RW, mem_store);
269*1b4c136bSAlex Bennée qemu_plugin_register_vcpu_mem_inline_per_vcpu(
270*1b4c136bSAlex Bennée insn, QEMU_PLUGIN_MEM_RW,
271*1b4c136bSAlex Bennée QEMU_PLUGIN_INLINE_ADD_U64,
272*1b4c136bSAlex Bennée count_mem_inline, 1);
273*1b4c136bSAlex Bennée }
274*1b4c136bSAlex Bennée }
275*1b4c136bSAlex Bennée
276*1b4c136bSAlex Bennée QEMU_PLUGIN_EXPORT
qemu_plugin_install(qemu_plugin_id_t id,const qemu_info_t * info,int argc,char ** argv)277*1b4c136bSAlex Bennée int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
278*1b4c136bSAlex Bennée int argc, char **argv)
279*1b4c136bSAlex Bennée {
280*1b4c136bSAlex Bennée counts = qemu_plugin_scoreboard_new(sizeof(CPUCount));
281*1b4c136bSAlex Bennée count_tb = qemu_plugin_scoreboard_u64_in_struct(
282*1b4c136bSAlex Bennée counts, CPUCount, count_tb);
283*1b4c136bSAlex Bennée count_insn = qemu_plugin_scoreboard_u64_in_struct(
284*1b4c136bSAlex Bennée counts, CPUCount, count_insn);
285*1b4c136bSAlex Bennée count_mem = qemu_plugin_scoreboard_u64_in_struct(
286*1b4c136bSAlex Bennée counts, CPUCount, count_mem);
287*1b4c136bSAlex Bennée count_tb_inline = qemu_plugin_scoreboard_u64_in_struct(
288*1b4c136bSAlex Bennée counts, CPUCount, count_tb_inline);
289*1b4c136bSAlex Bennée count_insn_inline = qemu_plugin_scoreboard_u64_in_struct(
290*1b4c136bSAlex Bennée counts, CPUCount, count_insn_inline);
291*1b4c136bSAlex Bennée count_mem_inline = qemu_plugin_scoreboard_u64_in_struct(
292*1b4c136bSAlex Bennée counts, CPUCount, count_mem_inline);
293*1b4c136bSAlex Bennée tb_cond_num_trigger = qemu_plugin_scoreboard_u64_in_struct(
294*1b4c136bSAlex Bennée counts, CPUCount, tb_cond_num_trigger);
295*1b4c136bSAlex Bennée tb_cond_track_count = qemu_plugin_scoreboard_u64_in_struct(
296*1b4c136bSAlex Bennée counts, CPUCount, tb_cond_track_count);
297*1b4c136bSAlex Bennée insn_cond_num_trigger = qemu_plugin_scoreboard_u64_in_struct(
298*1b4c136bSAlex Bennée counts, CPUCount, insn_cond_num_trigger);
299*1b4c136bSAlex Bennée insn_cond_track_count = qemu_plugin_scoreboard_u64_in_struct(
300*1b4c136bSAlex Bennée counts, CPUCount, insn_cond_track_count);
301*1b4c136bSAlex Bennée data = qemu_plugin_scoreboard_new(sizeof(CPUData));
302*1b4c136bSAlex Bennée data_insn = qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data_insn);
303*1b4c136bSAlex Bennée data_tb = qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data_tb);
304*1b4c136bSAlex Bennée data_mem = qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data_mem);
305*1b4c136bSAlex Bennée
306*1b4c136bSAlex Bennée qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
307*1b4c136bSAlex Bennée qemu_plugin_register_atexit_cb(id, plugin_exit, NULL);
308*1b4c136bSAlex Bennée
309*1b4c136bSAlex Bennée return 0;
310*1b4c136bSAlex Bennée }
311