VirtualBox

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

Last change on this file since 84652 was 84552, checked in by vboxsync, 5 years ago

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