VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMRZ/VMMRZ.cpp@ 96860

Last change on this file since 96860 was 96407, checked in by vboxsync, 22 months ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/* $Id: VMMRZ.cpp 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * VMM - Virtual Machine Monitor, Raw-mode and ring-0 context code.
4 */
5
6/*
7 * Copyright (C) 2009-2022 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_VMM
33#include <VBox/vmm/vmm.h>
34#include "VMMInternal.h"
35#include <VBox/vmm/vmcc.h>
36
37#include <iprt/assert.h>
38#include <iprt/asm-amd64-x86.h>
39#include <iprt/errcore.h>
40#include <iprt/string.h>
41
42
43/**
44 * Disables all host calls, except certain fatal ones.
45 *
46 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
47 * @thread EMT.
48 */
49VMMRZDECL(void) VMMRZCallRing3Disable(PVMCPUCC pVCpu)
50{
51 VMCPU_ASSERT_EMT(pVCpu);
52#if defined(LOG_ENABLED) && defined(IN_RING0)
53 RTCCUINTREG fFlags = ASMIntDisableFlags(); /* preemption consistency. */
54#endif
55
56 Assert(pVCpu->vmmr0.s.cCallRing3Disabled < 16);
57 if (ASMAtomicUoIncU32(&pVCpu->vmmr0.s.cCallRing3Disabled) == 1)
58 {
59#ifdef IN_RC
60 pVCpu->pVMRC->vmm.s.fRCLoggerFlushingDisabled = true;
61#else
62 pVCpu->vmmr0.s.fLogFlushingDisabled = true;
63#endif
64 }
65
66#if defined(LOG_ENABLED) && defined(IN_RING0)
67 ASMSetFlags(fFlags);
68#endif
69}
70
71
72/**
73 * Counters VMMRZCallRing3Disable() and re-enables host calls.
74 *
75 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
76 * @thread EMT.
77 */
78VMMRZDECL(void) VMMRZCallRing3Enable(PVMCPUCC pVCpu)
79{
80 VMCPU_ASSERT_EMT(pVCpu);
81#if defined(LOG_ENABLED) && defined(IN_RING0)
82 RTCCUINTREG fFlags = ASMIntDisableFlags(); /* preemption consistency. */
83#endif
84
85 Assert(pVCpu->vmmr0.s.cCallRing3Disabled > 0);
86 if (ASMAtomicUoDecU32(&pVCpu->vmmr0.s.cCallRing3Disabled) == 0)
87 {
88#ifdef IN_RC
89 pVCpu->pVMRC->vmm.s.fRCLoggerFlushingDisabled = false;
90#else
91 pVCpu->vmmr0.s.fLogFlushingDisabled = false;
92#endif
93 }
94
95#if defined(LOG_ENABLED) && defined(IN_RING0)
96 ASMSetFlags(fFlags);
97#endif
98}
99
100
101/**
102 * Checks whether its possible to call host context or not.
103 *
104 * @returns true if it's safe, false if it isn't.
105 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
106 */
107VMMRZDECL(bool) VMMRZCallRing3IsEnabled(PVMCPUCC pVCpu)
108{
109 VMCPU_ASSERT_EMT(pVCpu);
110 Assert(pVCpu->vmmr0.s.cCallRing3Disabled <= 16);
111 return pVCpu->vmmr0.s.cCallRing3Disabled == 0;
112}
113
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use