VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMGC/CPUMGC.cpp@ 400

Last change on this file since 400 was 23, checked in by vboxsync, 18 years ago

string.h & stdio.h + header cleanups.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1/* $Id: CPUMGC.cpp 23 2007-01-15 14:08:28Z vboxsync $ */
2/** @file
3 * CPUM - Guest Context Code.
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung GmbH
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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#define LOG_GROUP LOG_GROUP_CPUM
27#include <VBox/cpum.h>
28#include <VBox/vmm.h>
29#include <VBox/trpm.h>
30#include "CPUMInternal.h"
31#include <VBox/vm.h>
32#include <VBox/err.h>
33#include <iprt/assert.h>
34#include <VBox/log.h>
35
36
37/*******************************************************************************
38* Internal Functions *
39*******************************************************************************/
40__BEGIN_DECLS /* addressed from asm (not called so no DECLASM). */
41DECLCALLBACK(int) cpumGCHandleNPAndGP(PVM pVM, PCPUMCTXCORE pRegFrame, uintptr_t uUser);
42__END_DECLS
43
44
45/**
46 * Deal with traps occuring during segment loading and IRET
47 * when resuming guest context.
48 *
49 * @returns VBox status code.
50 * @param pVM The VM handle.
51 * @param pRegFrame The register frame.
52 * @param uUser User argument. In this case a combination of the
53 * CPUM_HANDLER_* \#defines.
54 */
55DECLCALLBACK(int) cpumGCHandleNPAndGP(PVM pVM, PCPUMCTXCORE pRegFrame, uintptr_t uUser)
56{
57 LogFlow(("cpumGCHandleNPAndGP: eip=%RX32 uUser=%#x\n", pRegFrame->eip, uUser));
58
59 /*
60 * Update the guest cpu state.
61 */
62 if (uUser & CPUM_HANDLER_CTXCORE_IN_EBP)
63 {
64 PCPUMCTXCORE pGstCtxCore = CPUMCTX2CORE(&pVM->cpum.s.Guest);
65 PCCPUMCTXCORE pGstCtxCoreSrc = (PCPUMCTXCORE)pRegFrame->ebp;
66 *pGstCtxCore = *pGstCtxCoreSrc;
67 }
68
69 /*
70 * Take action based on what's happended.
71 */
72 switch (uUser & CPUM_HANDLER_TYPEMASK)
73 {
74 case CPUM_HANDLER_GS:
75 // if (!pVM->cpum.s.Guest.ldtr)
76 // {
77 // pRegFrame->gs = 0;
78 // pRegFrame->eip += 6; /* mov gs, [edx + CPUM.Guest.gs] */
79 // return VINF_SUCCESS;
80 // }
81 case CPUM_HANDLER_DS:
82 case CPUM_HANDLER_ES:
83 case CPUM_HANDLER_FS:
84 TRPMGCHyperReturnToHost(pVM, VINF_EM_RAW_STALE_SELECTOR);
85 break;
86
87 case CPUM_HANDLER_IRET:
88 TRPMGCHyperReturnToHost(pVM, VINF_EM_RAW_IRET_TRAP);
89 break;
90 }
91 return VERR_TRPM_DONT_PANIC;
92}
93
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