VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR3/NEMR3.cpp@ 99370

Last change on this file since 99370 was 99370, checked in by vboxsync, 14 months ago

VMM/NEM-win: Disable MONITOR/MWAIT CPUID flag as it seems Hyper-V never implements MONITOR and only sometimes MWAIT. Reportely causes troubles for Solaris guests. Untested!

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 18.8 KB
RevLine 
[70918]1/* $Id: NEMR3.cpp 99370 2023-04-11 00:32:33Z vboxsync $ */
2/** @file
3 * NEM - Native execution manager.
4 */
5
6/*
[98103]7 * Copyright (C) 2018-2023 Oracle and/or its affiliates.
[70918]8 *
[96407]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
[70918]26 */
27
28/** @page pg_nem NEM - Native Execution Manager.
29 *
[71283]30 * This is an alternative execution manage to HM and raw-mode. On one host
31 * (Windows) we're forced to use this, on the others we just do it because we
32 * can. Since this is host specific in nature, information about an
33 * implementation is contained in the NEMR3Native-xxxx.cpp files.
[70918]34 *
[71284]35 * @ref pg_nem_win
[70918]36 */
37
38
39/*********************************************************************************************************************************
40* Header Files *
41*********************************************************************************************************************************/
42#define LOG_GROUP LOG_GROUP_NEM
[93787]43#include <VBox/vmm/dbgf.h>
[70918]44#include <VBox/vmm/nem.h>
[72470]45#include <VBox/vmm/gim.h>
[70918]46#include "NEMInternal.h"
47#include <VBox/vmm/vm.h>
[72267]48#include <VBox/vmm/uvm.h>
[76397]49#include <VBox/err.h>
[70918]50
[70948]51#include <iprt/asm.h>
[99370]52#include <iprt/string.h>
[70918]53
54
[70948]55
[70918]56/**
57 * Basic init and configuration reading.
58 *
59 * Always call NEMR3Term after calling this.
60 *
61 * @returns VBox status code.
[70945]62 * @param pVM The cross context VM structure.
[70918]63 */
64VMMR3_INT_DECL(int) NEMR3InitConfig(PVM pVM)
65{
66 LogFlow(("NEMR3Init\n"));
67
68 /*
69 * Assert alignment and sizes.
70 */
71 AssertCompileMemberAlignment(VM, nem.s, 64);
72 AssertCompile(sizeof(pVM->nem.s) <= sizeof(pVM->nem.padding));
73
74 /*
75 * Initialize state info so NEMR3Term will always be happy.
76 * No returning prior to setting magics!
77 */
78 pVM->nem.s.u32Magic = NEM_MAGIC;
[80191]79 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
80 {
81 PVMCPU pVCpu = pVM->apCpusR3[idCpu];
82 pVCpu->nem.s.u32Magic = NEMCPU_MAGIC;
83 }
[70918]84
85 /*
86 * Read configuration.
87 */
88 PCFGMNODE pCfgNem = CFGMR3GetChild(CFGMR3GetRoot(pVM), "NEM/");
89
90 /*
91 * Validate the NEM settings.
92 */
93 int rc = CFGMR3ValidateConfig(pCfgNem,
94 "/NEM/",
[72343]95 "Enabled"
[72924]96 "|Allow64BitGuests"
[86115]97 "|LovelyMesaDrvWorkaround"
[72924]98#ifdef RT_OS_WINDOWS
99 "|UseRing0Runloop"
[93722]100#elif defined(RT_OS_DARWIN)
101 "|VmxPleGap"
102 "|VmxPleWindow"
103 "|VmxLbr"
[72924]104#endif
105 ,
[70918]106 "" /* pszValidNodes */, "NEM" /* pszWho */, 0 /* uInstance */);
107 if (RT_FAILURE(rc))
108 return rc;
109
110 /** @cfgm{/NEM/NEMEnabled, bool, true}
111 * Whether NEM is enabled. */
112 rc = CFGMR3QueryBoolDef(pCfgNem, "Enabled", &pVM->nem.s.fEnabled, true);
113 AssertLogRelRCReturn(rc, rc);
114
[72343]115
116#ifdef VBOX_WITH_64_BITS_GUESTS
[72924]117 /** @cfgm{/NEM/Allow64BitGuests, bool, 32-bit:false, 64-bit:true}
[72343]118 * Enables AMD64 CPU features.
119 * On 32-bit hosts this isn't default and require host CPU support. 64-bit hosts
120 * already have the support. */
121 rc = CFGMR3QueryBoolDef(pCfgNem, "Allow64BitGuests", &pVM->nem.s.fAllow64BitGuests, HC_ARCH_BITS == 64);
122 AssertLogRelRCReturn(rc, rc);
123#else
124 pVM->nem.s.fAllow64BitGuests = false;
125#endif
126
[86117]127 /** @cfgm{/NEM/LovelyMesaDrvWorkaround, bool, false}
[86115]128 * Workaround for mesa vmsvga 3d driver making incorrect assumptions about
129 * the hypervisor it is running under. */
130 bool f;
131 rc = CFGMR3QueryBoolDef(pCfgNem, "LovelyMesaDrvWorkaround", &f, false);
132 AssertLogRelRCReturn(rc, rc);
133 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
134 {
135 PVMCPU pVCpu = pVM->apCpusR3[idCpu];
136 pVCpu->nem.s.fTrapXcptGpForLovelyMesaDrv = f;
137 }
138
[70918]139 return VINF_SUCCESS;
140}
141
142
143/**
144 * This is called by HMR3Init() when HM cannot be used.
145 *
[70948]146 * Sets VM::bMainExecutionEngine to VM_EXEC_ENGINE_NATIVE_API if we can use a
147 * native hypervisor API to execute the VM.
[70918]148 *
149 * @returns VBox status code.
[70945]150 * @param pVM The cross context VM structure.
[70918]151 * @param fFallback Whether this is a fallback call. Cleared if the VM is
152 * configured to use NEM instead of HM.
153 * @param fForced Whether /HM/HMForced was set. If set and we fail to
154 * enable NEM, we'll return a failure status code.
155 * Otherwise we'll assume HMR3Init falls back on raw-mode.
156 */
157VMMR3_INT_DECL(int) NEMR3Init(PVM pVM, bool fFallback, bool fForced)
158{
[70948]159 Assert(pVM->bMainExecutionEngine != VM_EXEC_ENGINE_NATIVE_API);
[70918]160 int rc;
161 if (pVM->nem.s.fEnabled)
162 {
163#ifdef VBOX_WITH_NATIVE_NEM
164 rc = nemR3NativeInit(pVM, fFallback, fForced);
[70948]165 ASMCompilerBarrier(); /* May have changed bMainExecutionEngine. */
[70918]166#else
167 RT_NOREF(fFallback);
168 rc = VINF_SUCCESS;
169#endif
170 if (RT_SUCCESS(rc))
171 {
[70948]172 if (pVM->bMainExecutionEngine == VM_EXEC_ENGINE_NATIVE_API)
[92225]173 {
174#ifdef RT_OS_WINDOWS /* The WHv* API is extremely slow at handling VM exits. The AppleHv and
175 KVM APIs are much faster, thus the different mode name. :-) */
176 LogRel(("NEM:\n"
177 "NEM: NEMR3Init: Snail execution mode is active!\n"
178 "NEM: Note! VirtualBox is not able to run at its full potential in this execution mode.\n"
179 "NEM: To see VirtualBox run at max speed you need to disable all Windows features\n"
180 "NEM: making use of Hyper-V. That is a moving target, so google how and carefully\n"
181 "NEM: consider the consequences of disabling these features.\n"
182 "NEM:\n"));
183#else
184 LogRel(("NEM:\n"
185 "NEM: NEMR3Init: Turtle execution mode is active!\n"
186 "NEM: Note! VirtualBox is not able to run at its full potential in this execution mode.\n"
187 "NEM:\n"));
188#endif
189 }
[70918]190 else
191 {
192 LogRel(("NEM: NEMR3Init: Not available.\n"));
193 if (fForced)
194 rc = VERR_NEM_NOT_AVAILABLE;
195 }
196 }
197 else
198 LogRel(("NEM: NEMR3Init: Native init failed: %Rrc.\n", rc));
199 }
200 else
201 {
202 LogRel(("NEM: NEMR3Init: Disabled.\n"));
203 rc = fForced ? VERR_NEM_NOT_ENABLED : VINF_SUCCESS;
204 }
205 return rc;
206}
207
208
209/**
[70945]210 * Perform initialization that depends on CPUM working.
211 *
212 * This is a noop if NEM wasn't activated by a previous NEMR3Init() call.
213 *
214 * @returns VBox status code.
215 * @param pVM The cross context VM structure.
216 */
217VMMR3_INT_DECL(int) NEMR3InitAfterCPUM(PVM pVM)
218{
219 int rc = VINF_SUCCESS;
[72343]220 if (pVM->bMainExecutionEngine == VM_EXEC_ENGINE_NATIVE_API)
221 {
222 /*
223 * Do native after-CPUM init.
224 */
[70945]225#ifdef VBOX_WITH_NATIVE_NEM
226 rc = nemR3NativeInitAfterCPUM(pVM);
[70946]227#else
[72343]228 RT_NOREF(pVM);
[70945]229#endif
[72343]230 }
[70945]231 return rc;
232}
233
234
235/**
[70918]236 * Called when a init phase has completed.
237 *
238 * @returns VBox status code.
[70945]239 * @param pVM The cross context VM structure.
240 * @param enmWhat The phase that completed.
[70918]241 */
242VMMR3_INT_DECL(int) NEMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat)
243{
[72470]244 /*
245 * Check if GIM needs #UD, since that applies to everyone.
246 */
247 if (enmWhat == VMINITCOMPLETED_RING3)
[80191]248 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
249 {
250 PVMCPU pVCpu = pVM->apCpusR3[idCpu];
251 pVCpu->nem.s.fGIMTrapXcptUD = GIMShouldTrapXcptUD(pVCpu);
252 }
[72470]253
254 /*
255 * Call native code.
256 */
[70918]257 int rc = VINF_SUCCESS;
258#ifdef VBOX_WITH_NATIVE_NEM
[70948]259 if (pVM->bMainExecutionEngine == VM_EXEC_ENGINE_NATIVE_API)
[70918]260 rc = nemR3NativeInitCompleted(pVM, enmWhat);
261#else
262 RT_NOREF(pVM, enmWhat);
263#endif
264 return rc;
265}
266
267
268/**
269 *
270 * @returns VBox status code.
[70945]271 * @param pVM The cross context VM structure.
[70918]272 */
273VMMR3_INT_DECL(int) NEMR3Term(PVM pVM)
274{
275 AssertReturn(pVM->nem.s.u32Magic == NEM_MAGIC, VERR_WRONG_ORDER);
[80191]276 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
277 AssertReturn(pVM->apCpusR3[idCpu]->nem.s.u32Magic == NEMCPU_MAGIC, VERR_WRONG_ORDER);
[70918]278
279 /* Do native termination. */
280 int rc = VINF_SUCCESS;
281#ifdef VBOX_WITH_NATIVE_NEM
[70948]282 if (pVM->bMainExecutionEngine == VM_EXEC_ENGINE_NATIVE_API)
[70918]283 rc = nemR3NativeTerm(pVM);
284#endif
285
286 /* Mark it as terminated. */
[80191]287 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
288 {
289 PVMCPU pVCpu = pVM->apCpusR3[idCpu];
290 pVCpu->nem.s.u32Magic = NEMCPU_MAGIC_DEAD;
291 }
[70918]292 pVM->nem.s.u32Magic = NEM_MAGIC_DEAD;
293 return rc;
294}
295
[72267]296/**
297 * External interface for querying whether native execution API is used.
298 *
299 * @returns true if NEM is being used, otherwise false.
300 * @param pUVM The user mode VM handle.
301 * @sa HMR3IsEnabled
302 */
303VMMR3DECL(bool) NEMR3IsEnabled(PUVM pUVM)
304{
305 UVM_ASSERT_VALID_EXT_RETURN(pUVM, false);
306 PVM pVM = pUVM->pVM;
307 VM_ASSERT_VALID_EXT_RETURN(pVM, false);
308 return VM_IS_NEM_ENABLED(pVM);
309}
[70918]310
[72267]311
[70918]312/**
313 * The VM is being reset.
314 *
315 * @param pVM The cross context VM structure.
316 */
317VMMR3_INT_DECL(void) NEMR3Reset(PVM pVM)
318{
319#ifdef VBOX_WITH_NATIVE_NEM
[70948]320 if (pVM->bMainExecutionEngine == VM_EXEC_ENGINE_NATIVE_API)
[70918]321 nemR3NativeReset(pVM);
322#else
323 RT_NOREF(pVM);
324#endif
325}
326
327
328/**
329 * Resets a virtual CPU.
330 *
331 * Used to bring up secondary CPUs on SMP as well as CPU hot plugging.
332 *
[71040]333 * @param pVCpu The cross context virtual CPU structure to reset.
334 * @param fInitIpi Set if being reset due to INIT IPI.
[70918]335 */
[71040]336VMMR3_INT_DECL(void) NEMR3ResetCpu(PVMCPU pVCpu, bool fInitIpi)
[70918]337{
338#ifdef VBOX_WITH_NATIVE_NEM
[70948]339 if (pVCpu->pVMR3->bMainExecutionEngine == VM_EXEC_ENGINE_NATIVE_API)
[71040]340 nemR3NativeResetCpu(pVCpu, fInitIpi);
[70918]341#else
[71040]342 RT_NOREF(pVCpu, fInitIpi);
[70918]343#endif
344}
345
[70954]346
[72526]347/**
348 * Indicates to TM that TMTSCMODE_NATIVE_API should be used for TSC.
349 *
350 * @returns true if TMTSCMODE_NATIVE_API must be used, otherwise @c false.
351 * @param pVM The cross context VM structure.
352 */
353VMMR3_INT_DECL(bool) NEMR3NeedSpecialTscMode(PVM pVM)
354{
355#ifdef VBOX_WITH_NATIVE_NEM
356 if (VM_IS_NEM_ENABLED(pVM))
357 return true;
358#else
359 RT_NOREF(pVM);
360#endif
361 return false;
362}
363
364
[72555]365/**
366 * Gets the name of a generic NEM exit code.
367 *
368 * @returns Pointer to read only string if @a uExit is known, otherwise NULL.
369 * @param uExit The NEM exit to name.
370 */
371VMMR3DECL(const char *) NEMR3GetExitName(uint32_t uExit)
372{
373 switch ((NEMEXITTYPE)uExit)
374 {
[92525]375 case NEMEXITTYPE_INTTERRUPT_WINDOW: return "NEM interrupt window";
376 case NEMEXITTYPE_HALT: return "NEM halt";
377
[72555]378 case NEMEXITTYPE_UNRECOVERABLE_EXCEPTION: return "NEM unrecoverable exception";
379 case NEMEXITTYPE_INVALID_VP_REGISTER_VALUE: return "NEM invalid vp register value";
380 case NEMEXITTYPE_XCPT_UD: return "NEM #UD";
381 case NEMEXITTYPE_XCPT_DB: return "NEM #DB";
382 case NEMEXITTYPE_XCPT_BP: return "NEM #BP";
383 case NEMEXITTYPE_CANCELED: return "NEM canceled";
[72575]384 case NEMEXITTYPE_MEMORY_ACCESS: return "NEM memory access";
[92525]385
386 case NEMEXITTYPE_INTERNAL_ERROR_EMULATION: return "NEM emulation IPE";
387 case NEMEXITTYPE_INTERNAL_ERROR_FATAL: return "NEM fatal IPE";
388 case NEMEXITTYPE_INTERRUPTED: return "NEM interrupted";
389 case NEMEXITTYPE_FAILED_ENTRY: return "NEM failed VT-x/AMD-V entry";
390
391 case NEMEXITTYPE_INVALID:
392 case NEMEXITTYPE_END:
393 break;
[72555]394 }
[72526]395
[72555]396 return NULL;
397}
398
399
[70979]400VMMR3_INT_DECL(VBOXSTRICTRC) NEMR3RunGC(PVM pVM, PVMCPU pVCpu)
401{
402 Assert(VM_IS_NEM_ENABLED(pVM));
[70980]403#ifdef VBOX_WITH_NATIVE_NEM
[70979]404 return nemR3NativeRunGC(pVM, pVCpu);
[70980]405#else
406 NOREF(pVM); NOREF(pVCpu);
407 return VERR_INTERNAL_ERROR_3;
408#endif
[70979]409}
410
411
[92120]412#ifndef VBOX_WITH_NATIVE_NEM
[72634]413VMMR3_INT_DECL(bool) NEMR3CanExecuteGuest(PVM pVM, PVMCPU pVCpu)
[70979]414{
[92120]415 RT_NOREF(pVM, pVCpu);
[70980]416 return false;
[92120]417}
[70980]418#endif
[70979]419
420
421VMMR3_INT_DECL(bool) NEMR3SetSingleInstruction(PVM pVM, PVMCPU pVCpu, bool fEnable)
422{
423 Assert(VM_IS_NEM_ENABLED(pVM));
[70980]424#ifdef VBOX_WITH_NATIVE_NEM
[70979]425 return nemR3NativeSetSingleInstruction(pVM, pVCpu, fEnable);
[70980]426#else
427 NOREF(pVM); NOREF(pVCpu); NOREF(fEnable);
428 return false;
429#endif
[70979]430}
431
432
[71040]433VMMR3_INT_DECL(void) NEMR3NotifyFF(PVM pVM, PVMCPU pVCpu, uint32_t fFlags)
434{
435 AssertLogRelReturnVoid(VM_IS_NEM_ENABLED(pVM));
436#ifdef VBOX_WITH_NATIVE_NEM
437 nemR3NativeNotifyFF(pVM, pVCpu, fFlags);
438#else
439 RT_NOREF(pVM, pVCpu, fFlags);
440#endif
441}
[70979]442
[93905]443#ifndef VBOX_WITH_NATIVE_NEM
[71040]444
[70954]445VMMR3_INT_DECL(void) NEMR3NotifySetA20(PVMCPU pVCpu, bool fEnabled)
446{
[92120]447 RT_NOREF(pVCpu, fEnabled);
448}
[70954]449
[93905]450# ifdef VBOX_WITH_PGM_NEM_MODE
[93787]451
[93905]452VMMR3_INT_DECL(bool) NEMR3IsMmio2DirtyPageTrackingSupported(PVM pVM)
453{
454 RT_NOREF(pVM);
455 return false;
456}
457
458
459VMMR3_INT_DECL(int) NEMR3PhysMmio2QueryAndResetDirtyBitmap(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t uNemRange,
460 void *pvBitmap, size_t cbBitmap)
461{
462 RT_NOREF(pVM, GCPhys, cb, uNemRange, pvBitmap, cbBitmap);
463 AssertFailed();
464 return VERR_INTERNAL_ERROR_2;
465}
466
467
468VMMR3_INT_DECL(int) NEMR3NotifyPhysMmioExMapEarly(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags,
469 void *pvRam, void *pvMmio2, uint8_t *pu2State, uint32_t *puNemRange)
470{
471 RT_NOREF(pVM, GCPhys, cb, fFlags, pvRam, pvMmio2, pu2State, puNemRange);
472 AssertFailed();
473 return VERR_INTERNAL_ERROR_2;
474}
475
476# endif /* VBOX_WITH_PGM_NEM_MODE */
477#endif /* !VBOX_WITH_NATIVE_NEM */
478
[93787]479/**
480 * Notification callback from DBGF when interrupt breakpoints or generic debug
481 * event settings changes.
482 *
483 * DBGF will call NEMR3NotifyDebugEventChangedPerCpu on each CPU afterwards, this
484 * function is just updating the VM globals.
485 *
486 * @param pVM The VM cross context VM structure.
487 * @thread EMT(0)
488 */
489VMMR3_INT_DECL(void) NEMR3NotifyDebugEventChanged(PVM pVM)
490{
491 AssertLogRelReturnVoid(VM_IS_NEM_ENABLED(pVM));
492
[93788]493#ifdef VBOX_WITH_NATIVE_NEM
[93787]494 /* Interrupts. */
495 bool fUseDebugLoop = pVM->dbgf.ro.cSoftIntBreakpoints > 0
496 || pVM->dbgf.ro.cHardIntBreakpoints > 0;
497
498 /* CPU Exceptions. */
499 for (DBGFEVENTTYPE enmEvent = DBGFEVENT_XCPT_FIRST;
500 !fUseDebugLoop && enmEvent <= DBGFEVENT_XCPT_LAST;
501 enmEvent = (DBGFEVENTTYPE)(enmEvent + 1))
502 fUseDebugLoop = DBGF_IS_EVENT_ENABLED(pVM, enmEvent);
503
504 /* Common VM exits. */
505 for (DBGFEVENTTYPE enmEvent = DBGFEVENT_EXIT_FIRST;
506 !fUseDebugLoop && enmEvent <= DBGFEVENT_EXIT_LAST_COMMON;
507 enmEvent = (DBGFEVENTTYPE)(enmEvent + 1))
508 fUseDebugLoop = DBGF_IS_EVENT_ENABLED(pVM, enmEvent);
509
510 /* Done. */
511 pVM->nem.s.fUseDebugLoop = nemR3NativeNotifyDebugEventChanged(pVM, fUseDebugLoop);
[93788]512#else
513 RT_NOREF(pVM);
514#endif
[93787]515}
516
517
518/**
519 * Follow up notification callback to NEMR3NotifyDebugEventChanged for each CPU.
520 *
521 * NEM uses this to combine the decision made NEMR3NotifyDebugEventChanged with
522 * per CPU settings.
523 *
524 * @param pVM The VM cross context VM structure.
525 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
526 */
527VMMR3_INT_DECL(void) NEMR3NotifyDebugEventChangedPerCpu(PVM pVM, PVMCPU pVCpu)
528{
529 AssertLogRelReturnVoid(VM_IS_NEM_ENABLED(pVM));
530
[93788]531#ifdef VBOX_WITH_NATIVE_NEM
[93787]532 pVCpu->nem.s.fUseDebugLoop = nemR3NativeNotifyDebugEventChangedPerCpu(pVM, pVCpu,
533 pVCpu->nem.s.fSingleInstruction | pVM->nem.s.fUseDebugLoop);
[93788]534#else
535 RT_NOREF(pVM, pVCpu);
536#endif
[93787]537}
[99370]538
539
540/**
541 * Disables a CPU ISA extension, like MONITOR/MWAIT.
542 *
543 * @returns VBox status code
544 * @param pVM The cross context VM structure.
545 * @param pszIsaExt The ISA extension name in the config tree.
546 */
547int nemR3DisableCpuIsaExt(PVM pVM, const char *pszIsaExt)
548{
549 /*
550 * Get IsaExts config node under CPUM.
551 */
552 PCFGMNODE pIsaExts = CFGMR3GetChild(CFGMR3GetRoot(pVM), "/CPUM/IsaExts");
553 if (!pIsaExts)
554 {
555 int rc = CFGMR3InsertNode(CFGMR3GetRoot(pVM), "/CPUM/IsaExts", &pIsaExts);
556 AssertLogRelMsgReturn(RT_SUCCESS(rc), ("CFGMR3InsertNode: rc=%Rrc pszIsaExt=%s\n", rc, pszIsaExt), rc);
557 }
558
559 /*
560 * Look for a value by the given name (pszIsaExt).
561 */
562 /* Integer values 1 (CPUMISAEXTCFG_ENABLED_SUPPORTED) and 9 (CPUMISAEXTCFG_ENABLED_PORTABLE) will be replaced. */
563 uint64_t u64Value;
564 int rc = CFGMR3QueryInteger(pIsaExts, pszIsaExt, &u64Value);
565 if (RT_SUCCESS(rc))
566 {
567 if (u64Value != 1 && u64Value != 9)
568 {
569 LogRel(("NEM: Not disabling IsaExt '%s', already configured with int value %lld\n", pszIsaExt, u64Value));
570 return VINF_SUCCESS;
571 }
572 CFGMR3RemoveValue(pIsaExts, pszIsaExt);
573 }
574 /* String value 'default', 'enabled' and 'portable' will be replaced. */
575 else if (rc == VERR_CFGM_NOT_INTEGER)
576 {
577 char szValue[32];
578 rc = CFGMR3QueryString(pIsaExts, pszIsaExt, szValue, sizeof(szValue));
579 AssertRCReturn(rc, VINF_SUCCESS);
580
581 if ( RTStrICmpAscii(szValue, "default") != 0
582 && RTStrICmpAscii(szValue, "def") != 0
583 && RTStrICmpAscii(szValue, "enabled") != 0
584 && RTStrICmpAscii(szValue, "enable") != 0
585 && RTStrICmpAscii(szValue, "on") != 0
586 && RTStrICmpAscii(szValue, "yes") != 0
587 && RTStrICmpAscii(szValue, "portable") != 0)
588 {
589 LogRel(("NEM: Not disabling IsaExt '%s', already configured with string value '%s'\n", pszIsaExt, szValue));
590 return VINF_SUCCESS;
591 }
592 CFGMR3RemoveValue(pIsaExts, pszIsaExt);
593 }
594 else
595 AssertLogRelMsgReturn(rc == VERR_CFGM_VALUE_NOT_FOUND, ("CFGMR3QueryInteger: rc=%Rrc pszIsaExt=%s\n", rc, pszIsaExt),
596 VERR_NEM_IPE_8);
597
598 /*
599 * Insert the disabling value.
600 */
601 rc = CFGMR3InsertInteger(pIsaExts, pszIsaExt, 0 /* disabled */);
602 AssertLogRelMsgReturn(RT_SUCCESS(rc), ("CFGMR3InsertInteger: rc=%Rrc pszIsaExt=%s\n", rc, pszIsaExt), rc);
603
604 return VINF_SUCCESS;
605}
606
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use