1
/* $Id: HWSVMR0.h 4071 2007-08-07 17:07:59Z vboxsync $ */
3
* HWACCM SVM - Internal header file.
7
* Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
13
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14
* distribution. VirtualBox OSE is distributed in the hope that it will
15
* be useful, but WITHOUT ANY WARRANTY of any kind.
21
#include <VBox/cdefs.h>
22
#include <VBox/types.h>
24
#include <VBox/stam.h>
26
#include <VBox/hwaccm.h>
28
#include <VBox/hwacc_svm.h>
32
/** @defgroup grp_svm Internal
43
* @returns VBox status code.
44
* @param pVM The VM to operate on.
46
HWACCMR0DECL(int) SVMR0Enable(PVM pVM);
51
* @returns VBox status code.
52
* @param pVM The VM to operate on.
54
HWACCMR0DECL(int) SVMR0Disable(PVM pVM);
57
* Sets up and activates SVM
59
* @returns VBox status code.
60
* @param pVM The VM to operate on.
62
HWACCMR0DECL(int) SVMR0Setup(PVM pVM);
66
* Runs guest code in a SVM VM.
68
* @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)
70
* @returns VBox status code.
71
* @param pVM The VM to operate on.
72
* @param pCtx Guest context
74
HWACCMR0DECL(int) SVMR0RunGuestCode(PVM pVM, CPUMCTX *pCtx);
78
* Loads the guest state
80
* @returns VBox status code.
81
* @param pVM The VM to operate on.
82
* @param pCtx Guest context
84
HWACCMR0DECL(int) SVMR0LoadGuestState(PVM pVM, CPUMCTX *pCtx);
87
/* Convert hidden selector attribute word between VMX and SVM formats. */
88
#define SVM_HIDSEGATTR_VMX2SVM(a) (a & 0xFF) | ((a & 0xF000) >> 4)
89
#define SVM_HIDSEGATTR_SVM2VMX(a) (a & 0xFF) | ((a & 0x0F00) << 4)
91
#define SVM_WRITE_SELREG(REG, reg) \
92
pVMCB->guest.REG.u16Sel = pCtx->reg; \
93
pVMCB->guest.REG.u32Limit = pCtx->reg##Hid.u32Limit; \
94
pVMCB->guest.REG.u64Base = pCtx->reg##Hid.u32Base; \
95
pVMCB->guest.REG.u16Attr = SVM_HIDSEGATTR_VMX2SVM(pCtx->reg##Hid.Attr.u);
97
#define SVM_READ_SELREG(REG, reg) \
98
pCtx->reg = pVMCB->guest.REG.u16Sel; \
99
pCtx->reg##Hid.u32Limit = pVMCB->guest.REG.u32Limit; \
100
pCtx->reg##Hid.u32Base = pVMCB->guest.REG.u64Base; \
101
pCtx->reg##Hid.Attr.u = SVM_HIDSEGATTR_SVM2VMX(pVMCB->guest.REG.u16Attr);
103
#endif /* IN_RING0 */