HWSVMR0.h revision b45d66c0e496e2fd861479202f3d43aad592bd14
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * HWACCM AMD-V - Internal header file.
506df97a8c78dacfe69bc4d3ee5d3de832d0f19avboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
6ec4e1827eab6a424d672ef0e5a17b065e52db20vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
6ec4e1827eab6a424d672ef0e5a17b065e52db20vboxsync * available from http://www.virtualbox.org. This file is free software;
6ec4e1827eab6a424d672ef0e5a17b065e52db20vboxsync * you can redistribute it and/or modify it under the terms of the GNU
6ec4e1827eab6a424d672ef0e5a17b065e52db20vboxsync * General Public License (GPL) as published by the Free Software
6ec4e1827eab6a424d672ef0e5a17b065e52db20vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
6ec4e1827eab6a424d672ef0e5a17b065e52db20vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
6ec4e1827eab6a424d672ef0e5a17b065e52db20vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * additional information or have any questions.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync/** @defgroup grp_svm Internal
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @ingroup grp_svm
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @internal
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * Enters the AMD-V session
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @returns VBox status code.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pVM The VM to operate on.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * Leaves the AMD-V session
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @returns VBox status code.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pVM The VM to operate on.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * Sets up and activates AMD-V on the current CPU
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @returns VBox status code.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param idCpu The identifier for the CPU the function is called on.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pVM The VM to operate on.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pvPageCpu Pointer to the global cpu page
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pPageCpuPhys Physical address of the global cpu page
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsyncHWACCMR0DECL(int) SVMR0EnableCpu(RTCPUID idCpu, PVM pVM, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * Deactivates AMD-V on the current CPU
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @returns VBox status code.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param idCpu The identifier for the CPU the function is called on.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pvPageCpu Pointer to the global cpu page
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pPageCpuPhys Physical address of the global cpu page
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsyncHWACCMR0DECL(int) SVMR0DisableCpu(RTCPUID idCpu, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * Does Ring-0 per VM AMD-V init.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @returns VBox status code.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pVM The VM to operate on.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * Does Ring-0 per VM AMD-V termination.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @returns VBox status code.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pVM The VM to operate on.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * Sets up AMD-V for the specified VM
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @returns VBox status code.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pVM The VM to operate on.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * Runs guest code in an AMD-V VM.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @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)
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @returns VBox status code.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pVM The VM to operate on.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pCtx Guest context
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsyncHWACCMR0DECL(int) SVMR0RunGuestCode(PVM pVM, CPUMCTX *pCtx);
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * Loads the guest state
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @returns VBox status code.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pVM The VM to operate on.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pCtx Guest context
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsyncHWACCMR0DECL(int) SVMR0LoadGuestState(PVM pVM, CPUMCTX *pCtx);
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * Invalidates a guest page
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @returns VBox status code.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pVM The VM to operate on.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param GCVirt Page to invalidate
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsyncHWACCMR0DECL(int) SVMR0InvalidatePage(PVM pVM, RTGCPTR GCVirt);
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * Flushes the guest TLB
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @returns VBox status code.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync * @param pVM The VM to operate on.
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync/* Convert hidden selector attribute word between VMX and SVM formats. */
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync#define SVM_HIDSEGATTR_VMX2SVM(a) (a & 0xFF) | ((a & 0xF000) >> 4)
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync#define SVM_HIDSEGATTR_SVM2VMX(a) (a & 0xFF) | ((a & 0x0F00) << 4)
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync pVMCB->guest.REG.u32Limit = pCtx->reg##Hid.u32Limit; \
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync pVMCB->guest.REG.u64Base = pCtx->reg##Hid.u32Base; \
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync pVMCB->guest.REG.u16Attr = SVM_HIDSEGATTR_VMX2SVM(pCtx->reg##Hid.Attr.u);
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync pCtx->reg##Hid.u32Limit = pVMCB->guest.REG.u32Limit; \
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync pCtx->reg##Hid.u32Base = pVMCB->guest.REG.u64Base; \
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync pCtx->reg##Hid.Attr.u = SVM_HIDSEGATTR_SVM2VMX(pVMCB->guest.REG.u16Attr);
a33af978add1a03aab11b2895f441af5cb2a11a6vboxsync#endif /* IN_RING0 */