There have been several places that has been calling functions
regarding module level code blocks. This change removes all old
vestiges in the codebase. This is dead code.
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
For the objects that are created by default (_GPE, _SB_, etc)
there is no need to use the heavyweight NsLookup function.
Instead, simply create each object and link it in as the namespace
is built.
Implemented additional buffer overflow analysis for BufferField
declarations. Check if a buffer index argument to a create buffer
field operation is beyond the end of the target buffer.
*
* This affects these AML operators:
*
* AML_CREATE_FIELD_OP
* AML_CREATE_BIT_FIELD_OP
* AML_CREATE_BYTE_FIELD_OP
* AML_CREATE_WORD_FIELD_OP
* AML_CREATE_DWORD_FIELD_OP
* AML_CREATE_QWORD_FIELD_OP
This change improves forward reference detection for named objects
inside of scopes.
If a parse object has the OP_NOT_FOUND_DURING_LOAD set, it means that
Op is a reference to a named object that is declared later in the AML
bytecode. This is allowed if the reference is inside of a method and
the declaration is outside of a method like so:
DefinitionBlock(...)
{
Method (TEST)
{
Return (NUM0)
}
Name (NUM0,0)
}
However, if the declaration and reference are both in the same method
or outside any methods, this is a forward reference and should be
marked as an error because it would result in runtime errors.
DefinitionBlock(...)
{
Name (BUFF, Buffer (NUM0) {}) // Forward reference
Name (NUM0, 0x0)
Method (TEST)
{
Local0 = NUM1
Name (NUM1, 0x1) // Forward reference
return (Local0)
}
}
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
Create___Field declares a BufferField over an existing buffer. This
change adds an additional check to analyze constant values in the
declarations of these buffer fields. This attempt to detect that the
new buffer does not overrun the original source buffer.
There have been 2 more compiler remarks added. One that states that
the starting index of the new buffer field is beyond the end of the
buffer and another message indicating that the this new buffer
extends beyond the end of the source buffer.
We initially thought that this would actually be an error. However,
consider the following case:
Name (BUF0, buffer(0){}) // Create an empty buffer
Name (BUF1, buffer(0x5){0x0,0x1,0x2,0x3,0x4})
BUF0 = BUF1
CreateByteField (BUF0, 0x0, BYTE) // this is valid!
This code runs without issues because BUF0 gets assigned to BUF1. Due
to the lack of usage analysis in iASL, the source buffer can change
throughout table load or a control method execution.
In order to make this analysis check result as an error, we need to
add additional steps to analyze the usage of BUF0 between its
declaration and it's use in CreateByteField.
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
This reverts commit 3132320003b348bcf48274d4e326e496ffc4b23b.
This commit unintentionally emitted AML bytecode with incorrect
package lengths for some ASL code related to Fields and
OperationRegions. This mal-formed AML can cause systems to crash
during boot.
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
This reverts ACPICA commit 6c43e1acdf93a04ca32898d1d89d93fde04d121a.
Revert "ACPICA: Clear status of GPEs before enabling them"
Revert commit c8b1917c8987 ("ACPICA: Clear status of GPEs before
enabling them") that causes problems with Thunderbolt controllers
to occur if a dock device is connected at init time (the xhci_hcd
and thunderbolt modules crash which prevents peripherals connected
through them from working).
Commit c8b1917c8987 effectively causes commit ecc1165b8b74 ("ACPICA:
Dispatch active GPEs at init time") to get undone, so the problem
addressed by commit ecc1165b8b74 appears again as a result of it.
Fixes: c8b1917c8987 ("ACPICA: Clear status of GPEs before enabling them")
Link: https://lore.kernel.org/lkml/s5hy33siofw.wl-tiwai@suse.de/T/#u
Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1132943
Reported-by: Michael Hirmke <opensuse@mike.franken.de>
Reported-by: Takashi Iwai <tiwai@suse.de>
Cc: 4.17+ <stable@vger.kernel.org> # 4.17+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This error is added because this can lead to unresolved references
during table load and control method execution. This warning helps
the user detect these issues during compilation rather than runtime.
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
Some ACPICA userspace tools call AcpiUtSubsystemShutdown() during
cleanup and dereference a null pointer when cleaning up the
namespace.
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
Performing parse tree analysis on all definition blocks
simultaneously results in more effective namespace cross-reference.
This enables iASL static analysis to determine unresolved external
declarations and namespace collisions during compilation.
In order to take advantage of this, compile definition blocks
with the following command:
iasl dsdt.asl ssdt1.asl ssdt2.asl ...
*** Changes related to multiple files:
Keep track of all files in a global list that is persistent
throughout compilation of both files. This is done in order to
compile multiple ASL files in the same namespace and parse tree.
This also resulted in moving the file handle assignment for the -vi
option during file initialization rather than commandline processing.
As each definition block is parsed, it is connected as a sibling node
to the previous definiton block.
*** Changes related to iASL error reporting:
Also, more error messages were added by replacing the fprintf to
stderr with AslError. By doing so, an error can be logged properly
and AML output files will be cleaned if there is a compiler error.
Adds the ability to print the correct source line by logging the .src
filename in each error node. This is necessary for errors that point
to an include file.
New iASL error: emitting an error when compiling duplicate files.
Ignore max error count when compiling with -f because
compilation needs to continue.
Fix parser error path to correctly abort compilation rather
than trying to proceed with more compilation.
*** Changes related to codegen behavior:
Seek to the end of the AML output file after codegen in case multiple
definition blocks need to be encoded in the same AML file. This makes
other parts of the codebase a little more convinent since it doesn't
have to seek to the correct place in the AML.
*** Misc changes:
Remove a call to ACPI_FREE. We should never be calling ACPI_FREE in
memory allocated in caches.
Display compilation summaries for multiple input files. Files that
have parser errors are reported as having parser errors. The summary
is based on the global file list.
Encapsulate global variables in global file nodes used for summary
reporting.
Final cleanup functions for iASL has been consolidated to the main()
function for simplicity.
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
This seems to be an old vestige resulting from some sort of
restructuring in iASL. These code snippsets are redundant. In
general, iASL needs to do the following:
1.) open all files before starting compilation or disassembly
2.) limit calling AslDoDisassembly() to only two places: for AML
disassembly and ASL/ASL+ converter
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
Commit 18996f2db918 ("ACPICA: Events: Stop unconditionally
clearing ACPI IRQs during suspend/resume") was added to stop clearing
of event status bits unconditionally on suspend and resume paths. This
was done because of an issue
reported (https://bugzilla.kernel.org/show_bug.cgi?id=196249) where
lid status stays closed even on resume (which happens because event
status bits are cleared unconditionally on resume). Though this change
fixed the issue on suspend path, it introduced regressions on several
resume paths.
First regression was reported and fixed on S5 path by the following
change: commit fa85015c0d95 ("ACPICA: Clear status of all events when
entering S5"). Next regression was reported and fixed on all legacy
sleep paths by the commit f317c7dc12b7 ("ACPICA: Clear status of all
events when entering sleep states"). However, regression still exists
on S0ix sleep path since it does not follow the legacy sleep path.
In case of S0ix, events are enabled as part of device suspend path. If
status bits for the events are set when they are enabled, it could
result in premature wake from S0ix. This change ensures that status is
cleared for any event that is being enabled so that any stale events
are cleared out.
Signed-off-by: Furquan Shaikh <furquan@google.com>
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>