VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR0/HWSVMR0.h@ 14414

Last change on this file since 14414 was 14366, checked in by vboxsync, 16 years ago

Cleaned up some more.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.1 KB
Line 
1/* $Id: HWSVMR0.h 14366 2008-11-19 17:20:49Z vboxsync $ */
2/** @file
3 * HWACCM AMD-V - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ___VMMR0_HWSVMR0_h
23#define ___VMMR0_HWSVMR0_h
24
25#include <VBox/cdefs.h>
26#include <VBox/types.h>
27#include <VBox/em.h>
28#include <VBox/stam.h>
29#include <VBox/dis.h>
30#include <VBox/hwaccm.h>
31#include <VBox/pgm.h>
32#include <VBox/hwacc_svm.h>
33
34__BEGIN_DECLS
35
36/** @defgroup grp_svm_int Internal
37 * @ingroup grp_svm
38 * @internal
39 * @{
40 */
41
42#ifdef IN_RING0
43
44/**
45 * Enters the AMD-V session
46 *
47 * @returns VBox status code.
48 * @param pVM The VM to operate on.
49 * @param pVCpu The VMCPU to operate on.
50 * @param pCpu CPU info struct
51 */
52VMMR0DECL(int) SVMR0Enter(PVM pVM, PVMCPU pVCpu, PHWACCM_CPUINFO pCpu);
53
54/**
55 * Leaves the AMD-V session
56 *
57 * @returns VBox status code.
58 * @param pVM The VM to operate on.
59 * @param pVCpu The VMCPU to operate on.
60 * @param pCtx CPU context
61 */
62VMMR0DECL(int) SVMR0Leave(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
63
64/**
65 * Sets up and activates AMD-V on the current CPU
66 *
67 * @returns VBox status code.
68 * @param pCpu CPU info struct
69 * @param pVM The VM to operate on. (can be NULL after a resume)
70 * @param pvPageCpu Pointer to the global cpu page
71 * @param pPageCpuPhys Physical address of the global cpu page
72 */
73VMMR0DECL(int) SVMR0EnableCpu(PHWACCM_CPUINFO pCpu, PVM pVM, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
74
75/**
76 * Deactivates AMD-V on the current CPU
77 *
78 * @returns VBox status code.
79 * @param pCpu CPU info struct
80 * @param pvPageCpu Pointer to the global cpu page
81 * @param pPageCpuPhys Physical address of the global cpu page
82 */
83VMMR0DECL(int) SVMR0DisableCpu(PHWACCM_CPUINFO pCpu, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
84
85/**
86 * Does Ring-0 per VM AMD-V init.
87 *
88 * @returns VBox status code.
89 * @param pVM The VM to operate on.
90 */
91VMMR0DECL(int) SVMR0InitVM(PVM pVM);
92
93/**
94 * Does Ring-0 per VM AMD-V termination.
95 *
96 * @returns VBox status code.
97 * @param pVM The VM to operate on.
98 */
99VMMR0DECL(int) SVMR0TermVM(PVM pVM);
100
101/**
102 * Sets up AMD-V for the specified VM
103 *
104 * @returns VBox status code.
105 * @param pVM The VM to operate on.
106 */
107VMMR0DECL(int) SVMR0SetupVM(PVM pVM);
108
109
110/**
111 * Runs guest code in an AMD-V VM.
112 *
113 * @returns VBox status code.
114 * @param pVM The VM to operate on.
115 * @param pVCpu The VMCPU to operate on.
116 * @param pCtx Guest context
117 */
118VMMR0DECL(int) SVMR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
119
120
121/**
122 * Save the host state
123 *
124 * @returns VBox status code.
125 * @param pVM The VM to operate on.
126 * @param pVCpu The VMCPU to operate on.
127 */
128VMMR0DECL(int) SVMR0SaveHostState(PVM pVM, PVMCPU pVCpu);
129
130/**
131 * Loads the guest state
132 *
133 * @returns VBox status code.
134 * @param pVM The VM to operate on.
135 * @param pVCpu The VMCPU to operate on.
136 * @param pCtx Guest context
137 */
138VMMR0DECL(int) SVMR0LoadGuestState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
139
140/**
141 * Prepares for and executes VMRUN (32 bits guests).
142 *
143 * @returns VBox status code.
144 * @param pVMCBHostPhys Physical address of host VMCB.
145 * @param pVMCBPhys Physical address of the VMCB.
146 * @param pCtx Guest context.
147 */
148DECLASM(int) SVMR0VMRun(RTHCPHYS pVMCBHostPhys, RTHCPHYS pVMCBPhys, PCPUMCTX pCtx);
149
150/**
151 * Prepares for and executes VMRUN (64 bits guests).
152 *
153 * @returns VBox status code.
154 * @param pVMCBHostPhys Physical address of host VMCB.
155 * @param pVMCBPhys Physical address of the VMCB.
156 * @param pCtx Guest context.
157 */
158DECLASM(int) SVMR0VMRun64(RTHCPHYS pVMCBHostPhys, RTHCPHYS pVMCBPhys, PCPUMCTX pCtx);
159
160/**
161 * Prepares for and executes VMRUN (64 bits guests from a 32 bits hosts).
162 *
163 * @returns VBox status code.
164 * @param pVMCBHostPhys Physical address of host VMCB.
165 * @param pVMCBPhys Physical address of the VMCB.
166 * @param pCtx Guest context.
167 */
168DECLASM(int) SVMR0VMSwitcherRun64(RTHCPHYS pVMCBHostPhys, RTHCPHYS pVMCBPhys, PCPUMCTX pCtx);
169
170/**
171 * Executes INVLPGA.
172 *
173 * @param pPageGC Virtual page to invalidate.
174 * @param u32ASID Tagged TLB id.
175 */
176DECLASM(void) SVMR0InvlpgA(RTGCPTR pPageGC, uint32_t u32ASID);
177
178/** Convert hidden selector attribute word between VMX and SVM formats. */
179#define SVM_HIDSEGATTR_VMX2SVM(a) (a & 0xFF) | ((a & 0xF000) >> 4)
180#define SVM_HIDSEGATTR_SVM2VMX(a) (a & 0xFF) | ((a & 0x0F00) << 4)
181
182#define SVM_WRITE_SELREG(REG, reg) \
183{ \
184 pVMCB->guest.REG.u16Sel = pCtx->reg; \
185 pVMCB->guest.REG.u32Limit = pCtx->reg##Hid.u32Limit; \
186 pVMCB->guest.REG.u64Base = pCtx->reg##Hid.u64Base; \
187 pVMCB->guest.REG.u16Attr = SVM_HIDSEGATTR_VMX2SVM(pCtx->reg##Hid.Attr.u); \
188}
189
190#define SVM_READ_SELREG(REG, reg) \
191{ \
192 pCtx->reg = pVMCB->guest.REG.u16Sel; \
193 pCtx->reg##Hid.u32Limit = pVMCB->guest.REG.u32Limit; \
194 pCtx->reg##Hid.u64Base = pVMCB->guest.REG.u64Base; \
195 pCtx->reg##Hid.Attr.u = SVM_HIDSEGATTR_SVM2VMX(pVMCB->guest.REG.u16Attr); \
196}
197
198#endif /* IN_RING0 */
199
200/** @} */
201
202__END_DECLS
203
204#endif
205
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