VirtualBox

Changeset 83988 in vbox for trunk/src/VBox/Devices/Bus


Ignore:
Timestamp:
Apr 27, 2020 8:40:58 AM (5 years ago)
Author:
vboxsync
Message:

AMD IOMMU: bugref:9654 Bits.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp

    r83985 r83988  
    20922092
    20932093/**
     2094 * An array of the masks to select the device table segment index from a device ID.
     2095 */
     2096static uint16_t const g_auDevTabSegMasks[] = { 0x0, 0x8000, 0xc000, 0xe000 };
     2097
     2098/**
    20942099 * The maximum size (inclusive) of each device table segment (0 to 7).
    20952100 * Indexed by the device table segment index.
     
    29082913
    29092914/**
     2915 * Reads a device table entry from guest memory given the device ID.
     2916 *
     2917 * @returns VBox status code.
     2918 * @param   pDevIns         The IOMMU device instance.
     2919 * @param   uDevId          The device ID.
     2920 * @param   pDevTabEntry    Where to store the device table entry.
     2921 */
     2922static int iommuAmdReadDevTabEntry(PPDMDEVINS pDevIns, uint16_t uDevId, DEV_TAB_ENTRY_T *pDevTabEntry)
     2923{
     2924    PCIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
     2925    IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrl(pThis);
     2926
     2927    uint8_t const idxSegsEn = Ctrl.n.u3DevTabSegEn;
     2928    Assert(idxSegsEn < RT_ELEMENTS(g_auDevTabSegMasks));
     2929
     2930    uint8_t const idxSeg = uDevId & g_auDevTabSegMasks[idxSegsEn] >> 13;
     2931    Assert(idxSeg < RT_ELEMENTS(pThis->aDevTabBaseAddrs));
     2932
     2933    RTGCPHYS const GCPhysDevTab   = pThis->aDevTabBaseAddrs[idxSeg].n.u40Base;
     2934    uint16_t const offDevTabEntry = uDevId & ~g_auDevTabSegMasks[idxSegsEn];
     2935    RTGCPHYS const GCPhysDevTabEntry = GCPhysDevTab + offDevTabEntry;
     2936
     2937    int rc = PDMDevHlpPCIPhysRead(pDevIns, GCPhysDevTabEntry, pDevTabEntry, sizeof(*pDevTabEntry));
     2938    if (RT_FAILURE(rc))
     2939        Log((IOMMU_LOG_PFX ": Failed to read device table entry at %#RGp. rc=%Rrc\n", GCPhysDevTabEntry, rc));
     2940
     2941    return rc;
     2942}
     2943
     2944
     2945/**
    29102946 * Memory read transaction from a device.
    29112947 *
    29122948 * @returns VBox status code.
    29132949 * @param   pDevIns     The IOMMU device instance.
    2914  * @param   uDeviceId   The device identifier (bus, device, function).
     2950 * @param   uDevId      The device identifier (bus, device, function).
    29152951 * @param   uDva        The device virtual address being read.
    29162952 * @param   cbRead      The number of bytes being read.
     
    29192955 * @thread  Any.
    29202956 */
    2921 static int iommuAmdDeviceMemRead(PPDMDEVINS pDevIns, uint16_t uDeviceId, uint64_t uDva, size_t cbRead, PRTGCPHYS pGCPhysOut)
    2922 {
    2923     RT_NOREF(pDevIns, uDeviceId, uDva, cbRead, pGCPhysOut);
     2957static int iommuAmdDeviceMemRead(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uDva, size_t cbRead, PRTGCPHYS pGCPhysOut)
     2958{
     2959    RT_NOREF(pDevIns, uDevId, uDva, cbRead, pGCPhysOut);
    29242960    return VERR_NOT_IMPLEMENTED;
    29252961}
     
    29312967 * @returns VBox status code.
    29322968 * @param   pDevIns     The IOMMU device instance.
    2933  * @param   uDeviceId   The device identifier (bus, device, function).
     2969 * @param   uDevId      The device identifier (bus, device, function).
    29342970 * @param   uDva        The device virtual address being written.
    29352971 * @param   cbWrite     The number of bytes being written.
     
    29382974 * @thread  Any.
    29392975 */
    2940 static int iommuAmdDeviceMemWrite(PPDMDEVINS pDevIns, uint16_t uDeviceId, uint64_t uDva, size_t cbWrite, PRTGCPHYS pGCPhysOut)
    2941 {
    2942     RT_NOREF(pDevIns, uDeviceId, uDva, cbWrite, pGCPhysOut);
     2976static int iommuAmdDeviceMemWrite(PPDMDEVINS pDevIns, uint16_t uDevId, uint64_t uDva, size_t cbWrite, PRTGCPHYS pGCPhysOut)
     2977{
     2978    RT_NOREF(pDevIns, uDevId, uDva, cbWrite, pGCPhysOut);
    29432979    return VERR_NOT_IMPLEMENTED;
    29442980}
Note: See TracChangeset for help on using the changeset viewer.

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