1 | /** @file
|
---|
2 | * SELM - The Selector Manager.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2012 Oracle Corporation
|
---|
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 |
|
---|
26 | #ifndef ___VBox_vmm_selm_h
|
---|
27 | #define ___VBox_vmm_selm_h
|
---|
28 |
|
---|
29 | #include <VBox/types.h>
|
---|
30 | #include <iprt/x86.h>
|
---|
31 | #include <VBox/dis.h>
|
---|
32 | #include <VBox/vmm/dbgfsel.h>
|
---|
33 |
|
---|
34 |
|
---|
35 | RT_C_DECLS_BEGIN
|
---|
36 |
|
---|
37 | /** @defgroup grp_selm The Selector Monitor(/Manager) API
|
---|
38 | * @{
|
---|
39 | */
|
---|
40 |
|
---|
41 | VMMDECL(RTSEL) SELMGetTrap8Selector(PVM pVM);
|
---|
42 | VMMDECL(void) SELMSetTrap8EIP(PVM pVM, uint32_t u32EIP);
|
---|
43 | VMMDECL(int) SELMGetRing1Stack(PVM pVM, uint32_t *pSS, PRTGCPTR32 pEsp);
|
---|
44 | VMMDECL(RTSEL) SELMGetHyperCS(PVM pVM);
|
---|
45 | VMMDECL(RTSEL) SELMGetHyperCS64(PVM pVM);
|
---|
46 | VMMDECL(RTSEL) SELMGetHyperDS(PVM pVM);
|
---|
47 | VMMDECL(RTSEL) SELMGetHyperTSS(PVM pVM);
|
---|
48 | VMMDECL(RTSEL) SELMGetHyperTSSTrap08(PVM pVM);
|
---|
49 | VMMDECL(RTRCPTR) SELMGetHyperGDT(PVM pVM);
|
---|
50 | VMMDECL(int) SELMGetTSSInfo(PVM pVM, PVMCPU pVCpu, PRTGCUINTPTR pGCPtrTss, PRTGCUINTPTR pcbTss, bool *pfCanHaveIOBitmap);
|
---|
51 | VMMDECL(RTGCPTR) SELMToFlat(PVM pVM, DISSELREG SelReg, PCPUMCTXCORE pCtxCore, RTGCPTR Addr);
|
---|
52 | VMMDECL(RTGCPTR) SELMToFlatBySel(PVM pVM, RTSEL Sel, RTGCPTR Addr);
|
---|
53 | VMMDECL(void) SELMShadowCR3Changed(PVM pVM, PVMCPU pVCpu);
|
---|
54 |
|
---|
55 | /** Flags for SELMToFlatEx().
|
---|
56 | * @{ */
|
---|
57 | /** Don't check the RPL,DPL or CPL. */
|
---|
58 | #define SELMTOFLAT_FLAGS_NO_PL RT_BIT(8)
|
---|
59 | /** Flags contains CPL information. */
|
---|
60 | #define SELMTOFLAT_FLAGS_HAVE_CPL RT_BIT(9)
|
---|
61 | /** CPL is 3. */
|
---|
62 | #define SELMTOFLAT_FLAGS_CPL3 3
|
---|
63 | /** CPL is 2. */
|
---|
64 | #define SELMTOFLAT_FLAGS_CPL2 2
|
---|
65 | /** CPL is 1. */
|
---|
66 | #define SELMTOFLAT_FLAGS_CPL1 1
|
---|
67 | /** CPL is 0. */
|
---|
68 | #define SELMTOFLAT_FLAGS_CPL0 0
|
---|
69 | /** Get the CPL from the flags. */
|
---|
70 | #define SELMTOFLAT_FLAGS_CPL(fFlags) ((fFlags) & X86_SEL_RPL)
|
---|
71 | /** Allow converting using Hypervisor GDT entries. */
|
---|
72 | #define SELMTOFLAT_FLAGS_HYPER RT_BIT(10)
|
---|
73 | /** @} */
|
---|
74 |
|
---|
75 | VMMDECL(int) SELMToFlatEx(PVMCPU pVCpu, DISSELREG SelReg, PCPUMCTXCORE pCtxCore, RTGCPTR Addr, uint32_t fFlags,
|
---|
76 | PRTGCPTR ppvGC);
|
---|
77 | VMMDECL(int) SELMToFlatBySelEx(PVMCPU pVCpu, X86EFLAGS eflags, RTSEL Sel, RTGCPTR Addr, uint32_t fFlags,
|
---|
78 | PRTGCPTR ppvGC, uint32_t *pcb);
|
---|
79 | VMMDECL(int) SELMValidateAndConvertCSAddr(PVMCPU pVCpu, X86EFLAGS eflags, RTSEL SelCPL, RTSEL SelCS,
|
---|
80 | PCPUMSELREG pSRegCS, RTGCPTR Addr, PRTGCPTR ppvFlat);
|
---|
81 | #ifdef VBOX_WITH_RAW_MODE
|
---|
82 | VMM_INT_DECL(void) SELMLoadHiddenSelectorReg(PVMCPU pVCpu, PCCPUMCTX pCtx, PCPUMSELREG pSReg);
|
---|
83 | #endif
|
---|
84 |
|
---|
85 |
|
---|
86 | #ifdef IN_RING3
|
---|
87 | /** @defgroup grp_selm_r3 The Selector Monitor(/Manager) API
|
---|
88 | * @ingroup grp_selm
|
---|
89 | * @{
|
---|
90 | */
|
---|
91 | VMMR3DECL(int) SELMR3Init(PVM pVM);
|
---|
92 | VMMR3DECL(int) SELMR3InitFinalize(PVM pVM);
|
---|
93 | VMMR3DECL(void) SELMR3Relocate(PVM pVM);
|
---|
94 | VMMR3DECL(int) SELMR3Term(PVM pVM);
|
---|
95 | VMMR3DECL(void) SELMR3Reset(PVM pVM);
|
---|
96 | # ifdef VBOX_WITH_RAW_MODE
|
---|
97 | VMMR3DECL(VBOXSTRICTRC) SELMR3UpdateFromCPUM(PVM pVM, PVMCPU pVCpu);
|
---|
98 | VMMR3DECL(int) SELMR3SyncTSS(PVM pVM, PVMCPU pVCpu);
|
---|
99 | # endif
|
---|
100 | VMMR3DECL(int) SELMR3GetSelectorInfo(PVM pVM, PVMCPU pVCpu, RTSEL Sel, PDBGFSELINFO pSelInfo);
|
---|
101 | VMMR3DECL(int) SELMR3GetShadowSelectorInfo(PVM pVM, RTSEL Sel, PDBGFSELINFO pSelInfo);
|
---|
102 | VMMR3DECL(void) SELMR3DumpDescriptor(X86DESC Desc, RTSEL Sel, const char *pszMsg);
|
---|
103 | VMMR3DECL(void) SELMR3DumpHyperGDT(PVM pVM);
|
---|
104 | VMMR3DECL(void) SELMR3DumpHyperLDT(PVM pVM);
|
---|
105 | VMMR3DECL(void) SELMR3DumpGuestGDT(PVM pVM);
|
---|
106 | VMMR3DECL(void) SELMR3DumpGuestLDT(PVM pVM);
|
---|
107 | VMMR3DECL(bool) SELMR3CheckTSS(PVM pVM);
|
---|
108 | VMMR3DECL(int) SELMR3DebugCheck(PVM pVM);
|
---|
109 | # ifdef VBOX_WITH_SAFE_STR
|
---|
110 | VMMR3DECL(bool) SELMR3CheckShadowTR(PVM pVM);
|
---|
111 | # endif
|
---|
112 |
|
---|
113 | /** @def SELMR3_DEBUG_CHECK
|
---|
114 | * Invokes SELMR3DebugCheck in stricts builds. */
|
---|
115 | # ifdef VBOX_STRICT
|
---|
116 | # define SELMR3_DEBUG_CHECK(pVM) SELMR3DebugCheck(pVM)
|
---|
117 | # else
|
---|
118 | # define SELMR3_DEBUG_CHECK(pVM) do { } while (0)
|
---|
119 | # endif
|
---|
120 | /** @} */
|
---|
121 | #endif /* IN_RING3 */
|
---|
122 |
|
---|
123 | /** @} */
|
---|
124 | RT_C_DECLS_END
|
---|
125 |
|
---|
126 | #endif
|
---|
127 |
|
---|