VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR0/HWVMXR0.h@ 7796

Last change on this file since 7796 was 7496, checked in by vboxsync, 17 years ago

Moved VMCS allocation to ring 0.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.0 KB
Line 
1/* $Id: HWVMXR0.h 7496 2008-03-19 10:22:50Z vboxsync $ */
2/** @file
3 * HWACCM VT-x - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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 ___HWVMXR0_h
19#define ___HWVMXR0_h
20
21#include <VBox/cdefs.h>
22#include <VBox/types.h>
23#include <VBox/em.h>
24#include <VBox/stam.h>
25#include <VBox/dis.h>
26#include <VBox/hwaccm.h>
27#include <VBox/pgm.h>
28#include <VBox/hwacc_vmx.h>
29
30__BEGIN_DECLS
31
32/** @defgroup grp_vmx Internal
33 * @ingroup grp_vmx
34 * @internal
35 * @{
36 */
37
38#ifdef IN_RING0
39
40/**
41 * Enters the VT-x session
42 *
43 * @returns VBox status code.
44 * @param pVM The VM to operate on.
45 */
46HWACCMR0DECL(int) VMXR0Enter(PVM pVM);
47
48/**
49 * Leaves the VT-x session
50 *
51 * @returns VBox status code.
52 * @param pVM The VM to operate on.
53 */
54HWACCMR0DECL(int) VMXR0Leave(PVM pVM);
55
56
57/**
58 * Sets up and activates VT-x on the current CPU
59 *
60 * @returns VBox status code.
61 * @param idCpu The identifier for the CPU the function is called on.
62 * @param pVM The VM to operate on.
63 * @param pvPageCpu Pointer to the global cpu page
64 * @param pPageCpuPhys Physical address of the global cpu page
65 */
66HWACCMR0DECL(int) VMXR0EnableCpu(RTCPUID idCpu, PVM pVM, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
67
68/**
69 * Deactivates VT-x on the current CPU
70 *
71 * @returns VBox status code.
72 * @param idCpu The identifier for the CPU the function is called on.
73 * @param pvPageCpu Pointer to the global cpu page
74 * @param pPageCpuPhys Physical address of the global cpu page
75 */
76HWACCMR0DECL(int) VMXR0DisableCpu(RTCPUID idCpu, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
77
78/**
79 * Does Ring-0 per VM VT-x init.
80 *
81 * @returns VBox status code.
82 * @param pVM The VM to operate on.
83 */
84HWACCMR0DECL(int) VMXR0InitVM(PVM pVM);
85
86/**
87 * Does Ring-0 per VM VT-x termination.
88 *
89 * @returns VBox status code.
90 * @param pVM The VM to operate on.
91 */
92HWACCMR0DECL(int) VMXR0TermVM(PVM pVM);
93
94/**
95 * Sets up VT-x for the specified VM
96 *
97 * @returns VBox status code.
98 * @param pVM The VM to operate on.
99 */
100HWACCMR0DECL(int) VMXR0SetupVM(PVM pVM);
101
102
103/**
104 * Save the host state
105 *
106 * @returns VBox status code.
107 * @param pVM The VM to operate on.
108 */
109HWACCMR0DECL(int) VMXR0SaveHostState(PVM pVM);
110
111/**
112 * Loads the guest state
113 *
114 * @returns VBox status code.
115 * @param pVM The VM to operate on.
116 * @param pCtx Guest context
117 */
118HWACCMR0DECL(int) VMXR0LoadGuestState(PVM pVM, CPUMCTX *pCtx);
119
120
121/**
122 * Runs guest code in a VT-x VM.
123 *
124 * @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)
125 *
126 * @returns VBox status code.
127 * @param pVM The VM to operate on.
128 * @param pCtx Guest context
129 */
130HWACCMR0DECL(int) VMXR0RunGuestCode(PVM pVM, CPUMCTX *pCtx);
131
132
133#define VMX_WRITE_SELREG(REG, reg) \
134 rc = VMXWriteVMCS(VMX_VMCS_GUEST_FIELD_##REG, pCtx->reg); \
135 rc |= VMXWriteVMCS(VMX_VMCS_GUEST_##REG##_LIMIT, pCtx->reg##Hid.u32Limit); \
136 rc |= VMXWriteVMCS(VMX_VMCS_GUEST_##REG##_BASE, pCtx->reg##Hid.u32Base); \
137 if (pCtx->eflags.u32 & X86_EFL_VM) \
138 val = pCtx->reg##Hid.Attr.u; \
139 else \
140 if (pCtx->reg && pCtx->reg##Hid.Attr.n.u1Present == 1) \
141 val = pCtx->reg##Hid.Attr.u | X86_SEL_TYPE_ACCESSED; \
142 else \
143 val = 0x10000; /* Invalid guest state error otherwise. (BIT(16) = Unusable) */ \
144 \
145 rc |= VMXWriteVMCS(VMX_VMCS_GUEST_##REG##_ACCESS_RIGHTS, val);
146
147#define VMX_READ_SELREG(REG, reg) \
148 VMXReadVMCS(VMX_VMCS_GUEST_FIELD_##REG, &val); \
149 pCtx->reg = val; \
150 VMXReadVMCS(VMX_VMCS_GUEST_##REG##_LIMIT, &val); \
151 pCtx->reg##Hid.u32Limit = val; \
152 VMXReadVMCS(VMX_VMCS_GUEST_##REG##_BASE, &val); \
153 pCtx->reg##Hid.u32Base = val; \
154 VMXReadVMCS(VMX_VMCS_GUEST_##REG##_ACCESS_RIGHTS, &val); \
155 pCtx->reg##Hid.Attr.u = val;
156
157
158#endif /* IN_RING0 */
159
160/** @} */
161
162__END_DECLS
163
164#endif
165
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