VirtualBox

source: vbox/trunk/src/VBox/VMM/include/VMMSwitcher.h@ 78033

Last change on this file since 78033 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 6.6 KB
Line 
1/* $Id: VMMSwitcher.h 76585 2019-01-01 06:31:29Z vboxsync $ */
2/** @file
3 * VMM - World Switchers.
4 */
5
6/*
7 * Copyright (C) 2006-2019 Oracle Corporation
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 (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef VMM_INCLUDED_SRC_include_VMMSwitcher_h
19#define VMM_INCLUDED_SRC_include_VMMSwitcher_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <VBox/vmm/vmm.h>
25
26/** @name Fixup Types.
27 * @{
28 */
29/** @todo document what arguments these take and what they do. */
30#define FIX_HC_2_GC_NEAR_REL 1
31#define FIX_HC_2_ID_NEAR_REL 2
32#define FIX_GC_2_HC_NEAR_REL 3
33#define FIX_GC_2_ID_NEAR_REL 4
34#define FIX_ID_2_HC_NEAR_REL 5
35#define FIX_ID_2_GC_NEAR_REL 6
36#define FIX_GC_FAR32 7
37#define FIX_GC_CPUM_OFF 8
38#define FIX_GC_VM_OFF 9 /** @todo cleanup fixup names GC->RC, HC->R0. */
39#define FIX_HC_CPUM_OFF 10
40#define FIX_HC_VM_OFF 11
41#define FIX_INTER_32BIT_CR3 12
42#define FIX_INTER_PAE_CR3 13
43#define FIX_INTER_AMD64_CR3 14
44#define FIX_HYPER_CS 18
45#define FIX_HYPER_DS 19
46#define FIX_HYPER_TSS 20
47#define FIX_GC_TSS_GDTE_DW2 21
48/*#define FIX_NO_FXSAVE_JMP 24 - reusable */
49#define FIX_NO_SYSENTER_JMP 25
50#define FIX_NO_SYSCALL_JMP 26
51#define FIX_HC_32BIT 27
52#define FIX_HC_64BIT 28
53#define FIX_HC_64BIT_CPUM 29
54#define FIX_HC_64BIT_CS 30
55#define FIX_ID_32BIT 31
56#define FIX_ID_64BIT 32
57#define FIX_ID_FAR32_TO_64BIT_MODE 33
58#define FIX_GC_APIC_BASE_32BIT 34
59#define FIX_HC_64BIT_NOCHECK 35
60#define FIX_GC_64_BIT_CPUM_OFF 36
61#define FIX_GC_CPUMCPU_OFF 37
62#define FIX_EFER_OR_MASK 38
63#define FIX_THE_END 255
64/** @} */
65
66
67/** Pointer to a switcher definition. */
68typedef struct VMMSWITCHERDEF *PVMMSWITCHERDEF;
69
70/**
71 * Callback function for relocating the core code belonging to a switcher.
72 *
73 * @param pVM The cross context VM structure.
74 * @param pSwitcher Pointer to the switcher structure.
75 * @param R0PtrCode Pointer to the first code byte in the ring-0 mapping.
76 * @param pu8CodeR3 Pointer to the first code byte in the ring-3 mapping.
77 * @param GCPtrCode The GC address of the first code byte.
78 * @param u32IDCode The address of the identity mapped code (first byte).
79 */
80typedef DECLCALLBACK(void) FNVMMSWITCHERRELOCATE(PVM pVM, PVMMSWITCHERDEF pSwitcher, RTR0PTR R0PtrCode, uint8_t *pu8CodeR3,
81 RTGCPTR GCPtrCode, uint32_t u32IDCode);
82/** Pointer to a FNVMMSWITCHERRELOCATE(). */
83typedef FNVMMSWITCHERRELOCATE *PFNVMMSWITCHERRELOCATE;
84
85/**
86 * VMM Switcher structure.
87 */
88#pragma pack(1)
89typedef struct VMMSWITCHERDEF
90{
91 /** Pointer to the code. */
92 void *pvCode;
93 /** Pointer to the fixup records. */
94 void *pvFixups;
95 /** Pointer to the description. */
96 const char *pszDesc;
97 /** Function which performs the necessary relocations. */
98 PFNVMMSWITCHERRELOCATE pfnRelocate;
99 /** The switcher type. */
100 VMMSWITCHER enmType;
101 /** Size of the entire code chunk. */
102 uint32_t cbCode;
103 /** vmmR0ToRawMode C entrypoint. */
104 uint32_t offR0ToRawMode;
105 /** vmmRCToHost C entrypoint. */
106 uint32_t offRCToHost;
107 /** vmmRCCallTrampoline address. */
108 uint32_t offRCCallTrampoline;
109 /** vmmRCToHostAsm - Assembly language entry point for switching from raw-mode
110 * context to host-context. This saves the RC register context. */
111 uint32_t offRCToHostAsm;
112 /** vmmRCToHostNoReturn - Assembly language entry point for switching from
113 * raw-mode context to host-context. This does not save any RC register
114 * context and expects the caller to have done that already. */
115 uint32_t offRCToHostAsmNoReturn;
116 /** @name Disassembly Regions.
117 * @{ */
118 uint32_t offHCCode0;
119 uint32_t cbHCCode0;
120 uint32_t offHCCode1;
121 uint32_t cbHCCode1;
122 uint32_t offIDCode0;
123 uint32_t cbIDCode0;
124 uint32_t offIDCode1;
125 uint32_t cbIDCode1;
126 uint32_t offGCCode;
127 uint32_t cbGCCode;
128 /** @} */
129} VMMSWITCHERDEF;
130#pragma pack()
131
132RT_C_DECLS_BEGIN
133extern VMMSWITCHERDEF vmmR3SwitcherX86Stub_Def;
134extern VMMSWITCHERDEF vmmR3Switcher32BitTo32Bit_Def;
135extern VMMSWITCHERDEF vmmR3Switcher32BitToPAE_Def;
136extern VMMSWITCHERDEF vmmR3Switcher32BitToAMD64_Def;
137extern VMMSWITCHERDEF vmmR3SwitcherPAETo32Bit_Def;
138extern VMMSWITCHERDEF vmmR3SwitcherPAEToPAE_Def;
139extern VMMSWITCHERDEF vmmR3SwitcherPAEToAMD64_Def;
140extern VMMSWITCHERDEF vmmR3SwitcherAMD64Stub_Def;
141extern VMMSWITCHERDEF vmmR3SwitcherAMD64To32Bit_Def;
142extern VMMSWITCHERDEF vmmR3SwitcherAMD64ToPAE_Def;
143extern VMMSWITCHERDEF vmmR3SwitcherAMD64ToAMD64_Def;
144
145extern DECLCALLBACK(void) vmmR3Switcher32BitTo32Bit_Relocate(PVM pVM, PVMMSWITCHERDEF pSwitcher, RTR0PTR R0PtrCode, uint8_t *pu8CodeR3, RTGCPTR GCPtrCode, uint32_t u32IdCode);
146extern DECLCALLBACK(void) vmmR3Switcher32BitToPAE_Relocate(PVM pVM, PVMMSWITCHERDEF pSwitcher, RTR0PTR R0PtrCode, uint8_t *pu8CodeR3, RTGCPTR GCPtrCode, uint32_t u32IdCode);
147extern DECLCALLBACK(void) vmmR3Switcher32BitToAMD64_Relocate(PVM pVM, PVMMSWITCHERDEF pSwitcher, RTR0PTR R0PtrCode, uint8_t *pu8CodeR3, RTGCPTR GCPtrCode, uint32_t u32IdCode);
148extern DECLCALLBACK(void) vmmR3SwitcherPAETo32Bit_Relocate(PVM pVM, PVMMSWITCHERDEF pSwitcher, RTR0PTR R0PtrCode, uint8_t *pu8CodeR3, RTGCPTR GCPtrCode, uint32_t u32IdCode);
149extern DECLCALLBACK(void) vmmR3SwitcherPAEToPAE_Relocate(PVM pVM, PVMMSWITCHERDEF pSwitcher, RTR0PTR R0PtrCode, uint8_t *pu8CodeR3, RTGCPTR GCPtrCode, uint32_t u32IdCode);
150extern DECLCALLBACK(void) vmmR3SwitcherPAEToAMD64_Relocate(PVM pVM, PVMMSWITCHERDEF pSwitcher, RTR0PTR R0PtrCode, uint8_t *pu8CodeR3, RTGCPTR GCPtrCode, uint32_t u32IdCode);
151extern DECLCALLBACK(void) vmmR3SwitcherAMD64To32Bit_Relocate(PVM pVM, PVMMSWITCHERDEF pSwitcher, RTR0PTR R0PtrCode, uint8_t *pu8CodeR3, RTGCPTR GCPtrCode, uint32_t u32IdCode);
152extern DECLCALLBACK(void) vmmR3SwitcherAMD64ToPAE_Relocate(PVM pVM, PVMMSWITCHERDEF pSwitcher, RTR0PTR R0PtrCode, uint8_t *pu8CodeR3, RTGCPTR GCPtrCode, uint32_t u32IdCode);
153extern DECLCALLBACK(void) vmmR3SwitcherAMD64ToAMD64_Relocate(PVM pVM, PVMMSWITCHERDEF pSwitcher, RTR0PTR R0PtrCode, uint8_t *pu8CodeR3, RTGCPTR GCPtrCode, uint32_t u32IdCode);
154RT_C_DECLS_END
155
156#endif /* !VMM_INCLUDED_SRC_include_VMMSwitcher_h */
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