13989 Commits

Author SHA1 Message Date
Robert Moore
7ab9a21d3d
Merge pull request #474 from SchmErik/iasl-index-field
iASL: fix type mismatch on IndexField
2019-05-29 13:18:54 -07:00
Robert Moore
fa068aaecb
Merge pull request #473 from SchmErik/remove-module-level-code
remove legacy module-level code due to deprecation
2019-05-29 13:18:40 -07:00
Robert Moore
6a152fd728
Merge pull request #472 from SchmErik/iasl-special-names
iASL: ensure that _WAK and _PTS are declared only at the root scope
2019-05-29 13:18:23 -07:00
Erik Schmauss
8efcfcafde iASL: fix type mismatch on IndexField
By definition, Index field should be based off of Field units rather
than Operation Regions.

Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-05-29 11:24:41 -07:00
Erik Schmauss
9125603c53 iASL: ensure that certain named objects are declared only at the root scope
_WAK, _PTS, _TTS, and _Sx in any other scope will not be invoked by OS.

Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-05-20 14:40:55 -07:00
Erik Schmauss
1ca34b1a7b remove legacy module-level code due to deprecation
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>
2019-05-16 13:48:39 -07:00
Robert Moore
316dc10d9a Update file permission
nsaccess.c
2019-05-15 10:40:19 -07:00
Robert Moore
76658f55d8 Namespace: simplify creation of the initial/default namespace
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.
2019-05-15 10:00:35 -07:00
Robert Moore
36449fa1dc Update version to 20190509
Version 20190509.
R05_09_19
2019-05-09 13:53:47 -07:00
Robert Moore
c81b5184f4 Logfile: Changes for version 20190509
Version 20190509.
2019-05-09 13:53:10 -07:00
Robert Moore
2e000583b0
Merge pull request #470 from SchmErik/linux-dbg
Linux: move ACPI_DEBUG_DEFAULT flag out of ifndef
2019-05-09 13:46:52 -07:00
Erik Schmauss
c14f17fa0a Linux: move ACPI_DEBUG_DEFAULT flag out of ifndef
This flag should not be included in #ifndef CONFIG_ACPI. It should be
used unconditionally.

Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-05-09 13:32:06 -07:00
Robert Moore
a73bac9888
Merge pull request #469 from SchmErik/fwd-ref
Improve forward reference detection
2019-05-09 12:55:10 -07:00
Robert Moore
ee72d6550e iASL: Add buffer overflow analysis for Create Buffer Field ops
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
2019-05-09 12:52:08 -07:00
Erik Schmauss
be7eaf9586 iASL: improve forward reference detection
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>
2019-05-07 13:35:52 -07:00
Erik Schmauss
095238f69f iASL: detect forward references for field declarations at root scope
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-05-06 10:53:08 -07:00
Robert Moore
263015ebba
Merge pull request #467 from SchmErik/iasl-create-field-error
iASL: add buffer overflow analysis for BufferField declarations
2019-05-03 07:24:19 -07:00
Robert Moore
1fcba8c753
Merge pull request #466 from SchmErik/revert-field-fwd-ref
Revert "iASL: Additional forward reference detection (illegal)"
2019-05-03 07:23:54 -07:00
Robert Moore
3fb00a7346
Merge pull request #465 from SchmErik/trivial-message
iASL: clarify error message when scanning file during checksum genera…
2019-05-03 07:23:32 -07:00
Robert Moore
e82934bba0
Merge pull request #464 from SchmErik/gpe-fix
Revert "Events: Clear status of an event before enabling it"
2019-05-03 07:23:07 -07:00
Robert Moore
a76cd1cf9a
Merge pull request #463 from SchmErik/iasl-fix
iASL: stop clearing error log after parsing each file
2019-05-03 07:21:55 -07:00
Erik Schmauss
96fe359802 iASL: add buffer overflow analysis for BufferField declarations
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>
2019-05-02 21:26:44 -07:00
Erik Schmauss
018bc6b4d3 Revert "iASL: Additional forward reference detection (illegal)"
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>
2019-05-02 16:03:19 -07:00
Erik Schmauss
6617e101c1 iASL: clarify error message when scanning file during checksum generation
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-05-02 15:03:04 -07:00
Rafael J. Wysocki
0ae256fd7b Revert "Events: Clear status of an event before enabling it"
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>
2019-04-30 11:30:16 -07:00
Erik Schmauss
f6fcb7f449 iASL: stop clearing error log after parsing each file
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-04-23 11:28:18 -07:00
Robert Moore
a18df084aa
Merge pull request #460 from SchmErik/iasl-preprocess-fix
iASL: do not perform static analysis with -P option
2019-04-18 13:24:43 -07:00
Robert Moore
fb681b3557
Merge pull request #461 from SchmErik/iasl-revert
Revert "iASL: use .src file handle only for include file error messages"
2019-04-18 13:24:18 -07:00
Erik Schmauss
30d64aaef1 Revert "iASL: use .src file handle only for include file error messages"
This reverts commit 1eb3ee94b6ab2e231a5f7cdf7ca6388ff886c031.
2019-04-18 12:46:00 -07:00
Erik Schmauss
982ba4eccc iASL: do not perform static analysis with -P option
This option only does preprocessing. No need to perform static
analysis.

Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-04-17 15:39:27 -07:00
Robert Moore
0c1495275a Update version to 20190405
Version 20190405.
R04_05_19
2019-04-05 08:08:46 -07:00
Robert Moore
c38cf00852 Logfile: Changes for version 20190405
Version 20190405.
2019-04-05 08:08:08 -07:00
Robert Moore
25237e8db3
Merge pull request #456 from SchmErik/iasl-ext-04
Multiple file compilation feature
2019-04-05 07:48:58 -07:00
Erik Schmauss
1eb3ee94b6 iASL: use .src file handle only for include file error messages
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-04-04 19:23:08 -07:00
Erik Schmauss
40d879fa54 iASL: use pre-increment for globals to avoid confusion between pointer arithmetic and actual increment 2019-04-04 19:00:16 -07:00
Erik Schmauss
15daa52f2f iASL: trivial clean up, no functional change
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-04-04 17:14:48 -07:00
Erik Schmauss
55dfffb23f iASL: change summary variables from UINT64 to UINT32 2019-04-04 16:52:56 -07:00
Erik Schmauss
db39b23890 iASL: clarify up summary message to be more explicit about AML output generation
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-04-03 20:45:56 -07:00
Robert Moore
2b181da5e8
Merge pull request #457 from SchmErik/gpe-fix
Events: Clear status of an event before enabling it
2019-04-03 12:23:54 -07:00
Erik Schmauss
2be1df511f iASL: improve parser error message and clean up any .aml output files
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-04-02 17:42:46 -07:00
Erik Schmauss
5359545e06 iASL: remove trivial code, edit debug message, no functional change
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-04-02 17:42:46 -07:00
Erik Schmauss
309ff1e32b iASL: only display summary/clean up after compilation or conversion
The disassembler does not need summary/clean up functionality.

Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-04-02 17:41:59 -07:00
Erik Schmauss
65e878d88c iASL: add null check for file search functionality 2019-04-02 17:40:29 -07:00
Erik Schmauss
7ed23f3f8e iASL: perform middle and back-end only for ASL files
The data table compiler and disassembler can go to clean up at this
point.

Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-04-02 17:40:17 -07:00
Erik Schmauss
57972e2f7b don't close files that point to stderr or stdout 2019-04-02 17:09:37 -07:00
Erik Schmauss
94173b172e iASL: correctly resolve field unit externals
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2019-04-02 17:09:37 -07:00
Erik Schmauss
8c7e732f98 iASL: emit error on unresolved external when compiling multiple tables
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>
2019-04-02 17:09:37 -07:00
Erik Schmauss
7586a625f9 Namespace: add check to avoid null pointer dereference
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>
2019-04-02 17:09:37 -07:00
Erik Schmauss
997f6ca123 iASL: perform analysis and code generation after parsing all tables
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>
2019-04-02 17:09:37 -07:00
Erik Schmauss
fbff97048d iASL: getting rid of unnecessary code, no functional change intended
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>
2019-04-02 17:09:37 -07:00