VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMRC/CPUMRC.cpp@ 43054

Last change on this file since 43054 was 42774, checked in by vboxsync, 12 years ago

CPUMRC.cpp: Disabled a logging statement I forgot to remove.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 4.9 KB
Line 
1/* $Id: CPUMRC.cpp 42774 2012-08-11 20:17:35Z vboxsync $ */
2/** @file
3 * CPUM - Raw-mode Context Code.
4 */
5
6/*
7 * Copyright (C) 2006-2012 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_CPUM
23#include <VBox/vmm/cpum.h>
24#include <VBox/vmm/vmm.h>
25#include <VBox/vmm/patm.h>
26#include <VBox/vmm/trpm.h>
27#include "CPUMInternal.h"
28#include <VBox/vmm/vm.h>
29#include <VBox/err.h>
30#include <iprt/assert.h>
31#include <VBox/log.h>
32
33
34/*******************************************************************************
35* Internal Functions *
36*******************************************************************************/
37RT_C_DECLS_BEGIN /* addressed from asm (not called so no DECLASM). */
38DECLCALLBACK(int) cpumRCHandleNPAndGP(PVM pVM, PCPUMCTXCORE pRegFrame, uintptr_t uUser);
39RT_C_DECLS_END
40
41
42/**
43 * Deal with traps occurring during segment loading and IRET when resuming guest
44 * context execution.
45 *
46 * @returns VBox status code.
47 * @param pVM Pointer to the VM.
48 * @param pRegFrame The register frame.
49 * @param uUser User argument. In this case a combination of the
50 * CPUM_HANDLER_* \#defines.
51 */
52DECLCALLBACK(int) cpumRCHandleNPAndGP(PVM pVM, PCPUMCTXCORE pRegFrame, uintptr_t uUser)
53{
54 Log(("********************************************************\n"));
55 Log(("cpumRCHandleNPAndGP: eip=%RX32 uUser=%#x\n", pRegFrame->eip, uUser));
56 Log(("********************************************************\n"));
57
58 /*
59 * Take action based on what's happened.
60 */
61 switch (uUser & CPUM_HANDLER_TYPEMASK)
62 {
63 case CPUM_HANDLER_GS:
64 case CPUM_HANDLER_DS:
65 case CPUM_HANDLER_ES:
66 case CPUM_HANDLER_FS:
67 TRPMGCHyperReturnToHost(pVM, VINF_EM_RAW_STALE_SELECTOR);
68 break;
69
70 case CPUM_HANDLER_IRET:
71 TRPMGCHyperReturnToHost(pVM, VINF_EM_RAW_IRET_TRAP);
72 break;
73 }
74
75 AssertMsgFailed(("uUser=%#x eip=%#x\n", uUser, pRegFrame->eip));
76 return VERR_TRPM_DONT_PANIC;
77}
78
79
80/**
81 * Called by TRPM and CPUM assembly code to make sure the guest state is
82 * ready for execution.
83 *
84 * @param pVM The VM handle.
85 */
86DECLASM(void) CPUMRCAssertPreExecutionSanity(PVM pVM)
87{
88 /*
89 * Check some important assumptions before resuming guest execution.
90 */
91 PVMCPU pVCpu = VMMGetCpu0(pVM);
92 PCCPUMCTX pCtx = &pVCpu->cpum.s.Guest;
93 uint8_t const uRawCpl = CPUMGetGuestCPL(pVCpu);
94 uint32_t const u32EFlags = CPUMRawGetEFlags(pVCpu);
95 bool const fPatch = PATMIsPatchGCAddr(pVM, pCtx->eip);
96 AssertMsg(pCtx->eflags.Bits.u1IF, ("cs:eip=%04x:%08x ss:esp=%04x:%08x cpl=%u raw/efl=%#x/%#x%s\n", pCtx->cs.Sel, pCtx->eip, pCtx->ss.Sel, pCtx->esp, uRawCpl, u32EFlags, pCtx->eflags.u, fPatch ? " patch" : ""));
97 AssertMsg(pCtx->eflags.Bits.u2IOPL < RT_MAX(uRawCpl, 1U),
98 ("cs:eip=%04x:%08x ss:esp=%04x:%08x cpl=%u raw/efl=%#x/%#x%s\n", pCtx->cs.Sel, pCtx->eip, pCtx->ss.Sel, pCtx->esp, uRawCpl, u32EFlags, pCtx->eflags.u, fPatch ? " patch" : ""));
99 if (!(u32EFlags & X86_EFL_VM))
100 {
101 AssertMsg((u32EFlags & X86_EFL_IF) || fPatch,("cs:eip=%04x:%08x ss:esp=%04x:%08x cpl=%u raw/efl=%#x/%#x%s\n", pCtx->cs.Sel, pCtx->eip, pCtx->ss.Sel, pCtx->esp, uRawCpl, u32EFlags, pCtx->eflags.u, fPatch ? " patch" : ""));
102 AssertMsg((pCtx->cs.Sel & X86_SEL_RPL) > 0, ("cs:eip=%04x:%08x ss:esp=%04x:%08x cpl=%u raw/efl=%#x/%#x%s\n", pCtx->cs.Sel, pCtx->eip, pCtx->ss.Sel, pCtx->esp, uRawCpl, u32EFlags, pCtx->eflags.u, fPatch ? " patch" : ""));
103 AssertMsg((pCtx->ss.Sel & X86_SEL_RPL) > 0, ("cs:eip=%04x:%08x ss:esp=%04x:%08x cpl=%u raw/efl=%#x/%#x%s\n", pCtx->cs.Sel, pCtx->eip, pCtx->ss.Sel, pCtx->esp, uRawCpl, u32EFlags, pCtx->eflags.u, fPatch ? " patch" : ""));
104 }
105 AssertMsg(CPUMIsGuestInRawMode(pVCpu), ("cs:eip=%04x:%08x ss:esp=%04x:%08x cpl=%u raw/efl=%#x/%#x%s\n", pCtx->cs.Sel, pCtx->eip, pCtx->ss.Sel, pCtx->esp, uRawCpl, u32EFlags, pCtx->eflags.u, fPatch ? " patch" : ""));
106 //Log2(("cs:eip=%04x:%08x ss:esp=%04x:%08x cpl=%u raw/efl=%#x/%#x%s\n", pCtx->cs.Sel, pCtx->eip, pCtx->ss.Sel, pCtx->esp, uRawCpl, u32EFlags, pCtx->eflags.u, fPatch ? " patch" : ""));
107}
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