1 | /* $Id: HWSVMR0.h 7471 2008-03-17 10:50:10Z 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 | */
|
---|
46 | HWACCMR0DECL(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 | */
|
---|
54 | HWACCMR0DECL(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 | */
|
---|
65 | HWACCMR0DECL(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 | */
|
---|
75 | HWACCMR0DECL(int) SVMR0DisableCpu(RTCPUID idCpu, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Sets up AMD-V for the specified VM
|
---|
79 | *
|
---|
80 | * @returns VBox status code.
|
---|
81 | * @param pVM The VM to operate on.
|
---|
82 | */
|
---|
83 | HWACCMR0DECL(int) SVMR0SetupVM(PVM pVM);
|
---|
84 |
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * Runs guest code in an AMD-V VM.
|
---|
88 | *
|
---|
89 | * @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)
|
---|
90 | *
|
---|
91 | * @returns VBox status code.
|
---|
92 | * @param pVM The VM to operate on.
|
---|
93 | * @param pCtx Guest context
|
---|
94 | */
|
---|
95 | HWACCMR0DECL(int) SVMR0RunGuestCode(PVM pVM, CPUMCTX *pCtx);
|
---|
96 |
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Loads the guest state
|
---|
100 | *
|
---|
101 | * @returns VBox status code.
|
---|
102 | * @param pVM The VM to operate on.
|
---|
103 | * @param pCtx Guest context
|
---|
104 | */
|
---|
105 | HWACCMR0DECL(int) SVMR0LoadGuestState(PVM pVM, CPUMCTX *pCtx);
|
---|
106 |
|
---|
107 |
|
---|
108 | /* Convert hidden selector attribute word between VMX and SVM formats. */
|
---|
109 | #define SVM_HIDSEGATTR_VMX2SVM(a) (a & 0xFF) | ((a & 0xF000) >> 4)
|
---|
110 | #define SVM_HIDSEGATTR_SVM2VMX(a) (a & 0xFF) | ((a & 0x0F00) << 4)
|
---|
111 |
|
---|
112 | #define SVM_WRITE_SELREG(REG, reg) \
|
---|
113 | pVMCB->guest.REG.u16Sel = pCtx->reg; \
|
---|
114 | pVMCB->guest.REG.u32Limit = pCtx->reg##Hid.u32Limit; \
|
---|
115 | pVMCB->guest.REG.u64Base = pCtx->reg##Hid.u32Base; \
|
---|
116 | pVMCB->guest.REG.u16Attr = SVM_HIDSEGATTR_VMX2SVM(pCtx->reg##Hid.Attr.u);
|
---|
117 |
|
---|
118 | #define SVM_READ_SELREG(REG, reg) \
|
---|
119 | pCtx->reg = pVMCB->guest.REG.u16Sel; \
|
---|
120 | pCtx->reg##Hid.u32Limit = pVMCB->guest.REG.u32Limit; \
|
---|
121 | pCtx->reg##Hid.u32Base = pVMCB->guest.REG.u64Base; \
|
---|
122 | pCtx->reg##Hid.Attr.u = SVM_HIDSEGATTR_SVM2VMX(pVMCB->guest.REG.u16Attr);
|
---|
123 |
|
---|
124 | #endif /* IN_RING0 */
|
---|
125 |
|
---|
126 | /** @} */
|
---|
127 |
|
---|
128 | __END_DECLS
|
---|
129 |
|
---|
130 | #endif
|
---|
131 |
|
---|