VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR0/EMR0.cpp@ 80274

Last change on this file since 80274 was 80274, checked in by vboxsync, 6 years ago

VMM: Refactoring VMMR0/* and VMMRZ/* to use VMCC & VMMCPUCC. bugref:9217

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1/* $Id: EMR0.cpp 80274 2019-08-14 14:34:38Z vboxsync $ */
2/** @file
3 * EM - Host Context Ring 0.
4 */
5
6/*
7 * Copyright (C) 2006-2019 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 VBOX_BUGREF_9217_PART_I
23#define LOG_GROUP LOG_GROUP_EM
24#include <VBox/vmm/em.h>
25#include "EMInternal.h"
26#include <VBox/vmm/vmcc.h>
27#include <VBox/vmm/gvm.h>
28#include <iprt/errcore.h>
29#include <VBox/log.h>
30#include <iprt/assert.h>
31#include <iprt/thread.h>
32
33
34
35/**
36 * Adjusts EM configuration options.
37 *
38 * @returns VBox status code.
39 * @param pGVM The ring-0 VM structure.
40 * @param pVM The cross context VM structure.
41 */
42#ifdef VBOX_BUGREF_9217
43VMMR0_INT_DECL(int) EMR0InitVM(PGVM pGVM)
44#else
45VMMR0_INT_DECL(int) EMR0InitVM(PGVM pGVM, PVMCC pVM)
46#endif
47{
48 /*
49 * Override ring-0 exit optimizations settings.
50 */
51#ifdef VBOX_BUGREF_9217
52 PVMCPUCC pVCpu0 = &pGVM->aCpus[0];
53#else
54 PVMCPUCC pVCpu0 = VMCC_GET_CPU_0(pVM);
55#endif
56
57 bool fEnabledR0 = pVCpu0->em.s.fExitOptimizationEnabled
58 && pVCpu0->em.s.fExitOptimizationEnabledR0
59 && (RTThreadPreemptIsPossible() || RTThreadPreemptIsPendingTrusty());
60 bool fEnabledR0PreemptDisabled = fEnabledR0
61 && pVCpu0->em.s.fExitOptimizationEnabledR0PreemptDisabled
62 && RTThreadPreemptIsPendingTrusty();
63 for (VMCPUID idCpu = 0; idCpu < pGVM->cCpus; idCpu++)
64 {
65#ifdef VBOX_BUGREF_9217
66 PVMCPUCC pVCpu = &pGVM->aCpus[idCpu];
67#else
68 PVMCPUCC pVCpu = VMCC_GET_CPU(pVM, idCpu);
69#endif
70 pVCpu->em.s.fExitOptimizationEnabledR0 = fEnabledR0;
71 pVCpu->em.s.fExitOptimizationEnabledR0PreemptDisabled = fEnabledR0PreemptDisabled;
72 }
73
74 return VINF_SUCCESS;
75}
76
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