VirtualBox

source: vbox/trunk/src/VBox/VMM/TRPMInternal.h@ 400

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

Completed most of VBOX_WITHOUT_IDT_PATCHING. (hope I didn't break anything...) TODO: IST support on AMD64.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.0 KB
Line 
1/* $Id: TRPMInternal.h 397 2007-01-28 02:34:06Z vboxsync $ */
2/** @file
3 * TRPM - Internal header file.
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#ifndef __TRPMInternal_h__
23#define __TRPMInternal_h__
24
25#include <VBox/cdefs.h>
26#include <VBox/types.h>
27#include <VBox/stam.h>
28#include <VBox/cpum.h>
29
30
31#if !defined(IN_TRPM_R3) && !defined(IN_TRPM_R0) && !defined(IN_TRPM_GC)
32# error "Not in TRPM! This is an internal header!"
33#endif
34
35/* Enable to allow trap forwarding in GC. */
36#define TRPM_FORWARD_TRAPS_IN_GC
37
38__BEGIN_DECLS
39
40
41/** @defgroup grp_trpm_int Internals
42 * @ingroup grp_trpm
43 * @internal
44 * @{
45 */
46
47/** @name TRPMGCTrapIn* flags.
48 * The lower bits are offsets into the CPUMCTXCORE structure.
49 * @{ */
50/** The mask for the operation. */
51#define TRPM_TRAP_IN_OP_MASK 0xffff
52/** Traps on MOV GS, eax. */
53#define TRPM_TRAP_IN_MOV_GS 1
54/** Traps on MOV FS, eax. */
55#define TRPM_TRAP_IN_MOV_FS 2
56/** Traps on MOV ES, eax. */
57#define TRPM_TRAP_IN_MOV_ES 3
58/** Traps on MOV DS, eax. */
59#define TRPM_TRAP_IN_MOV_DS 4
60/** Traps on IRET. */
61#define TRPM_TRAP_IN_IRET 5
62/** Set if this is a V86 resume. */
63#define TRPM_TRAP_IN_V86 BIT(30)
64/** If set this is a hypervisor register set. If cleared it's a guest set. */
65#define TRPM_TRAP_IN_HYPER BIT(31)
66/** @} */
67
68
69/**
70 * Converts a TRPM pointer into a VM pointer.
71 * @returns Pointer to the VM structure the TRPM is part of.
72 * @param pTRPM Pointer to TRPM instance data.
73 */
74#define TRPM2VM(pTRPM) ( (PVM)((char*)pTRPM - pTRPM->offVM) )
75
76
77/**
78 * TRPM Data (part of VM)
79 *
80 * IMPORTANT! Keep the nasm version of this struct up-to-date.
81 */
82#pragma pack(4)
83typedef struct TRPM
84{
85 /** Offset to the VM structure.
86 * See TRPM2VM(). */
87 RTINT offVM;
88
89 /** Active Interrupt or trap vector number.
90 * If not ~0U this indicates that we're currently processing
91 * a interrupt, trap, fault, abort, whatever which have arrived
92 * at that vector number.
93 */
94 RTUINT uActiveVector;
95
96 /** If set the active trap is a software interrupt. */
97 RTUINT fActiveSoftwareInterrupt;
98
99 /** Errorcode for the active interrupt/trap. */
100 RTGCUINT uActiveErrorCode;
101
102 /** CR2 at the time of the active exception. */
103 RTGCUINTPTR uActiveCR2;
104
105 /** Saved trap vector number. */
106 RTGCUINT uSavedVector;
107
108 /** Saved software interrupt indicator. */
109 RTUINT fSavedSoftwareInterrupt;
110
111 /** Saved errorcode. */
112 RTGCUINT uSavedErrorCode;
113
114 /** Saved cr2. */
115 RTGCUINTPTR uSavedCR2;
116
117 /** Previous trap vector # - for debugging. */
118 RTGCUINT uPrevVector;
119
120 /** IDT monitoring and sync flag */
121 RTUINT fDisableMonitoring; /** @todo r=bird: bool and 7 byte achPadding1. */
122
123 /** Padding to get the IDTs at a 16 byte alignement. */
124 char achPadding1[4];
125
126 /** IDTs. Aligned at 16 byte offset for speed. */
127 VBOXIDTE aIdt[256];
128
129 /** Bitmap for IDTEs that contain PATM handlers. (needed for relocation) */
130 uint32_t au32IdtPatched[8];
131
132 /** Temporary Hypervisor trap handlers.
133 * NULL means default action. */
134 RTGCPTR aTmpTrapHandlers[256];
135
136 /** GC Pointer to the IDT shadow area (aIdt) placed in Hypervisor memory arena. */
137 RTGCPTR GCPtrIdt;
138 /** Current (last) Guest's IDTR. */
139 VBOXIDTR GuestIdtr;
140
141 /** padding. */
142 uint8_t au8Padding[2];
143
144 /** Checked trap & interrupt handler array */
145 RTGCPTR aGuestTrapHandler[256];
146
147 /** GC: The number of times writes to the Guest IDT were detected. */
148 STAMCOUNTER StatGCWriteGuestIDT;
149 /** HC: Profiling of the TRPMR3SyncIDT() method. */
150 STAMPROFILE StatSyncIDT;
151 /** GC: Statistics for the trap handlers. */
152 STAMPROFILEADV aStatGCTraps[0x14];
153
154 STAMCOUNTER StatForwardFailNoHandler;
155 STAMCOUNTER StatForwardFailPatchAddr;
156 STAMCOUNTER StatForwardFailGC;
157 STAMCOUNTER StatForwardFailHC;
158
159 /* R3: Statistics for interrupt handlers (allocated on the hypervisor heap). */
160 R3PTRTYPE(PSTAMCOUNTER) paStatForwardedIRQR3;
161 /* R0: Statistics for interrupt handlers (allocated on the hypervisor heap). */
162 R0PTRTYPE(PSTAMCOUNTER) paStatForwardedIRQR0;
163 /* GC: Statistics for interrupt handlers (allocated on the hypervisor heap). */
164 GCPTRTYPE(PSTAMCOUNTER) paStatForwardedIRQGC;
165} TRPM;
166#pragma pack()
167
168/** Pointer to TRPM Data. */
169typedef TRPM *PTRPM;
170
171TRPMGCDECL(int) trpmgcGuestIDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, void *pvRange, uintptr_t offRange);
172TRPMGCDECL(int) trpmgcShadowIDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, void *pvRange, uintptr_t offRange);
173
174
175#ifdef IN_RING3
176
177#endif
178
179
180#ifdef IN_RING0
181
182/**
183 * Calls the interrupt gate as if we received an interrupt while in Ring-0.
184 *
185 * Returns with interrupts enabled.
186 *
187 * @param uIP The interrupt gate IP.
188 * @param SelCS The interrupt gate CS.
189 * @param RSP The interrupt gate RSP. ~0 if no stack switch should take place. (only AMD64)
190 */
191DECLASM(void) trpmR0DispatchHostInterrupt(RTR0UINTPTR uIP, RTSEL SelCS, RTR0UINTPTR RSP);
192
193# ifndef VBOX_WITHOUT_IDT_PATCHING
194/**
195 * Code used for the dispatching of interrupts in HC.
196 * @internal
197 */
198DECLASM(int) trpmR0InterruptDispatcher(void);
199# endif /* !VBOX_WITHOUT_IDT_PATCHING */
200
201#endif
202
203/** @} */
204
205__END_DECLS
206
207#endif
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