VirtualBox

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

Last change on this file since 84766 was 84766, checked in by vboxsync, 4 years ago

VMM/DBGFTracer: Add events when I/O port and MMIO regions are created, bugref:9210

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.7 KB
Line 
1/* $Id: DBGFAllTracer.cpp 84766 2020-06-10 17:40:13Z 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 LogFlowFunc(("pVM=%p pThisCC=%p hEvtSrc=%llu enmTraceEvt=%u idEvtPrev=%llu pvEvtDesc=%p cbEvtDesc=%zu pidEvt=%p\n",
97 pVM, pThisCC, hEvtSrc, enmTraceEvt, idEvtPrev, pvEvtDesc, cbEvtDesc, pidEvt));
98
99 PDBGFTRACERSHARED pSharedCC = pThisCC->CTX_SUFF(pShared);
100 size_t cRingBufEvts = dbgfTracerGetRingBufSz(pThisCC) / DBGF_TRACER_EVT_SZ;
101 AssertReturn(cRingBufEvts, VERR_DBGF_TRACER_IPE_1);
102 AssertReturn(cbEvtDesc <= DBGF_TRACER_EVT_PAYLOAD_SZ, VERR_DBGF_TRACER_IPE_1);
103
104 /* Grab a new event ID first. */
105 uint64_t idEvt = ASMAtomicIncU64(&pSharedCC->idEvt) - 1;
106 uint64_t idxRingBuf = idEvt % cRingBufEvts; /* This gives the index in the ring buffer for the event. */
107 PDBGFTRACEREVTHDR pEvtHdr = (PDBGFTRACEREVTHDR)(pThisCC->CTX_SUFF(pbRingBuf) + idxRingBuf * DBGF_TRACER_EVT_SZ);
108
109 if (RT_UNLIKELY(ASMAtomicReadU64(&pEvtHdr->idEvt) != DBGF_TRACER_EVT_HDR_ID_INVALID))
110 {
111 /** @todo The event ring buffer is full and we need to go back (from R0 to R3) and wait for the flusher thread to
112 * get its act together.
113 */
114 AssertMsgFailed(("Flush thread can't keep up with event amount!\n"));
115 }
116
117 /* Write the event and kick the flush thread if necessary. */
118 if (cbEvtDesc)
119 memcpy(pEvtHdr + 1, pvEvtDesc, cbEvtDesc);
120 pEvtHdr->idEvtPrev = idEvtPrev;
121 pEvtHdr->hEvtSrc = hEvtSrc;
122 pEvtHdr->enmEvt = enmTraceEvt;
123 pEvtHdr->fFlags = DBGF_TRACER_EVT_HDR_F_DEFAULT;
124 ASMAtomicWriteU64(&pEvtHdr->idEvt, idEvt);
125
126 int rc = VINF_SUCCESS;
127 if (!ASMAtomicXchgBool(&pSharedCC->fEvtsWaiting, true))
128 {
129 if (!ASMAtomicXchgBool(&pSharedCC->fFlushThrdActive, true))
130 rc = SUPSemEventSignal(pVM->pSession, pSharedCC->hSupSemEvtFlush);
131 }
132
133 if (pidEvt)
134 *pidEvt = idEvt;
135 return rc;
136}
137
138
139/**
140 * Posts a single event descriptor to the ring buffer of the given tracer instance.
141 *
142 * @returns VBox status code.
143 * @param pVM The current context VM instance data.
144 * @param pThisCC The event tracer instance current context data.
145 * @param hEvtSrc The event source for the posted event.
146 * @param enmTraceEvt The trace event type posted.
147 * @param pvEvtDesc The event descriptor to copy after the header.
148 * @param pidEvt Where to store the assigned event ID, optional.
149 */
150DECLINLINE(int) dbgfTracerEvtPostSingle(PVMCC pVM, PDBGFTRACERINSCC pThisCC, DBGFTRACEREVTSRC hEvtSrc,
151 DBGFTRACEREVT enmTraceEvt, const void *pvEvtDesc, uint64_t *pidEvt)
152{
153 return dbgfTracerEvtPostEx(pVM, pThisCC, hEvtSrc, enmTraceEvt, DBGF_TRACER_EVT_HDR_ID_INVALID,
154 pvEvtDesc, DBGF_TRACER_EVT_PAYLOAD_SZ, pidEvt);
155}
156
157
158#ifdef IN_RING3
159/**
160 * Posts a single event descriptor to the ring buffer of the given tracer instance - R3 only variant
161 * (used for the register/deregister event source events currently).
162 *
163 * @returns VBox status code.
164 * @param pVM The current context VM instance data.
165 * @param pThisCC The event tracer instance current context data.
166 * @param hEvtSrc The event source for the posted event.
167 * @param enmTraceEvt The trace event type posted.
168 * @param pvEvtDesc The event descriptor to copy after the header.
169 * @param cbEvtDesc Event descriptor size in bytes.
170 * @param pidEvt Where to store the assigned event ID, optional.
171 */
172DECLHIDDEN(int) dbgfTracerR3EvtPostSingle(PVMCC pVM, PDBGFTRACERINSCC pThisCC, DBGFTRACEREVTSRC hEvtSrc,
173 DBGFTRACEREVT enmTraceEvt, const void *pvEvtDesc, size_t cbEvtDesc,
174 uint64_t *pidEvt)
175{
176 return dbgfTracerEvtPostEx(pVM, pThisCC, hEvtSrc, enmTraceEvt, DBGF_TRACER_EVT_HDR_ID_INVALID,
177 pvEvtDesc, cbEvtDesc, pidEvt);
178}
179#endif
180
181/**
182 * Copies the given MMIO value into the event descriptor based on the given size.
183 *
184 * @returns nothing.
185 * @param pEvtMmio Pointer to the MMIO event descriptor to fill.
186 * @param pvVal The value to copy.
187 * @param cbVal Size of the value in bytes.
188 */
189static void dbgfTracerEvtMmioCopyVal(PDBGFTRACEREVTMMIO pEvtMmio, const void *pvVal, size_t cbVal)
190{
191 switch (cbVal)
192 {
193 case 1:
194 pEvtMmio->u64Val = *(uint8_t *)pvVal;
195 break;
196 case 2:
197 pEvtMmio->u64Val = *(uint16_t *)pvVal;
198 break;
199 case 4:
200 pEvtMmio->u64Val = *(uint32_t *)pvVal;
201 break;
202 case 8:
203 pEvtMmio->u64Val = *(uint64_t *)pvVal;
204 break;
205 default:
206 AssertMsgFailed(("The value size %zu is not supported!\n", cbVal));
207 }
208}
209
210
211/**
212 * Copies the given I/O port value into the event descriptor based on the given size.
213 *
214 * @returns nothing.
215 * @param pEvtIoPort Pointer to the I/O port read/write event descriptor to fill.
216 * @param pvVal The value to copy.
217 * @param cbVal Size of the value in bytes.
218 */
219static void dbgfTracerEvtIoPortCopyVal(PDBGFTRACEREVTIOPORT pEvtIoPort, const void *pvVal, size_t cbVal)
220{
221 switch (cbVal)
222 {
223 case 1:
224 pEvtIoPort->u32Val = *(uint8_t *)pvVal;
225 break;
226 case 2:
227 pEvtIoPort->u32Val = *(uint16_t *)pvVal;
228 break;
229 case 4:
230 pEvtIoPort->u32Val = *(uint32_t *)pvVal;
231 break;
232 default:
233 AssertMsgFailed(("The value size %zu is not supported!\n", cbVal));
234 }
235}
236
237
238/**
239 * Handles a guest memory transfer event.
240 *
241 * @returns VBox status code.
242 * @param pVM The current context VM instance data.
243 * @param pThisCC The event tracer instance current context data.
244 * @param enmTraceEvt The trace event type posted.
245 * @param hEvtSrc The event source for the posted event.
246 * @param GCPhys The guest physical address the transfer starts at.
247 * @param pvBuf The data being transfered.
248 * @param cbXfer Number of bytes being transfered.
249 */
250static int dbgfTracerEvtGCPhys(PVMCC pVM, PDBGFTRACERINSCC pThisCC, DBGFTRACEREVT enmTraceEvt, DBGFTRACEREVTSRC hEvtSrc,
251 RTGCPHYS GCPhys, const void *pvBuf, size_t cbXfer)
252{
253 /* Fast path for really small transfers where everything fits into the descriptor. */
254 DBGFTRACEREVTGCPHYS EvtGCPhys;
255 EvtGCPhys.GCPhys = GCPhys;
256 EvtGCPhys.cbXfer = cbXfer;
257 if (cbXfer <= sizeof(EvtGCPhys.abData))
258 {
259 memcpy(&EvtGCPhys.abData[0], pvBuf, cbXfer);
260 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, enmTraceEvt, &EvtGCPhys, NULL /*pidEvt*/);
261 }
262
263 /*
264 * Slow path where we have to split the data into multiple entries.
265 * Each one is linked to the previous one by the previous event ID.
266 */
267 const uint8_t *pbBuf = (const uint8_t *)pvBuf;
268 size_t cbLeft = cbXfer;
269 uint64_t idEvtPrev = 0;
270 memcpy(&EvtGCPhys.abData[0], pbBuf, sizeof(EvtGCPhys.abData));
271 pbBuf += sizeof(EvtGCPhys.abData);
272 cbLeft -= sizeof(EvtGCPhys.abData);
273
274 int rc = dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, enmTraceEvt, &EvtGCPhys, &idEvtPrev);
275 while ( RT_SUCCESS(rc)
276 && cbLeft)
277 {
278 size_t cbThisXfer = RT_MIN(cbLeft, DBGF_TRACER_EVT_PAYLOAD_SZ);
279 rc = dbgfTracerEvtPostEx(pVM, pThisCC, hEvtSrc, enmTraceEvt, idEvtPrev,
280 pbBuf, cbThisXfer, &idEvtPrev);
281
282 pbBuf += cbThisXfer;
283 cbLeft -= cbThisXfer;
284 }
285
286 return rc;
287}
288
289
290/**
291 * Handles a I/O port string transfer event.
292 *
293 * @returns VBox status code.
294 * @param pVM The current context VM instance data.
295 * @param pThisCC The event tracer instance current context data.
296 * @param enmTraceEvt The trace event type posted.
297 * @param hEvtSrc The event source for the posted event.
298 * @param hIoPorts The I/O port region handle for the transfer.
299 * @param offPort The offset into the region where the transfer happened.
300 * @param pv The data being transfered.
301 * @param cb Number of bytes of valid data in the buffer.
302 * @param cbItem Item size in bytes.
303 * @param cTransfersReq Number of transfers requested.
304 * @param cTransfersRet Number of transfers done.
305 */
306static int dbgfTracerEvtIoPortStr(PVMCC pVM, PDBGFTRACERINSCC pThisCC, DBGFTRACEREVT enmTraceEvt, DBGFTRACEREVTSRC hEvtSrc,
307 uint64_t hIoPorts, RTIOPORT offPort, const void *pv, size_t cb, size_t cbItem, uint32_t cTransfersReq,
308 uint32_t cTransfersRet)
309{
310 /* Fast path for really small transfers where everything fits into the descriptor. */
311 DBGFTRACEREVTIOPORTSTR EvtIoPortStr;
312 EvtIoPortStr.hIoPorts = hIoPorts;
313 EvtIoPortStr.cbItem = cbItem;
314 EvtIoPortStr.cTransfersReq = cTransfersReq;
315 EvtIoPortStr.cTransfersRet = cTransfersRet;
316 EvtIoPortStr.offPort = offPort;
317 if (cb <= sizeof(EvtIoPortStr.abData))
318 {
319 memcpy(&EvtIoPortStr.abData[0], pv, cb);
320 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, enmTraceEvt, &EvtIoPortStr, NULL /*pidEvt*/);
321 }
322
323 /*
324 * Slow path where we have to split the data into multiple entries.
325 * Each one is linked to the previous one by the previous event ID.
326 */
327 const uint8_t *pbBuf = (const uint8_t *)pv;
328 size_t cbLeft = cb;
329 uint64_t idEvtPrev = 0;
330 memcpy(&EvtIoPortStr.abData[0], pbBuf, sizeof(EvtIoPortStr.abData));
331 pbBuf += sizeof(EvtIoPortStr.abData);
332 cbLeft -= sizeof(EvtIoPortStr.abData);
333
334 int rc = dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, enmTraceEvt, &EvtIoPortStr, &idEvtPrev);
335 while ( RT_SUCCESS(rc)
336 && cbLeft)
337 {
338 size_t cbThisXfer = RT_MIN(cbLeft, DBGF_TRACER_EVT_PAYLOAD_SZ);
339 rc = dbgfTracerEvtPostEx(pVM, pThisCC, hEvtSrc, enmTraceEvt, idEvtPrev,
340 pbBuf, cbThisXfer, &idEvtPrev);
341
342 pbBuf += cbThisXfer;
343 cbLeft -= cbThisXfer;
344 }
345
346 return rc;
347}
348
349
350/**
351 * Registers an MMIO region mapping event for the given event source.
352 *
353 * @returns VBox status code.
354 * @param pVM The current context VM instance data.
355 * @param hEvtSrc The event source for the posted event.
356 * @param hRegion The MMIO region handle being mapped.
357 * @param GCPhysMmio The guest physical address where the region is mapped.
358 */
359VMM_INT_DECL(int) DBGFTracerEvtMmioMap(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hRegion, RTGCPHYS GCPhysMmio)
360{
361 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
362 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
363
364 DBGFTRACEREVTMMIOMAP EvtMmioMap;
365 EvtMmioMap.hMmioRegion = hRegion;
366 EvtMmioMap.GCPhysMmioBase = GCPhysMmio;
367 EvtMmioMap.au64Pad0[0] = 0;
368 EvtMmioMap.au64Pad0[1] = 0;
369
370 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_MMIO_MAP, &EvtMmioMap, NULL /*pidEvt*/);
371}
372
373
374/**
375 * Registers an MMIO region unmap event for the given event source.
376 *
377 * @returns VBox status code.
378 * @param pVM The current context VM instance data.
379 * @param hEvtSrc The event source for the posted event.
380 * @param hRegion The MMIO region handle being unmapped.
381 */
382VMM_INT_DECL(int) DBGFTracerEvtMmioUnmap(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hRegion)
383{
384 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
385 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
386
387 DBGFTRACEREVTMMIOUNMAP EvtMmioUnmap;
388 EvtMmioUnmap.hMmioRegion = hRegion;
389 EvtMmioUnmap.au64Pad0[0] = 0;
390 EvtMmioUnmap.au64Pad0[1] = 0;
391 EvtMmioUnmap.au64Pad0[2] = 0;
392
393 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_MMIO_UNMAP, &EvtMmioUnmap, NULL /*pidEvt*/);
394}
395
396
397/**
398 * Registers an MMIO region read event for the given event source.
399 *
400 * @returns VBox status code.
401 * @param pVM The current context VM instance data.
402 * @param hEvtSrc The event source for the posted event.
403 * @param hRegion The MMIO region handle being read.
404 * @param offMmio The MMIO offset into the region where the read happened.
405 * @param pvVal The value being read.
406 * @param cbVal Value size in bytes.
407 */
408VMM_INT_DECL(int) DBGFTracerEvtMmioRead(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hRegion, RTGCPHYS offMmio, const void *pvVal, size_t cbVal)
409{
410 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
411 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
412
413 DBGFTRACEREVTMMIO EvtMmio;
414 EvtMmio.hMmioRegion = hRegion;
415 EvtMmio.offMmio = offMmio;
416 EvtMmio.cbXfer = cbVal;
417 dbgfTracerEvtMmioCopyVal(&EvtMmio, pvVal, cbVal);
418
419 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_MMIO_READ, &EvtMmio, NULL /*pidEvt*/);
420}
421
422
423/**
424 * Registers an MMIO region write event for the given event source.
425 *
426 * @returns VBox status code.
427 * @param pVM The current context VM instance data.
428 * @param hEvtSrc The event source for the posted event.
429 * @param hRegion The MMIO region handle being written to.
430 * @param offMmio The MMIO offset into the region where the write happened.
431 * @param pvVal The value being written.
432 * @param cbVal Value size in bytes.
433 */
434VMM_INT_DECL(int) DBGFTracerEvtMmioWrite(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hRegion, RTGCPHYS offMmio, const void *pvVal, size_t cbVal)
435{
436 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
437 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
438
439 DBGFTRACEREVTMMIO EvtMmio;
440 EvtMmio.hMmioRegion = hRegion;
441 EvtMmio.offMmio = offMmio;
442 EvtMmio.cbXfer = cbVal;
443 dbgfTracerEvtMmioCopyVal(&EvtMmio, pvVal, cbVal);
444
445 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_MMIO_WRITE, &EvtMmio, NULL /*pidEvt*/);
446}
447
448
449/**
450 * Registers an MMIO region fill event for the given event source.
451 *
452 * @returns VBox status code.
453 * @param pVM The current context VM instance data.
454 * @param hEvtSrc The event source for the posted event.
455 * @param hRegion The MMIO region handle being filled.
456 * @param offMmio The MMIO offset into the region where the fill starts.
457 * @param u32Item The value being used for filling.
458 * @param cbItem Item size in bytes.
459 * @param cItems Number of items being written.
460 */
461VMM_INT_DECL(int) DBGFTracerEvtMmioFill(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hRegion, RTGCPHYS offMmio,
462 uint32_t u32Item, uint32_t cbItem, uint32_t cItems)
463{
464 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
465 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
466
467 DBGFTRACEREVTMMIOFILL EvtMmioFill;
468 EvtMmioFill.hMmioRegion = hRegion;
469 EvtMmioFill.offMmio = offMmio;
470 EvtMmioFill.cbItem = cbItem;
471 EvtMmioFill.cItems = cItems;
472 EvtMmioFill.u32Item = u32Item;
473 EvtMmioFill.u32Pad0 = 0;
474
475 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_MMIO_FILL, &EvtMmioFill, NULL /*pidEvt*/);
476}
477
478
479/**
480 * Registers an I/O region mapping event for the given event source.
481 *
482 * @returns VBox status code.
483 * @param pVM The current context VM instance data.
484 * @param hEvtSrc The event source for the posted event.
485 * @param hIoPorts The I/O port region handle being mapped.
486 * @param IoPortBase The I/O port base where the region is mapped.
487 */
488VMM_INT_DECL(int) DBGFTracerEvtIoPortMap(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hIoPorts, RTIOPORT IoPortBase)
489{
490 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
491 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
492
493 DBGFTRACEREVTIOPORTMAP EvtIoPortMap;
494 RT_ZERO(EvtIoPortMap);
495 EvtIoPortMap.hIoPorts = hIoPorts;
496 EvtIoPortMap.IoPortBase = IoPortBase;
497
498 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_IOPORT_MAP, &EvtIoPortMap, NULL /*pidEvt*/);
499}
500
501
502/**
503 * Registers an I/O region unmap event for the given event source.
504 *
505 * @returns VBox status code.
506 * @param pVM The current context VM instance data.
507 * @param hEvtSrc The event source for the posted event.
508 * @param hIoPorts The I/O port region handle being unmapped.
509 */
510VMM_INT_DECL(int) DBGFTracerEvtIoPortUnmap(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hIoPorts)
511{
512 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
513 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
514
515 DBGFTRACEREVTIOPORTUNMAP EvtIoPortUnmap;
516 EvtIoPortUnmap.hIoPorts = hIoPorts;
517 EvtIoPortUnmap.au64Pad0[0] = 0;
518 EvtIoPortUnmap.au64Pad0[1] = 0;
519 EvtIoPortUnmap.au64Pad0[2] = 0;
520
521 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_IOPORT_UNMAP, &EvtIoPortUnmap, NULL /*pidEvt*/);
522}
523
524
525/**
526 * Registers an I/O region read event for the given event source.
527 *
528 * @returns VBox status code.
529 * @param pVM The current context VM instance data.
530 * @param hEvtSrc The event source for the posted event.
531 * @param hIoPorts The I/O port region handle being read from.
532 * @param offPort The offset into the region where the read happened.
533 * @param pvVal The value being read.
534 * @param cbVal Value size in bytes.
535 */
536VMM_INT_DECL(int) DBGFTracerEvtIoPortRead(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hIoPorts, RTIOPORT offPort, const void *pvVal, size_t cbVal)
537{
538 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
539 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
540
541 DBGFTRACEREVTIOPORT EvtIoPort;
542 RT_ZERO(EvtIoPort);
543 EvtIoPort.hIoPorts = hIoPorts;
544 EvtIoPort.offPort = offPort;
545 EvtIoPort.cbXfer = cbVal;
546 dbgfTracerEvtIoPortCopyVal(&EvtIoPort, pvVal, cbVal);
547
548 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_IOPORT_READ, &EvtIoPort, NULL /*pidEvt*/);
549}
550
551
552/**
553 * Registers an I/O region string read event for the given event source.
554 *
555 * @returns VBox status code.
556 * @param pVM The current context VM instance data.
557 * @param hEvtSrc The event source for the posted event.
558 * @param hIoPorts The I/O port region handle being read from.
559 * @param offPort The offset into the region where the read happened.
560 * @param pv The data being read.
561 * @param cb Item size in bytes.
562 * @param cTransfersReq Number of transfers requested.
563 * @param cTransfersRet Number of transfers done.
564 */
565VMM_INT_DECL(int) DBGFTracerEvtIoPortReadStr(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hIoPorts, RTIOPORT offPort, const void *pv, size_t cb,
566 uint32_t cTransfersReq, uint32_t cTransfersRet)
567{
568 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
569 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
570
571 return dbgfTracerEvtIoPortStr(pVM, pThisCC, DBGFTRACEREVT_IOPORT_READ_STR, hEvtSrc, hIoPorts, offPort, pv, cTransfersRet * cb,
572 cb, cTransfersReq, cTransfersRet);
573}
574
575
576/**
577 * Registers an I/O region write event for the given event source.
578 *
579 * @returns VBox status code.
580 * @param pVM The current context VM instance data.
581 * @param hEvtSrc The event source for the posted event.
582 * @param hIoPorts The I/O port region handle being written to.
583 * @param offPort The offset into the region where the write happened.
584 * @param pvVal The value being written.
585 * @param cbVal Value size in bytes.
586 */
587VMM_INT_DECL(int) DBGFTracerEvtIoPortWrite(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hIoPorts, RTIOPORT offPort, const void *pvVal, size_t cbVal)
588{
589 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
590 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
591
592 DBGFTRACEREVTIOPORT EvtIoPort;
593 RT_ZERO(EvtIoPort);
594 EvtIoPort.hIoPorts = hIoPorts;
595 EvtIoPort.offPort = offPort;
596 EvtIoPort.cbXfer = cbVal;
597 dbgfTracerEvtIoPortCopyVal(&EvtIoPort, pvVal, cbVal);
598
599 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_IOPORT_WRITE, &EvtIoPort, NULL /*pidEvt*/);
600}
601
602
603/**
604 * Registers an I/O region string write event for the given event source.
605 *
606 * @returns VBox status code.
607 * @param pVM The current context VM instance data.
608 * @param hEvtSrc The event source for the posted event.
609 * @param hIoPorts The I/O port region handle being written to.
610 * @param offPort The offset into the region where the write happened.
611 * @param pv The data being written.
612 * @param cb Item size in bytes.
613 * @param cTransfersReq Number of transfers requested.
614 * @param cTransfersRet Number of transfers done.
615 */
616VMM_INT_DECL(int) DBGFTracerEvtIoPortWriteStr(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, uint64_t hIoPorts, RTIOPORT offPort, const void *pv, size_t cb,
617 uint32_t cTransfersReq, uint32_t cTransfersRet)
618{
619 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
620 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
621
622 return dbgfTracerEvtIoPortStr(pVM, pThisCC, DBGFTRACEREVT_IOPORT_WRITE_STR, hEvtSrc, hIoPorts, offPort, pv, cTransfersReq * cb,
623 cb, cTransfersReq, cTransfersRet);
624}
625
626
627/**
628 * Registers an IRQ change event for the given event source.
629 *
630 * @returns VBox status code.
631 * @param pVM The current context VM instance data.
632 * @param hEvtSrc The event source for the posted event.
633 * @param iIrq The IRQ line changed.
634 * @param fIrqLvl The new IRQ level mask.
635 */
636VMM_INT_DECL(int) DBGFTracerEvtIrq(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, int32_t iIrq, int32_t fIrqLvl)
637{
638 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
639 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
640
641 DBGFTRACEREVTIRQ EvtIrq;
642 RT_ZERO(EvtIrq);
643 EvtIrq.iIrq = iIrq;
644 EvtIrq.fIrqLvl = fIrqLvl;
645
646 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_IRQ, &EvtIrq, NULL /*pidEvt*/);
647}
648
649
650/**
651 * Registers an I/O APIC MSI event for the given event source.
652 *
653 * @returns VBox status code.
654 * @param pVM The current context VM instance data.
655 * @param hEvtSrc The event source for the posted event.
656 * @param GCPhys Guest physical address where the value is written to.
657 * @param u32Val The MSI event value being written.
658 */
659VMM_INT_DECL(int) DBGFTracerEvtIoApicMsi(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, RTGCPHYS GCPhys, uint32_t u32Val)
660{
661 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
662 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
663
664 DBGFTRACEREVTIOAPICMSI EvtMsi;
665 RT_ZERO(EvtMsi);
666 EvtMsi.GCPhys = GCPhys;
667 EvtMsi.u32Val = u32Val;
668
669 return dbgfTracerEvtPostSingle(pVM, pThisCC, hEvtSrc, DBGFTRACEREVT_IOAPIC_MSI, &EvtMsi, NULL /*pidEvt*/);
670}
671
672
673/**
674 * Registers an guest physical memory read event for the given event source.
675 *
676 * @returns VBox status code.
677 * @param pVM The current context VM instance data.
678 * @param hEvtSrc The event source for the posted event.
679 * @param GCPhys Guest physical address the read started at.
680 * @param pvBuf The read data.
681 * @param cbRead Number of bytes read.
682 */
683VMM_INT_DECL(int) DBGFTracerEvtGCPhysRead(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, RTGCPHYS GCPhys, const void *pvBuf, size_t cbRead)
684{
685 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
686 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
687
688 return dbgfTracerEvtGCPhys(pVM, pThisCC, DBGFTRACEREVT_GCPHYS_READ, hEvtSrc, GCPhys, pvBuf, cbRead);
689}
690
691
692/**
693 * Registers an guest physical memory write event for the given event source.
694 *
695 * @returns VBox status code.
696 * @param pVM The current context VM instance data.
697 * @param hEvtSrc The event source for the posted event.
698 * @param GCPhys Guest physical address the write started at.
699 * @param pvBuf The written data.
700 * @param cbWrite Number of bytes written.
701 */
702VMM_INT_DECL(int) DBGFTracerEvtGCPhysWrite(PVMCC pVM, DBGFTRACEREVTSRC hEvtSrc, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
703{
704 PDBGFTRACERINSCC pThisCC = dbgfTracerGetInstance(pVM);
705 AssertReturn(pThisCC, VERR_DBGF_TRACER_IPE_1);
706
707 return dbgfTracerEvtGCPhys(pVM, pThisCC, DBGFTRACEREVT_GCPHYS_WRITE, hEvtSrc, GCPhys, pvBuf, cbWrite);
708}
709
Note: See TracBrowser for help on using the repository browser.

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