VirtualBox

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

Last change on this file since 8862 was 8853, checked in by vboxsync, 17 years ago

Manual page invalidation or TLB flush is required for AMD-V.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.7 KB
Line 
1/* $Id: HWSVMR0.h 8853 2008-05-15 13:57:31Z 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 ___HWSVMR0_h
23#define ___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 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 */
50HWACCMR0DECL(int) SVMR0Enter(PVM pVM);
51
52/**
53 * Leaves the AMD-V session
54 *
55 * @returns VBox status code.
56 * @param pVM The VM to operate on.
57 */
58HWACCMR0DECL(int) SVMR0Leave(PVM pVM);
59
60/**
61 * Sets up and activates AMD-V on the current CPU
62 *
63 * @returns VBox status code.
64 * @param idCpu The identifier for the CPU the function is called on.
65 * @param pVM The VM to operate on.
66 * @param pvPageCpu Pointer to the global cpu page
67 * @param pPageCpuPhys Physical address of the global cpu page
68 */
69HWACCMR0DECL(int) SVMR0EnableCpu(RTCPUID idCpu, PVM pVM, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
70
71/**
72 * Deactivates AMD-V on the current CPU
73 *
74 * @returns VBox status code.
75 * @param idCpu The identifier for the CPU the function is called on.
76 * @param pvPageCpu Pointer to the global cpu page
77 * @param pPageCpuPhys Physical address of the global cpu page
78 */
79HWACCMR0DECL(int) SVMR0DisableCpu(RTCPUID idCpu, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
80
81/**
82 * Does Ring-0 per VM AMD-V init.
83 *
84 * @returns VBox status code.
85 * @param pVM The VM to operate on.
86 */
87HWACCMR0DECL(int) SVMR0InitVM(PVM pVM);
88
89/**
90 * Does Ring-0 per VM AMD-V termination.
91 *
92 * @returns VBox status code.
93 * @param pVM The VM to operate on.
94 */
95HWACCMR0DECL(int) SVMR0TermVM(PVM pVM);
96
97/**
98 * Sets up AMD-V for the specified VM
99 *
100 * @returns VBox status code.
101 * @param pVM The VM to operate on.
102 */
103HWACCMR0DECL(int) SVMR0SetupVM(PVM pVM);
104
105
106/**
107 * Runs guest code in an AMD-V VM.
108 *
109 * @note NEVER EVER turn on interrupts here. Due to our illegal entry into the kernel, it might mess things up. (XP kernel traps have been frequently observed)
110 *
111 * @returns VBox status code.
112 * @param pVM The VM to operate on.
113 * @param pCtx Guest context
114 */
115HWACCMR0DECL(int) SVMR0RunGuestCode(PVM pVM, CPUMCTX *pCtx);
116
117
118/**
119 * Loads the guest state
120 *
121 * @returns VBox status code.
122 * @param pVM The VM to operate on.
123 * @param pCtx Guest context
124 */
125HWACCMR0DECL(int) SVMR0LoadGuestState(PVM pVM, CPUMCTX *pCtx);
126
127/**
128 * Invalidates a guest page
129 *
130 * @returns VBox status code.
131 * @param pVM The VM to operate on.
132 * @param GCVirt Page to invalidate
133 */
134HWACCMR0DECL(int) SVMR0InvalidatePage(PVM pVM, RTGCPTR GCVirt);
135
136/**
137 * Flushes the guest TLB
138 *
139 * @returns VBox status code.
140 * @param pVM The VM to operate on.
141 */
142HWACCMR0DECL(int) SVMR0FlushTLB(PVM pVM);
143
144
145/* Convert hidden selector attribute word between VMX and SVM formats. */
146#define SVM_HIDSEGATTR_VMX2SVM(a) (a & 0xFF) | ((a & 0xF000) >> 4)
147#define SVM_HIDSEGATTR_SVM2VMX(a) (a & 0xFF) | ((a & 0x0F00) << 4)
148
149#define SVM_WRITE_SELREG(REG, reg) \
150 pVMCB->guest.REG.u16Sel = pCtx->reg; \
151 pVMCB->guest.REG.u32Limit = pCtx->reg##Hid.u32Limit; \
152 pVMCB->guest.REG.u64Base = pCtx->reg##Hid.u32Base; \
153 pVMCB->guest.REG.u16Attr = SVM_HIDSEGATTR_VMX2SVM(pCtx->reg##Hid.Attr.u);
154
155#define SVM_READ_SELREG(REG, reg) \
156 pCtx->reg = pVMCB->guest.REG.u16Sel; \
157 pCtx->reg##Hid.u32Limit = pVMCB->guest.REG.u32Limit; \
158 pCtx->reg##Hid.u32Base = pVMCB->guest.REG.u64Base; \
159 pCtx->reg##Hid.Attr.u = SVM_HIDSEGATTR_SVM2VMX(pVMCB->guest.REG.u16Attr);
160
161#endif /* IN_RING0 */
162
163/** @} */
164
165__END_DECLS
166
167#endif
168
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