VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/DBGFAllTracer.cpp@ 84478

Last change on this file since 84478 was 84458, checked in by vboxsync, 5 years ago

VMM/DBGF: First commit of new tracing facility, bugref:9210

The new DBGF tracing facility allows efficient capturing of events to a compact binary
trace log for later analysis. It is primarily intended for recording device/guest
interactions for now but can be extended easily for other types of events later on.
It supports capturing events happening in both R0 and R3 by using a shared ring buffer
to post events to. The events are processed by a dedicated I/O thread which writes
new events into the binary trace log file.

This is only the core VMM/DBGF part providing the API, the integration with PDM
comes in a separate commit.

Disabled by default for now because it is still work in progress,
enable with VBOX_WITH_DBGF_TRACING.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.2 KB
Line 
1/* $Id: DBGFAllTracer.cpp 84458 2020-05-22 12:51:49Z vboxsync $ */
2/** @file
3 * DBGF - Debugger Facility, All Context Code tracing part.
4 */
5
6/*
7 * Copyright (C) 2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#define LOG_GROUP LOG_GROUP_DBGF
23#include "DBGFInternal.h"
24#include <VBox/types.h>
25#include <VBox/err.h>
26#include <VBox/vmm/dbgf.h>
27#if defined(IN_RING3)
28# include <VBox/vmm/uvm.h>
29# include <VBox/vmm/vm.h>
30#elif defined(IN_RING0)
31# include <VBox/vmm/gvm.h>
32#else
33# error "Invalid environment"
34#endif
35
36
37/*********************************************************************************************************************************
38* Internal Functions *
39*********************************************************************************************************************************/
40
41/**
42 * Returns the current context tracer instance of the given VM instance.
43 *
44 * @returns Current context pointer to the DBGF tracer instance.
45 */
46DECLINLINE(PDBGFTRACERINSCC) dbgfTracerGetInstance(PVMCC pVM)
47{
48#if defined(IN_RING0)
49 return pVM->dbgfr0.s.pTracerR0;
50#elif defined(IN_RING3)
51 PUVM pUVM = pVM->pUVM;
52 return pUVM->dbgf.s.pTracerR3;
53#elif defined(IN_RC)
54# error "Not implemented"
55#else
56# error "No/Invalid context specified"
57#endif
58
59 return NULL;
60}
61
62
63/**
64 * Returns the size of the tracing ring buffer.
65 *
66 * @returns Size of the ring buffer in bytes.
67 * @param pThisCC The event tracer instance current context data.
68 */
69DECLINLINE(size_t) dbgfTracerGetRingBufSz(PDBGFTRACERINSCC pThisCC)
70{
71#if defined(IN_RING0) /* For R0 we are extra cautious and use the ring buffer size stored in R0 memory so R3 can't corrupt it. */
72 return pThisCC->cbRingBuf;
73#else
74 return pThisCC->CTX_SUFF(pShared)->cbRingBuf;
75#endif
76}
77
78
79/**
80 * Posts a single event descriptor to the ring buffer of the given tracer instance - extended version.
81 *
82 * @returns VBox status code.
83 * @param pVM The current context VM instance data.
84 * @param pThisCC The event tracer instance current context data.
85 * @param hEvtSrc The event source for the posted event.
86 * @param enmTraceEvt The trace event type posted.
87 * @param idEvtPrev The previous event ID the posted event links to.
88 * @param pvEvtDesc The event descriptor to copy after the header.
89 * @param cbEvtDesc Size of the event descriptor.
90 * @param pidEvt Where to store the assigned event ID, optional.
91 */
92static int dbgfTracerEvtPostEx(PVMCC pVM, PDBGFTRACERINSCC pThisCC, DBGFTRACEREVTSRC hEvtSrc,
93 DBGFTRACEREVT enmTraceEvt, uint64_t idEvtPrev, const void *pvEvtDesc,
94 size_t cbEvtDesc, uint64_t *pidEvt)
95{
96 PDBGFTRACERSHARED pSharedCC = pThisCC->CTX_SUFF(pShared);
97 size_t cRingBufEvts = dbgfTracerGetRingBufSz(pThisCC) / DBGF_TRACER_EVT_SZ;
98 AssertReturn(cRingBufEvts, VERR_DBGF_TRACER_IPE_1);
99 AssertReturn(cbEvtDesc <= DBGF_TRACER_EVT_PAYLOAD_SZ, VERR_DBGF_TRACER_IPE_1);
100
101 /* Grab a new event ID first. */
102 uint64_t idEvt = ASMAtomicIncU64(&pSharedCC->idEvt) - 1;
103 uint64_t idxRingBuf = idEvt % cRingBufEvts; /* This gives the index in the ring buffer for the event. */
104 PDBGFTRACEREVTHDR pEvtHdr = (PDBGFTRACEREVTHDR)(pThisCC->CTX_SUFF(pbRingBuf) + idxRingBuf * DBGF_TRACER_EVT_SZ);
105
106 if (RT_UNLIKELY(ASMAtomicReadU64(&pEvtHdr->idEvt) != DBGF_TRACER_EVT_HDR_ID_INVALID))
107 {
108 /** @todo The event ring buffer is full and we need to go back (from R0 to R3) and wait for the flusher thread to
109 * get its act together.
110 */
111 }
112
113 /* Write the event and kick the flush thread if necessary. */
114 memcpy(pEvtHdr + 1, pvEvtDesc, cbEvtDesc);
115 pEvtHdr->idEvtPrev = idEvtPrev;
116 pEvtHdr->hEvtSrc = hEvtSrc;
117 pEvtHdr->enmEvt = enmTraceEvt;
118 pEvtHdr->fFlags = DBGF_TRACER_EVT_HDR_F_DEFAULT;
119 ASMAtomicWriteU64(&pEvtHdr->idEvt, idEvt);
120
121 int rc = VINF_SUCCESS;
122 if (!ASMAtomicXchgBool(&pSharedCC->fEvtsWaiting, true))
123 {
124 if (!ASMAtomicXchgBool(&pSharedCC->fFlushThrdActive, true))
125 rc = SUPSemEventSignal(pVM->pSession, pSharedCC->hSupSemEvtFlush);
126 }
127
128 if (pidEvt)
129 *pidEvt = idEvt;
130 return rc;
131}
132
133
134/**
135 * Posts a single event descriptor to the ring buffer of the given tracer instance.
136 *
137 * @returns VBox status code.
138 * @param pVM The current context VM instance data.
139 * @param pThisCC The event tracer instance current context data.
140 * @param hEvtSrc The event source for the posted event.
141 * @param enmTraceEvt The trace event type posted.
142 * @param pvEvtDesc The event descriptor to copy after the header.
143 * @param pidEvt Where to store the assigned event ID, optional.
144 */
145DECLINLINE(int) dbgfTracerEvtPostSingle(PVMCC pVM, PDBGFTRACERINSCC pThisCC, DBGFTRACEREVTSRC hEvtSrc,
146 DBGFTRACEREVT enmTraceEvt, const void *pvEvtDesc, uint64_t *pidEvt)
147{
148 return dbgfTracerEvtPostEx(pVM, pThisCC, hEvtSrc, enmTraceEvt, DBGF_TRACER_EVT_HDR_ID_INVALID,
149 pvEvtDesc, DBGF_TRACER_EVT_PAYLOAD_SZ, pidEvt);
150}
151
152
153/**
154 * Copies the given MMIO value into the event descriptor based on the given size.
155 *
156 * @returns nothing.
157 * @param pEvtMmio Pointer to the MMIO event descriptor to fill.
158 * @param pvVal The value to copy.
159 * @param cbVal Size of the value in bytes.
160 */
161static void dbgfTracerEvtMmioCopyVal(PDBGFTRACEREVTMMIO pEvtMmio, const void *pvVal, size_t cbVal)
162{
163 switch (cbVal)
164 {
165 case 1:
166 pEvtMmio->u64Val = *(uint8_t *)pvVal;
167 break;
168 case 2:
169 pEvtMmio->u64Val = *(uint16_t *)pvVal;
170 break;
171 case 4:
172 pEvtMmio->u64Val = *(uint32_t *)pvVal;
173 break;
174 case 8:
175 pEvtMmio->u64Val = *(uint64_t *)pvVal;
176 break;
177 default:
178 AssertMsgFailed(("The value size %zu is not supported!\n", cbVal));
179 }
180}
181
182
183/**
184 * Copies the given I/O port value into the event descriptor based on the given size.
185 *
186 * @returns nothing.
187 * @param pEvtIoPort Pointer to the I/O port read/write event descriptor to fill.
188 * @param pvVal The value to copy.
189 * @param cbVal Size of the value in bytes.
190 */
191static void dbgfTracerEvtIoPortCopyVal(PDBGFTRACEREVTIOPORT pEvtIoPort, const void *pvVal, size_t cbVal)
192{
193 switch (cbVal)
194 {
195 case 1:
196 pEvtIoPort->u32Val = *(uint8_t *)pvVal;
197 break;
198 case 2:
199 pEvtIoPort->u32Val = *(uint16_t *)pvVal;
200 break;
201 case 4:
202 pEvtIoPort->u32Val = *(uint32_t *)pvVal;
203 break;
204 default:
205 AssertMsgFailed(("The value size %zu is not supported!\n", cbVal));
206 }
207}
208
209
210/**
211 * Handles a guest memory transfer event.
212 *
213 * @returns VBox status code.
214 * @param pVM The current context VM instance data.
215 * @param pThisCC The event tracer instance current context data.
216 * @param enmTraceEvt The trace event type posted.
217 * @param hEvtSrc The event source for the posted event.
218 * @param GCPhys The guest physical address the transfer starts at.
219 * @param pvBuf The data being transfered.
220 * @param cbXfer Number of bytes being transfered.
221 */
222static int dbgfTracerEvtGCPhys(PVMCC pVM, PDBGFTRACERINSCC pThisCC, DBGFTRACEREVT enmTraceEvt, DBGFTRACEREVTSRC hEvtSrc,
223 RTGCPHYS GCPhys, const void *pvBuf, size_t cbXfer)
224{
225 /* Fast path for really small transfers where everything fits into the descriptor. */
226 DBGFTRACEREVTGCPHYS EvtGCPhys;
227 EvtGCPhys.GCPhys = GCPhys;
228 EvtGCPhys.cbXfer = cbXfer;
229 if (cbXfer <= sizeof(EvtGCPhys.abData))
230 {
231 memcpy(&EvtGCPhys.abData[0], pvBuf, cbXfer);
232 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, enmTraceEvt, &EvtGCPhys, NULL /*pidEvt*/);
233 }
234
235 /*
236 * Slow path where we have to split the data into multiple entries.
237 * Each one is linked to the previous one by the previous event ID.
238 */
239 const uint8_t *pbBuf = (const uint8_t *)pvBuf;
240 size_t cbLeft = cbXfer;
241 uint64_t idEvtPrev = 0;
242 memcpy(&EvtGCPhys.abData[0], pbBuf, sizeof(EvtGCPhys.abData));
243 pbBuf += sizeof(EvtGCPhys.abData);
244 cbLeft -= sizeof(EvtGCPhys.abData);
245
246 int rc = dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, enmTraceEvt, &EvtGCPhys, &idEvtPrev);
247 while ( RT_SUCCESS(rc)
248 && cbLeft)
249 {
250 size_t cbThisXfer = RT_MIN(cbLeft, DBGF_TRACER_EVT_PAYLOAD_SZ);
251 rc = dbgfTracerEvtPostEx(pVM, pThisCC, hEvtSrc, enmTraceEvt, idEvtPrev,
252 pbBuf, cbThisXfer, &idEvtPrev);
253
254 pbBuf += cbThisXfer;
255 cbLeft -= cbThisXfer;
256 }
257
258 return rc;
259}
260
261
262/**
263 * Registers an MMIO region mapping event for the given event source.
264 *
265 * @returns VBox status code.
266 * @param pVM The current context VM instance data.
267 * @param hEvtSrc The event source for the posted event.
268 * @param hRegion The MMIO region handle being mapped.
269 * @param GCPhysMmio The guest physical address where the region is mapped.
270 */
271VMM_INT_DECL(int) DBGFTracerEvtMmioMap(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hRegion, RTGCPHYS GCPhysMmio)
272{
273 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
274 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
275
276 DBGFTRACEREVTMMIOMAP EvtMmioMap;
277 EvtMmioMap.hMmioRegion = hRegion;
278 EvtMmioMap.GCPhysMmioBase = GCPhysMmio;
279 EvtMmioMap.au64Pad0[0] = 0;
280 EvtMmioMap.au64Pad0[1] = 0;
281
282 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_MMIO_MAP, &EvtMmioMap, NULL /*pidEvt*/);
283}
284
285
286/**
287 * Registers an MMIO region unmap event for the given event source.
288 *
289 * @returns VBox status code.
290 * @param pVM The current context VM instance data.
291 * @param hEvtSrc The event source for the posted event.
292 * @param hRegion The MMIO region handle being unmapped.
293 */
294VMM_INT_DECL(int) DBGFTracerEvtMmioUnmap(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hRegion)
295{
296 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
297 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
298
299 DBGFTRACEREVTMMIOUNMAP EvtMmioUnmap;
300 EvtMmioUnmap.hMmioRegion = hRegion;
301 EvtMmioUnmap.au64Pad0[0] = 0;
302 EvtMmioUnmap.au64Pad0[1] = 0;
303 EvtMmioUnmap.au64Pad0[2] = 0;
304
305 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_MMIO_UNMAP, &EvtMmioUnmap, NULL /*pidEvt*/);
306}
307
308
309/**
310 * Registers an MMIO region read event for the given event source.
311 *
312 * @returns VBox status code.
313 * @param pVM The current context VM instance data.
314 * @param hEvtSrc The event source for the posted event.
315 * @param hRegion The MMIO region handle being read.
316 * @param offMmio The MMIO offset into the region where the read happened.
317 * @param pvVal The value being read.
318 * @param cbVal Value size in bytes.
319 */
320VMM_INT_DECL(int) DBGFTracerEvtMmioRead(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hRegion, RTGCPHYS offMmio, const void *pvVal, size_t cbVal)
321{
322 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
323 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
324
325 DBGFTRACEREVTMMIO EvtMmio;
326 EvtMmio.hMmioRegion = hRegion;
327 EvtMmio.offMmio = offMmio;
328 EvtMmio.cbXfer = cbVal;
329 dbgfTracerEvtMmioCopyVal(&EvtMmio, pvVal, cbVal);
330
331 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_MMIO_READ, &EvtMmio, NULL /*pidEvt*/);
332}
333
334
335/**
336 * Registers an MMIO region write event for the given event source.
337 *
338 * @returns VBox status code.
339 * @param pVM The current context VM instance data.
340 * @param hEvtSrc The event source for the posted event.
341 * @param hRegion The MMIO region handle being written to.
342 * @param offMmio The MMIO offset into the region where the write happened.
343 * @param pvVal The value being written.
344 * @param cbVal Value size in bytes.
345 */
346VMM_INT_DECL(int) DBGFTracerEvtMmioWrite(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hRegion, RTGCPHYS offMmio, const void *pvVal, size_t cbVal)
347{
348 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
349 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
350
351 DBGFTRACEREVTMMIO EvtMmio;
352 EvtMmio.hMmioRegion = hRegion;
353 EvtMmio.offMmio = offMmio;
354 EvtMmio.cbXfer = cbVal;
355 dbgfTracerEvtMmioCopyVal(&EvtMmio, pvVal, cbVal);
356
357 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_MMIO_WRITE, &EvtMmio, NULL /*pidEvt*/);
358}
359
360
361/**
362 * Registers an MMIO region fill event for the given event source.
363 *
364 * @returns VBox status code.
365 * @param pVM The current context VM instance data.
366 * @param hEvtSrc The event source for the posted event.
367 * @param hRegion The MMIO region handle being filled.
368 * @param offMmio The MMIO offset into the region where the fill starts.
369 * @param u32Item The value being used for filling.
370 * @param cbItem Item size in bytes.
371 * @param cItems Number of items being written.
372 */
373VMM_INT_DECL(int) DBGFTracerEvtMmioFill(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hRegion, RTGCPHYS offMmio,
374 uint32_t u32Item, uint32_t cbItem, uint32_t cItems)
375{
376 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
377 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
378
379 DBGFTRACEREVTMMIOFILL EvtMmioFill;
380 EvtMmioFill.hMmioRegion = hRegion;
381 EvtMmioFill.offMmio = offMmio;
382 EvtMmioFill.cbItem = cbItem;
383 EvtMmioFill.cItems = cItems;
384 EvtMmioFill.u32Item = u32Item;
385 EvtMmioFill.u32Pad0 = 0;
386
387 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_MMIO_FILL, &EvtMmioFill, NULL /*pidEvt*/);
388}
389
390
391/**
392 * Registers an I/O region mapping event for the given event source.
393 *
394 * @returns VBox status code.
395 * @param pVM The current context VM instance data.
396 * @param hEvtSrc The event source for the posted event.
397 * @param hIoPorts The I/O port region handle being mapped.
398 * @param IoPortBase The I/O port base where the region is mapped.
399 */
400VMM_INT_DECL(int) DBGFTracerEvtIoPortMap(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hIoPorts, RTIOPORT IoPortBase)
401{
402 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
403 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
404
405 DBGFTRACEREVTIOPORTMAP EvtIoPortMap;
406 RT_ZERO(EvtIoPortMap);
407 EvtIoPortMap.hIoPorts = hIoPorts;
408 EvtIoPortMap.IoPortBase = IoPortBase;
409
410 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_IOPORT_MAP, &EvtIoPortMap, NULL /*pidEvt*/);
411}
412
413
414/**
415 * Registers an I/O region unmap event for the given event source.
416 *
417 * @returns VBox status code.
418 * @param pVM The current context VM instance data.
419 * @param hEvtSrc The event source for the posted event.
420 * @param hIoPorts The I/O port region handle being unmapped.
421 */
422VMM_INT_DECL(int) DBGFTracerEvtIoPortUnmap(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hIoPorts)
423{
424 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
425 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
426
427 DBGFTRACEREVTIOPORTUNMAP EvtIoPortUnmap;
428 EvtIoPortUnmap.hIoPorts = hIoPorts;
429 EvtIoPortUnmap.au64Pad0[0] = 0;
430 EvtIoPortUnmap.au64Pad0[1] = 0;
431 EvtIoPortUnmap.au64Pad0[2] = 0;
432
433 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_IOPORT_UNMAP, &EvtIoPortUnmap, NULL /*pidEvt*/);
434}
435
436
437/**
438 * Registers an I/O region read event for the given event source.
439 *
440 * @returns VBox status code.
441 * @param pVM The current context VM instance data.
442 * @param hEvtSrc The event source for the posted event.
443 * @param hIoPorts The I/O port region handle being read from.
444 * @param offPort The offset into the region where the read happened.
445 * @param pvVal The value being read.
446 * @param cbVal Value size in bytes.
447 */
448VMM_INT_DECL(int) DBGFTracerEvtIoPortRead(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hIoPorts, RTIOPORT offPort, const void *pvVal, size_t cbVal)
449{
450 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
451 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
452
453 DBGFTRACEREVTIOPORT EvtIoPort;
454 RT_ZERO(EvtIoPort);
455 EvtIoPort.hIoPorts = hIoPorts;
456 EvtIoPort.offPort = offPort;
457 EvtIoPort.cbXfer = cbVal;
458 dbgfTracerEvtIoPortCopyVal(&EvtIoPort, pvVal, cbVal);
459
460 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_IOPORT_READ, &EvtIoPort, NULL /*pidEvt*/);
461}
462
463
464/**
465 * Registers an I/O region write event for the given event source.
466 *
467 * @returns VBox status code.
468 * @param pVM The current context VM instance data.
469 * @param hEvtSrc The event source for the posted event.
470 * @param hIoPorts The I/O port region handle being written to.
471 * @param offPort The offset into the region where the write happened.
472 * @param pvVal The value being written.
473 * @param cbVal Value size in bytes.
474 */
475VMM_INT_DECL(int) DBGFTracerEvtIoPortWrite(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hIoPorts, RTIOPORT offPort, const void *pvVal, size_t cbVal)
476{
477 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
478 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
479
480 DBGFTRACEREVTIOPORT EvtIoPort;
481 RT_ZERO(EvtIoPort);
482 EvtIoPort.hIoPorts = hIoPorts;
483 EvtIoPort.offPort = offPort;
484 EvtIoPort.cbXfer = cbVal;
485 dbgfTracerEvtIoPortCopyVal(&EvtIoPort, pvVal, cbVal);
486
487 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_IOPORT_WRITE, &EvtIoPort, NULL /*pidEvt*/);
488}
489
490
491/**
492 * Registers an IRQ change event for the given event source.
493 *
494 * @returns VBox status code.
495 * @param pVM The current context VM instance data.
496 * @param hEvtSrc The event source for the posted event.
497 * @param iIrq The IRQ line changed.
498 * @param fIrqLvl The new IRQ level mask.
499 */
500VMM_INT_DECL(int) DBGFTracerEvtIrq(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, int32_t iIrq, int32_t fIrqLvl)
501{
502 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
503 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
504
505 DBGFTRACEREVTIRQ EvtIrq;
506 RT_ZERO(EvtIrq);
507 EvtIrq.iIrq = iIrq;
508 EvtIrq.fIrqLvl = fIrqLvl;
509
510 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_IRQ, &EvtIrq, NULL /*pidEvt*/);
511}
512
513
514/**
515 * Registers an I/O APIC MSI event for the given event source.
516 *
517 * @returns VBox status code.
518 * @param pVM The current context VM instance data.
519 * @param hEvtSrc The event source for the posted event.
520 * @param GCPhys Guest physical address where the value is written to.
521 * @param u32Val The MSI event value being written.
522 */
523VMM_INT_DECL(int) DBGFTracerEvtIoApicMsi(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, RTGCPHYS GCPhys, uint32_t u32Val)
524{
525 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
526 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
527
528 DBGFTRACEREVTIOAPICMSI EvtMsi;
529 RT_ZERO(EvtMsi);
530 EvtMsi.GCPhys = GCPhys;
531 EvtMsi.u32Val = u32Val;
532
533 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_IOAPIC_MSI, &EvtMsi, NULL /*pidEvt*/);
534}
535
536
537/**
538 * Registers an guest physical memory read event for the given event source.
539 *
540 * @returns VBox status code.
541 * @param pVM The current context VM instance data.
542 * @param hEvtSrc The event source for the posted event.
543 * @param GCPhys Guest physical address the read started at.
544 * @param pvBuf The read data.
545 * @param cbRead Number of bytes read.
546 */
547VMM_INT_DECL(int) DBGFTracerEvtGCPhysRead(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, RTGCPHYS GCPhys, const void *pvBuf, size_t cbRead)
548{
549 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
550 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
551
552 return dbgfTracerEvtGCPhys(pVM, pThisCC, DBGFTRACEREVT_GCPHYS_READ, hEvtSrc, GCPhys, pvBuf, cbRead);
553}
554
555
556/**
557 * Registers an guest physical memory write event for the given event source.
558 *
559 * @returns VBox status code.
560 * @param pVM The current context VM instance data.
561 * @param hEvtSrc The event source for the posted event.
562 * @param GCPhys Guest physical address the write started at.
563 * @param pvBuf The written data.
564 * @param cbWrite Number of bytes written.
565 */
566VMM_INT_DECL(int) DBGFTracerEvtGCPhysWrite(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
567{
568 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
569 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
570
571 return dbgfTracerEvtGCPhys(pVM, pThisCC, DBGFTRACEREVT_GCPHYS_WRITE, hEvtSrc, GCPhys, pvBuf, cbWrite);
572}
573
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette