VirtualBox

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

Last change on this file since 107631 was 106920, checked in by vboxsync, 2 months ago

/Config.kmk,Devices/Makefile.kmk,VMM/*: Introducing VBOX_WITH_MINIMAL_R0 for win.arm64 and similar build configurations not really needing much from VMMR0.r0/VBoxSup.sys. jiraref:VBP-1449

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