VirtualBox

source: vbox/trunk/src/VBox/VMM/SELMInternal.h@ 2676

Last change on this file since 2676 was 1502, checked in by vboxsync, 17 years ago

Syncing of TSS virtual interrupt redirection bitmap added.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.5 KB
Line 
1/* $Id: SELMInternal.h 1502 2007-03-15 10:00:42Z vboxsync $ */
2/** @file
3 * SELM - 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 __SELMInternal_h__
23#define __SELMInternal_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_SELM_R3) && !defined(IN_SELM_R0) && !defined(IN_SELM_GC)
32# error "Not in SELM! This is an internal header!"
33#endif
34
35/** @defgroup grp_selm_int Internals
36 * @ingroup grp_selm
37 * @internal
38 * @{
39 */
40
41/** The number of GDTS allocated for our GDT. (full size) */
42#define SELM_GDT_ELEMENTS 8192
43
44/** aHyperSel index to retrieve hypervisor selectors */
45/** The Flat CS selector used by the VMM inside the GC. */
46#define SELM_HYPER_SEL_CS 0
47/** The Flat DS selector used by the VMM inside the GC. */
48#define SELM_HYPER_SEL_DS 1
49/** The 64-bit mode CS selector used by the VMM inside the GC. */
50#define SELM_HYPER_SEL_CS64 2
51/** The TSS selector used by the VMM inside the GC. */
52#define SELM_HYPER_SEL_TSS 3
53/** The TSS selector for taking trap 08 (\#DF). */
54#define SELM_HYPER_SEL_TSS_TRAP08 4
55/** Number of GDTs we need for internal use */
56#define SELM_HYPER_SEL_MAX (SELM_HYPER_SEL_TSS_TRAP08 + 1)
57
58
59/** Default GDT selectors we use for the hypervisor. */
60#define SELM_HYPER_DEFAULT_SEL_CS ((SELM_GDT_ELEMENTS - 0x1) << 3)
61#define SELM_HYPER_DEFAULT_SEL_DS ((SELM_GDT_ELEMENTS - 0x2) << 3)
62#define SELM_HYPER_DEFAULT_SEL_CS64 ((SELM_GDT_ELEMENTS - 0x3) << 3)
63#define SELM_HYPER_DEFAULT_SEL_TSS ((SELM_GDT_ELEMENTS - 0x4) << 3)
64#define SELM_HYPER_DEFAULT_SEL_TSS_TRAP08 ((SELM_GDT_ELEMENTS - 0x5) << 3)
65/** The lowest value default we use. */
66#define SELM_HYPER_DEFAULT_BASE SELM_HYPER_DEFAULT_SEL_TSS_TRAP08
67
68/**
69 * Converts a SELM pointer into a VM pointer.
70 * @returns Pointer to the VM structure the SELM is part of.
71 * @param pSELM Pointer to SELM instance data.
72 */
73#define SELM2VM(pSELM) ( (PVM)((char*)pSELM - pSELM->offVM) )
74
75
76
77/**
78 * SELM Data (part of VM)
79 */
80typedef struct SELM
81{
82 /** Offset to the VM structure.
83 * See SELM2VM(). */
84 RTINT offVM;
85
86 /* Flat CS, DS, 64 bit mode CS, TSS & trap 8 TSS. */
87 RTSEL aHyperSel[SELM_HYPER_SEL_MAX];
88
89 /** Pointer to the GCs - HC Ptr.
90 * This size is governed by SELM_GDT_ELEMENTS. */
91 HCPTRTYPE(PVBOXDESC) paGdtHC;
92 /** Pointer to the GCs - GC Ptr.
93 * This is not initialized until the first relocation because it's used to
94 * check if the shadow GDT virtual handler requires deregistration. */
95 GCPTRTYPE(PVBOXDESC) paGdtGC;
96 /** Current (last) Guest's GDTR. */
97 VBOXGDTR GuestGdtr;
98 /** The current (last) effective Guest GDT size. */
99 RTUINT cbEffGuestGdtLimit;
100
101 /** HC Pointer to the LDT shadow area placed in Hypervisor memory arena. */
102 HCPTRTYPE(void *) HCPtrLdt;
103 /** GC Pointer to the LDT shadow area placed in Hypervisor memory arena. */
104 GCPTRTYPE(void *) GCPtrLdt;
105 /** GC Pointer to the current Guest's LDT. */
106 RTGCPTR GCPtrGuestLdt;
107 /** Current LDT limit, both Guest and Shadow. */
108 RTUINT cbLdtLimit;
109 /** Current LDT offset relative to pvLdt*. */
110 RTUINT offLdtHyper;
111
112#if HC_ARCH_BITS == 32
113 /** TSS alignment padding. */
114 RTUINT auPadding[2];
115#endif
116 /** TSS. (This is 16 byte aligned!)
117 * @todo I/O bitmap & interrupt redirection table? */
118 VBOXTSS Tss;
119
120 /** TSS for trap 08 (\#DF). */
121 VBOXTSS TssTrap08;
122
123 /** GC Pointer to the TSS shadow area (Tss) placed in Hypervisor memory arena. */
124 RTGCPTR GCPtrTss;
125 /** GC Pointer to the current Guest's TSS. */
126 RTGCPTR GCPtrGuestTss;
127 /** The size of the guest TSS. */
128 RTUINT cbGuestTss;
129 /** Set if it's a 32-bit TSS. */
130 bool fGuestTss32Bit;
131 /** The size of the Guest's TSS part we're monitoring. */
132 RTUINT cbMonitoredGuestTss;
133 /** GC shadow TSS selector */
134 RTSEL GCSelTss;
135
136 /** Indicates that the Guest GDT access handler have been registered. */
137 bool fGDTRangeRegistered;
138
139 /** Indicates whether LDT/GDT/TSS monitoring and syncing is disabled. */
140 bool fDisableMonitoring;
141
142 /** Indicates whether the TSS stack selector & base address need to be refreshed. */
143 bool fSyncTSSRing0Stack;
144 /** alignment . */
145 RTUINT uPadding2;
146
147 /** SELMR3UpdateFromCPUM() profiling. */
148 STAMPROFILE StatUpdateFromCPUM;
149 /** SELMR3SyncTSS() profiling. */
150 STAMPROFILE StatTSSSync;
151
152 /** GC: The number of handled writes to the Guest's GDT. */
153 STAMCOUNTER StatGCWriteGuestGDTHandled;
154 /** GC: The number of unhandled write to the Guest's GDT. */
155 STAMCOUNTER StatGCWriteGuestGDTUnhandled;
156 /** GC: The number of times writes to Guest's LDT was detected. */
157 STAMCOUNTER StatGCWriteGuestLDT;
158 /** GC: The number of handled writes to the Guest's TSS. */
159 STAMCOUNTER StatGCWriteGuestTSSHandled;
160 /** GC: The number of handled writes to the Guest's TSS where we detected a change. */
161 STAMCOUNTER StatGCWriteGuestTSSHandledChanged;
162 /** GC: The number of handled redir writes to the Guest's TSS where we detected a change. */
163 STAMCOUNTER StatGCWriteGuestTSSRedir;
164 /** GC: The number of unhandled writes to the Guest's TSS. */
165 STAMCOUNTER StatGCWriteGuestTSSUnhandled;
166 /** The number of times we had to relocate our hypervisor selectors. */
167 STAMCOUNTER StatHyperSelsChanged;
168 /** The number of times we had find free hypervisor selectors. */
169 STAMCOUNTER StatScanForHyperSels;
170} SELM, *PSELM;
171
172__BEGIN_DECLS
173
174SELMGCDECL(int) selmgcGuestGDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, void *pvRange, uintptr_t offRange);
175SELMGCDECL(int) selmgcGuestLDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, void *pvRange, uintptr_t offRange);
176SELMGCDECL(int) selmgcGuestTSSWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, void *pvRange, uintptr_t offRange);
177
178SELMGCDECL(int) selmgcShadowGDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, void *pvRange, uintptr_t offRange);
179SELMGCDECL(int) selmgcShadowLDTWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, void *pvRange, uintptr_t offRange);
180SELMGCDECL(int) selmgcShadowTSSWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, void *pvFault, void *pvRange, uintptr_t offRange);
181
182__END_DECLS
183
184#ifdef IN_RING3
185
186#endif
187
188/** @} */
189
190#endif
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use