VirtualBox

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


Ignore:
Timestamp:
Jun 14, 2021 7:28:22 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145112
Message:

Intel IOMMU: bugref:9967 Validate the offsets of our implementation-defined MMIO registers in saved states.

File:
1 edited

Legend:

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

    r89591 r89666  
    110110/** Size of the group 0 (in bytes). */
    111111#define DMAR_MMIO_GROUP_0_SIZE                      (DMAR_MMIO_GROUP_0_OFF_END - DMAR_MMIO_GROUP_0_OFF_FIRST)
    112 /**< Implementation-specific MMIO offset of IVA_REG. */
     112/** Number of MMIO register offsets defined by our implementation (for saved
     113 *  states) - IVA_REG, IOTLB_REG, FRCD_LO, FRCD_HI. */
     114#define DMAR_MMIO_OFF_IMPL_COUNT                    4
     115/** Implementation-specific MMIO offset of IVA_REG (used in saved state). */
    113116#define DMAR_MMIO_OFF_IVA_REG                       0xe50
    114 /**< Implementation-specific MMIO offset of IOTLB_REG. */
     117/** Implementation-specific MMIO offset of IOTLB_REG (used in saved state). */
    115118#define DMAR_MMIO_OFF_IOTLB_REG                     0xe58
    116 /**< Implementation-specific MMIO offset of FRCD_LO_REG. */
     119/** Implementation-specific MMIO offset of FRCD_LO_REG (used in saved state). */
    117120#define DMAR_MMIO_OFF_FRCD_LO_REG                   0xe70
    118 /**< Implementation-specific MMIO offset of FRCD_HI_REG. */
     121/** Implementation-specific MMIO offset of FRCD_HI_REG (used in saved state). */
    119122#define DMAR_MMIO_OFF_FRCD_HI_REG                   0xe78
    120123AssertCompile(!(DMAR_MMIO_OFF_FRCD_LO_REG & 0xf));
     
    39453948    pHlp->pfnSSMPutMem(pSSM, &pThis->abRegs1[0], sizeof(pThis->abRegs1));
    39463949
     3950    /*
     3951     * Save our implemention-defined MMIO registers offsets.
     3952     * The register themselves are currently all part of group 1 (saved above).
     3953     * We save these to ensure they're located where the code expects them while loading state.
     3954     */
     3955    pHlp->pfnSSMPutU16(pSSM, DMAR_MMIO_OFF_IMPL_COUNT);
     3956    AssertCompile(DMAR_MMIO_OFF_IMPL_COUNT == 4);
     3957    pHlp->pfnSSMPutU16(pSSM, DMAR_MMIO_OFF_IVA_REG);
     3958    pHlp->pfnSSMPutU16(pSSM, DMAR_MMIO_OFF_IOTLB_REG);
     3959    pHlp->pfnSSMPutU16(pSSM, DMAR_MMIO_OFF_FRCD_LO_REG);
     3960    pHlp->pfnSSMPutU16(pSSM, DMAR_MMIO_OFF_FRCD_HI_REG);
     3961
    39473962    /* Save lazily activated registers. */
    39483963    pHlp->pfnSSMPutU64(pSSM, pThis->uIrtaReg);
     
    39823997    {
    39833998        /* VER_REG */
    3984         uint32_t uVerReg;
     3999        uint32_t uVerReg = 0;
    39854000        int rc = pHlp->pfnSSMGetU32(pSSM, &uVerReg);
    39864001        AssertRCReturn(rc, rc);
     
    39894004                              rcDataErr);
    39904005        /* CAP_REG */
    3991         uint64_t fCapReg;
     4006        uint64_t fCapReg = 0;
    39924007        pHlp->pfnSSMGetU64(pSSM, &fCapReg);
    39934008        AssertLogRelMsgReturn(fCapReg == pThis->fCapReg,
     
    39954010                              rcDataErr);
    39964011        /* ECAP_REG */
    3997         uint64_t fExtCapReg;
     4012        uint64_t fExtCapReg = 0;
    39984013        pHlp->pfnSSMGetU64(pSSM, &fExtCapReg);
    39994014        AssertLogRelMsgReturn(fExtCapReg == pThis->fExtCapReg,
     
    40074022    {
    40084023        /* Group count. */
    4009         uint32_t cRegGroups;
     4024        uint32_t cRegGroups = 0;
    40104025        pHlp->pfnSSMGetU32(pSSM, &cRegGroups);
    40114026        AssertLogRelMsgReturn(cRegGroups == DMAR_MMIO_GROUP_COUNT,
     
    40134028                               cRegGroups), rcFmtErr);
    40144029        /* Group 0. */
    4015         uint32_t cbRegs0;
     4030        uint32_t cbRegs0 = 0;
    40164031        pHlp->pfnSSMGetU32(pSSM, &cbRegs0);
    40174032        AssertLogRelMsgReturn(cbRegs0 == sizeof(pThis->abRegs0),
     
    40204035        pHlp->pfnSSMGetMem(pSSM, &pThis->abRegs0[0], cbRegs0);
    40214036        /* Group 1. */
    4022         uint32_t cbRegs1;
     4037        uint32_t cbRegs1 = 0;
    40234038        pHlp->pfnSSMGetU32(pSSM, &cbRegs1);
    40244039        AssertLogRelMsgReturn(cbRegs1 == sizeof(pThis->abRegs1),
     
    40264041                               cbRegs1), rcFmtErr);
    40274042        pHlp->pfnSSMGetMem(pSSM, &pThis->abRegs1[0], cbRegs1);
     4043    }
     4044
     4045    /*
     4046     * Validate implementation-defined MMIO register offsets.
     4047     */
     4048    {
     4049        /* Offset count. */
     4050        uint16_t cOffsets = 0;
     4051        pHlp->pfnSSMGetU16(pSSM, &cOffsets);
     4052        AssertLogRelMsgReturn(cOffsets == DMAR_MMIO_OFF_IMPL_COUNT,
     4053                              ("%s: MMIO offset count mismatch (expected %u got %u)\n", DMAR_LOG_PFX, DMAR_MMIO_OFF_IMPL_COUNT,
     4054                               cOffsets), rcFmtErr);
     4055        /* IVA_REG. */
     4056        uint16_t offReg = 0;
     4057        pHlp->pfnSSMGetU16(pSSM, &offReg);
     4058        AssertLogRelMsgReturn(offReg == DMAR_MMIO_OFF_IVA_REG,
     4059                              ("%s: IVA_REG offset mismatch (expected %u got %u)\n", DMAR_LOG_PFX, DMAR_MMIO_OFF_IVA_REG,
     4060                               offReg), rcFmtErr);
     4061        /* IOTLB_REG. */
     4062        pHlp->pfnSSMGetU16(pSSM, &offReg);
     4063        AssertLogRelMsgReturn(offReg == DMAR_MMIO_OFF_IOTLB_REG,
     4064                              ("%s: IOTLB_REG offset mismatch (expected %u got %u)\n", DMAR_LOG_PFX, DMAR_MMIO_OFF_IOTLB_REG,
     4065                               offReg), rcFmtErr);
     4066        /* FRCD_LO_REG. */
     4067        pHlp->pfnSSMGetU16(pSSM, &offReg);
     4068        AssertLogRelMsgReturn(offReg == DMAR_MMIO_OFF_FRCD_LO_REG,
     4069                              ("%s: FRCD_LO_REG offset mismatch (expected %u got %u)\n", DMAR_LOG_PFX, DMAR_MMIO_OFF_FRCD_LO_REG,
     4070                               offReg), rcFmtErr);
     4071        /* FRCD_HI_REG. */
     4072        pHlp->pfnSSMGetU16(pSSM, &offReg);
     4073        AssertLogRelMsgReturn(offReg == DMAR_MMIO_OFF_FRCD_HI_REG,
     4074                              ("%s: FRCD_HI_REG offset mismatch (expected %u got %u)\n", DMAR_LOG_PFX, DMAR_MMIO_OFF_FRCD_HI_REG,
     4075                               offReg), rcFmtErr);
    40284076    }
    40294077
     
    40464094     */
    40474095    {
    4048         uint32_t uEndMarker;
     4096        uint32_t uEndMarker = 0;
    40494097        int const rc = pHlp->pfnSSMGetU32(pSSM, &uEndMarker);
    40504098        AssertRCReturn(rc, rc);
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