rust-osdev/acpi

AML: PkgLength handling in *Field

alnyan opened this issue · 1 comments

While working on my PR, I noticed that PkgLength may sometimes be handled incorrectly for *Field opcode parsing: it seems like the length needs to be checked against the corresponding Operation Region length and not the AML bytecode slice length.

The following code should be valid, but parsing it results in InvalidPkgLength if there's "not enough" bytes after the Field opcode:

OperationRegion (GIO0, SystemIO, 0x125, 0x100)

Field (GIO0, ByteAcc, NoLock, WriteAsZeros) {
   IDX0, 8,
   DAT0, 8,
   IDX1, 8,
   DAT1, 16,
   Offset(0x90),  // This line fails, but should be valid, as it's still within the GIO0 opreg
   IDX2, 8,
   DAT2, 8
}

#191 should fix the issue