VirtualBox

Changeset 108114 in vbox for trunk


Ignore:
Timestamp:
Feb 7, 2025 2:04:49 PM (3 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167412
Message:

Runtime/RTAcpi*: Fix overwriting the argument count with the sync level when parsing ASL and fix decoding empty tables, bugref:10733

Location:
trunk/src/VBox/Runtime/common/acpi
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/acpi/acpi-compiler.cpp

    r108095 r108114  
    982982                        return RTErrInfoSetF(pThis->pErrInfo, VERR_INVALID_PARAMETER,
    983983                                             "SyncLevel value is out of range [0..15]: %u", u64);
    984                     pAstNd->aArgs[1].u.u8 = (uint8_t)u64;
     984                    pAstNd->aArgs[3].u.u8 = (uint8_t)u64;
    985985                }
    986986
  • trunk/src/VBox/Runtime/common/acpi/acpi-decompiler.cpp

    r108020 r108114  
    16381638            || Hdr.u32Signature == ACPI_TABLE_HDR_SIGNATURE_DSDT)
    16391639        {
    1640             uint8_t *pbTbl = (uint8_t *)RTMemAlloc(Hdr.cbTbl);
    1641             if (pbTbl)
     1640            /** @todo Verify checksum */
     1641            ssize_t cch = RTVfsIoStrmPrintf(hVfsIosOut, "DefinitionBlock(\"\", \"%s\", %u, \"%.6s\", \"%.8s\", %u)",
     1642                                            Hdr.u32Signature == ACPI_TABLE_HDR_SIGNATURE_SSDT ? "SSDT" : "DSDT",
     1643                                            1, &Hdr.abOemId[0], &Hdr.abOemTblId[0], Hdr.u32OemRevision);
     1644            if (cch > 0)
    16421645            {
    1643                 rc = RTVfsIoStrmRead(hVfsIosIn, pbTbl, Hdr.cbTbl - sizeof(Hdr), true /*fBlocking*/, NULL /*pcbRead*/);
    1644                 if (RT_SUCCESS(rc))
    1645                 {
    1646                     /** @todo Verify checksum */
    1647                     ssize_t cch = RTVfsIoStrmPrintf(hVfsIosOut, "DefinitionBlock(\"\", \"%s\", %u, \"%.6s\", \"%.8s\", %u)",
    1648                                                     Hdr.u32Signature == ACPI_TABLE_HDR_SIGNATURE_SSDT ? "SSDT" : "DSDT",
    1649                                                     1, &Hdr.abOemId[0], &Hdr.abOemTblId[0], Hdr.u32OemRevision);
    1650                     if (cch > 0)
     1646                uint32_t const cbTbl = Hdr.cbTbl - sizeof(Hdr);
     1647                if (cbTbl) /* Do we have something to decode at all? */
     1648                {
     1649                    uint8_t *pbTbl = (uint8_t *)RTMemAlloc(cbTbl);
     1650                    if (pbTbl)
    16511651                    {
    1652                         RTACPITBLAMLDECODE AmlDecode;
    1653                         AmlDecode.pbTbl        = pbTbl;
    1654                         AmlDecode.cbTbl        = Hdr.cbTbl - sizeof(Hdr);
    1655                         AmlDecode.offTbl       = 0;
    1656                         AmlDecode.iLvl         = 0;
    1657                         AmlDecode.cPkgStackMax = 0;
    1658                         AmlDecode.pacbPkgLeft  = NULL;
    1659                         AmlDecode.fIndent      = true;
    1660                         RTListInit(&AmlDecode.LstObjs);
    1661                         rc = rtAcpiTblAmlDecodePkgPush(&AmlDecode, hVfsIosOut, AmlDecode.cbTbl, pErrInfo);
    1662                         while (   RT_SUCCESS(rc)
    1663                                && AmlDecode.offTbl < Hdr.cbTbl - sizeof(Hdr))
    1664                         {
    1665                             rc = rtAcpiTblAmlDecodeTerminal(&AmlDecode, hVfsIosOut, pErrInfo);
    1666                             if (RT_SUCCESS(rc))
    1667                                 rc = rtAcpiTblAmlDecodePkgPop(&AmlDecode, hVfsIosOut, pErrInfo);
    1668                         }
    1669                         if (AmlDecode.pacbPkgLeft)
    1670                             RTMemFree(AmlDecode.pacbPkgLeft);
    1671 
    1672                         PRTACPITBLAMLOBJ pIt, pItNext;
    1673                         RTListForEachSafe(&AmlDecode.LstObjs, pIt, pItNext, RTACPITBLAMLOBJ, NdObjs)
    1674                         {
    1675                             RTListNodeRemove(&pIt->NdObjs);
    1676                             RTMemFree(pIt);
    1677                         }
    1678 
     1652                        rc = RTVfsIoStrmRead(hVfsIosIn, pbTbl, cbTbl, true /*fBlocking*/, NULL /*pcbRead*/);
    16791653                        if (RT_SUCCESS(rc))
    16801654                        {
    1681                             cch = RTVfsIoStrmPrintf(hVfsIosOut, "}\n");
    1682                             if (cch <= 0)
    1683                                 rc = RTErrInfoSetF(pErrInfo, cch == 0 ? VERR_NO_MEMORY : (int)cch, "Failed to emit closing definition block");
     1655
     1656                                RTACPITBLAMLDECODE AmlDecode;
     1657                                AmlDecode.pbTbl        = pbTbl;
     1658                                AmlDecode.cbTbl        = cbTbl;
     1659                                AmlDecode.offTbl       = 0;
     1660                                AmlDecode.iLvl         = 0;
     1661                                AmlDecode.cPkgStackMax = 0;
     1662                                AmlDecode.pacbPkgLeft  = NULL;
     1663                                AmlDecode.fIndent      = true;
     1664                                RTListInit(&AmlDecode.LstObjs);
     1665                                rc = rtAcpiTblAmlDecodePkgPush(&AmlDecode, hVfsIosOut, AmlDecode.cbTbl, pErrInfo);
     1666                                while (   RT_SUCCESS(rc)
     1667                                       && AmlDecode.offTbl < cbTbl)
     1668                                {
     1669                                    rc = rtAcpiTblAmlDecodeTerminal(&AmlDecode, hVfsIosOut, pErrInfo);
     1670                                    if (RT_SUCCESS(rc))
     1671                                        rc = rtAcpiTblAmlDecodePkgPop(&AmlDecode, hVfsIosOut, pErrInfo);
     1672                                }
     1673                                if (AmlDecode.pacbPkgLeft)
     1674                                    RTMemFree(AmlDecode.pacbPkgLeft);
     1675
     1676                                PRTACPITBLAMLOBJ pIt, pItNext;
     1677                                RTListForEachSafe(&AmlDecode.LstObjs, pIt, pItNext, RTACPITBLAMLOBJ, NdObjs)
     1678                                {
     1679                                    RTListNodeRemove(&pIt->NdObjs);
     1680                                    RTMemFree(pIt);
     1681                                }
    16841682                        }
     1683                        else
     1684                            rc = RTErrInfoSetF(pErrInfo, rc, "Reading %u bytes of the ACPI table failed", Hdr.cbTbl);
     1685
     1686                        RTMemFree(pbTbl);
     1687                        pbTbl = NULL;
    16851688                    }
    16861689                    else
    1687                         rc = RTErrInfoSetF(pErrInfo, cch == 0 ? VERR_NO_MEMORY : (int)cch, "Failed to emit DefinitionBlock()");
     1690                        rc = RTErrInfoSetF(pErrInfo, VERR_NO_MEMORY, "Allocating memory for the ACPI table failed");
    16881691                }
    16891692                else
    1690                     rc = RTErrInfoSetF(pErrInfo, rc, "Reading %u bytes of the ACPI table failed", Hdr.cbTbl);
    1691 
    1692                 RTMemFree(pbTbl);
    1693                 pbTbl = NULL;
     1693                { 
     1694                    cch = RTVfsIoStrmPrintf(hVfsIosOut, "{\n}\n");
     1695                    if (cch <= 0)
     1696                        rc = RTErrInfoSetF(pErrInfo, cch == 0 ? VERR_NO_MEMORY : (int)cch, "Failed to emit empty body");
     1697                }
    16941698            }
    16951699            else
    1696                 rc = RTErrInfoSetF(pErrInfo, VERR_NO_MEMORY, "Allocating memory for the ACPI table failed");
     1700                rc = RTErrInfoSetF(pErrInfo, cch == 0 ? VERR_NO_MEMORY : (int)cch, "Failed to emit DefinitionBlock()");
    16971701        }
    16981702        else
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