VirtualBox

source: vbox/trunk/include/VBox/selm.h@ 17537

Last change on this file since 17537 was 17035, checked in by vboxsync, 16 years ago

VMM,REM: Brushed up the TR/TSS shadowing. We're now relying on the hidden TR registers in SELM and CPUM/REM will make sure these are always in sync. Joined CPUMGetGuestTRHid and CPUMGetGuestTR. Kicked out sync_tr (unused now) and SELMGCGetRing1Stack.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.3 KB
Line 
1/** @file
2 * SELM - The Selector Manager.
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___VBox_selm_h
31#define ___VBox_selm_h
32
33#include <VBox/cdefs.h>
34#include <VBox/types.h>
35#include <VBox/x86.h>
36#include <VBox/dis.h>
37
38
39__BEGIN_DECLS
40
41/** @defgroup grp_selm The Selector Monitor(/Manager) API
42 * @{
43 */
44
45VMMDECL(RTSEL) SELMGetTrap8Selector(PVM pVM);
46VMMDECL(void) SELMSetTrap8EIP(PVM pVM, uint32_t u32EIP);
47VMMDECL(int) SELMGetRing1Stack(PVM pVM, uint32_t *pSS, PRTGCPTR32 pEsp);
48VMMDECL(RTGCPTR) SELMGetGuestTSS(PVM pVM);
49VMMDECL(RTSEL) SELMGetHyperCS(PVM pVM);
50VMMDECL(RTSEL) SELMGetHyperCS64(PVM pVM);
51VMMDECL(RTSEL) SELMGetHyperDS(PVM pVM);
52VMMDECL(RTSEL) SELMGetHyperTSS(PVM pVM);
53VMMDECL(RTSEL) SELMGetHyperTSSTrap08(PVM pVM);
54VMMDECL(RTRCPTR) SELMGetHyperGDT(PVM pVM);
55VMMDECL(int) SELMGetTSSInfo(PVM pVM, PRTGCUINTPTR pGCPtrTss, PRTGCUINTPTR pcbTss, bool *pfCanHaveIOBitmap);
56VMMDECL(RTGCPTR) SELMToFlat(PVM pVM, DIS_SELREG SelReg, PCPUMCTXCORE pCtxCore, RTGCPTR Addr);
57VMMDECL(RTGCPTR) SELMToFlatBySel(PVM pVM, RTSEL Sel, RTGCPTR Addr);
58
59/** Flags for SELMToFlatEx().
60 * @{ */
61/** Don't check the RPL,DPL or CPL. */
62#define SELMTOFLAT_FLAGS_NO_PL RT_BIT(8)
63/** Flags contains CPL information. */
64#define SELMTOFLAT_FLAGS_HAVE_CPL RT_BIT(9)
65/** CPL is 3. */
66#define SELMTOFLAT_FLAGS_CPL3 3
67/** CPL is 2. */
68#define SELMTOFLAT_FLAGS_CPL2 2
69/** CPL is 1. */
70#define SELMTOFLAT_FLAGS_CPL1 1
71/** CPL is 0. */
72#define SELMTOFLAT_FLAGS_CPL0 0
73/** Get the CPL from the flags. */
74#define SELMTOFLAT_FLAGS_CPL(fFlags) ((fFlags) & X86_SEL_RPL)
75/** Allow converting using Hypervisor GDT entries. */
76#define SELMTOFLAT_FLAGS_HYPER RT_BIT(10)
77/** @} */
78
79VMMDECL(int) SELMToFlatEx(PVM pVM, DIS_SELREG SelReg, PCCPUMCTXCORE pCtxCore, RTGCPTR Addr, unsigned fFlags, PRTGCPTR ppvGC);
80VMMDECL(int) SELMToFlatBySelEx(PVM pVM, X86EFLAGS eflags, RTSEL Sel, RTGCPTR Addr, PCPUMSELREGHID pHiddenSel, unsigned fFlags, PRTGCPTR ppvGC, uint32_t *pcb);
81VMMDECL(int) SELMValidateAndConvertCSAddr(PVM pVM, X86EFLAGS eflags, RTSEL SelCPL, RTSEL SelCS, PCPUMSELREGHID pHiddenCSSel, RTGCPTR Addr, PRTGCPTR ppvFlat);
82VMMDECL(int) SELMValidateAndConvertCSAddrGCTrap(PVM pVM, X86EFLAGS eflags, RTSEL SelCPL, RTSEL SelCS, RTGCPTR Addr, PRTGCPTR ppvFlat, uint32_t *pcBits);
83VMMDECL(DISCPUMODE) SELMGetCpuModeFromSelector(PVM pVM, X86EFLAGS eflags, RTSEL Sel, PCPUMSELREGHID pHiddenSel);
84VMMDECL(int) SELMGetLDTFromSel(PVM pVM, RTSEL SelLdt, PRTGCPTR ppvLdt, unsigned *pcbLimit);
85
86/**
87 * Selector information structure.
88 */
89typedef struct SELMSELINFO
90{
91 /** The base address. */
92 RTGCPTR GCPtrBase;
93 /** The limit (-1). */
94 RTGCUINTPTR cbLimit;
95 /** The raw descriptor. */
96 union
97 {
98 X86DESC Raw;
99 X86DESC64 Raw64;
100 };
101 /** The selector. */
102 RTSEL Sel;
103 /** Set if the selector is used by the hypervisor. */
104 bool fHyper;
105 /** Set if the selector is a real mode segment. */
106 bool fRealMode;
107} SELMSELINFO;
108/** Pointer to a SELM selector information struct. */
109typedef SELMSELINFO *PSELMSELINFO;
110/** Pointer to a const SELM selector information struct. */
111typedef const SELMSELINFO *PCSELMSELINFO;
112
113VMMDECL(int) SELMSelInfoValidateCS(PCSELMSELINFO pSelInfo, RTSEL SelCPL);
114
115/** @def SELMSelInfoIsExpandDown
116 * Tests whether the selector info describes an expand-down selector or now.
117 *
118 * @returns true / false.
119 * @param pSelInfo The selector info.
120 *
121 * @remark Realized as a macro for reasons of speed/lazyness and to avoid
122 * dragging in VBox/x86.h for now.
123 */
124#define SELMSelInfoIsExpandDown(pSelInfo) \
125 ( (pSelInfo)->Raw.Gen.u1DescType \
126 && ((pSelInfo)->Raw.Gen.u4Type & (X86_SEL_TYPE_DOWN | X86_SEL_TYPE_CODE)) == X86_SEL_TYPE_DOWN)
127
128
129#ifdef IN_RING3
130/** @defgroup grp_selm_r3 The Selector Monitor(/Manager) API
131 * @ingroup grp_selm
132 * @{
133 */
134VMMR3DECL(int) SELMR3Init(PVM pVM);
135VMMR3DECL(int) SELMR3InitFinalize(PVM pVM);
136VMMR3DECL(void) SELMR3Relocate(PVM pVM);
137VMMR3DECL(void) SELMR3PagingModeChanged(PVM pVM);
138VMMR3DECL(int) SELMR3Term(PVM pVM);
139VMMR3DECL(void) SELMR3Reset(PVM pVM);
140VMMR3DECL(int) SELMR3UpdateFromCPUM(PVM pVM);
141VMMR3DECL(int) SELMR3SyncTSS(PVM pVM);
142VMMR3DECL(int) SELMR3GetSelectorInfo(PVM pVM, RTSEL Sel, PSELMSELINFO pSelInfo);
143VMMR3DECL(int) SELMR3GetShadowSelectorInfo(PVM pVM, RTSEL Sel, PSELMSELINFO pSelInfo);
144VMMR3DECL(void) SELMR3DisableMonitoring(PVM pVM);
145VMMR3DECL(void) SELMR3DumpDescriptor(X86DESC Desc, RTSEL Sel, const char *pszMsg);
146VMMR3DECL(void) SELMR3DumpHyperGDT(PVM pVM);
147VMMR3DECL(void) SELMR3DumpHyperLDT(PVM pVM);
148VMMR3DECL(void) SELMR3DumpGuestGDT(PVM pVM);
149VMMR3DECL(void) SELMR3DumpGuestLDT(PVM pVM);
150VMMR3DECL(bool) SELMR3CheckTSS(PVM pVM);
151VMMR3DECL(int) SELMR3DebugCheck(PVM pVM);
152/** @def SELMR3_DEBUG_CHECK
153 * Invokes SELMR3DebugCheck in stricts builds. */
154# ifdef VBOX_STRICT
155# define SELMR3_DEBUG_CHECK(pVM) SELMR3DebugCheck(pVM)
156# else
157# define SELMR3_DEBUG_CHECK(pVM) do { } while (0)
158# endif
159/** @} */
160#endif /* IN_RING3 */
161
162/** @} */
163__END_DECLS
164
165#endif
166
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