VirtualBox

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

Last change on this file since 103778 was 99739, checked in by vboxsync, 19 months ago

*: doxygen corrections (mostly about removing @returns from functions returning void).

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