xref: /openbmc/qemu/docs/devel/tcg-plugins.rst (revision 3011c1dd)
1..
2   Copyright (C) 2017, Emilio G. Cota <cota@braap.org>
3   Copyright (c) 2019, Linaro Limited
4   Written by Emilio Cota and Alex Bennée
5
6.. _TCG Plugins:
7
8QEMU TCG Plugins
9================
10
11QEMU TCG plugins provide a way for users to run experiments taking
12advantage of the total system control emulation can have over a guest.
13It provides a mechanism for plugins to subscribe to events during
14translation and execution and optionally callback into the plugin
15during these events. TCG plugins are unable to change the system state
16only monitor it passively. However they can do this down to an
17individual instruction granularity including potentially subscribing
18to all load and store operations.
19
20Usage
21-----
22
23Any QEMU binary with TCG support has plugins enabled by default.
24Earlier releases needed to be explicitly enabled with::
25
26  configure --enable-plugins
27
28Once built a program can be run with multiple plugins loaded each with
29their own arguments::
30
31  $QEMU $OTHER_QEMU_ARGS \
32      -plugin contrib/plugin/libhowvec.so,inline=on,count=hint \
33      -plugin contrib/plugin/libhotblocks.so
34
35Arguments are plugin specific and can be used to modify their
36behaviour. In this case the howvec plugin is being asked to use inline
37ops to count and break down the hint instructions by type.
38
39Linux user-mode emulation also evaluates the environment variable
40``QEMU_PLUGIN``::
41
42  QEMU_PLUGIN="file=contrib/plugins/libhowvec.so,inline=on,count=hint" $QEMU
43
44Writing plugins
45---------------
46
47API versioning
48~~~~~~~~~~~~~~
49
50This is a new feature for QEMU and it does allow people to develop
51out-of-tree plugins that can be dynamically linked into a running QEMU
52process. However the project reserves the right to change or break the
53API should it need to do so. The best way to avoid this is to submit
54your plugin upstream so they can be updated if/when the API changes.
55
56All plugins need to declare a symbol which exports the plugin API
57version they were built against. This can be done simply by::
58
59  QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
60
61The core code will refuse to load a plugin that doesn't export a
62``qemu_plugin_version`` symbol or if plugin version is outside of QEMU's
63supported range of API versions.
64
65Additionally the ``qemu_info_t`` structure which is passed to the
66``qemu_plugin_install`` method of a plugin will detail the minimum and
67current API versions supported by QEMU. The API version will be
68incremented if new APIs are added. The minimum API version will be
69incremented if existing APIs are changed or removed.
70
71Lifetime of the query handle
72~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73
74Each callback provides an opaque anonymous information handle which
75can usually be further queried to find out information about a
76translation, instruction or operation. The handles themselves are only
77valid during the lifetime of the callback so it is important that any
78information that is needed is extracted during the callback and saved
79by the plugin.
80
81Plugin life cycle
82~~~~~~~~~~~~~~~~~
83
84First the plugin is loaded and the public qemu_plugin_install function
85is called. The plugin will then register callbacks for various plugin
86events. Generally plugins will register a handler for the *atexit*
87if they want to dump a summary of collected information once the
88program/system has finished running.
89
90When a registered event occurs the plugin callback is invoked. The
91callbacks may provide additional information. In the case of a
92translation event the plugin has an option to enumerate the
93instructions in a block of instructions and optionally register
94callbacks to some or all instructions when they are executed.
95
96There is also a facility to add an inline event where code to
97increment a counter can be directly inlined with the translation.
98Currently only a simple increment is supported. This is not atomic so
99can miss counts. If you want absolute precision you should use a
100callback which can then ensure atomicity itself.
101
102Finally when QEMU exits all the registered *atexit* callbacks are
103invoked.
104
105Exposure of QEMU internals
106~~~~~~~~~~~~~~~~~~~~~~~~~~
107
108The plugin architecture actively avoids leaking implementation details
109about how QEMU's translation works to the plugins. While there are
110conceptions such as translation time and translation blocks the
111details are opaque to plugins. The plugin is able to query select
112details of instructions and system configuration only through the
113exported *qemu_plugin* functions.
114
115However the following assumptions can be made:
116
117Translation Blocks
118++++++++++++++++++
119
120All code will go through a translation phase although not all
121translations will be necessarily be executed. You need to instrument
122actual executions to track what is happening.
123
124It is quite normal to see the same address translated multiple times.
125If you want to track the code in system emulation you should examine
126the underlying physical address (``qemu_plugin_insn_haddr``) to take
127into account the effects of virtual memory although if the system does
128paging this will change too.
129
130Not all instructions in a block will always execute so if its
131important to track individual instruction execution you need to
132instrument them directly. However asynchronous interrupts will not
133change control flow mid-block.
134
135Instructions
136++++++++++++
137
138Instruction instrumentation runs before the instruction executes. You
139can be can be sure the instruction will be dispatched, but you can't
140be sure it will complete. Generally this will be because of a
141synchronous exception (e.g. SIGILL) triggered by the instruction
142attempting to execute. If you want to be sure you will need to
143instrument the next instruction as well. See the ``execlog.c`` plugin
144for examples of how to track this and finalise details after execution.
145
146Memory Accesses
147+++++++++++++++
148
149Memory callbacks are called after a successful load or store.
150Unsuccessful operations (i.e. faults) will not be visible to memory
151instrumentation although the execution side effects can be observed
152(e.g. entering a exception handler).
153
154System Idle and Resume States
155+++++++++++++++++++++++++++++
156
157The ``qemu_plugin_register_vcpu_idle_cb`` and
158``qemu_plugin_register_vcpu_resume_cb`` functions can be used to track
159when CPUs go into and return from sleep states when waiting for
160external I/O. Be aware though that these may occur less frequently
161than in real HW due to the inefficiencies of emulation giving less
162chance for the CPU to idle.
163
164Internals
165---------
166
167Locking
168~~~~~~~
169
170We have to ensure we cannot deadlock, particularly under MTTCG. For
171this we acquire a lock when called from plugin code. We also keep the
172list of callbacks under RCU so that we do not have to hold the lock
173when calling the callbacks. This is also for performance, since some
174callbacks (e.g. memory access callbacks) might be called very
175frequently.
176
177  * A consequence of this is that we keep our own list of CPUs, so that
178    we do not have to worry about locking order wrt cpu_list_lock.
179  * Use a recursive lock, since we can get registration calls from
180    callbacks.
181
182As a result registering/unregistering callbacks is "slow", since it
183takes a lock. But this is very infrequent; we want performance when
184calling (or not calling) callbacks, not when registering them. Using
185RCU is great for this.
186
187We support the uninstallation of a plugin at any time (e.g. from
188plugin callbacks). This allows plugins to remove themselves if they no
189longer want to instrument the code. This operation is asynchronous
190which means callbacks may still occur after the uninstall operation is
191requested. The plugin isn't completely uninstalled until the safe work
192has executed while all vCPUs are quiescent.
193
194Example Plugins
195===============
196
197There are a number of plugins included with QEMU and you are
198encouraged to contribute your own plugins plugins upstream. There is a
199``contrib/plugins`` directory where they can go. There are also some
200basic plugins that are used to test and exercise the API during the
201``make check-tcg`` target in ``tests\plugins``.
202
203- tests/plugins/empty.c
204
205Purely a test plugin for measuring the overhead of the plugins system
206itself. Does no instrumentation.
207
208- tests/plugins/bb.c
209
210A very basic plugin which will measure execution in course terms as
211each basic block is executed. By default the results are shown once
212execution finishes::
213
214  $ qemu-aarch64 -plugin tests/plugin/libbb.so \
215      -d plugin ./tests/tcg/aarch64-linux-user/sha1
216  SHA1=15dd99a1991e0b3826fede3deffc1feba42278e6
217  bb's: 2277338, insns: 158483046
218
219Behaviour can be tweaked with the following arguments:
220
221 * inline=true|false
222
223 Use faster inline addition of a single counter. Not per-cpu and not
224 thread safe.
225
226 * idle=true|false
227
228 Dump the current execution stats whenever the guest vCPU idles
229
230- tests/plugins/insn.c
231
232This is a basic instruction level instrumentation which can count the
233number of instructions executed on each core/thread::
234
235  $ qemu-aarch64 -plugin tests/plugin/libinsn.so \
236      -d plugin ./tests/tcg/aarch64-linux-user/threadcount
237  Created 10 threads
238  Done
239  cpu 0 insns: 46765
240  cpu 1 insns: 3694
241  cpu 2 insns: 3694
242  cpu 3 insns: 2994
243  cpu 4 insns: 1497
244  cpu 5 insns: 1497
245  cpu 6 insns: 1497
246  cpu 7 insns: 1497
247  total insns: 63135
248
249Behaviour can be tweaked with the following arguments:
250
251 * inline=true|false
252
253 Use faster inline addition of a single counter. Not per-cpu and not
254 thread safe.
255
256 * sizes=true|false
257
258 Give a summary of the instruction sizes for the execution
259
260 * match=<string>
261
262 Only instrument instructions matching the string prefix. Will show
263 some basic stats including how many instructions have executed since
264 the last execution. For example::
265
266   $ qemu-aarch64 -plugin tests/plugin/libinsn.so,match=bl \
267       -d plugin ./tests/tcg/aarch64-linux-user/sha512-vector
268   ...
269   0x40069c, 'bl #0x4002b0', 10 hits, 1093 match hits, Δ+1257 since last match, 98 avg insns/match
270   0x4006ac, 'bl #0x403690', 10 hits, 1094 match hits, Δ+47 since last match, 98 avg insns/match
271   0x4037fc, 'bl #0x4002b0', 18 hits, 1095 match hits, Δ+22 since last match, 98 avg insns/match
272   0x400720, 'bl #0x403690', 10 hits, 1096 match hits, Δ+58 since last match, 98 avg insns/match
273   0x4037fc, 'bl #0x4002b0', 19 hits, 1097 match hits, Δ+22 since last match, 98 avg insns/match
274   0x400730, 'bl #0x403690', 10 hits, 1098 match hits, Δ+33 since last match, 98 avg insns/match
275   0x4037ac, 'bl #0x4002b0', 12 hits, 1099 match hits, Δ+20 since last match, 98 avg insns/match
276   ...
277
278For more detailed execution tracing see the ``execlog`` plugin for
279other options.
280
281- tests/plugins/mem.c
282
283Basic instruction level memory instrumentation::
284
285  $ qemu-aarch64 -plugin tests/plugin/libmem.so,inline=true \
286      -d plugin ./tests/tcg/aarch64-linux-user/sha1
287  SHA1=15dd99a1991e0b3826fede3deffc1feba42278e6
288  inline mem accesses: 79525013
289
290Behaviour can be tweaked with the following arguments:
291
292 * inline=true|false
293
294 Use faster inline addition of a single counter. Not per-cpu and not
295 thread safe.
296
297 * callback=true|false
298
299 Use callbacks on each memory instrumentation.
300
301 * hwaddr=true|false
302
303 Count IO accesses (only for system emulation)
304
305- tests/plugins/syscall.c
306
307A basic syscall tracing plugin. This only works for user-mode. By
308default it will give a summary of syscall stats at the end of the
309run::
310
311  $ qemu-aarch64 -plugin tests/plugin/libsyscall \
312      -d plugin ./tests/tcg/aarch64-linux-user/threadcount
313  Created 10 threads
314  Done
315  syscall no.  calls  errors
316  226          12     0
317  99           11     11
318  115          11     0
319  222          11     0
320  93           10     0
321  220          10     0
322  233          10     0
323  215          8      0
324  214          4      0
325  134          2      0
326  64           2      0
327  96           1      0
328  94           1      0
329  80           1      0
330  261          1      0
331  78           1      0
332  160          1      0
333  135          1      0
334
335- contrib/plugins/hotblocks.c
336
337The hotblocks plugin allows you to examine the where hot paths of
338execution are in your program. Once the program has finished you will
339get a sorted list of blocks reporting the starting PC, translation
340count, number of instructions and execution count. This will work best
341with linux-user execution as system emulation tends to generate
342re-translations as blocks from different programs get swapped in and
343out of system memory.
344
345If your program is single-threaded you can use the ``inline`` option for
346slightly faster (but not thread safe) counters.
347
348Example::
349
350  $ qemu-aarch64 \
351    -plugin contrib/plugins/libhotblocks.so -d plugin \
352    ./tests/tcg/aarch64-linux-user/sha1
353  SHA1=15dd99a1991e0b3826fede3deffc1feba42278e6
354  collected 903 entries in the hash table
355  pc, tcount, icount, ecount
356  0x0000000041ed10, 1, 5, 66087
357  0x000000004002b0, 1, 4, 66087
358  ...
359
360- contrib/plugins/hotpages.c
361
362Similar to hotblocks but this time tracks memory accesses::
363
364  $ qemu-aarch64 \
365    -plugin contrib/plugins/libhotpages.so -d plugin \
366    ./tests/tcg/aarch64-linux-user/sha1
367  SHA1=15dd99a1991e0b3826fede3deffc1feba42278e6
368  Addr, RCPUs, Reads, WCPUs, Writes
369  0x000055007fe000, 0x0001, 31747952, 0x0001, 8835161
370  0x000055007ff000, 0x0001, 29001054, 0x0001, 8780625
371  0x00005500800000, 0x0001, 687465, 0x0001, 335857
372  0x0000000048b000, 0x0001, 130594, 0x0001, 355
373  0x0000000048a000, 0x0001, 1826, 0x0001, 11
374
375The hotpages plugin can be configured using the following arguments:
376
377  * sortby=reads|writes|address
378
379  Log the data sorted by either the number of reads, the number of writes, or
380  memory address. (Default: entries are sorted by the sum of reads and writes)
381
382  * io=on
383
384  Track IO addresses. Only relevant to full system emulation. (Default: off)
385
386  * pagesize=N
387
388  The page size used. (Default: N = 4096)
389
390- contrib/plugins/howvec.c
391
392This is an instruction classifier so can be used to count different
393types of instructions. It has a number of options to refine which get
394counted. You can give a value to the ``count`` argument for a class of
395instructions to break it down fully, so for example to see all the system
396registers accesses::
397
398  $ qemu-system-aarch64 $(QEMU_ARGS) \
399    -append "root=/dev/sda2 systemd.unit=benchmark.service" \
400    -smp 4 -plugin ./contrib/plugins/libhowvec.so,count=sreg -d plugin
401
402which will lead to a sorted list after the class breakdown::
403
404  Instruction Classes:
405  Class:   UDEF                   not counted
406  Class:   SVE                    (68 hits)
407  Class:   PCrel addr             (47789483 hits)
408  Class:   Add/Sub (imm)          (192817388 hits)
409  Class:   Logical (imm)          (93852565 hits)
410  Class:   Move Wide (imm)        (76398116 hits)
411  Class:   Bitfield               (44706084 hits)
412  Class:   Extract                (5499257 hits)
413  Class:   Cond Branch (imm)      (147202932 hits)
414  Class:   Exception Gen          (193581 hits)
415  Class:     NOP                  not counted
416  Class:   Hints                  (6652291 hits)
417  Class:   Barriers               (8001661 hits)
418  Class:   PSTATE                 (1801695 hits)
419  Class:   System Insn            (6385349 hits)
420  Class:   System Reg             counted individually
421  Class:   Branch (reg)           (69497127 hits)
422  Class:   Branch (imm)           (84393665 hits)
423  Class:   Cmp & Branch           (110929659 hits)
424  Class:   Tst & Branch           (44681442 hits)
425  Class:   AdvSimd ldstmult       (736 hits)
426  Class:   ldst excl              (9098783 hits)
427  Class:   Load Reg (lit)         (87189424 hits)
428  Class:   ldst noalloc pair      (3264433 hits)
429  Class:   ldst pair              (412526434 hits)
430  Class:   ldst reg (imm)         (314734576 hits)
431  Class: Loads & Stores           (2117774 hits)
432  Class: Data Proc Reg            (223519077 hits)
433  Class: Scalar FP                (31657954 hits)
434  Individual Instructions:
435  Instr: mrs x0, sp_el0           (2682661 hits)  (op=0xd5384100/  System Reg)
436  Instr: mrs x1, tpidr_el2        (1789339 hits)  (op=0xd53cd041/  System Reg)
437  Instr: mrs x2, tpidr_el2        (1513494 hits)  (op=0xd53cd042/  System Reg)
438  Instr: mrs x0, tpidr_el2        (1490823 hits)  (op=0xd53cd040/  System Reg)
439  Instr: mrs x1, sp_el0           (933793 hits)   (op=0xd5384101/  System Reg)
440  Instr: mrs x2, sp_el0           (699516 hits)   (op=0xd5384102/  System Reg)
441  Instr: mrs x4, tpidr_el2        (528437 hits)   (op=0xd53cd044/  System Reg)
442  Instr: mrs x30, ttbr1_el1       (480776 hits)   (op=0xd538203e/  System Reg)
443  Instr: msr ttbr1_el1, x30       (480713 hits)   (op=0xd518203e/  System Reg)
444  Instr: msr vbar_el1, x30        (480671 hits)   (op=0xd518c01e/  System Reg)
445  ...
446
447To find the argument shorthand for the class you need to examine the
448source code of the plugin at the moment, specifically the ``*opt``
449argument in the InsnClassExecCount tables.
450
451- contrib/plugins/lockstep.c
452
453This is a debugging tool for developers who want to find out when and
454where execution diverges after a subtle change to TCG code generation.
455It is not an exact science and results are likely to be mixed once
456asynchronous events are introduced. While the use of -icount can
457introduce determinism to the execution flow it doesn't always follow
458the translation sequence will be exactly the same. Typically this is
459caused by a timer firing to service the GUI causing a block to end
460early. However in some cases it has proved to be useful in pointing
461people at roughly where execution diverges. The only argument you need
462for the plugin is a path for the socket the two instances will
463communicate over::
464
465
466  $ qemu-system-sparc -monitor none -parallel none \
467    -net none -M SS-20 -m 256 -kernel day11/zImage.elf \
468    -plugin ./contrib/plugins/liblockstep.so,sockpath=lockstep-sparc.sock \
469    -d plugin,nochain
470
471which will eventually report::
472
473  qemu-system-sparc: warning: nic lance.0 has no peer
474  @ 0x000000ffd06678 vs 0x000000ffd001e0 (2/1 since last)
475  @ 0x000000ffd07d9c vs 0x000000ffd06678 (3/1 since last)
476  Δ insn_count @ 0x000000ffd07d9c (809900609) vs 0x000000ffd06678 (809900612)
477    previously @ 0x000000ffd06678/10 (809900609 insns)
478    previously @ 0x000000ffd001e0/4 (809900599 insns)
479    previously @ 0x000000ffd080ac/2 (809900595 insns)
480    previously @ 0x000000ffd08098/5 (809900593 insns)
481    previously @ 0x000000ffd080c0/1 (809900588 insns)
482
483- contrib/plugins/hwprofile.c
484
485The hwprofile tool can only be used with system emulation and allows
486the user to see what hardware is accessed how often. It has a number of options:
487
488 * track=read or track=write
489
490 By default the plugin tracks both reads and writes. You can use one
491 of these options to limit the tracking to just one class of accesses.
492
493 * source
494
495 Will include a detailed break down of what the guest PC that made the
496 access was. Not compatible with the pattern option. Example output::
497
498   cirrus-low-memory @ 0xfffffd00000a0000
499    pc:fffffc0000005cdc, 1, 256
500    pc:fffffc0000005ce8, 1, 256
501    pc:fffffc0000005cec, 1, 256
502
503 * pattern
504
505 Instead break down the accesses based on the offset into the HW
506 region. This can be useful for seeing the most used registers of a
507 device. Example output::
508
509    pci0-conf @ 0xfffffd01fe000000
510      off:00000004, 1, 1
511      off:00000010, 1, 3
512      off:00000014, 1, 3
513      off:00000018, 1, 2
514      off:0000001c, 1, 2
515      off:00000020, 1, 2
516      ...
517
518- contrib/plugins/execlog.c
519
520The execlog tool traces executed instructions with memory access. It can be used
521for debugging and security analysis purposes.
522Please be aware that this will generate a lot of output.
523
524The plugin needs default argument::
525
526  $ qemu-system-arm $(QEMU_ARGS) \
527    -plugin ./contrib/plugins/libexeclog.so -d plugin
528
529which will output an execution trace following this structure::
530
531  # vCPU, vAddr, opcode, disassembly[, load/store, memory addr, device]...
532  0, 0xa12, 0xf8012400, "movs r4, #0"
533  0, 0xa14, 0xf87f42b4, "cmp r4, r6"
534  0, 0xa16, 0xd206, "bhs #0xa26"
535  0, 0xa18, 0xfff94803, "ldr r0, [pc, #0xc]", load, 0x00010a28, RAM
536  0, 0xa1a, 0xf989f000, "bl #0xd30"
537  0, 0xd30, 0xfff9b510, "push {r4, lr}", store, 0x20003ee0, RAM, store, 0x20003ee4, RAM
538  0, 0xd32, 0xf9893014, "adds r0, #0x14"
539  0, 0xd34, 0xf9c8f000, "bl #0x10c8"
540  0, 0x10c8, 0xfff96c43, "ldr r3, [r0, #0x44]", load, 0x200000e4, RAM
541
542the output can be filtered to only track certain instructions or
543addresses using the ``ifilter`` or ``afilter`` options. You can stack the
544arguments if required::
545
546  $ qemu-system-arm $(QEMU_ARGS) \
547    -plugin ./contrib/plugins/libexeclog.so,ifilter=st1w,afilter=0x40001808 -d plugin
548
549This plugin can also dump registers when they change value. Specify the name of the
550registers with multiple ``reg`` options. You can also use glob style matching if you wish::
551
552  $ qemu-system-arm $(QEMU_ARGS) \
553    -plugin ./contrib/plugins/libexeclog.so,reg=\*_el2,reg=sp -d plugin
554
555Be aware that each additional register to check will slow down
556execution quite considerably. You can optimise the number of register
557checks done by using the rdisas option. This will only instrument
558instructions that mention the registers in question in disassembly.
559This is not foolproof as some instructions implicitly change
560instructions. You can use the ifilter to catch these cases:
561
562  $ qemu-system-arm $(QEMU_ARGS) \
563    -plugin ./contrib/plugins/libexeclog.so,ifilter=msr,ifilter=blr,reg=x30,reg=\*_el1,rdisas=on
564
565- contrib/plugins/cache.c
566
567Cache modelling plugin that measures the performance of a given L1 cache
568configuration, and optionally a unified L2 per-core cache when a given working
569set is run::
570
571  $ qemu-x86_64 -plugin ./contrib/plugins/libcache.so \
572      -d plugin -D cache.log ./tests/tcg/x86_64-linux-user/float_convs
573
574will report the following::
575
576    core #, data accesses, data misses, dmiss rate, insn accesses, insn misses, imiss rate
577    0       996695         508             0.0510%  2642799        18617           0.7044%
578
579    address, data misses, instruction
580    0x424f1e (_int_malloc), 109, movq %rax, 8(%rcx)
581    0x41f395 (_IO_default_xsputn), 49, movb %dl, (%rdi, %rax)
582    0x42584d (ptmalloc_init.part.0), 33, movaps %xmm0, (%rax)
583    0x454d48 (__tunables_init), 20, cmpb $0, (%r8)
584    ...
585
586    address, fetch misses, instruction
587    0x4160a0 (__vfprintf_internal), 744, movl $1, %ebx
588    0x41f0a0 (_IO_setb), 744, endbr64
589    0x415882 (__vfprintf_internal), 744, movq %r12, %rdi
590    0x4268a0 (__malloc), 696, andq $0xfffffffffffffff0, %rax
591    ...
592
593The plugin has a number of arguments, all of them are optional:
594
595  * limit=N
596
597  Print top N icache and dcache thrashing instructions along with their
598  address, number of misses, and its disassembly. (default: 32)
599
600  * icachesize=N
601  * iblksize=B
602  * iassoc=A
603
604  Instruction cache configuration arguments. They specify the cache size, block
605  size, and associativity of the instruction cache, respectively.
606  (default: N = 16384, B = 64, A = 8)
607
608  * dcachesize=N
609  * dblksize=B
610  * dassoc=A
611
612  Data cache configuration arguments. They specify the cache size, block size,
613  and associativity of the data cache, respectively.
614  (default: N = 16384, B = 64, A = 8)
615
616  * evict=POLICY
617
618  Sets the eviction policy to POLICY. Available policies are: :code:`lru`,
619  :code:`fifo`, and :code:`rand`. The plugin will use the specified policy for
620  both instruction and data caches. (default: POLICY = :code:`lru`)
621
622  * cores=N
623
624  Sets the number of cores for which we maintain separate icache and dcache.
625  (default: for linux-user, N = 1, for full system emulation: N = cores
626  available to guest)
627
628  * l2=on
629
630  Simulates a unified L2 cache (stores blocks for both instructions and data)
631  using the default L2 configuration (cache size = 2MB, associativity = 16-way,
632  block size = 64B).
633
634  * l2cachesize=N
635  * l2blksize=B
636  * l2assoc=A
637
638  L2 cache configuration arguments. They specify the cache size, block size, and
639  associativity of the L2 cache, respectively. Setting any of the L2
640  configuration arguments implies ``l2=on``.
641  (default: N = 2097152 (2MB), B = 64, A = 16)
642
643Plugin API
644==========
645
646The following API is generated from the inline documentation in
647``include/qemu/qemu-plugin.h``. Please ensure any updates to the API
648include the full kernel-doc annotations.
649
650.. kernel-doc:: include/qemu/qemu-plugin.h
651