hm.h revision f8f484be8e0e78344ba79891ce9751c172517062
/** @file
*/
/*
* Copyright (C) 2006-2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___VBox_vmm_hm_h
#define ___VBox_vmm_hm_h
/** @defgroup grp_hm The VM Hardware Manager API
* @{
*/
/**
*
* @retval @c true if used.
* @retval @c false if software virtualization (raw-mode) is used.
*
* @param a_pVM The cross context VM structure.
* @sa HMIsEnabledNotMacro, HMR3IsEnabled
* @internal
*/
#if defined(VBOX_STRICT) && defined(IN_RING3)
#else
#endif
/**
* Checks whether raw-mode context is required for any purpose.
*
* @retval @c true if required either by raw-mode itself or by HM for doing
* switching the cpu to 64-bit mode.
* @retval @c false if not required.
*
* @param a_pVM The cross context VM structure.
* @internal
*/
#if HC_ARCH_BITS == 64
#else
#endif
/**
* Check if the current CPU state is valid for emulating IO blocks in the recompiler
*
* @returns boolean
* @param a_pVCpu Pointer to the shared virtual CPU structure.
* @internal
*/
/**
* Check if the current CPU state is valid for emulating IO blocks in the recompiler
*
* @returns boolean
* @param a_pCtx Pointer to the CPU context (within PVM).
* @internal
*/
/**
* Checks whether we're in the special hardware virtualization context.
* @returns true / false.
* @param a_pVCpu The caller's cross context virtual CPU structure.
* @thread EMT
*/
#ifdef IN_RING0
#else
# define HMIsInHwVirtCtx(a_pVCpu) (false)
#endif
/**
* Checks whether we're in the special hardware virtualization context and we
* cannot perform long jump without guru meditating and possibly messing up the
*
* This is after we've turned interrupts off and such.
*
* @returns true / false.
* @param a_pVCpu The caller's cross context virtual CPU structure.
* @thread EMT
*/
#ifdef IN_RING0
#else
# define HMIsInHwVirtNoLongJmpCtx(a_pVCpu) (false)
#endif
/**
* 64-bit raw-mode (intermediate memory context) operations.
*
* These are special hypervisor eip values used when running 64-bit guests on
* 32-bit hosts. Each operation corresponds to a routine.
*
* @note Duplicated in the assembly code!
*/
typedef enum HM64ON32OP
{
HM64ON32OP_INVALID = 0,
HM64ON32OP_32BIT_HACK = 0x7fffffff
} HM64ON32OP;
VMM_INT_DECL(int) HMAmdIsSubjectToErratum170(uint32_t *pu32Family, uint32_t *pu32Model, uint32_t *pu32Stepping);
#ifndef IN_RC
#else /* Nops in RC: */
# define HMFlushTLB(pVCpu) do { } while (0)
# define HMIsNestedPagingActive(pVM) false
# define HMAreMsrBitmapsAvailable(pVM) false
# define HMFlushTLBOnAllVCpus(pVM) do { } while (0)
#endif
#ifdef IN_RING0
/** @defgroup grp_hm_r0 The VM Hardware Manager API
* @ingroup grp_hm
* @{
*/
VMMR0_INT_DECL(int) HMR0Init(void);
VMMR0_INT_DECL(int) HMR0Term(void);
VMMR0_INT_DECL(void) HMR0SavePendingIOPortWrite(PVMCPU pVCpu, RTGCPTR GCPtrRip, RTGCPTR GCPtrRipNext,
VMMR0_INT_DECL(void) HMR0SavePendingIOPortRead(PVMCPU pVCpu, RTGCPTR GCPtrRip, RTGCPTR GCPtrRipNext,
/** @} */
#endif /* IN_RING0 */
#ifdef IN_RING3
/** @defgroup grp_hm_r3 The VM Hardware Manager API
* @ingroup grp_hm
* @{
*/
VMMR3_INT_DECL(void) HMR3PagingModeChanged(PVM pVM, PVMCPU pVCpu, PGMMODE enmShadowMode, PGMMODE enmGuestMode);
/** @} */
#endif /* IN_RING3 */
#ifdef IN_RING0
/** @addtogroup grp_hm_r0
* @{
*/
/** Disables preemption if required. */
# define HM_DISABLE_PREEMPT_IF_NEEDED() \
bool fPreemptDisabledInternal = false; \
if (RTThreadPreemptIsEnabled(NIL_RTTHREAD)) \
{ \
fPreemptDisabledInternal = true; \
}
/** Restores preemption if previously disabled by HM_DISABLE_PREEMPT(). */
# define HM_RESTORE_PREEMPT_IF_NEEDED() \
do \
{ \
if (fPreemptDisabledInternal) \
} while (0)
VMMR0_INT_DECL(bool) HMR0SuspendPending(void);
# endif
/** @} */
#endif /* IN_RING0 */
/** @} */
#endif