VirtualBox

Changeset 100826 in vbox for trunk/src/VBox/VMM/include


Ignore:
Timestamp:
Aug 9, 2023 1:57:40 AM (20 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
158725
Message:

VMM/IEM: Started refactoring IEM_MC_MEM_MAP into type and access specific variant so we can more efficiently apply inlined code using the TLB. Converted a bunch of 8-bit accesses in the one-byte opcode map. bugref:10369

Location:
trunk/src/VBox/VMM/include
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/include/IEMInline.h

    r100822 r100826  
    34453445
    34463446#define TMPL_MEM_NO_STORE
     3447#define TMPL_MEM_NO_MAPPING
    34473448#define TMPL_MEM_TYPE       uint64_t
    34483449#define TMPL_MEM_TYPE_ALIGN 15
  • trunk/src/VBox/VMM/include/IEMInternal.h

    r100822 r100826  
    18091809/** @}  */
    18101810
     1811typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINROU8,(uint8_t const *pu8Dst, uint8_t u8Src, uint32_t *pEFlags));
     1812typedef FNIEMAIMPLBINROU8 *PFNIEMAIMPLBINROU8;
     1813typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINROU16,(uint16_t const *pu16Dst, uint16_t u16Src, uint32_t *pEFlags));
     1814typedef FNIEMAIMPLBINROU16 *PFNIEMAIMPLBINROU16;
     1815typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINROU32,(uint32_t const *pu32Dst, uint32_t u32Src, uint32_t *pEFlags));
     1816typedef FNIEMAIMPLBINROU32 *PFNIEMAIMPLBINROU32;
     1817typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINROU64,(uint64_t const *pu64Dst, uint64_t u64Src, uint32_t *pEFlags));
     1818typedef FNIEMAIMPLBINROU64 *PFNIEMAIMPLBINROU64;
     1819
    18111820/** @name Compare operations (thrown in with the binary ops).
    18121821 * @{ */
    1813 FNIEMAIMPLBINU8  iemAImpl_cmp_u8;
     1822FNIEMAIMPLBINROU8  iemAImpl_cmp_u8;
    18141823FNIEMAIMPLBINU16 iemAImpl_cmp_u16;
    18151824FNIEMAIMPLBINU32 iemAImpl_cmp_u32;
     
    18191828/** @name Test operations (thrown in with the binary ops).
    18201829 * @{ */
    1821 FNIEMAIMPLBINU8  iemAImpl_test_u8;
     1830FNIEMAIMPLBINROU8  iemAImpl_test_u8;
    18221831FNIEMAIMPLBINU16 iemAImpl_test_u16;
    18231832FNIEMAIMPLBINU32 iemAImpl_test_u32;
     
    46514660void            iemMemStoreDataU256Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
    46524661void            iemMemStoreDataU256AlignedAvxJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
     4662#endif
     4663
     4664#ifdef IEM_WITH_SETJMP
     4665uint8_t        *iemMemMapDataU8RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
     4666uint8_t        *iemMemMapDataU8WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
     4667uint8_t const  *iemMemMapDataU8RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
     4668uint16_t       *iemMemMapDataU16RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
     4669uint16_t       *iemMemMapDataU16WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
     4670uint16_t const *iemMemMapDataU16RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
     4671uint32_t       *iemMemMapDataU32RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
     4672uint32_t       *iemMemMapDataU32WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
     4673uint32_t const *iemMemMapDataU32RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
     4674uint64_t       *iemMemMapDataU64RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
     4675uint64_t       *iemMemMapDataU64WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
     4676uint64_t const *iemMemMapDataU64RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
    46534677#endif
    46544678
  • trunk/src/VBox/VMM/include/IEMMc.h

    r100820 r100826  
    13251325 * The purpose is to pass it to an operand implementation, thus the a_iArg.
    13261326 * @remarks     May return.
     1327 * @deprecated
    13271328 */
    13281329#define IEM_MC_MEM_MAP(a_pMem, a_fAccess, a_iSeg, a_GCPtrMem, a_iArg) \
     
    13301331                                       (a_GCPtrMem), (a_fAccess), sizeof(*(a_pMem)) - 1))
    13311332
    1332 /** Flat variant of IEM_MC_MEM_MAP. */
     1333/** Flat variant of IEM_MC_MEM_MAP.
     1334 * @deprecated
     1335 */
    13331336#define IEM_MC_MEM_FLAT_MAP(a_pMem, a_fAccess, a_GCPtrMem, a_iArg) \
    13341337    IEM_MC_RETURN_ON_FAILURE(iemMemMap(pVCpu, (void **)&(a_pMem), sizeof(*(a_pMem)), UINT8_MAX, \
     
    13381341 * The purpose is to pass it to an operand implementation, thus the a_iArg.
    13391342 * @remarks     May return.
     1343 * @deprecated
    13401344 */
    13411345#define IEM_MC_MEM_MAP_EX(a_pvMem, a_fAccess, a_cbMem, a_iSeg, a_GCPtrMem, a_cbAlign, a_iArg) \
     
    13431347                                       (a_GCPtrMem), (a_fAccess), (a_cbAlign)))
    13441348
    1345 /** Flat variant of IEM_MC_MEM_MAP_EX. */
     1349/** Flat variant of IEM_MC_MEM_MAP_EX.
     1350 * @deprecated
     1351 */
    13461352#define IEM_MC_MEM_FLAT_MAP_EX(a_pvMem, a_fAccess, a_cbMem, a_GCPtrMem, a_cbAlign, a_iArg) \
    13471353    IEM_MC_RETURN_ON_FAILURE(iemMemMap(pVCpu, (void **)&(a_pvMem), (a_cbMem), UINT8_MAX, \
     
    13501356/** Commits the memory and unmaps the guest memory.
    13511357 * @remarks     May return.
     1358 * @deprecated
    13521359 */
    13531360#define IEM_MC_MEM_COMMIT_AND_UNMAP(a_pvMem, a_fAccess) \
    13541361    IEM_MC_RETURN_ON_FAILURE(iemMemCommitAndUnmap(pVCpu, (a_pvMem), (a_fAccess)))
     1362
     1363
     1364/**
     1365 * Maps guest memory for byte read+write direct (or bounce) buffer acccess.
     1366 *
     1367 * @param[out] a_pu8Mem     Where to return the pointer to the mapping.
     1368 * @param[out] a_bUnmapInfo Where to return umapping instructions. uint8_t.
     1369 * @param[in]  a_iSeg       The segment register to access via. No UINT8_MAX!
     1370 * @param[in]  a_GCPtrMem   The memory address.
     1371 * @remarks Will return/long jump on errors.
     1372 * @see     IEM_MC_MEM_COMMIT_AND_UNMAP_RW
     1373 */
     1374#ifndef IEM_WITH_SETJMP
     1375# define IEM_MC_MEM_MAP_U8_RW(a_pu8Mem, a_bUnmapInfo, a_iSeg, a_GCPtrMem) do { \
     1376        IEM_MC_RETURN_ON_FAILURE(iemMemMap(pVCpu, (void **)&(a_pu8Mem), sizeof(uint8_t), (a_iSeg), \
     1377                                           (a_GCPtrMem), IEM_ACCESS_DATA_RW, 0)); \
     1378        a_bUnmapInfo = 1 | ((IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE) << 4); \
     1379    } while (0)
     1380#else
     1381# define IEM_MC_MEM_MAP_U8_RW(a_pu8Mem, a_bUnmapInfo, a_iSeg, a_GCPtrMem) \
     1382    (a_pu8Mem) = iemMemMapDataU8RwJmp(pVCpu, &(a_bUnmapInfo), (a_iSeg), (a_GCPtrMem))
     1383#endif
     1384
     1385/**
     1386 * Maps guest memory for byte writeonly direct (or bounce) buffer acccess.
     1387 *
     1388 * @param[out] a_pu8Mem     Where to return the pointer to the mapping.
     1389 * @param[out] a_bUnmapInfo Where to return umapping instructions. uint8_t.
     1390 * @param[in]  a_iSeg       The segment register to access via. No UINT8_MAX!
     1391 * @param[in]  a_GCPtrMem   The memory address.
     1392 * @remarks Will return/long jump on errors.
     1393 * @see     IEM_MC_MEM_COMMIT_AND_UNMAP_WO
     1394 */
     1395#ifndef IEM_WITH_SETJMP
     1396# define IEM_MC_MEM_MAP_U8_WO(a_pu8Mem, a_bUnmapInfo, a_iSeg, a_GCPtrMem) do { \
     1397        IEM_MC_RETURN_ON_FAILURE(iemMemMap(pVCpu, (void **)&(a_pu8Mem), sizeof(uint8_t), (a_iSeg), \
     1398                                           (a_GCPtrMem), IEM_ACCESS_DATA_W, 0)); \
     1399        a_bUnmapInfo = 1 | (IEM_ACCESS_TYPE_WRITE << 4); \
     1400    } while (0)
     1401#else
     1402# define IEM_MC_MEM_MAP_U8_WO(a_pu8Mem, a_bUnmapInfo, a_iSeg, a_GCPtrMem) \
     1403    (a_pu8Mem) = iemMemMapDataU8WoJmp(pVCpu, &(a_bUnmapInfo), (a_iSeg), (a_GCPtrMem))
     1404#endif
     1405
     1406/**
     1407 * Maps guest memory for byte readonly direct (or bounce) buffer acccess.
     1408 *
     1409 * @param[out] a_pu8Mem     Where to return the pointer to the mapping.
     1410 * @param[out] a_bUnmapInfo Where to return umapping instructions. uint8_t.
     1411 * @param[in]  a_iSeg       The segment register to access via. No UINT8_MAX!
     1412 * @param[in]  a_GCPtrMem   The memory address.
     1413 * @remarks Will return/long jump on errors.
     1414 * @see     IEM_MC_MEM_COMMIT_AND_UNMAP_RO
     1415 */
     1416#ifndef IEM_WITH_SETJMP
     1417# define IEM_MC_MEM_MAP_U8_RO(a_pu8Mem, a_bUnmapInfo, a_iSeg, a_GCPtrMem) do { \
     1418        IEM_MC_RETURN_ON_FAILURE(iemMemMap(pVCpu, (void **)&(a_pu8Mem), sizeof(uint8_t), (a_iSeg), \
     1419                                           (a_GCPtrMem), IEM_ACCESS_DATA_R, 0)); \
     1420        a_bUnmapInfo = 1 | (IEM_ACCESS_TYPE_READ << 4); \
     1421    } while (0)
     1422#else
     1423# define IEM_MC_MEM_MAP_U8_RO(a_pu8Mem, a_bUnmapInfo, a_iSeg, a_GCPtrMem) \
     1424    (a_pu8Mem) = iemMemMapDataU8RoJmp(pVCpu, &(a_bUnmapInfo), (a_iSeg), (a_GCPtrMem))
     1425#endif
     1426
     1427/**
     1428 * Maps guest memory for byte read+write direct (or bounce) buffer acccess, flat
     1429 * address variant.
     1430 *
     1431 * @param[out] a_pu8Mem     Where to return the pointer to the mapping.
     1432 * @param[out] a_bUnmapInfo Where to return umapping instructions. uint8_t.
     1433 * @param[in]  a_GCPtrMem   The memory address.
     1434 * @remarks Will return/long jump on errors.
     1435 * @see     IEM_MC_MEM_COMMIT_AND_UNMAP_RW
     1436 */
     1437#ifndef IEM_WITH_SETJMP
     1438# define IEM_MC_MEM_FLAT_MAP_U8_RW(a_pu8Mem, a_bUnmapInfo, a_GCPtrMem) do { \
     1439        IEM_MC_RETURN_ON_FAILURE(iemMemMap(pVCpu, (void **)&(a_pu8Mem), sizeof(uint8_t), UINT8_MAX, \
     1440                                           (a_GCPtrMem), IEM_ACCESS_DATA_RW, 0)); \
     1441        a_bUnmapInfo = 1 | ((IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE) << 4); \
     1442    } while (0)
     1443#else
     1444# define IEM_MC_MEM_FLAT_MAP_U8_RW(a_pu8Mem, a_bUnmapInfo, a_GCPtrMem) \
     1445    (a_pu8Mem) = iemMemFlatMapDataU8RwJmp(pVCpu, &(a_bUnmapInfo), (a_GCPtrMem))
     1446#endif
     1447
     1448/**
     1449 * Maps guest memory for byte writeonly direct (or bounce) buffer acccess, flat
     1450 * address variant.
     1451 *
     1452 * @param[out] a_pu8Mem     Where to return the pointer to the mapping.
     1453 * @param[out] a_bUnmapInfo Where to return umapping instructions. uint8_t.
     1454 * @param[in]  a_GCPtrMem   The memory address.
     1455 * @remarks Will return/long jump on errors.
     1456 * @see     IEM_MC_MEM_COMMIT_AND_UNMAP_WO
     1457 */
     1458#ifndef IEM_WITH_SETJMP
     1459# define IEM_MC_MEM_FLAT_MAP_U8_WO(a_pu8Mem, a_bUnmapInfo, a_GCPtrMem) do { \
     1460        IEM_MC_RETURN_ON_FAILURE(iemMemMap(pVCpu, (void **)&(a_pu8Mem), sizeof(uint8_t), UINT8_MAX, \
     1461                                           (a_GCPtrMem), IEM_ACCESS_DATA_W, 0)); \
     1462        a_bUnmapInfo = 1 | (IEM_ACCESS_TYPE_WRITE << 4); \
     1463    } while (0)
     1464#else
     1465# define IEM_MC_MEM_FLAT_MAP_U8_WO(a_pu8Mem, a_bUnmapInfo, a_GCPtrMem) \
     1466    (a_pu8Mem) = iemMemFlatMapDataU8WoJmp(pVCpu, &(a_bUnmapInfo), (a_GCPtrMem))
     1467#endif
     1468
     1469/**
     1470 * Maps guest memory for byte readonly direct (or bounce) buffer acccess, flat
     1471 * address variant.
     1472 *
     1473 * @param[out] a_pu8Mem     Where to return the pointer to the mapping.
     1474 * @param[out] a_bUnmapInfo Where to return umapping instructions. uint8_t.
     1475 * @param[in]  a_GCPtrMem   The memory address.
     1476 * @remarks Will return/long jump on errors.
     1477 * @see     IEM_MC_MEM_COMMIT_AND_UNMAP_RO
     1478 */
     1479#ifndef IEM_WITH_SETJMP
     1480# define IEM_MC_MEM_FLAT_MAP_U8_RO(a_pu8Mem, a_bUnmapInfo, a_GCPtrMem) do { \
     1481        IEM_MC_RETURN_ON_FAILURE(iemMemMap(pVCpu, (void **)&(a_pu8Mem), sizeof(uint8_t), UINT8_MAX, \
     1482                                           (a_GCPtrMem), IEM_ACCESS_DATA_R, 0)); \
     1483        a_bUnmapInfo = 1 | (IEM_ACCESS_TYPE_READ << 4); \
     1484    } while (0)
     1485#else
     1486# define IEM_MC_MEM_FLAT_MAP_U8_RO(a_pu8Mem, a_bUnmapInfo, a_GCPtrMem) \
     1487    (a_pu8Mem) = iemMemFlatMapDataU8RoJmp(pVCpu, &(a_bUnmapInfo), (a_GCPtrMem))
     1488#endif
     1489
     1490
     1491/** Commits the memory and unmaps guest memory previously mapped RW.
     1492 * @remarks     May return.
     1493 */
     1494#define IEM_MC_MEM_COMMIT_AND_UNMAP_RW(a_pvMem, a_bMapInfo) do { \
     1495        RT_NOREF_PV(a_bMapInfo); Assert(a_bMapInfo == (1 | ((IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE) << 4)) ); \
     1496        IEM_MC_RETURN_ON_FAILURE(iemMemCommitAndUnmap(pVCpu, (a_pvMem), IEM_ACCESS_DATA_RW)); \
     1497    } while (0)
     1498
     1499/** Commits the memory and unmaps guest memory previously mapped W.
     1500 * @remarks     May return.
     1501 */
     1502#define IEM_MC_MEM_COMMIT_AND_UNMAP_WO(a_pvMem, a_bMapInfo) do { \
     1503        RT_NOREF_PV(a_bMapInfo); Assert(a_bMapInfo == (1 | (IEM_ACCESS_TYPE_WRITE << 4)) ); \
     1504        IEM_MC_RETURN_ON_FAILURE(iemMemCommitAndUnmap(pVCpu, (a_pvMem), IEM_ACCESS_DATA_W)); \
     1505    } while (0)
     1506
     1507/** Commits the memory and unmaps guest memory previously mapped R.
     1508 * @remarks     May return.
     1509 */
     1510#define IEM_MC_MEM_COMMIT_AND_UNMAP_RO(a_pvMem, a_bMapInfo) do { \
     1511        RT_NOREF_PV(a_bMapInfo); Assert(a_bMapInfo == (1 | (IEM_ACCESS_TYPE_READ << 4)) ); \
     1512        IEM_MC_RETURN_ON_FAILURE(iemMemCommitAndUnmap(pVCpu, (void *)(a_pvMem), IEM_ACCESS_DATA_R)); \
     1513    } while (0)
     1514
    13551515
    13561516/** Commits the memory and unmaps the guest memory unless the FPU status word
     
    13701530            IEM_MC_RETURN_ON_FAILURE(iemMemCommitAndUnmap(pVCpu, (a_pvMem), (a_fAccess))); \
    13711531    } while (0)
     1532
     1533
    13721534
    13731535/** Calculate efficient address from R/M. */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette