VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR3/PDMCritSect.cpp@ 90468

Last change on this file since 90468 was 90468, checked in by vboxsync, 3 years ago

VMM/PDM: Fixed the VERR_INTERRUPTED w/ rcBusy=VINF_SUCCESS case. More stats. bugref:6695

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 39.9 KB
Line 
1/* $Id: PDMCritSect.cpp 90468 2021-08-02 10:58:26Z vboxsync $ */
2/** @file
3 * PDM - Critical Sections, Ring-3.
4 */
5
6/*
7 * Copyright (C) 2006-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_PDM//_CRITSECT
23#include "PDMInternal.h"
24#include <VBox/vmm/pdmcritsect.h>
25#include <VBox/vmm/pdmcritsectrw.h>
26#include <VBox/vmm/mm.h>
27#include <VBox/vmm/vm.h>
28#include <VBox/vmm/uvm.h>
29
30#include <VBox/err.h>
31#include <VBox/log.h>
32#include <VBox/sup.h>
33#include <iprt/asm.h>
34#include <iprt/assert.h>
35#include <iprt/lockvalidator.h>
36#include <iprt/string.h>
37#include <iprt/thread.h>
38
39
40/*********************************************************************************************************************************
41* Internal Functions *
42*********************************************************************************************************************************/
43static int pdmR3CritSectDeleteOne(PVM pVM, PUVM pUVM, PPDMCRITSECTINT pCritSect, PPDMCRITSECTINT pPrev, bool fFinal);
44static int pdmR3CritSectRwDeleteOne(PVM pVM, PUVM pUVM, PPDMCRITSECTRWINT pCritSect, PPDMCRITSECTRWINT pPrev, bool fFinal);
45
46
47
48/**
49 * Register statistics related to the critical sections.
50 *
51 * @returns VBox status code.
52 * @param pVM The cross context VM structure.
53 */
54int pdmR3CritSectBothInitStats(PVM pVM)
55{
56 RT_NOREF_PV(pVM);
57 STAM_REL_REG(pVM, &pVM->pdm.s.StatQueuedCritSectLeaves, STAMTYPE_COUNTER, "/PDM/CritSects/00-QueuedLeaves", STAMUNIT_OCCURENCES,
58 "Number of times a critical section leave request needed to be queued for ring-3 execution.");
59 STAM_REL_REG(pVM, &pVM->pdm.s.StatAbortedCritSectEnters, STAMTYPE_COUNTER, "/PDM/CritSects/00-AbortedEnters", STAMUNIT_OCCURENCES,
60 "Number of times we've successfully aborted a wait in ring-0.");
61 STAM_REL_REG(pVM, &pVM->pdm.s.StatCritSectEntersWhileAborting, STAMTYPE_COUNTER, "/PDM/CritSects/00-EntersWhileAborting", STAMUNIT_OCCURENCES,
62 "Number of times we've got the critical section ownership while trying to abort a wait due to VERR_INTERRUPTED.");
63 STAM_REL_REG(pVM, &pVM->pdm.s.StatCritSectVerrInterrupted, STAMTYPE_COUNTER, "/PDM/CritSects/00-VERR_INTERRUPTED", STAMUNIT_OCCURENCES,
64 "Number of VERR_INTERRUPTED returns.");
65 STAM_REL_REG(pVM, &pVM->pdm.s.StatCritSectVerrTimeout, STAMTYPE_COUNTER, "/PDM/CritSects/00-VERR_TIMEOUT", STAMUNIT_OCCURENCES,
66 "Number of VERR_TIMEOUT returns.");
67 STAM_REL_REG(pVM, &pVM->pdm.s.StatCritSectNonInterruptibleWaits, STAMTYPE_COUNTER, "/PDM/CritSects/00-Non-interruptible-Waits-VINF_SUCCESS",
68 STAMUNIT_OCCURENCES, "Number of non-interruptible waits for rcBusy=VINF_SUCCESS");
69 return VINF_SUCCESS;
70}
71
72
73/**
74 * Deletes all remaining critical sections.
75 *
76 * This is called at the very end of the termination process. It is also called
77 * at the end of vmR3CreateU failure cleanup, which may cause it to be called
78 * twice depending on where vmR3CreateU actually failed. We have to do the
79 * latter call because other components expect the critical sections to be
80 * automatically deleted.
81 *
82 * @returns VBox status code.
83 * First error code, rest is lost.
84 * @param pVM The cross context VM structure.
85 * @remark Don't confuse this with PDMR3CritSectDelete.
86 */
87VMMR3_INT_DECL(int) PDMR3CritSectBothTerm(PVM pVM)
88{
89 PUVM pUVM = pVM->pUVM;
90 int rc = VINF_SUCCESS;
91 RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
92
93 while (pUVM->pdm.s.pCritSects)
94 {
95 int rc2 = pdmR3CritSectDeleteOne(pVM, pUVM, pUVM->pdm.s.pCritSects, NULL, true /* final */);
96 AssertRC(rc2);
97 if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
98 rc = rc2;
99 }
100
101 while (pUVM->pdm.s.pRwCritSects)
102 {
103 int rc2 = pdmR3CritSectRwDeleteOne(pVM, pUVM, pUVM->pdm.s.pRwCritSects, NULL, true /* final */);
104 AssertRC(rc2);
105 if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
106 rc = rc2;
107 }
108
109 RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
110 return rc;
111}
112
113
114/**
115 * Initializes a critical section and inserts it into the list.
116 *
117 * @returns VBox status code.
118 * @param pVM The cross context VM structure.
119 * @param pCritSect The critical section.
120 * @param pvKey The owner key.
121 * @param SRC_POS The source position.
122 * @param fUniqueClass Whether to create a unique lock validator class for
123 * it or not.
124 * @param pszNameFmt Format string for naming the critical section. For
125 * statistics and lock validation.
126 * @param va Arguments for the format string.
127 */
128static int pdmR3CritSectInitOne(PVM pVM, PPDMCRITSECTINT pCritSect, void *pvKey, RT_SRC_POS_DECL, bool fUniqueClass,
129 const char *pszNameFmt, va_list va)
130{
131 VM_ASSERT_EMT(pVM);
132 Assert(pCritSect->Core.u32Magic != RTCRITSECT_MAGIC);
133
134 /*
135 * Allocate the semaphore.
136 */
137 AssertCompile(sizeof(SUPSEMEVENT) == sizeof(pCritSect->Core.EventSem));
138 int rc = SUPSemEventCreate(pVM->pSession, (PSUPSEMEVENT)&pCritSect->Core.EventSem);
139 if (RT_SUCCESS(rc))
140 {
141 /* Only format the name once. */
142 char *pszName = RTStrAPrintf2V(pszNameFmt, va); /** @todo plug the "leak"... */
143 if (pszName)
144 {
145 RT_SRC_POS_NOREF(); RT_NOREF(fUniqueClass);
146#ifndef PDMCRITSECT_STRICT
147 pCritSect->Core.pValidatorRec = NULL;
148#else
149 rc = RTLockValidatorRecExclCreate(&pCritSect->Core.pValidatorRec,
150# ifdef RT_LOCK_STRICT_ORDER
151 fUniqueClass
152 ? RTLockValidatorClassCreateUnique(RT_SRC_POS_ARGS, "%s", pszName)
153 : RTLockValidatorClassForSrcPos(RT_SRC_POS_ARGS, "%s", pszName),
154# else
155 NIL_RTLOCKVALCLASS,
156# endif
157 RTLOCKVAL_SUB_CLASS_NONE,
158 pCritSect, true, "%s", pszName);
159#endif
160 if (RT_SUCCESS(rc))
161 {
162 /*
163 * Initialize the structure (first bit is c&p from RTCritSectInitEx).
164 */
165 pCritSect->Core.u32Magic = RTCRITSECT_MAGIC;
166 pCritSect->Core.fFlags = 0;
167 pCritSect->Core.cNestings = 0;
168 pCritSect->Core.cLockers = -1;
169 pCritSect->Core.NativeThreadOwner = NIL_RTNATIVETHREAD;
170 pCritSect->pvKey = pvKey;
171 pCritSect->fAutomaticDefaultCritsect = false;
172 pCritSect->fUsedByTimerOrSimilar = false;
173 pCritSect->hEventToSignal = NIL_SUPSEMEVENT;
174 pCritSect->pszName = pszName;
175
176 STAMR3RegisterF(pVM, &pCritSect->StatContentionRZLock, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
177 STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionRZLock", pCritSect->pszName);
178 STAMR3RegisterF(pVM, &pCritSect->StatContentionRZLockBusy, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
179 STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionRZLockBusy", pCritSect->pszName);
180 STAMR3RegisterF(pVM, &pCritSect->StatContentionRZUnlock, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
181 STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionRZUnlock", pCritSect->pszName);
182 STAMR3RegisterF(pVM, &pCritSect->StatContentionR3, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS,
183 STAMUNIT_OCCURENCES, NULL, "/PDM/CritSects/%s/ContentionR3", pCritSect->pszName);
184 STAMR3RegisterF(pVM, &pCritSect->StatContentionWait, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS,
185 STAMUNIT_TICKS_PER_OCCURENCE, NULL, "/PDM/CritSects/%s/ContentionWait", pCritSect->pszName);
186#ifdef VBOX_WITH_STATISTICS
187 STAMR3RegisterF(pVM, &pCritSect->StatLocked, STAMTYPE_PROFILE_ADV, STAMVISIBILITY_ALWAYS,
188 STAMUNIT_TICKS_PER_OCCURENCE, NULL, "/PDM/CritSects/%s/Locked", pCritSect->pszName);
189#endif
190
191 PUVM pUVM = pVM->pUVM;
192 RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
193 pCritSect->pNext = pUVM->pdm.s.pCritSects;
194 pUVM->pdm.s.pCritSects = pCritSect;
195 RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
196
197 return VINF_SUCCESS;
198 }
199
200 RTStrFree(pszName);
201 }
202 else
203 rc = VERR_NO_STR_MEMORY;
204 SUPSemEventClose(pVM->pSession, (SUPSEMEVENT)pCritSect->Core.EventSem);
205 }
206 return rc;
207}
208
209
210/**
211 * Initializes a read/write critical section and inserts it into the list.
212 *
213 * @returns VBox status code.
214 * @param pVM The cross context VM structure.
215 * @param pCritSect The read/write critical section.
216 * @param pvKey The owner key.
217 * @param SRC_POS The source position.
218 * @param pszNameFmt Format string for naming the critical section. For
219 * statistics and lock validation.
220 * @param va Arguments for the format string.
221 */
222static int pdmR3CritSectRwInitOne(PVM pVM, PPDMCRITSECTRWINT pCritSect, void *pvKey, RT_SRC_POS_DECL,
223 const char *pszNameFmt, va_list va)
224{
225 VM_ASSERT_EMT(pVM);
226 Assert(pCritSect->Core.u32Magic != RTCRITSECTRW_MAGIC);
227
228 /*
229 * Allocate the semaphores.
230 */
231 AssertCompile(sizeof(SUPSEMEVENT) == sizeof(pCritSect->Core.hEvtWrite));
232 int rc = SUPSemEventCreate(pVM->pSession, (PSUPSEMEVENT)&pCritSect->Core.hEvtWrite);
233 if (RT_SUCCESS(rc))
234 {
235 AssertCompile(sizeof(SUPSEMEVENTMULTI) == sizeof(pCritSect->Core.hEvtRead));
236 rc = SUPSemEventMultiCreate(pVM->pSession, (PSUPSEMEVENT)&pCritSect->Core.hEvtRead);
237 if (RT_SUCCESS(rc))
238 {
239 /* Only format the name once. */
240 char *pszName = RTStrAPrintf2V(pszNameFmt, va); /** @todo plug the "leak"... */
241 if (pszName)
242 {
243 pCritSect->Core.pValidatorRead = NULL;
244 pCritSect->Core.pValidatorWrite = NULL;
245 RT_SRC_POS_NOREF();
246#ifdef PDMCRITSECTRW_STRICT
247# ifdef RT_LOCK_STRICT_ORDER
248 RTLOCKVALCLASS hClass = RTLockValidatorClassForSrcPos(RT_SRC_POS_ARGS, "%s", pszName);
249# else
250 RTLOCKVALCLASS hClass = NIL_RTLOCKVALCLASS;
251# endif
252 rc = RTLockValidatorRecExclCreate(&pCritSect->Core.pValidatorWrite, hClass, RTLOCKVAL_SUB_CLASS_NONE,
253 pCritSect, true, "%s", pszName);
254 if (RT_SUCCESS(rc))
255 rc = RTLockValidatorRecSharedCreate(&pCritSect->Core.pValidatorRead, hClass, RTLOCKVAL_SUB_CLASS_NONE,
256 pCritSect, false /*fSignaller*/, true, "%s", pszName);
257#endif
258 if (RT_SUCCESS(rc))
259 {
260 /*
261 * Initialize the structure (first bit is c&p from RTCritSectRwInitEx).
262 */
263 pCritSect->Core.u32Magic = RTCRITSECTRW_MAGIC;
264 pCritSect->Core.fNeedReset = false;
265 pCritSect->Core.u64State = 0;
266 pCritSect->Core.hNativeWriter = NIL_RTNATIVETHREAD;
267 pCritSect->Core.cWriterReads = 0;
268 pCritSect->Core.cWriteRecursions = 0;
269#if HC_ARCH_BITS == 32
270 pCritSect->Core.HCPtrPadding = NIL_RTHCPTR;
271#endif
272 pCritSect->pvKey = pvKey;
273 pCritSect->pszName = pszName;
274
275 STAMR3RegisterF(pVM, &pCritSect->StatContentionRZEnterExcl, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSectsRw/%s/ContentionRZEnterExcl", pCritSect->pszName);
276 STAMR3RegisterF(pVM, &pCritSect->StatContentionRZLeaveExcl, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSectsRw/%s/ContentionRZLeaveExcl", pCritSect->pszName);
277 STAMR3RegisterF(pVM, &pCritSect->StatContentionRZEnterShared, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSectsRw/%s/ContentionRZEnterShared", pCritSect->pszName);
278 STAMR3RegisterF(pVM, &pCritSect->StatContentionRZLeaveShared, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSectsRw/%s/ContentionRZLeaveShared", pCritSect->pszName);
279 STAMR3RegisterF(pVM, &pCritSect->StatContentionR3EnterExcl, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSectsRw/%s/ContentionR3EnterExcl", pCritSect->pszName);
280 STAMR3RegisterF(pVM, &pCritSect->StatContentionR3EnterShared, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSectsRw/%s/ContentionR3EnterShared", pCritSect->pszName);
281 STAMR3RegisterF(pVM, &pCritSect->StatRZEnterExcl, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSectsRw/%s/RZEnterExcl", pCritSect->pszName);
282 STAMR3RegisterF(pVM, &pCritSect->StatRZEnterShared, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSectsRw/%s/RZEnterShared", pCritSect->pszName);
283 STAMR3RegisterF(pVM, &pCritSect->StatR3EnterExcl, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSectsRw/%s/R3EnterExcl", pCritSect->pszName);
284 STAMR3RegisterF(pVM, &pCritSect->StatR3EnterShared, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, NULL, "/PDM/CritSectsRw/%s/R3EnterShared", pCritSect->pszName);
285#ifdef VBOX_WITH_STATISTICS
286 STAMR3RegisterF(pVM, &pCritSect->StatWriteLocked, STAMTYPE_PROFILE_ADV, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_OCCURENCE, NULL, "/PDM/CritSectsRw/%s/WriteLocked", pCritSect->pszName);
287#endif
288
289 PUVM pUVM = pVM->pUVM;
290 RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
291 pCritSect->pNext = pUVM->pdm.s.pRwCritSects;
292 pUVM->pdm.s.pRwCritSects = pCritSect;
293 RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
294
295 return VINF_SUCCESS;
296 }
297
298 RTStrFree(pszName);
299 }
300 else
301 rc = VERR_NO_STR_MEMORY;
302 SUPSemEventMultiClose(pVM->pSession, (SUPSEMEVENT)pCritSect->Core.hEvtRead);
303 }
304 SUPSemEventClose(pVM->pSession, (SUPSEMEVENT)pCritSect->Core.hEvtWrite);
305 }
306 return rc;
307}
308
309
310/**
311 * Initializes a PDM critical section for internal use.
312 *
313 * The PDM critical sections are derived from the IPRT critical sections, but
314 * works in ring-0 and raw-mode context as well.
315 *
316 * @returns VBox status code.
317 * @param pVM The cross context VM structure.
318 * @param pCritSect Pointer to the critical section.
319 * @param SRC_POS Use RT_SRC_POS.
320 * @param pszNameFmt Format string for naming the critical section. For
321 * statistics and lock validation.
322 * @param ... Arguments for the format string.
323 * @thread EMT
324 */
325VMMR3DECL(int) PDMR3CritSectInit(PVM pVM, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL, const char *pszNameFmt, ...)
326{
327#if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32
328 AssertCompile(sizeof(pCritSect->padding) >= sizeof(pCritSect->s));
329#endif
330 Assert(RT_ALIGN_P(pCritSect, sizeof(uintptr_t)) == pCritSect);
331 va_list va;
332 va_start(va, pszNameFmt);
333 int rc = pdmR3CritSectInitOne(pVM, &pCritSect->s, pCritSect, RT_SRC_POS_ARGS, false /*fUniqueClass*/, pszNameFmt, va);
334 va_end(va);
335 return rc;
336}
337
338
339/**
340 * Initializes a PDM read/write critical section for internal use.
341 *
342 * The PDM read/write critical sections are derived from the IPRT read/write
343 * critical sections, but works in ring-0 and raw-mode context as well.
344 *
345 * @returns VBox status code.
346 * @param pVM The cross context VM structure.
347 * @param pCritSect Pointer to the read/write critical section.
348 * @param SRC_POS Use RT_SRC_POS.
349 * @param pszNameFmt Format string for naming the critical section. For
350 * statistics and lock validation.
351 * @param ... Arguments for the format string.
352 * @thread EMT
353 */
354VMMR3DECL(int) PDMR3CritSectRwInit(PVM pVM, PPDMCRITSECTRW pCritSect, RT_SRC_POS_DECL, const char *pszNameFmt, ...)
355{
356#if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32
357 AssertCompile(sizeof(pCritSect->padding) >= sizeof(pCritSect->s));
358#endif
359 Assert(RT_ALIGN_P(pCritSect, sizeof(uintptr_t)) == pCritSect);
360 va_list va;
361 va_start(va, pszNameFmt);
362 int rc = pdmR3CritSectRwInitOne(pVM, &pCritSect->s, pCritSect, RT_SRC_POS_ARGS, pszNameFmt, va);
363 va_end(va);
364 return rc;
365}
366
367
368/**
369 * Initializes a PDM critical section for a device.
370 *
371 * @returns VBox status code.
372 * @param pVM The cross context VM structure.
373 * @param pDevIns Device instance.
374 * @param pCritSect Pointer to the critical section.
375 * @param SRC_POS The source position. Optional.
376 * @param pszNameFmt Format string for naming the critical section. For
377 * statistics and lock validation.
378 * @param va Arguments for the format string.
379 */
380int pdmR3CritSectInitDevice(PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
381 const char *pszNameFmt, va_list va)
382{
383 return pdmR3CritSectInitOne(pVM, &pCritSect->s, pDevIns, RT_SRC_POS_ARGS, false /*fUniqueClass*/, pszNameFmt, va);
384}
385
386
387/**
388 * Initializes a PDM read/write critical section for a device.
389 *
390 * @returns VBox status code.
391 * @param pVM The cross context VM structure.
392 * @param pDevIns Device instance.
393 * @param pCritSect Pointer to the read/write critical section.
394 * @param SRC_POS The source position. Optional.
395 * @param pszNameFmt Format string for naming the critical section. For
396 * statistics and lock validation.
397 * @param va Arguments for the format string.
398 */
399int pdmR3CritSectRwInitDevice(PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECTRW pCritSect, RT_SRC_POS_DECL,
400 const char *pszNameFmt, va_list va)
401{
402 return pdmR3CritSectRwInitOne(pVM, &pCritSect->s, pDevIns, RT_SRC_POS_ARGS, pszNameFmt, va);
403}
404
405
406/**
407 * Initializes the automatic default PDM critical section for a device.
408 *
409 * @returns VBox status code.
410 * @param pVM The cross context VM structure.
411 * @param pDevIns Device instance.
412 * @param SRC_POS The source position. Optional.
413 * @param pCritSect Pointer to the critical section.
414 * @param pszNameFmt Format string for naming the critical section. For
415 * statistics and lock validation.
416 * @param ... Arguments for the format string.
417 */
418int pdmR3CritSectInitDeviceAuto(PVM pVM, PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
419 const char *pszNameFmt, ...)
420{
421 va_list va;
422 va_start(va, pszNameFmt);
423 int rc = pdmR3CritSectInitOne(pVM, &pCritSect->s, pDevIns, RT_SRC_POS_ARGS, true /*fUniqueClass*/, pszNameFmt, va);
424 if (RT_SUCCESS(rc))
425 pCritSect->s.fAutomaticDefaultCritsect = true;
426 va_end(va);
427 return rc;
428}
429
430
431/**
432 * Initializes a PDM critical section for a driver.
433 *
434 * @returns VBox status code.
435 * @param pVM The cross context VM structure.
436 * @param pDrvIns Driver instance.
437 * @param pCritSect Pointer to the critical section.
438 * @param SRC_POS The source position. Optional.
439 * @param pszNameFmt Format string for naming the critical section. For
440 * statistics and lock validation.
441 * @param ... Arguments for the format string.
442 */
443int pdmR3CritSectInitDriver(PVM pVM, PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
444 const char *pszNameFmt, ...)
445{
446 va_list va;
447 va_start(va, pszNameFmt);
448 int rc = pdmR3CritSectInitOne(pVM, &pCritSect->s, pDrvIns, RT_SRC_POS_ARGS, false /*fUniqueClass*/, pszNameFmt, va);
449 va_end(va);
450 return rc;
451}
452
453
454/**
455 * Initializes a PDM read/write critical section for a driver.
456 *
457 * @returns VBox status code.
458 * @param pVM The cross context VM structure.
459 * @param pDrvIns Driver instance.
460 * @param pCritSect Pointer to the read/write critical section.
461 * @param SRC_POS The source position. Optional.
462 * @param pszNameFmt Format string for naming the critical section. For
463 * statistics and lock validation.
464 * @param ... Arguments for the format string.
465 */
466int pdmR3CritSectRwInitDriver(PVM pVM, PPDMDRVINS pDrvIns, PPDMCRITSECTRW pCritSect, RT_SRC_POS_DECL,
467 const char *pszNameFmt, ...)
468{
469 va_list va;
470 va_start(va, pszNameFmt);
471 int rc = pdmR3CritSectRwInitOne(pVM, &pCritSect->s, pDrvIns, RT_SRC_POS_ARGS, pszNameFmt, va);
472 va_end(va);
473 return rc;
474}
475
476
477/**
478 * Deletes one critical section.
479 *
480 * @returns Return code from RTCritSectDelete.
481 *
482 * @param pVM The cross context VM structure.
483 * @param pUVM The user mode VM handle.
484 * @param pCritSect The critical section.
485 * @param pPrev The previous critical section in the list.
486 * @param fFinal Set if this is the final call and statistics shouldn't be deregistered.
487 *
488 * @remarks Caller must have entered the ListCritSect.
489 */
490static int pdmR3CritSectDeleteOne(PVM pVM, PUVM pUVM, PPDMCRITSECTINT pCritSect, PPDMCRITSECTINT pPrev, bool fFinal)
491{
492 /*
493 * Assert free waiters and so on (c&p from RTCritSectDelete).
494 */
495 Assert(pCritSect->Core.u32Magic == RTCRITSECT_MAGIC);
496 //Assert(pCritSect->Core.cNestings == 0); - we no longer reset this when leaving.
497 Assert(pCritSect->Core.cLockers == -1);
498 Assert(pCritSect->Core.NativeThreadOwner == NIL_RTNATIVETHREAD);
499 Assert(RTCritSectIsOwner(&pUVM->pdm.s.ListCritSect));
500
501 /*
502 * Unlink it.
503 */
504 if (pPrev)
505 pPrev->pNext = pCritSect->pNext;
506 else
507 pUVM->pdm.s.pCritSects = pCritSect->pNext;
508
509 /*
510 * Delete it (parts taken from RTCritSectDelete).
511 * In case someone is waiting we'll signal the semaphore cLockers + 1 times.
512 */
513 ASMAtomicWriteU32(&pCritSect->Core.u32Magic, 0);
514 SUPSEMEVENT hEvent = (SUPSEMEVENT)pCritSect->Core.EventSem;
515 pCritSect->Core.EventSem = NIL_RTSEMEVENT;
516 while (pCritSect->Core.cLockers-- >= 0)
517 SUPSemEventSignal(pVM->pSession, hEvent);
518 ASMAtomicWriteS32(&pCritSect->Core.cLockers, -1);
519 int rc = SUPSemEventClose(pVM->pSession, hEvent);
520 AssertRC(rc);
521 RTLockValidatorRecExclDestroy(&pCritSect->Core.pValidatorRec);
522 pCritSect->pNext = NULL;
523 pCritSect->pvKey = NULL;
524 if (!fFinal)
525 STAMR3DeregisterF(pVM->pUVM, "/PDM/CritSects/%s/*", pCritSect->pszName);
526 RTStrFree((char *)pCritSect->pszName);
527 pCritSect->pszName = NULL;
528 return rc;
529}
530
531
532/**
533 * Deletes one read/write critical section.
534 *
535 * @returns VBox status code.
536 *
537 * @param pVM The cross context VM structure.
538 * @param pUVM The user mode VM handle.
539 * @param pCritSect The read/write critical section.
540 * @param pPrev The previous critical section in the list.
541 * @param fFinal Set if this is the final call and statistics shouldn't be deregistered.
542 *
543 * @remarks Caller must have entered the ListCritSect.
544 */
545static int pdmR3CritSectRwDeleteOne(PVM pVM, PUVM pUVM, PPDMCRITSECTRWINT pCritSect, PPDMCRITSECTRWINT pPrev, bool fFinal)
546{
547 /*
548 * Assert free waiters and so on (c&p from RTCritSectRwDelete).
549 */
550 Assert(pCritSect->Core.u32Magic == RTCRITSECTRW_MAGIC);
551 //Assert(pCritSect->Core.cNestings == 0);
552 //Assert(pCritSect->Core.cLockers == -1);
553 Assert(pCritSect->Core.hNativeWriter == NIL_RTNATIVETHREAD);
554
555 /*
556 * Invalidate the structure and free the semaphores.
557 */
558 if (!ASMAtomicCmpXchgU32(&pCritSect->Core.u32Magic, RTCRITSECTRW_MAGIC_DEAD, RTCRITSECTRW_MAGIC))
559 AssertFailed();
560
561 /*
562 * Unlink it.
563 */
564 if (pPrev)
565 pPrev->pNext = pCritSect->pNext;
566 else
567 pUVM->pdm.s.pRwCritSects = pCritSect->pNext;
568
569 /*
570 * Delete it (parts taken from RTCritSectRwDelete).
571 * In case someone is waiting we'll signal the semaphore cLockers + 1 times.
572 */
573 pCritSect->Core.fFlags = 0;
574 pCritSect->Core.u64State = 0;
575
576 SUPSEMEVENT hEvtWrite = (SUPSEMEVENT)pCritSect->Core.hEvtWrite;
577 pCritSect->Core.hEvtWrite = NIL_RTSEMEVENT;
578 AssertCompile(sizeof(hEvtWrite) == sizeof(pCritSect->Core.hEvtWrite));
579
580 SUPSEMEVENTMULTI hEvtRead = (SUPSEMEVENTMULTI)pCritSect->Core.hEvtRead;
581 pCritSect->Core.hEvtRead = NIL_RTSEMEVENTMULTI;
582 AssertCompile(sizeof(hEvtRead) == sizeof(pCritSect->Core.hEvtRead));
583
584 int rc1 = SUPSemEventClose(pVM->pSession, hEvtWrite); AssertRC(rc1);
585 int rc2 = SUPSemEventMultiClose(pVM->pSession, hEvtRead); AssertRC(rc2);
586
587 RTLockValidatorRecSharedDestroy(&pCritSect->Core.pValidatorRead);
588 RTLockValidatorRecExclDestroy(&pCritSect->Core.pValidatorWrite);
589
590 pCritSect->pNext = NULL;
591 pCritSect->pvKey = NULL;
592 if (!fFinal)
593 STAMR3DeregisterF(pVM->pUVM, "/PDM/CritSectsRw/%s/*", pCritSect->pszName);
594 RTStrFree((char *)pCritSect->pszName);
595 pCritSect->pszName = NULL;
596
597 return RT_SUCCESS(rc1) ? rc2 : rc1;
598}
599
600
601/**
602 * Deletes all critical sections with a give initializer key.
603 *
604 * @returns VBox status code.
605 * The entire list is processed on failure, so we'll only
606 * return the first error code. This shouldn't be a problem
607 * since errors really shouldn't happen here.
608 * @param pVM The cross context VM structure.
609 * @param pvKey The initializer key.
610 */
611static int pdmR3CritSectDeleteByKey(PVM pVM, void *pvKey)
612{
613 /*
614 * Iterate the list and match key.
615 */
616 PUVM pUVM = pVM->pUVM;
617 int rc = VINF_SUCCESS;
618 PPDMCRITSECTINT pPrev = NULL;
619 RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
620 PPDMCRITSECTINT pCur = pUVM->pdm.s.pCritSects;
621 while (pCur)
622 {
623 if (pCur->pvKey == pvKey)
624 {
625 int rc2 = pdmR3CritSectDeleteOne(pVM, pUVM, pCur, pPrev, false /* not final */);
626 AssertRC(rc2);
627 if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
628 rc = rc2;
629 }
630
631 /* next */
632 pPrev = pCur;
633 pCur = pCur->pNext;
634 }
635 RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
636 return rc;
637}
638
639
640/**
641 * Deletes all read/write critical sections with a give initializer key.
642 *
643 * @returns VBox status code.
644 * The entire list is processed on failure, so we'll only
645 * return the first error code. This shouldn't be a problem
646 * since errors really shouldn't happen here.
647 * @param pVM The cross context VM structure.
648 * @param pvKey The initializer key.
649 */
650static int pdmR3CritSectRwDeleteByKey(PVM pVM, void *pvKey)
651{
652 /*
653 * Iterate the list and match key.
654 */
655 PUVM pUVM = pVM->pUVM;
656 int rc = VINF_SUCCESS;
657 PPDMCRITSECTRWINT pPrev = NULL;
658 RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
659 PPDMCRITSECTRWINT pCur = pUVM->pdm.s.pRwCritSects;
660 while (pCur)
661 {
662 if (pCur->pvKey == pvKey)
663 {
664 int rc2 = pdmR3CritSectRwDeleteOne(pVM, pUVM, pCur, pPrev, false /* not final */);
665 AssertRC(rc2);
666 if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
667 rc = rc2;
668 }
669
670 /* next */
671 pPrev = pCur;
672 pCur = pCur->pNext;
673 }
674 RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
675 return rc;
676}
677
678
679/**
680 * Deletes all undeleted critical sections (both types) initialized by a given
681 * device.
682 *
683 * @returns VBox status code.
684 * @param pVM The cross context VM structure.
685 * @param pDevIns The device handle.
686 */
687int pdmR3CritSectBothDeleteDevice(PVM pVM, PPDMDEVINS pDevIns)
688{
689 int rc1 = pdmR3CritSectDeleteByKey(pVM, pDevIns);
690 int rc2 = pdmR3CritSectRwDeleteByKey(pVM, pDevIns);
691 return RT_SUCCESS(rc1) ? rc2 : rc1;
692}
693
694
695/**
696 * Deletes all undeleted critical sections (both types) initialized by a given
697 * driver.
698 *
699 * @returns VBox status code.
700 * @param pVM The cross context VM structure.
701 * @param pDrvIns The driver handle.
702 */
703int pdmR3CritSectBothDeleteDriver(PVM pVM, PPDMDRVINS pDrvIns)
704{
705 int rc1 = pdmR3CritSectDeleteByKey(pVM, pDrvIns);
706 int rc2 = pdmR3CritSectRwDeleteByKey(pVM, pDrvIns);
707 return RT_SUCCESS(rc1) ? rc2 : rc1;
708}
709
710
711/**
712 * Deletes the critical section.
713 *
714 * @returns VBox status code.
715 * @param pVM The cross context VM structure.
716 * @param pCritSect The PDM critical section to destroy.
717 */
718VMMR3DECL(int) PDMR3CritSectDelete(PVM pVM, PPDMCRITSECT pCritSect)
719{
720 if (!RTCritSectIsInitialized(&pCritSect->s.Core))
721 return VINF_SUCCESS;
722
723 /*
724 * Find and unlink it.
725 */
726 PUVM pUVM = pVM->pUVM;
727 AssertReleaseReturn(pVM, VERR_PDM_CRITSECT_IPE);
728 PPDMCRITSECTINT pPrev = NULL;
729 RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
730 PPDMCRITSECTINT pCur = pUVM->pdm.s.pCritSects;
731 while (pCur)
732 {
733 if (pCur == &pCritSect->s)
734 {
735 int rc = pdmR3CritSectDeleteOne(pVM, pUVM, pCur, pPrev, false /* not final */);
736 RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
737 return rc;
738 }
739
740 /* next */
741 pPrev = pCur;
742 pCur = pCur->pNext;
743 }
744 RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
745 AssertReleaseMsgFailed(("pCritSect=%p wasn't found!\n", pCritSect));
746 return VERR_PDM_CRITSECT_NOT_FOUND;
747}
748
749
750/**
751 * Deletes the read/write critical section.
752 *
753 * @returns VBox status code.
754 * @param pVM The cross context VM structure.
755 * @param pCritSect The PDM read/write critical section to destroy.
756 */
757VMMR3DECL(int) PDMR3CritSectRwDelete(PVM pVM, PPDMCRITSECTRW pCritSect)
758{
759 if (!PDMCritSectRwIsInitialized(pCritSect))
760 return VINF_SUCCESS;
761
762 /*
763 * Find and unlink it.
764 */
765 PUVM pUVM = pVM->pUVM;
766 AssertReleaseReturn(pVM, VERR_PDM_CRITSECT_IPE);
767 PPDMCRITSECTRWINT pPrev = NULL;
768 RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
769 PPDMCRITSECTRWINT pCur = pUVM->pdm.s.pRwCritSects;
770 while (pCur)
771 {
772 if (pCur == &pCritSect->s)
773 {
774 int rc = pdmR3CritSectRwDeleteOne(pVM, pUVM, pCur, pPrev, false /* not final */);
775 RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
776 return rc;
777 }
778
779 /* next */
780 pPrev = pCur;
781 pCur = pCur->pNext;
782 }
783 RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
784 AssertReleaseMsgFailed(("pCritSect=%p wasn't found!\n", pCritSect));
785 return VERR_PDM_CRITSECT_NOT_FOUND;
786}
787
788
789/**
790 * Gets the name of the critical section.
791 *
792 *
793 * @returns Pointer to the critical section name (read only) on success,
794 * NULL on failure (invalid critical section).
795 * @param pCritSect The critical section.
796 */
797VMMR3DECL(const char *) PDMR3CritSectName(PCPDMCRITSECT pCritSect)
798{
799 AssertPtrReturn(pCritSect, NULL);
800 AssertReturn(pCritSect->s.Core.u32Magic == RTCRITSECT_MAGIC, NULL);
801 return pCritSect->s.pszName;
802}
803
804
805/**
806 * Gets the name of the read/write critical section.
807 *
808 *
809 * @returns Pointer to the critical section name (read only) on success,
810 * NULL on failure (invalid critical section).
811 * @param pCritSect The read/write critical section.
812 */
813VMMR3DECL(const char *) PDMR3CritSectRwName(PCPDMCRITSECTRW pCritSect)
814{
815 AssertPtrReturn(pCritSect, NULL);
816 AssertReturn(pCritSect->s.Core.u32Magic == RTCRITSECTRW_MAGIC, NULL);
817 return pCritSect->s.pszName;
818}
819
820
821/**
822 * Yield the critical section if someone is waiting on it.
823 *
824 * When yielding, we'll leave the critical section and try to make sure the
825 * other waiting threads get a chance of entering before we reclaim it.
826 *
827 * @retval true if yielded.
828 * @retval false if not yielded.
829 * @param pVM The cross context VM structure.
830 * @param pCritSect The critical section.
831 */
832VMMR3DECL(bool) PDMR3CritSectYield(PVM pVM, PPDMCRITSECT pCritSect)
833{
834 AssertPtrReturn(pCritSect, false);
835 AssertReturn(pCritSect->s.Core.u32Magic == RTCRITSECT_MAGIC, false);
836 Assert(pCritSect->s.Core.NativeThreadOwner == RTThreadNativeSelf());
837 Assert(!(pCritSect->s.Core.fFlags & RTCRITSECT_FLAGS_NOP));
838 RT_NOREF(pVM);
839
840 /* No recursion allowed here. */
841 int32_t const cNestings = pCritSect->s.Core.cNestings;
842 AssertReturn(cNestings == 1, false);
843
844 int32_t const cLockers = ASMAtomicReadS32(&pCritSect->s.Core.cLockers);
845 if (cLockers < cNestings)
846 return false;
847
848#ifdef PDMCRITSECT_STRICT
849 RTLOCKVALSRCPOS const SrcPos = pCritSect->s.Core.pValidatorRec->SrcPos;
850#endif
851 PDMCritSectLeave(pVM, pCritSect);
852
853 /*
854 * If we're lucky, then one of the waiters has entered the lock already.
855 * We spin a little bit in hope for this to happen so we can avoid the
856 * yield detour.
857 */
858 if (ASMAtomicUoReadS32(&pCritSect->s.Core.cNestings) == 0)
859 {
860 int cLoops = 20;
861 while ( cLoops > 0
862 && ASMAtomicUoReadS32(&pCritSect->s.Core.cNestings) == 0
863 && ASMAtomicUoReadS32(&pCritSect->s.Core.cLockers) >= 0)
864 {
865 ASMNopPause();
866 cLoops--;
867 }
868 if (cLoops == 0)
869 RTThreadYield();
870 }
871
872#ifdef PDMCRITSECT_STRICT
873 int rc = PDMCritSectEnterDebug(pVM, pCritSect, VERR_IGNORED,
874 SrcPos.uId, SrcPos.pszFile, SrcPos.uLine, SrcPos.pszFunction);
875#else
876 int rc = PDMCritSectEnter(pVM, pCritSect, VERR_IGNORED);
877#endif
878 PDM_CRITSECT_RELEASE_ASSERT_RC(pVM, pCritSect, rc);
879 return true;
880}
881
882
883/**
884 * PDMR3CritSectBothCountOwned worker.
885 *
886 * @param pszName The critical section name.
887 * @param ppszNames Pointer to the pszNames variable.
888 * @param pcchLeft Pointer to the cchLeft variable.
889 * @param fFirst Whether this is the first name or not.
890 */
891static void pdmR3CritSectAppendNameToList(char const *pszName, char **ppszNames, size_t *pcchLeft, bool fFirst)
892{
893 size_t cchLeft = *pcchLeft;
894 if (cchLeft)
895 {
896 char *pszNames = *ppszNames;
897
898 /* try add comma. */
899 if (fFirst)
900 {
901 *pszNames++ = ',';
902 if (--cchLeft)
903 {
904 *pszNames++ = ' ';
905 cchLeft--;
906 }
907 }
908
909 /* try copy the name. */
910 if (cchLeft)
911 {
912 size_t const cchName = strlen(pszName);
913 if (cchName < cchLeft)
914 {
915 memcpy(pszNames, pszName, cchName);
916 pszNames += cchName;
917 cchLeft -= cchName;
918 }
919 else
920 {
921 if (cchLeft > 2)
922 {
923 memcpy(pszNames, pszName, cchLeft - 2);
924 pszNames += cchLeft - 2;
925 cchLeft = 2;
926 }
927 while (cchLeft-- > 0)
928 *pszNames++ = '+';
929 }
930 }
931 *pszNames = '\0';
932
933 *pcchLeft = cchLeft;
934 *ppszNames = pszNames;
935 }
936}
937
938
939/**
940 * Counts the critical sections (both type) owned by the calling thread,
941 * optionally returning a comma separated list naming them.
942 *
943 * Read ownerships are not included in non-strict builds.
944 *
945 * This is for diagnostic purposes only.
946 *
947 * @returns Lock count.
948 *
949 * @param pVM The cross context VM structure.
950 * @param pszNames Where to return the critical section names.
951 * @param cbNames The size of the buffer.
952 */
953VMMR3DECL(uint32_t) PDMR3CritSectCountOwned(PVM pVM, char *pszNames, size_t cbNames)
954{
955 /*
956 * Init the name buffer.
957 */
958 size_t cchLeft = cbNames;
959 if (cchLeft)
960 {
961 cchLeft--;
962 pszNames[0] = pszNames[cchLeft] = '\0';
963 }
964
965 /*
966 * Iterate the critical sections.
967 */
968 uint32_t cCritSects = 0;
969 RTNATIVETHREAD const hNativeThread = RTThreadNativeSelf();
970 /* This is unsafe, but wtf. */
971 for (PPDMCRITSECTINT pCur = pVM->pUVM->pdm.s.pCritSects;
972 pCur;
973 pCur = pCur->pNext)
974 {
975 /* Same as RTCritSectIsOwner(). */
976 if (pCur->Core.NativeThreadOwner == hNativeThread)
977 {
978 cCritSects++;
979 pdmR3CritSectAppendNameToList(pCur->pszName, &pszNames, &cchLeft, cCritSects == 1);
980 }
981 }
982
983 /* This is unsafe, but wtf. */
984 for (PPDMCRITSECTRWINT pCur = pVM->pUVM->pdm.s.pRwCritSects;
985 pCur;
986 pCur = pCur->pNext)
987 {
988 if ( pCur->Core.hNativeWriter == hNativeThread
989 || PDMCritSectRwIsReadOwner(pVM, (PPDMCRITSECTRW)pCur, false /*fWannaHear*/) )
990 {
991 cCritSects++;
992 pdmR3CritSectAppendNameToList(pCur->pszName, &pszNames, &cchLeft, cCritSects == 1);
993 }
994 }
995
996 return cCritSects;
997}
998
999
1000/**
1001 * Leave all critical sections the calling thread owns.
1002 *
1003 * This is only used when entering guru meditation in order to prevent other
1004 * EMTs and I/O threads from deadlocking.
1005 *
1006 * @param pVM The cross context VM structure.
1007 */
1008VMMR3_INT_DECL(void) PDMR3CritSectLeaveAll(PVM pVM)
1009{
1010 RTNATIVETHREAD const hNativeSelf = RTThreadNativeSelf();
1011 PUVM pUVM = pVM->pUVM;
1012
1013 RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
1014 for (PPDMCRITSECTINT pCur = pUVM->pdm.s.pCritSects;
1015 pCur;
1016 pCur = pCur->pNext)
1017 {
1018 while ( pCur->Core.NativeThreadOwner == hNativeSelf
1019 && pCur->Core.cNestings > 0)
1020 PDMCritSectLeave(pVM, (PPDMCRITSECT)pCur);
1021 }
1022 RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
1023}
1024
1025
1026/**
1027 * Gets the address of the NOP critical section.
1028 *
1029 * The NOP critical section will not perform any thread serialization but let
1030 * all enter immediately and concurrently.
1031 *
1032 * @returns The address of the NOP critical section.
1033 * @param pVM The cross context VM structure.
1034 */
1035VMMR3DECL(PPDMCRITSECT) PDMR3CritSectGetNop(PVM pVM)
1036{
1037 VM_ASSERT_VALID_EXT_RETURN(pVM, NULL);
1038 return &pVM->pdm.s.NopCritSect;
1039}
1040
1041
1042/**
1043 * Gets the ring-0 address of the NOP critical section.
1044 *
1045 * @returns The ring-0 address of the NOP critical section.
1046 * @param pVM The cross context VM structure.
1047 */
1048VMMR3DECL(R0PTRTYPE(PPDMCRITSECT)) PDMR3CritSectGetNopR0(PVM pVM)
1049{
1050 VM_ASSERT_VALID_EXT_RETURN(pVM, NIL_RTR0PTR);
1051 return MMHyperR3ToR0(pVM, &pVM->pdm.s.NopCritSect);
1052}
1053
1054
1055/**
1056 * Gets the raw-mode context address of the NOP critical section.
1057 *
1058 * @returns The raw-mode context address of the NOP critical section.
1059 * @param pVM The cross context VM structure.
1060 */
1061VMMR3DECL(RCPTRTYPE(PPDMCRITSECT)) PDMR3CritSectGetNopRC(PVM pVM)
1062{
1063 VM_ASSERT_VALID_EXT_RETURN(pVM, NIL_RTRCPTR);
1064 return MMHyperR3ToRC(pVM, &pVM->pdm.s.NopCritSect);
1065}
1066
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