> Date: Fri, 26 Feb 2021 13:42:32 +0900 (JST) > From: YASUOKA Masahiko <yasu...@openbsd.org> > > Hi, > > My vaio repeatedly crashed by "Data modified on freelist"(*1) or other > memory corruptions. After my long time debug, I found the route cause > is a handling of references of LocalX, like the following: > > If ((SMRW (0x0B, 0x16, 0x21, RefOf (Local0)) == Zero)) > > In the called control method, "RefOf (Local1)" is referred as Arg3, is > stored a value like the following: > > Arg3 = \_SB.PCI0.LPCB.EC0.SMD0 > > In aml_store(), lvalue is reset if lvalue is a LocalX. But since that > was done before resolving the reference, lvalue was not reset if > lvalue is a reference of LocalX. > > diff #1 fixes that problem. It resets lvalue after resolving > references. > > ok? > > diff #2 adds aml_die() if any memory corruption occurs when creating > field in a buffer. This actually happens on my vaio (pro pk 14) if > diff #1 is not applied. > > ok? > > diff #1 > > Index: sys/dev/acpi/dsdt.c > =================================================================== > RCS file: /var/cvs/openbsd/src/sys/dev/acpi/dsdt.c,v > retrieving revision 1.257 > diff -u -p -r1.257 dsdt.c > --- sys/dev/acpi/dsdt.c 17 Dec 2020 17:57:19 -0000 1.257 > +++ sys/dev/acpi/dsdt.c 26 Feb 2021 04:12:03 -0000 > @@ -2961,11 +2961,11 @@ aml_store(struct aml_scope *scope, struc > aml_rwfield(rhs, 0, rhs->v_field.bitlen, &tmp, ACPI_IOREAD); > rhs = &tmp; > } > + > + lhs = aml_gettgt(lhs, AMLOP_STORE);
Can you add a blank line here? > /* Store to LocalX: free value */ > if (lhs->stack >= AMLOP_LOCAL0 && lhs->stack <= AMLOP_LOCAL7) > aml_freevalue(lhs); > - > - lhs = aml_gettgt(lhs, AMLOP_STORE); > switch (lhs->type) { > case AML_OBJTYPE_UNINITIALIZED: > aml_copyvalue(lhs, rhs); diff #1 is ok kettenis@ with the fix mentioned above