VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR3/IEMR3.cpp@ 60387

Last change on this file since 60387 was 60384, checked in by vboxsync, 9 years ago

IEM: Marked instructions introduced by the 186, 286, 386 and 486 to speed up debugging bs3kit on the 286.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/* $Id: IEMR3.cpp 60384 2016-04-08 00:16:58Z vboxsync $ */
2/** @file
3 * IEM - Interpreted Execution Manager.
4 */
5
6/*
7 * Copyright (C) 2011-2015 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_EM
23#include <VBox/vmm/iem.h>
24#include <VBox/vmm/cpum.h>
25#include "IEMInternal.h"
26#include <VBox/vmm/vm.h>
27#include <VBox/err.h>
28
29#include <iprt/asm-amd64-x86.h>
30#include <iprt/assert.h>
31
32
33
34/**
35 * Initializes the interpreted execution manager.
36 *
37 * This must be called after CPUM as we're quering information from CPUM about
38 * the guest and host CPUs.
39 *
40 * @returns VBox status code.
41 * @param pVM The cross context VM structure.
42 */
43VMMR3DECL(int) IEMR3Init(PVM pVM)
44{
45 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
46 {
47 PVMCPU pVCpu = &pVM->aCpus[idCpu];
48 pVCpu->iem.s.offVM = -RT_OFFSETOF(VM, aCpus[idCpu].iem.s);
49 pVCpu->iem.s.offVMCpu = -RT_OFFSETOF(VMCPU, iem.s);
50 pVCpu->iem.s.pCtxR3 = CPUMQueryGuestCtxPtr(pVCpu);
51 pVCpu->iem.s.pCtxR0 = VM_R0_ADDR(pVM, pVCpu->iem.s.pCtxR3);
52 pVCpu->iem.s.pCtxRC = VM_RC_ADDR(pVM, pVCpu->iem.s.pCtxR3);
53
54 STAMR3RegisterF(pVM, &pVCpu->iem.s.cInstructions, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
55 "Instructions interpreted", "/IEM/CPU%u/cInstructions", idCpu);
56 STAMR3RegisterF(pVM, &pVCpu->iem.s.cPotentialExits, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
57 "Potential exits", "/IEM/CPU%u/cPotentialExits", idCpu);
58 STAMR3RegisterF(pVM, &pVCpu->iem.s.cRetAspectNotImplemented, STAMTYPE_U32_RESET, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
59 "VERR_IEM_ASPECT_NOT_IMPLEMENTED", "/IEM/CPU%u/cRetAspectNotImplemented", idCpu);
60 STAMR3RegisterF(pVM, &pVCpu->iem.s.cRetInstrNotImplemented, STAMTYPE_U32_RESET, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
61 "VERR_IEM_INSTR_NOT_IMPLEMENTED", "/IEM/CPU%u/cRetInstrNotImplemented", idCpu);
62 STAMR3RegisterF(pVM, &pVCpu->iem.s.cRetInfStatuses, STAMTYPE_U32_RESET, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
63 "Informational statuses returned", "/IEM/CPU%u/cRetInfStatuses", idCpu);
64 STAMR3RegisterF(pVM, &pVCpu->iem.s.cRetErrStatuses, STAMTYPE_U32_RESET, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
65 "Error statuses returned", "/IEM/CPU%u/cRetErrStatuses", idCpu);
66 STAMR3RegisterF(pVM, &pVCpu->iem.s.cbWritten, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,
67 "Approx bytes written", "/IEM/CPU%u/cbWritten", idCpu);
68 STAMR3RegisterF(pVM, &pVCpu->iem.s.cPendingCommit, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,
69 "Times RC/R0 had to postpone instruction committing to ring-3", "/IEM/CPU%u/cPendingCommit", idCpu);
70
71 /*
72 * Host and guest CPU information.
73 */
74#if IEM_CFG_TARGET_CPU == IEMTARGETCPU_DYNAMIC
75 pVCpu->iem.s.uTargetCpu = IEMTARGETCPU_CURRENT;
76#endif
77 if (idCpu == 0)
78 {
79 pVCpu->iem.s.enmCpuVendor = CPUMGetGuestCpuVendor(pVM);
80 pVCpu->iem.s.enmHostCpuVendor = CPUMGetHostCpuVendor(pVM);
81 }
82 else
83 {
84 pVCpu->iem.s.enmCpuVendor = pVM->aCpus[0].iem.s.enmCpuVendor;
85 pVCpu->iem.s.enmHostCpuVendor = pVM->aCpus[0].iem.s.enmHostCpuVendor;
86 }
87
88 /*
89 * Mark all buffers free.
90 */
91 uint32_t iMemMap = RT_ELEMENTS(pVCpu->iem.s.aMemMappings);
92 while (iMemMap-- > 0)
93 pVCpu->iem.s.aMemMappings[iMemMap].fAccess = IEM_ACCESS_INVALID;
94 }
95 return VINF_SUCCESS;
96}
97
98
99VMMR3DECL(int) IEMR3Term(PVM pVM)
100{
101 NOREF(pVM);
102 return VINF_SUCCESS;
103}
104
105
106VMMR3DECL(void) IEMR3Relocate(PVM pVM)
107{
108 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
109 pVM->aCpus[idCpu].iem.s.pCtxRC = VM_RC_ADDR(pVM, pVM->aCpus[idCpu].iem.s.pCtxR3);
110}
111
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