1 | /** @file
|
---|
2 | * SELM - The Selector Manager.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2022 Oracle and/or its affiliates.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox base platform packages, as
|
---|
9 | * available from https://www.virtualbox.org.
|
---|
10 | *
|
---|
11 | * This program is free software; you can redistribute it and/or
|
---|
12 | * modify it under the terms of the GNU General Public License
|
---|
13 | * as published by the Free Software Foundation, in version 3 of the
|
---|
14 | * License.
|
---|
15 | *
|
---|
16 | * This program is distributed in the hope that it will be useful, but
|
---|
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | * General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
23 | *
|
---|
24 | * The contents of this file may alternatively be used under the terms
|
---|
25 | * of the Common Development and Distribution License Version 1.0
|
---|
26 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
27 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
28 | * CDDL are applicable instead of those of the GPL.
|
---|
29 | *
|
---|
30 | * You may elect to license modified versions of this file under the
|
---|
31 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
32 | *
|
---|
33 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef VBOX_INCLUDED_vmm_selm_h
|
---|
37 | #define VBOX_INCLUDED_vmm_selm_h
|
---|
38 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
39 | # pragma once
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #include <VBox/types.h>
|
---|
43 | #include <iprt/x86.h>
|
---|
44 | #include <VBox/dis.h>
|
---|
45 | #include <VBox/vmm/dbgfsel.h>
|
---|
46 |
|
---|
47 |
|
---|
48 | RT_C_DECLS_BEGIN
|
---|
49 |
|
---|
50 | /** @defgroup grp_selm The Selector Monitor(/Manager) API
|
---|
51 | * @ingroup grp_vmm
|
---|
52 | * @{
|
---|
53 | */
|
---|
54 |
|
---|
55 | VMMDECL(int) SELMGetTSSInfo(PVM pVM, PVMCPU pVCpu, PRTGCUINTPTR pGCPtrTss, PRTGCUINTPTR pcbTss, bool *pfCanHaveIOBitmap);
|
---|
56 | VMMDECL(RTGCPTR) SELMToFlat(PVMCC pVM, DISSELREG SelReg, PCPUMCTXCORE pCtxCore, RTGCPTR Addr);
|
---|
57 | VMMDECL(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 | #define SELMTOFLAT_FLAGS_HYPER RT_BIT(10)
|
---|
76 | /** @} */
|
---|
77 |
|
---|
78 | VMMDECL(int) SELMToFlatEx(PVMCPU pVCpu, DISSELREG SelReg, PCPUMCTXCORE pCtxCore, RTGCPTR Addr, uint32_t fFlags,
|
---|
79 | PRTGCPTR ppvGC);
|
---|
80 | VMMDECL(int) SELMValidateAndConvertCSAddr(PVMCPU pVCpu, X86EFLAGS eflags, RTSEL SelCPL, RTSEL SelCS,
|
---|
81 | PCPUMSELREG pSRegCS, RTGCPTR Addr, PRTGCPTR ppvFlat);
|
---|
82 | #ifdef VBOX_WITH_RAW_MODE
|
---|
83 | VMM_INT_DECL(void) SELMLoadHiddenSelectorReg(PVMCPU pVCpu, PCCPUMCTX pCtx, PCPUMSELREG pSReg);
|
---|
84 | #endif
|
---|
85 |
|
---|
86 |
|
---|
87 | #ifdef IN_RING3
|
---|
88 | /** @defgroup grp_selm_r3 The SELM ring-3 Context API
|
---|
89 | * @{
|
---|
90 | */
|
---|
91 | VMMR3DECL(int) SELMR3Init(PVM pVM);
|
---|
92 | VMMR3DECL(void) SELMR3Relocate(PVM pVM);
|
---|
93 | VMMR3DECL(int) SELMR3Term(PVM pVM);
|
---|
94 | VMMR3DECL(void) SELMR3Reset(PVM pVM);
|
---|
95 | VMMR3DECL(int) SELMR3GetSelectorInfo(PVMCPU pVCpu, RTSEL Sel, PDBGFSELINFO pSelInfo);
|
---|
96 | VMMR3DECL(void) SELMR3DumpDescriptor(X86DESC Desc, RTSEL Sel, const char *pszMsg);
|
---|
97 | VMMR3DECL(void) SELMR3DumpGuestGDT(PVM pVM);
|
---|
98 | VMMR3DECL(void) SELMR3DumpGuestLDT(PVM pVM);
|
---|
99 |
|
---|
100 | /** @def SELMR3_DEBUG_CHECK
|
---|
101 | * Invokes SELMR3DebugCheck in stricts builds. */
|
---|
102 | # ifdef VBOX_STRICT
|
---|
103 | # define SELMR3_DEBUG_CHECK(pVM) SELMR3DebugCheck(pVM)
|
---|
104 | # else
|
---|
105 | # define SELMR3_DEBUG_CHECK(pVM) do { } while (0)
|
---|
106 | # endif
|
---|
107 | /** @} */
|
---|
108 | #endif /* IN_RING3 */
|
---|
109 |
|
---|
110 | /** @} */
|
---|
111 |
|
---|
112 | RT_C_DECLS_END
|
---|
113 |
|
---|
114 | #endif /* !VBOX_INCLUDED_vmm_selm_h */
|
---|
115 |
|
---|