VirtualBox

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

Last change on this file since 7498 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: 4.1 KB
Line 
1/* $Id: HWSVMR0.h 7496 2008-03-19 10:22:50Z vboxsync $ */
2/** @file
3 * HWACCM AMD-V - 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 ___HWSVMR0_h
19#define ___HWSVMR0_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_svm.h>
29
30__BEGIN_DECLS
31
32/** @defgroup grp_svm Internal
33 * @ingroup grp_svm
34 * @internal
35 * @{
36 */
37
38#ifdef IN_RING0
39
40/**
41 * Enters the AMD-V session
42 *
43 * @returns VBox status code.
44 * @param pVM The VM to operate on.
45 */
46HWACCMR0DECL(int) SVMR0Enter(PVM pVM);
47
48/**
49 * Leaves the AMD-V session
50 *
51 * @returns VBox status code.
52 * @param pVM The VM to operate on.
53 */
54HWACCMR0DECL(int) SVMR0Leave(PVM pVM);
55
56/**
57 * Sets up and activates AMD-V on the current CPU
58 *
59 * @returns VBox status code.
60 * @param idCpu The identifier for the CPU the function is called on.
61 * @param pVM The VM to operate on.
62 * @param pvPageCpu Pointer to the global cpu page
63 * @param pPageCpuPhys Physical address of the global cpu page
64 */
65HWACCMR0DECL(int) SVMR0EnableCpu(RTCPUID idCpu, PVM pVM, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
66
67/**
68 * Deactivates AMD-V on the current CPU
69 *
70 * @returns VBox status code.
71 * @param idCpu The identifier for the CPU the function is called on.
72 * @param pvPageCpu Pointer to the global cpu page
73 * @param pPageCpuPhys Physical address of the global cpu page
74 */
75HWACCMR0DECL(int) SVMR0DisableCpu(RTCPUID idCpu, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
76
77/**
78 * Does Ring-0 per VM AMD-V init.
79 *
80 * @returns VBox status code.
81 * @param pVM The VM to operate on.
82 */
83HWACCMR0DECL(int) SVMR0InitVM(PVM pVM);
84
85/**
86 * Does Ring-0 per VM AMD-V termination.
87 *
88 * @returns VBox status code.
89 * @param pVM The VM to operate on.
90 */
91HWACCMR0DECL(int) SVMR0TermVM(PVM pVM);
92
93/**
94 * Sets up AMD-V for the specified VM
95 *
96 * @returns VBox status code.
97 * @param pVM The VM to operate on.
98 */
99HWACCMR0DECL(int) SVMR0SetupVM(PVM pVM);
100
101
102/**
103 * Runs guest code in an AMD-V VM.
104 *
105 * @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)
106 *
107 * @returns VBox status code.
108 * @param pVM The VM to operate on.
109 * @param pCtx Guest context
110 */
111HWACCMR0DECL(int) SVMR0RunGuestCode(PVM pVM, CPUMCTX *pCtx);
112
113
114/**
115 * Loads the guest state
116 *
117 * @returns VBox status code.
118 * @param pVM The VM to operate on.
119 * @param pCtx Guest context
120 */
121HWACCMR0DECL(int) SVMR0LoadGuestState(PVM pVM, CPUMCTX *pCtx);
122
123
124/* Convert hidden selector attribute word between VMX and SVM formats. */
125#define SVM_HIDSEGATTR_VMX2SVM(a) (a & 0xFF) | ((a & 0xF000) >> 4)
126#define SVM_HIDSEGATTR_SVM2VMX(a) (a & 0xFF) | ((a & 0x0F00) << 4)
127
128#define SVM_WRITE_SELREG(REG, reg) \
129 pVMCB->guest.REG.u16Sel = pCtx->reg; \
130 pVMCB->guest.REG.u32Limit = pCtx->reg##Hid.u32Limit; \
131 pVMCB->guest.REG.u64Base = pCtx->reg##Hid.u32Base; \
132 pVMCB->guest.REG.u16Attr = SVM_HIDSEGATTR_VMX2SVM(pCtx->reg##Hid.Attr.u);
133
134#define SVM_READ_SELREG(REG, reg) \
135 pCtx->reg = pVMCB->guest.REG.u16Sel; \
136 pCtx->reg##Hid.u32Limit = pVMCB->guest.REG.u32Limit; \
137 pCtx->reg##Hid.u32Base = pVMCB->guest.REG.u64Base; \
138 pCtx->reg##Hid.Attr.u = SVM_HIDSEGATTR_SVM2VMX(pVMCB->guest.REG.u16Attr);
139
140#endif /* IN_RING0 */
141
142/** @} */
143
144__END_DECLS
145
146#endif
147
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