IOMAllMMIO.cpp revision 24880d547852c49324fbf11fc3c1f6ec4795c67c
/* $Id$ */
/** @file
* IOM - Input / Output Monitor - Any Context, MMIO & String I/O.
*/
/*
* Copyright (C) 2006-2010 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_IOM
#if defined(IEM_VERIFICATION_MODE) && defined(IN_RING3)
#endif
#include "IOMInternal.h"
#include "IOMInline.h"
#include <VBox/disopcode.h>
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/**
* Array for fast recode of the operand size (1/2/4/8 bytes) to bit shift value.
*/
static const unsigned g_aSize2Shift[] =
{
~0U, /* 0 - invalid */
0, /* *1 == 2^0 */
1, /* *2 == 2^1 */
~0U, /* 3 - invalid */
2, /* *4 == 2^2 */
~0U, /* 5 - invalid */
~0U, /* 6 - invalid */
~0U, /* 7 - invalid */
3 /* *8 == 2^3 */
};
/**
* Macro for fast recode of the operand size (1/2/4/8 bytes) to bit shift value.
*/
/**
* Deals with complicated MMIO writes.
*
* the MMIO region's access mode flags.
*
* @returns Strict VBox status code. Any EM scheduling status code,
* VINF_IOM_R3_MMIO_WRITE, VINF_IOM_R3_MMIO_READ_WRITE or
* VINF_IOM_R3_MMIO_READ may be returned.
*
* @param pVM The VM handle.
* @param pRange The range to write to.
* @param GCPhys The physical address to start writing.
* @param pvValue Where to store the value.
* @param cbValue The size of the value to write.
*/
static VBOXSTRICTRC iomMMIODoComplicatedWrite(PVM pVM, PIOMMMIORANGE pRange, RTGCPHYS GCPhys, void const *pvValue, unsigned cbValue)
{
bool const fReadMissing = (pRange->fFlags & IOMMMIO_FLAGS_WRITE_MODE) >= IOMMMIO_FLAGS_WRITE_DWORD_READ_MISSING;
/*
* Do debug stop if requested.
*/
#ifdef VBOX_STRICT
# ifdef IN_RING3
# else
return VINF_IOM_R3_MMIO_WRITE;
# endif
#endif
/*
* Split and conquer.
*/
for (;;)
{
if (cbThisPart > cbValue)
/*
* Get the missing bits (if any).
*/
uint32_t u32MissingValue = 0;
{
switch (rc2)
{
case VINF_SUCCESS:
break;
case VINF_IOM_MMIO_UNUSED_FF:
break;
case VINF_IOM_MMIO_UNUSED_00:
u32MissingValue = 0;
break;
case VINF_IOM_R3_MMIO_READ:
case VINF_IOM_R3_MMIO_WRITE:
/** @todo What if we've split a transfer and already read
* something? Since reads can have sideeffects we could be
* kind of screwed here... */
LogFlow(("iomMMIODoComplicatedWrite: GCPhys=%RGp GCPhysStart=%RGp cbValue=%u rc=%Rrc [read]\n", GCPhys, GCPhysStart, cbValue, rc2));
return rc2;
default:
if (RT_FAILURE(rc2))
{
Log(("iomMMIODoComplicatedWrite: GCPhys=%RGp GCPhysStart=%RGp cbValue=%u rc=%Rrc [read]\n", GCPhys, GCPhysStart, cbValue, rc2));
return rc2;
}
AssertMsgReturn(rc2 >= VINF_EM_FIRST && rc2 <= VINF_EM_LAST, ("%Rrc\n", rc2), VERR_IPE_UNEXPECTED_INFO_STATUS);
break;
}
}
/*
* Merge missing and given bits.
*/
switch (cbThisPart)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
default:
}
if (offAccess)
{
}
| (u32GivenValue & u32GivenMask);
/*
* Do DWORD write to the device.
*/
switch (rc2)
{
case VINF_SUCCESS:
break;
case VINF_IOM_R3_MMIO_READ:
case VINF_IOM_R3_MMIO_WRITE:
/** @todo What if we've split a transfer and already read
* something? Since reads can have sideeffects we could be
* kind of screwed here... */
LogFlow(("iomMMIODoComplicatedWrite: GCPhys=%RGp GCPhysStart=%RGp cbValue=%u rc=%Rrc [write]\n", GCPhys, GCPhysStart, cbValue, rc2));
return rc2;
default:
if (RT_FAILURE(rc2))
{
Log(("iomMMIODoComplicatedWrite: GCPhys=%RGp GCPhysStart=%RGp cbValue=%u rc=%Rrc [write]\n", GCPhys, GCPhysStart, cbValue, rc2));
return rc2;
}
AssertMsgReturn(rc2 >= VINF_EM_FIRST && rc2 <= VINF_EM_LAST, ("%Rrc\n", rc2), VERR_IPE_UNEXPECTED_INFO_STATUS);
break;
}
/*
* Advance.
*/
cbValue -= cbThisPart;
if (!cbValue)
break;
GCPhys += cbThisPart;
}
return rc;
}
/**
* Wrapper which does the write and updates range statistics when such are enabled.
* @warning RT_SUCCESS(rc=VINF_IOM_R3_MMIO_WRITE) is TRUE!
*/
static int iomMMIODoWrite(PVM pVM, PIOMMMIORANGE pRange, RTGCPHYS GCPhysFault, const void *pvData, unsigned cb)
{
#ifdef VBOX_WITH_STATISTICS
#endif
{
else
}
else
rc = VINF_SUCCESS;
return VBOXSTRICTRC_TODO(rc);
}
/**
* Deals with complicated MMIO reads.
*
* the MMIO region's access mode flags.
*
* @returns Strict VBox status code. Any EM scheduling status code,
* VINF_IOM_R3_MMIO_READ, VINF_IOM_R3_MMIO_READ_WRITE or
* VINF_IOM_R3_MMIO_WRITE may be returned.
*
* @param pVM The VM handle.
* @param pRange The range to read from.
* @param GCPhys The physical address to start reading.
* @param pvValue Where to store the value.
* @param cbValue The size of the value to read.
*/
static VBOXSTRICTRC iomMMIODoComplicatedRead(PVM pVM, PIOMMMIORANGE pRange, RTGCPHYS GCPhys, void *pvValue, unsigned cbValue)
{
/*
* Do debug stop if requested.
*/
#ifdef VBOX_STRICT
# ifdef IN_RING3
# else
return VINF_IOM_R3_MMIO_READ;
# endif
#endif
/*
* Split and conquer.
*/
for (;;)
{
/*
* Do DWORD read from the device.
*/
switch (rc2)
{
case VINF_SUCCESS:
break;
case VINF_IOM_MMIO_UNUSED_FF:
break;
case VINF_IOM_MMIO_UNUSED_00:
u32Value = 0;
break;
case VINF_IOM_R3_MMIO_READ:
case VINF_IOM_R3_MMIO_WRITE:
/** @todo What if we've split a transfer and already read
* something? Since reads can have sideeffects we could be
* kind of screwed here... */
LogFlow(("iomMMIODoComplicatedRead: GCPhys=%RGp GCPhysStart=%RGp cbValue=%u rc=%Rrc\n", GCPhys, GCPhysStart, cbValue, rc2));
return rc2;
default:
if (RT_FAILURE(rc2))
{
Log(("iomMMIODoComplicatedRead: GCPhys=%RGp GCPhysStart=%RGp cbValue=%u rc=%Rrc\n", GCPhys, GCPhysStart, cbValue, rc2));
return rc2;
}
AssertMsgReturn(rc2 >= VINF_EM_FIRST && rc2 <= VINF_EM_LAST, ("%Rrc\n", rc2), VERR_IPE_UNEXPECTED_INFO_STATUS);
break;
}
/*
* Write what we've read.
*/
if (cbThisPart > cbValue)
switch (cbThisPart)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
}
/*
* Advance.
*/
cbValue -= cbThisPart;
if (!cbValue)
break;
GCPhys += cbThisPart;
}
return rc;
}
/**
* Implements VINF_IOM_MMIO_UNUSED_FF.
*
* @returns VINF_SUCCESS.
* @param pvValue Where to store the zeros.
* @param cbValue How many bytes to read.
*/
{
switch (cbValue)
{
default:
{
while (cbValue--)
break;
}
}
return VINF_SUCCESS;
}
/**
* Implements VINF_IOM_MMIO_UNUSED_00.
*
* @returns VINF_SUCCESS.
* @param pvValue Where to store the zeros.
* @param cbValue How many bytes to read.
*/
{
switch (cbValue)
{
default:
{
while (cbValue--)
break;
}
}
return VINF_SUCCESS;
}
/**
* Wrapper which does the read and updates range statistics when such are enabled.
*/
DECLINLINE(int) iomMMIODoRead(PVM pVM, PIOMMMIORANGE pRange, RTGCPHYS GCPhys, void *pvValue, unsigned cbValue)
{
#ifdef VBOX_WITH_STATISTICS
#endif
{
rc = pRange->CTX_SUFF(pfnReadCallback)(pRange->CTX_SUFF(pDevIns), pRange->CTX_SUFF(pvUser), GCPhys, pvValue, cbValue);
else
}
else
if (rc != VINF_SUCCESS)
{
switch (VBOXSTRICTRC_VAL(rc))
{
}
}
return VBOXSTRICTRC_VAL(rc);
}
/**
* Internal - statistics only.
*/
{
#ifdef VBOX_WITH_STATISTICS
switch (cb)
{
case 1:
break;
case 2:
break;
case 4:
break;
case 8:
break;
default:
/* No way. */
break;
}
#else
#endif
}
/**
* MOV reg, mem (read)
* MOVZX reg, mem (read)
* MOVSX reg, mem (read)
*
* @returns VBox status code.
*
* @param pVM The virtual machine.
* @param pRegFrame Pointer to CPUMCTXCORE guest registers structure.
* @param pCpu Disassembler CPU state.
* @param pRange Pointer MMIO range.
* @param GCPhysFault The GC physical address corresponding to pvFault.
*/
static int iomInterpretMOVxXRead(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu, PIOMMMIORANGE pRange, RTGCPHYS GCPhysFault)
{
/*
* Get the data size from parameter 2,
* and call the handler function to get the data.
*/
if (rc == VINF_SUCCESS)
{
/*
* Do sign extension for MOVSX.
*/
/** @todo checkup MOVSX implementation! */
{
if (cb == 1)
{
/* DWORD <- BYTE */
}
else
{
/* DWORD <- WORD */
}
}
/*
* Store the result to register (parameter 1).
*/
}
if (rc == VINF_SUCCESS)
return rc;
}
/**
* MOV mem, reg|imm (write)
*
* @returns VBox status code.
*
* @param pVM The virtual machine.
* @param pRegFrame Pointer to CPUMCTXCORE guest registers structure.
* @param pCpu Disassembler CPU state.
* @param pRange Pointer MMIO range.
* @param GCPhysFault The GC physical address corresponding to pvFault.
*/
static int iomInterpretMOVxXWrite(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu, PIOMMMIORANGE pRange, RTGCPHYS GCPhysFault)
{
/*
* Get data to write from second parameter,
* and call the callback to write it.
*/
unsigned cb = 0;
if (rc == VINF_SUCCESS)
return rc;
}
/** Wrapper for reading virtual memory. */
{
/* Note: This will fail in R0 or RC if it hits an access handler. That
isn't a problem though since the operation can be restarted in REM. */
#ifdef IN_RC
/* Page may be protected and not directly accessible. */
if (rc == VERR_ACCESS_DENIED)
return rc;
#else
#endif
}
/** Wrapper for writing virtual memory. */
DECLINLINE(int) iomRamWrite(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, RTGCPTR GCPtrDst, void *pvSrc, uint32_t cb)
{
/** @todo Need to update PGMVerifyAccess to take access handlers into account for Ring-0 and
* raw mode code. Some thought needs to be spent on theoretical concurrency issues as
* as well since we're not behind the pgm lock and handler may change between calls.
*
* PGMPhysInterpretedWriteNoHandlers/PGMPhysWriteGCPtr may mess up
* the state of some shadowed structures. */
return PGMPhysInterpretedWriteNoHandlers(pVCpu, pCtxCore, GCPtrDst, pvSrc, cb, false /*fRaiseTrap*/);
#else
#endif
}
#if defined(IOM_WITH_MOVS_SUPPORT) && 0 /* locking prevents this from working. has buggy ecx handling. */
/**
* [REP] MOVSB
* [REP] MOVSW
* [REP] MOVSD
*
* Restricted implementation.
*
*
* @returns VBox status code.
*
* @param pVM The virtual machine.
* @param uErrorCode CPU Error code.
* @param pRegFrame Trap register frame.
* @param GCPhysFault The GC physical address corresponding to pvFault.
* @param pCpu Disassembler CPU state.
* @param pRange Pointer MMIO range.
* @param ppStat Which sub-sample to attribute this call to.
*/
static int iomInterpretMOVS(PVM pVM, bool fWriteAccess, PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, PDISCPUSTATE pCpu, PIOMMMIORANGE pRange,
{
/*
* We do not support segment prefixes or REPNE.
*/
return VINF_IOM_R3_MMIO_READ_WRITE; /** @todo -> interpret whatever. */
/*
*/
{
#ifndef IN_RC
return VINF_EM_RAW_EMULATE_INSTR;
#endif
if (SELMGetCpuModeFromSelector(pVM, pRegFrame->eflags, pRegFrame->cs, &pRegFrame->csHid) == CPUMODE_16BIT)
cTransfers &= 0xffff;
if (!cTransfers)
return VINF_SUCCESS;
}
/* Get the current privilege level. */
/*
* Get data size.
*/
#ifdef VBOX_WITH_STATISTICS
#endif
/** @todo re-evaluate on page boundaries. */
int rc;
if (fWriteAccess)
{
/*
* Write operation: [Mem] -> [MMIO]
* ds:esi (Virt Src) -> es:edi (Phys Dst)
*/
/* Check callback. */
return VINF_IOM_R3_MMIO_WRITE;
/* Convert source address ds:esi. */
if (RT_SUCCESS(rc))
{
/* Access verification first; we currently can't recover properly from traps inside this instruction */
if (rc != VINF_SUCCESS)
{
return VINF_EM_RAW_EMULATE_INSTR;
}
#ifdef IN_RC
#endif
/* copy loop. */
while (cTransfers)
{
if (rc != VINF_SUCCESS)
break;
if (rc != VINF_SUCCESS)
break;
pu8Virt += offIncrement;
Phys += offIncrement;
cTransfers--;
}
#ifdef IN_RC
#endif
/* Update ecx. */
}
else
}
else
{
/*
* Read operation: [MMIO] -> [mem] or [MMIO] -> [MMIO]
* ds:[eSI] (Phys Src) -> es:[eDI] (Virt Dst)
*/
/* Check callback. */
return VINF_IOM_R3_MMIO_READ;
/* Convert destination address. */
if (RT_FAILURE(rc))
return VINF_IOM_R3_MMIO_READ;
/* Check if destination address is MMIO. */
if ( RT_SUCCESS(rc)
{
/** @todo implement per-device locks for MMIO access. */
/*
* Extra: [MMIO] -> [MMIO]
*/
{
return VINF_IOM_R3_MMIO_READ_WRITE;
}
/* copy loop. */
while (cTransfers)
{
if (rc != VINF_SUCCESS)
break;
if (rc != VINF_SUCCESS)
break;
Phys += offIncrement;
PhysDst += offIncrement;
cTransfers--;
}
}
else
{
/*
* Normal: [MMIO] -> [Mem]
*/
/* Access verification first; we currently can't recover properly from traps inside this instruction */
if (rc != VINF_SUCCESS)
{
return VINF_EM_RAW_EMULATE_INSTR;
}
/* copy loop. */
#ifdef IN_RC
#endif
while (cTransfers)
{
if (rc != VINF_SUCCESS)
break;
if (rc != VINF_SUCCESS)
{
break;
}
pu8Virt += offIncrement;
Phys += offIncrement;
cTransfers--;
}
#ifdef IN_RC
#endif
}
/* Update ecx on exit. */
}
/* work statistics. */
if (rc == VINF_SUCCESS)
return rc;
}
#endif /* IOM_WITH_MOVS_SUPPORT */
/**
* Gets the address / opcode mask corresponding to the given CPU mode.
*
* @returns Mask.
* @param enmCpuMode CPU mode.
*/
{
switch (enmCpuMode)
{
case CPUMODE_16BIT: return UINT16_MAX;
case CPUMODE_32BIT: return UINT32_MAX;
case CPUMODE_64BIT: return UINT64_MAX;
default:
}
}
/**
* [REP] STOSB
* [REP] STOSW
* [REP] STOSD
*
* Restricted implementation.
*
*
* @returns VBox status code.
*
* @param pVM The virtual machine.
* @param pRegFrame Trap register frame.
* @param GCPhysFault The GC physical address corresponding to pvFault.
* @param pCpu Disassembler CPU state.
* @param pRange Pointer MMIO range.
*/
static int iomInterpretSTOS(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, PDISCPUSTATE pCpu, PIOMMMIORANGE pRange)
{
/*
* We do not support segment prefixes or REPNE..
*/
return VINF_IOM_R3_MMIO_READ_WRITE; /** @todo -> REM instead of HC */
/*
*/
{
#ifndef IN_RC
return VINF_EM_RAW_EMULATE_INSTR;
#endif
if (!cTransfers)
return VINF_SUCCESS;
}
/** @todo r=bird: bounds checks! */
/*
* Get data size.
*/
#ifdef VBOX_WITH_STATISTICS
#endif
int rc;
{
/*
* Use the fill callback.
*/
/** @todo pfnFillCallback must return number of bytes successfully written!!! */
if (offIncrement > 0)
{
/* addr++ variant. */
if (rc == VINF_SUCCESS)
{
/* Update registers. */
}
}
else
{
/* addr-- variant. */
if (rc == VINF_SUCCESS)
{
/* Update registers. */
}
}
}
else
{
/*
* Use the write callback.
*/
/* fill loop. */
do
{
if (rc != VINF_SUCCESS)
break;
Phys += offIncrement;
cTransfers--;
} while (cTransfers);
/* Update rcx on exit. */
}
/*
* Work statistics and return.
*/
if (rc == VINF_SUCCESS)
return rc;
}
/**
* [REP] LODSB
* [REP] LODSW
* [REP] LODSD
*
* Restricted implementation.
*
*
* @returns VBox status code.
*
* @param pVM The virtual machine.
* @param pRegFrame Trap register frame.
* @param GCPhysFault The GC physical address corresponding to pvFault.
* @param pCpu Disassembler CPU state.
* @param pRange Pointer MMIO range.
*/
static int iomInterpretLODS(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, PDISCPUSTATE pCpu, PIOMMMIORANGE pRange)
{
/*
* We do not support segment prefixes or REP*.
*/
return VINF_IOM_R3_MMIO_READ_WRITE; /** @todo -> REM instead of HC */
/*
* Get data size.
*/
/*
* Perform read.
*/
if (rc == VINF_SUCCESS)
{
}
/*
* Work statistics and return.
*/
if (rc == VINF_SUCCESS)
return rc;
}
/**
* CMP [MMIO], reg|imm
* CMP reg|imm, [MMIO]
*
* Restricted implementation.
*
*
* @returns VBox status code.
*
* @param pVM The virtual machine.
* @param pRegFrame Trap register frame.
* @param GCPhysFault The GC physical address corresponding to pvFault.
* @param pCpu Disassembler CPU state.
* @param pRange Pointer MMIO range.
*/
static int iomInterpretCMP(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, PDISCPUSTATE pCpu, PIOMMMIORANGE pRange)
{
/*
* Get the operands.
*/
unsigned cb = 0;
int rc;
/* cmp reg, [MMIO]. */
/* cmp [MMIO], reg|imm. */
else
{
AssertMsgFailed(("Disassember CMP problem..\n"));
}
if (rc == VINF_SUCCESS)
{
#if HC_ARCH_BITS == 32
/* Can't deal with 8 byte operands in our 32-bit emulation code. */
if (cb > 4)
return VINF_IOM_R3_MMIO_READ_WRITE;
#endif
/* Emulate CMP and update guest flags. */
pRegFrame->eflags.u32 = (pRegFrame->eflags.u32 & ~(X86_EFL_CF | X86_EFL_PF | X86_EFL_AF | X86_EFL_ZF | X86_EFL_SF | X86_EFL_OF))
}
return rc;
}
/**
* AND [MMIO], reg|imm
* AND reg, [MMIO]
* OR [MMIO], reg|imm
* OR reg, [MMIO]
*
* Restricted implementation.
*
*
* @returns VBox status code.
*
* @param pVM The virtual machine.
* @param pRegFrame Trap register frame.
* @param GCPhysFault The GC physical address corresponding to pvFault.
* @param pCpu Disassembler CPU state.
* @param pRange Pointer MMIO range.
* @param pfnEmulate Instruction emulation function.
*/
static int iomInterpretOrXorAnd(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, PDISCPUSTATE pCpu, PIOMMMIORANGE pRange, PFNEMULATEPARAM3 pfnEmulate)
{
unsigned cb = 0;
bool fAndWrite;
int rc;
#ifdef LOG_ENABLED
const char *pszInstr;
pszInstr = "Xor";
pszInstr = "Or";
pszInstr = "And";
else
pszInstr = "OrXorAnd??";
#endif
{
#if HC_ARCH_BITS == 32
/* Can't deal with 8 byte operands in our 32-bit emulation code. */
if (cb > 4)
return VINF_IOM_R3_MMIO_READ_WRITE;
#endif
/* and reg, [MMIO]. */
fAndWrite = false;
}
{
#if HC_ARCH_BITS == 32
/* Can't deal with 8 byte operands in our 32-bit emulation code. */
if (cb > 4)
return VINF_IOM_R3_MMIO_READ_WRITE;
#endif
/* and [MMIO], reg|imm. */
fAndWrite = true;
else
}
else
{
AssertMsgFailed(("Disassember AND problem..\n"));
}
if (rc == VINF_SUCCESS)
{
/* Emulate AND and update guest flags. */
if (fAndWrite)
/* Store result to MMIO. */
else
{
/* Store result to register. */
}
if (rc == VINF_SUCCESS)
{
/* Update guest's eflags and finish. */
pRegFrame->eflags.u32 = (pRegFrame->eflags.u32 & ~(X86_EFL_CF | X86_EFL_PF | X86_EFL_AF | X86_EFL_ZF | X86_EFL_SF | X86_EFL_OF))
}
}
return rc;
}
/**
* TEST [MMIO], reg|imm
* TEST reg, [MMIO]
*
* Restricted implementation.
*
*
* @returns VBox status code.
*
* @param pVM The virtual machine.
* @param pRegFrame Trap register frame.
* @param GCPhysFault The GC physical address corresponding to pvFault.
* @param pCpu Disassembler CPU state.
* @param pRange Pointer MMIO range.
*/
static int iomInterpretTEST(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, PDISCPUSTATE pCpu, PIOMMMIORANGE pRange)
{
unsigned cb = 0;
int rc;
{
/* and test, [MMIO]. */
}
{
/* test [MMIO], reg|imm. */
}
else
{
AssertMsgFailed(("Disassember TEST problem..\n"));
}
if (rc == VINF_SUCCESS)
{
#if HC_ARCH_BITS == 32
/* Can't deal with 8 byte operands in our 32-bit emulation code. */
if (cb > 4)
return VINF_IOM_R3_MMIO_READ_WRITE;
#endif
/* Emulate TEST (=AND without write back) and update guest EFLAGS. */
pRegFrame->eflags.u32 = (pRegFrame->eflags.u32 & ~(X86_EFL_CF | X86_EFL_PF | X86_EFL_AF | X86_EFL_ZF | X86_EFL_SF | X86_EFL_OF))
}
return rc;
}
/**
* BT [MMIO], reg|imm
*
* Restricted implementation.
*
*
* @returns VBox status code.
*
* @param pVM The virtual machine.
* @param pRegFrame Trap register frame.
* @param GCPhysFault The GC physical address corresponding to pvFault.
* @param pCpu Disassembler CPU state.
* @param pRange Pointer MMIO range.
*/
static int iomInterpretBT(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, PDISCPUSTATE pCpu, PIOMMMIORANGE pRange)
{
unsigned cbIgnored;
{
AssertMsgFailed(("Disassember BT problem..\n"));
}
/* The size of the memory operand only matters here. */
/* bt [MMIO], reg|imm. */
if (rc == VINF_SUCCESS)
{
/* Find the bit inside the faulting address */
}
return rc;
}
/**
* XCHG [MMIO], reg
* XCHG reg, [MMIO]
*
* Restricted implementation.
*
*
* @returns VBox status code.
*
* @param pVM The virtual machine.
* @param pRegFrame Trap register frame.
* @param GCPhysFault The GC physical address corresponding to pvFault.
* @param pCpu Disassembler CPU state.
* @param pRange Pointer MMIO range.
*/
static int iomInterpretXCHG(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, PDISCPUSTATE pCpu, PIOMMMIORANGE pRange)
{
/* Check for read & write handlers since IOMMMIOHandler doesn't cover this. */
return VINF_IOM_R3_MMIO_READ_WRITE;
int rc;
unsigned cb = 0;
{
/* xchg reg, [MMIO]. */
if (rc == VINF_SUCCESS)
{
/* Store result to MMIO. */
if (rc == VINF_SUCCESS)
{
/* Store result to register. */
}
else
}
else
}
{
/* xchg [MMIO], reg. */
if (rc == VINF_SUCCESS)
{
/* Store result to MMIO. */
if (rc == VINF_SUCCESS)
{
/* Store result to register. */
}
else
AssertMsg(rc == VINF_IOM_R3_MMIO_READ_WRITE || rc == VINF_IOM_R3_MMIO_WRITE || rc == VINF_PATM_HC_MMIO_PATCH_WRITE, ("rc=%Rrc\n", rc));
}
else
AssertMsg(rc == VINF_IOM_R3_MMIO_READ_WRITE || rc == VINF_IOM_R3_MMIO_READ || rc == VINF_PATM_HC_MMIO_PATCH_READ, ("rc=%Rrc\n", rc));
}
else
{
AssertMsgFailed(("Disassember XCHG problem..\n"));
}
return rc;
}
/**
* \#PF Handler callback for MMIO ranges.
*
* @returns VBox status code (appropriate for GC return).
* @param pVM VM Handle.
* @param uErrorCode CPU Error code. This is UINT32_MAX when we don't have
* any error code (the EPT misconfig hack).
* @param pCtxCore Trap register frame.
* @param GCPhysFault The GC physical address corresponding to pvFault.
* @param pvUser Pointer to the MMIO ring-3 range entry.
*/
static int iomMMIOHandler(PVM pVM, uint32_t uErrorCode, PCPUMCTXCORE pCtxCore, RTGCPHYS GCPhysFault, void *pvUser)
{
/* Take the IOM lock before performing any MMIO. */
#ifndef IN_RING3
if (rc == VERR_SEM_BUSY)
return VINF_IOM_R3_MMIO_READ_WRITE;
#endif
Log(("iomMMIOHandler: GCPhys=%RGp uErr=%#x rip=%RGv\n",
#ifdef VBOX_WITH_STATISTICS
/*
* Locate the statistics, if > PAGE_SIZE we'll use the first byte for everything.
*/
if (!pStats)
{
# ifdef IN_RING3
return VERR_NO_MEMORY;
# else
return VINF_IOM_R3_MMIO_READ_WRITE;
# endif
}
#endif
#ifndef IN_RING3
/*
* Should we defer the request right away? This isn't usually the case, so
* do the simple test first and the try deal with uErrorCode being N/A.
*/
&& ( uErrorCode == UINT32_MAX
)
)
)
{
if (uErrorCode & X86_TRAP_PF_RW)
else
return VINF_IOM_R3_MMIO_READ_WRITE;
}
#endif /* !IN_RING3 */
/*
* Retain the range and do locking.
*/
if (rc != VINF_SUCCESS)
{
return rc;
}
/*
* Disassemble the instruction and interpret it.
*/
unsigned cbOp;
if (RT_FAILURE(rc))
{
return rc;
}
{
case OP_MOV:
case OP_MOVZX:
case OP_MOVSX:
{
AssertMsg(uErrorCode == UINT32_MAX || DIS_IS_EFFECTIVE_ADDR(pDis->param1.flags) == !!(uErrorCode & X86_TRAP_PF_RW), ("flags1=%#llx/%RTbool flags2=%#llx/%RTbool ErrCd=%#x\n", pDis->param1.flags, DIS_IS_EFFECTIVE_ADDR(pDis->param1.flags), pDis->param2.flags, DIS_IS_EFFECTIVE_ADDR(pDis->param2.flags), uErrorCode));
else
break;
}
#ifdef IOM_WITH_MOVS_SUPPORT
case OP_MOVSB:
case OP_MOVSWD:
{
if (uErrorCode == UINT32_MAX)
else
{
rc = iomInterpretMOVS(pVM, !!(uErrorCode & X86_TRAP_PF_RW), pCtxCore, GCPhysFault, pDis, pRange, &pStat);
}
break;
}
#endif
case OP_STOSB:
case OP_STOSWD:
break;
case OP_LODSB:
case OP_LODSWD:
break;
case OP_CMP:
break;
case OP_AND:
break;
case OP_OR:
break;
case OP_XOR:
break;
case OP_TEST:
break;
case OP_BT:
break;
case OP_XCHG:
break;
/*
* The instruction isn't supported. Hand it on to ring-3.
*/
default:
break;
}
/*
* On success advance EIP.
*/
if (rc == VINF_SUCCESS)
else
{
#if defined(VBOX_WITH_STATISTICS) && !defined(IN_RING3)
switch (rc)
{
case VINF_IOM_R3_MMIO_READ:
break;
case VINF_IOM_R3_MMIO_WRITE:
break;
}
#endif
}
return rc;
}
/**
* \#PF Handler callback for MMIO ranges.
*
* @returns VBox status code (appropriate for GC return).
* @param pVM VM Handle.
* @param uErrorCode CPU Error code.
* @param pCtxCore Trap register frame.
* @param pvFault The fault address (cr2).
* @param GCPhysFault The GC physical address corresponding to pvFault.
* @param pvUser Pointer to the MMIO ring-3 range entry.
*/
VMMDECL(int) IOMMMIOHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pCtxCore, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser)
{
LogFlow(("IOMMMIOHandler: GCPhys=%RGp uErr=%#x pvFault=%RGv rip=%RGv\n",
return VBOXSTRICTRC_VAL(rcStrict);
}
/**
* Physical access handler for MMIO ranges.
*
* @returns VBox status code (appropriate for GC return).
* @param pVM VM Handle.
* @param uErrorCode CPU Error code.
* @param pCtxCore Trap register frame.
* @param GCPhysFault The GC physical address.
*/
VMMDECL(VBOXSTRICTRC) IOMMMIOPhysHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pCtxCore, RTGCPHYS GCPhysFault)
{
#ifndef IN_RING3
if (rc2 == VERR_SEM_BUSY)
return VINF_IOM_R3_MMIO_READ_WRITE;
#endif
VBOXSTRICTRC rcStrict = iomMMIOHandler(pVM, (uint32_t)uErrorCode, pCtxCore, GCPhysFault, iomMmioGetRange(pVM, GCPhysFault));
return VBOXSTRICTRC_VAL(rcStrict);
}
#ifdef IN_RING3
/**
* \#PF Handler callback for MMIO ranges.
*
* @returns VINF_SUCCESS if the handler have carried out the operation.
* @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
* @param pVM VM Handle.
* @param GCPhys The physical address the guest is writing to.
* @param pvPhys The HC mapping of that address.
* @param enmAccessType The access type.
* @param pvUser Pointer to the MMIO range entry.
*/
DECLCALLBACK(int) IOMR3MMIOHandler(PVM pVM, RTGCPHYS GCPhysFault, void *pvPhys, void *pvBuf, size_t cbBuf,
{
/*
* Validate the range.
*/
/*
* Perform locking.
*/
if (rc != VINF_SUCCESS)
{
return rc;
}
/*
* Perform the access.
*/
if (enmAccessType == PGMACCESSTYPE_READ)
else
return rc;
}
#endif /* IN_RING3 */
/**
* Reads a MMIO register.
*
* @returns VBox status code.
*
* @param pVM VM handle.
* @param GCPhys The physical address to read.
* @param pu32Value Where to store the value read.
* @param cbValue The size of the register to read in bytes. 1, 2 or 4 bytes.
*/
{
/* Take the IOM lock before performing any MMIO. */
#ifndef IN_RING3
if (rc == VERR_SEM_BUSY)
return VINF_IOM_R3_MMIO_WRITE;
#endif
#if defined(IEM_VERIFICATION_MODE) && defined(IN_RING3)
#endif
/*
* Lookup the current context range node and statistics.
*/
if (!pRange)
{
AssertMsgFailed(("Handlers and page tables are out of sync or something! GCPhys=%RGp cbValue=%d\n", GCPhys, cbValue));
return VERR_IOM_MMIO_RANGE_NOT_FOUND;
}
#ifdef VBOX_WITH_STATISTICS
if (!pStats)
{
# ifdef IN_RING3
return VERR_NO_MEMORY;
# else
return VINF_IOM_R3_MMIO_READ;
# endif
}
#endif /* VBOX_WITH_STATISTICS */
{
/*
* Perform locking.
*/
if (rc != VINF_SUCCESS)
{
return rc;
}
/*
* Perform the read and deal with the result.
*/
else
switch (VBOXSTRICTRC_VAL(rc))
{
case VINF_SUCCESS:
Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=VINF_SUCCESS\n", GCPhys, *pu32Value, cbValue));
return rc;
#ifndef IN_RING3
case VINF_IOM_R3_MMIO_READ:
#endif
default:
Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, *pu32Value, cbValue, VBOXSTRICTRC_VAL(rc)));
return rc;
case VINF_IOM_MMIO_UNUSED_00:
Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, *pu32Value, cbValue, VBOXSTRICTRC_VAL(rc)));
return VINF_SUCCESS;
case VINF_IOM_MMIO_UNUSED_FF:
Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, *pu32Value, cbValue, VBOXSTRICTRC_VAL(rc)));
return VINF_SUCCESS;
}
/* not reached */
}
#ifndef IN_RING3
if (pRange->pfnReadCallbackR3)
{
return VINF_IOM_R3_MMIO_READ;
}
#endif
/*
* Unassigned memory - this is actually not supposed t happen...
*/
Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=VINF_SUCCESS\n", GCPhys, *pu32Value, cbValue));
return VINF_SUCCESS;
}
/**
* Writes to a MMIO register.
*
* @returns VBox status code.
*
* @param pVM VM handle.
* @param GCPhys The physical address to write to.
* @param u32Value The value to write.
* @param cbValue The size of the register to read in bytes. 1, 2 or 4 bytes.
*/
{
/* Take the IOM lock before performing any MMIO. */
#ifndef IN_RING3
if (rc == VERR_SEM_BUSY)
return VINF_IOM_R3_MMIO_WRITE;
#endif
#if defined(IEM_VERIFICATION_MODE) && defined(IN_RING3)
#endif
/*
* Lookup the current context range node.
*/
if (!pRange)
{
AssertMsgFailed(("Handlers and page tables are out of sync or something! GCPhys=%RGp cbValue=%d\n", GCPhys, cbValue));
return VERR_IOM_MMIO_RANGE_NOT_FOUND;
}
#ifdef VBOX_WITH_STATISTICS
if (!pStats)
{
# ifdef IN_RING3
return VERR_NO_MEMORY;
# else
return VINF_IOM_R3_MMIO_WRITE;
# endif
}
#endif /* VBOX_WITH_STATISTICS */
{
/*
* Perform locking.
*/
if (rc != VINF_SUCCESS)
{
return rc;
}
/*
* Perform the write.
*/
else
#ifndef IN_RING3
if ( rc == VINF_IOM_R3_MMIO_WRITE
|| rc == VINF_IOM_R3_MMIO_READ_WRITE)
#endif
Log4(("IOMMMIOWrite: GCPhys=%RGp u32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, u32Value, cbValue, VBOXSTRICTRC_VAL(rc)));
return rc;
}
#ifndef IN_RING3
if (pRange->pfnWriteCallbackR3)
{
return VINF_IOM_R3_MMIO_WRITE;
}
#endif
/*
* No write handler, nothing to do.
*/
Log4(("IOMMMIOWrite: GCPhys=%RGp u32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, u32Value, cbValue, VINF_SUCCESS));
return VINF_SUCCESS;
}
/**
* ES:EDI,DX[,ECX]
*
* @remark Assumes caller checked the access privileges (IOMInterpretCheckPortIOAccess)
*
* @returns Strict VBox status code. Informational status codes other than the one documented
* here are to be treated as internal failure. Use IOM_SUCCESS() to check for success.
* @retval VINF_SUCCESS Success.
* @retval VINF_EM_FIRST-VINF_EM_LAST Success with some exceptions (see IOM_SUCCESS()), the
* status code must be passed on to EM.
* @retval VINF_EM_RAW_EMULATE_INSTR Defer the read to the REM.
* @retval VINF_EM_RAW_GUEST_TRAP The exception was left pending. (TRPMRaiseXcptErr)
* @retval VINF_TRPM_XCPT_DISPATCHED The exception was raised and dispatched for raw-mode execution. (TRPMRaiseXcptErr)
* @retval VINF_EM_RESCHEDULE_REM The exception was dispatched and cannot be executed in raw-mode. (TRPMRaiseXcptErr)
*
* @param pVM The virtual machine.
* @param pRegFrame Pointer to CPUMCTXCORE guest registers structure.
* @param uPort IO Port
* @param uPrefix IO instruction prefix
* @param enmAddrMode The address mode.
* @param cbTransfer Size of transfer unit
*/
VMMDECL(VBOXSTRICTRC) IOMInterpretINSEx(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t uPort, uint32_t uPrefix,
{
/*
* We do not support REPNE or decrementing destination
* pointer. Segment prefixes are deliberately ignored, as per the instruction specification.
*/
if ( (uPrefix & PREFIX_REPNE)
return VINF_EM_RAW_EMULATE_INSTR;
/*
*/
if (uPrefix & PREFIX_REP)
{
#ifndef IN_RC
return VINF_EM_RAW_EMULATE_INSTR;
#endif
if (!cTransfers)
return VINF_SUCCESS;
}
/* Convert destination address es:edi. */
&GCPtrDst);
if (RT_FAILURE(rc2))
{
return VINF_EM_RAW_EMULATE_INSTR;
}
/* Access verification first; we can't recover from traps inside this instruction, as the port read cannot be repeated. */
if (rc2 != VINF_SUCCESS)
{
return VINF_EM_RAW_EMULATE_INSTR;
}
if (cTransfers > 1)
{
/* If the device supports string transfers, ask it to do as
* much as it wants. The rest is done with single-word transfers. */
}
#ifdef IN_RC
#endif
{
if (!IOM_SUCCESS(rcStrict))
break;
cTransfers--;
}
#ifdef IN_RC
#endif
/* Update rcx on exit. */
if (uPrefix & PREFIX_REP)
AssertMsg(rcStrict == VINF_SUCCESS || rcStrict == VINF_IOM_R3_IOPORT_READ || (rcStrict >= VINF_EM_FIRST && rcStrict <= VINF_EM_LAST) || RT_FAILURE(rcStrict), ("%Rrc\n", VBOXSTRICTRC_VAL(rcStrict)));
return rcStrict;
}
/**
* ES:EDI,DX[,ECX]
*
* @returns Strict VBox status code. Informational status codes other than the one documented
* here are to be treated as internal failure. Use IOM_SUCCESS() to check for success.
* @retval VINF_SUCCESS Success.
* @retval VINF_EM_FIRST-VINF_EM_LAST Success with some exceptions (see IOM_SUCCESS()), the
* status code must be passed on to EM.
* @retval VINF_EM_RAW_EMULATE_INSTR Defer the read to the REM.
* @retval VINF_EM_RAW_GUEST_TRAP The exception was left pending. (TRPMRaiseXcptErr)
* @retval VINF_TRPM_XCPT_DISPATCHED The exception was raised and dispatched for raw-mode execution. (TRPMRaiseXcptErr)
* @retval VINF_EM_RESCHEDULE_REM The exception was dispatched and cannot be executed in raw-mode. (TRPMRaiseXcptErr)
*
* @param pVM The virtual machine.
* @param pRegFrame Pointer to CPUMCTXCORE guest registers structure.
* @param pCpu Disassembler CPU state.
*/
{
/*
* Get port number directly from the register (no need to bother the
* disassembler). And get the I/O register size from the opcode / prefix.
*/
unsigned cb = 0;
cb = 1;
else
{
AssertMsg(rcStrict == VINF_EM_RAW_GUEST_TRAP || rcStrict == VINF_TRPM_XCPT_DISPATCHED || rcStrict == VINF_TRPM_XCPT_DISPATCHED || RT_FAILURE(rcStrict), ("%Rrc\n", VBOXSTRICTRC_VAL(rcStrict)));
return rcStrict;
}
}
/**
* DS:ESI,DX[,ECX]
*
* @remark Assumes caller checked the access privileges (IOMInterpretCheckPortIOAccess)
*
* @returns Strict VBox status code. Informational status codes other than the one documented
* here are to be treated as internal failure. Use IOM_SUCCESS() to check for success.
* @retval VINF_SUCCESS Success.
* @retval VINF_EM_FIRST-VINF_EM_LAST Success with some exceptions (see IOM_SUCCESS()), the
* status code must be passed on to EM.
* @retval VINF_EM_RAW_GUEST_TRAP The exception was left pending. (TRPMRaiseXcptErr)
* @retval VINF_TRPM_XCPT_DISPATCHED The exception was raised and dispatched for raw-mode execution. (TRPMRaiseXcptErr)
* @retval VINF_EM_RESCHEDULE_REM The exception was dispatched and cannot be executed in raw-mode. (TRPMRaiseXcptErr)
*
* @param pVM The virtual machine.
* @param pRegFrame Pointer to CPUMCTXCORE guest registers structure.
* @param uPort IO Port
* @param uPrefix IO instruction prefix
* @param enmAddrMode The address mode.
* @param cbTransfer Size of transfer unit
*/
VMMDECL(VBOXSTRICTRC) IOMInterpretOUTSEx(PVM pVM, PCPUMCTXCORE pRegFrame, uint32_t uPort, uint32_t uPrefix,
{
/*
* We do not support segment prefixes, REPNE or
* decrementing source pointer.
*/
return VINF_EM_RAW_EMULATE_INSTR;
/*
*/
if (uPrefix & PREFIX_REP)
{
#ifndef IN_RC
return VINF_EM_RAW_EMULATE_INSTR;
#endif
if (!cTransfers)
return VINF_SUCCESS;
}
/* Convert source address ds:esi. */
&GCPtrSrc);
if (RT_FAILURE(rc2))
{
return VINF_EM_RAW_EMULATE_INSTR;
}
/* Access verification first; we currently can't recover properly from traps inside this instruction */
if (rc2 != VINF_SUCCESS)
{
return VINF_EM_RAW_EMULATE_INSTR;
}
if (cTransfers > 1)
{
/*
* If the device supports string transfers, ask it to do as
* much as it wants. The rest is done with single-word transfers.
*/
}
#ifdef IN_RC
#endif
{
if (rcStrict != VINF_SUCCESS)
break;
if (!IOM_SUCCESS(rcStrict))
break;
cTransfers--;
}
#ifdef IN_RC
#endif
/* Update rcx on exit. */
if (uPrefix & PREFIX_REP)
AssertMsg(rcStrict == VINF_SUCCESS || rcStrict == VINF_IOM_R3_IOPORT_WRITE || (rcStrict >= VINF_EM_FIRST && rcStrict <= VINF_EM_LAST) || RT_FAILURE(rcStrict), ("%Rrc\n", VBOXSTRICTRC_VAL(rcStrict)));
return rcStrict;
}
/**
* DS:ESI,DX[,ECX]
*
* @returns Strict VBox status code. Informational status codes other than the one documented
* here are to be treated as internal failure. Use IOM_SUCCESS() to check for success.
* @retval VINF_SUCCESS Success.
* @retval VINF_EM_FIRST-VINF_EM_LAST Success with some exceptions (see IOM_SUCCESS()), the
* status code must be passed on to EM.
* @retval VINF_EM_RAW_EMULATE_INSTR Defer the write to the REM.
* @retval VINF_EM_RAW_GUEST_TRAP The exception was left pending. (TRPMRaiseXcptErr)
* @retval VINF_TRPM_XCPT_DISPATCHED The exception was raised and dispatched for raw-mode execution. (TRPMRaiseXcptErr)
* @retval VINF_EM_RESCHEDULE_REM The exception was dispatched and cannot be executed in raw-mode. (TRPMRaiseXcptErr)
*
* @param pVM The virtual machine.
* @param pRegFrame Pointer to CPUMCTXCORE guest registers structure.
* @param pCpu Disassembler CPU state.
*/
{
/*
* Get port number from the first parameter.
* And get the I/O register size from the opcode / prefix.
*/
unsigned cb = 0;
cb = 1;
else
{
AssertMsg(rcStrict == VINF_EM_RAW_GUEST_TRAP || rcStrict == VINF_TRPM_XCPT_DISPATCHED || rcStrict == VINF_TRPM_XCPT_DISPATCHED || RT_FAILURE(rcStrict), ("%Rrc\n", VBOXSTRICTRC_VAL(rcStrict)));
return rcStrict;
}
}
#ifndef IN_RC
/**
* Mapping an MMIO2 page in place of an MMIO page for direct access.
*
* (This is a special optimization used by the VGA device.)
*
* @returns VBox status code. This API may return VINF_SUCCESS even if no
* remapping is made,.
*
* @param pVM The virtual machine.
* @param GCPhys The address of the MMIO page to be changed.
* @param GCPhysRemapped The address of the MMIO2 page.
* @param fPageFlags Page flags to set. Must be (X86_PTE_RW | X86_PTE_P)
* for the time being.
*/
VMMDECL(int) IOMMMIOMapMMIO2Page(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysRemapped, uint64_t fPageFlags)
{
/* Currently only called from the VGA device during MMIO. */
/* This currently only works in real mode, protected mode without paging or with nested paging. */
&& !HWACCMIsNestedPagingActive(pVM)))
return VINF_SUCCESS; /* ignore */
if (RT_FAILURE(rc))
return VINF_SUCCESS; /* better luck the next time around */
/*
* Lookup the context range node the page belongs to.
*/
("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys), VERR_IOM_MMIO_RANGE_NOT_FOUND);
/*
* Do the aliasing; page align the addresses since PGM is picky.
*/
/*
* Modify the shadow page table. Since it's an MMIO page it won't be present and we
* can simply prefetch it.
*
* Note: This is a NOP in the EPT case; we'll just let it fault again to resync the page.
*/
#if 0 /* The assertion is wrong for the PGM_SYNC_CLEAR_PGM_POOL and VINF_PGM_HANDLER_ALREADY_ALIASED cases. */
# ifdef VBOX_STRICT
# endif
#endif
return VINF_SUCCESS;
}
/**
* Mapping a HC page in place of an MMIO page for direct access.
*
* (This is a special optimization used by the APIC in the VT-x case.)
*
* @returns VBox status code.
*
* @param pVM The virtual machine.
* @param GCPhys The address of the MMIO page to be changed.
* @param HCPhys The address of the host physical page.
* @param fPageFlags Page flags to set. Must be (X86_PTE_RW | X86_PTE_P)
* for the time being.
*/
{
/* Currently only called from VT-x code during a page fault. */
/*
* Lookup the context range node the page belongs to.
*/
#ifdef VBOX_STRICT
/* Can't lock IOM here due to potential deadlocks in the VGA device; not safe to access. */
("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys), VERR_IOM_MMIO_RANGE_NOT_FOUND);
#endif
/*
* Do the aliasing; page align the addresses since PGM is picky.
*/
/*
* Modify the shadow page table. Since it's an MMIO page it won't be present and we
* can simply prefetch it.
*
* Note: This is a NOP in the EPT case; we'll just let it fault again to resync the page.
*/
return VINF_SUCCESS;
}
/**
* Reset a previously modified MMIO region; restore the access flags.
*
* @returns VBox status code.
*
* @param pVM The virtual machine.
* @param GCPhys Physical address that's part of the MMIO region to be reset.
*/
{
/* This currently only works in real mode, protected mode without paging or with nested paging. */
&& !HWACCMIsNestedPagingActive(pVM)))
return VINF_SUCCESS; /* ignore */
/*
* Lookup the context range node the page belongs to.
*/
#ifdef VBOX_STRICT
/* Can't lock IOM here due to potential deadlocks in the VGA device; not safe to access. */
("Handlers and page tables are out of sync or something! GCPhys=%RGp\n", GCPhys), VERR_IOM_MMIO_RANGE_NOT_FOUND);
#endif
/*
* Call PGM to do the job work.
*
* After the call, all the pages should be non-present... unless there is
* a page pool flush pending (unlikely).
*/
#ifdef VBOX_STRICT
{
while (cb)
{
}
}
#endif
return rc;
}
#endif /* !IN_RC */