13397 Commits

Author SHA1 Message Date
Lv Zheng
8d618db7ba Tables: Fix a hidden logic related to AcpiTbInstallStandardTable()
There is a hidden logic for AcpiTbInstallStandardTable():
1. When it is invoked from the OS boot stage, ACPICA mutex may not be
   available, and thus no AcpiUtAcquireMutex()/AcpiUtReleaseMutex() are
   invoked in these code paths:
   AcpiInitializeTables
     AcpiTbParseRootTable
       AcpiTbInstallStandardTable (4 invocations)
   AcpiInstallTable
       AcpiTbInstallStandardTable
2. When it is invoked during the runtime, ACPICA mutex is correctly used:
   AcpiExLoadOp
     AcpiTbInstallAndLoadTable
       Lock(TABLES)
       AcpiTbInstallStandardTable
       UnLock(TABLES)
   AcpiLoadTable
     AcpiTbInstallAndLoadTable
       Lock(TABLES)
       AcpiTbInstallStandardTable
       UnLock(TABLES)
So the hidden logic is: AcpiTbInstallStandardTable() tries not to hold
mutexes to handle the difference of the boot stage and the runtime, but
leaves the mutexes held from some calling runtime APIs.

This introduces another problem in AcpiTbInstallStandardTable() where
AcpiGbl_TableHandler is invoked from and the lock contexts are thus not
consistent for the table handlers. Linux registers such a handler to track
the table installation and the handler is actually invoked from both
contexts. Since the handler also invokes AcpiGetTable(), when the following
commit corrected AcpiGetTable() to make it start to hold the table lock,
a regression is then triggered.
  Commit: cac6790954d4d752a083e6122220b8a22febcd07
  Subject: Tables: Back port acpi_get_table_with_size() and early_acpi_os_unmap_memory() from Linux kernel

The regression is noticed by LKP as new errors reported by ACPICA mutex
debugging facility.
[    2.043693] ACPI Error: Mutex [ACPI_MTX_Tables] already acquired by this thread [497483776] (20160930/utmutex-254)
[    2.054084] ACPI Error: Mutex [0x2] is not acquired, cannot release (20160930/utmutex-326)

And it triggers a dead lock:
[  247.066214] INFO: task swapper/0:1 blocked for more than 120 seconds.
...
[  247.091271] Call Trace:
...
[  247.121523]  down_timeout+0x47/0x50
[  247.125065]  acpi_os_wait_semaphore+0x47/0x62
[  247.129475]  acpi_ut_acquire_mutex+0x43/0x81
[  247.133798]  acpi_get_table+0x2d/0x84
[  247.137513]  acpi_table_attr_init+0xcd/0x100
[  247.146590]  acpi_sysfs_table_handler+0x5d/0xb8
[  247.151174]  acpi_bus_table_handler+0x23/0x2a
[  247.155583]  acpi_tb_install_standard_table+0xe0/0x213
[  247.164489]  acpi_tb_install_and_load_table+0x3a/0x82
[  247.169592]  acpi_ex_load_op+0x194/0x201
...
[  247.200108]  acpi_ns_evaluate+0x1bb/0x247
[  247.204170]  acpi_evaluate_object+0x178/0x274
[  247.213249]  acpi_processor_set_pdc+0x154/0x17b
...
The table mutex held in AcpiTbInstallAndLoadTable() is re-visited by
AcpiGetTable().

Noticing that the early mutex requirement actually belongs to the OSL layer
and has already been handled in Linux
acpi_os_wait_semaphore()/acpi_os_signal_semaphore(). This patch then can
fix the regression by removing this hidden logic from ACPICA core and
leaving it to OSPMs.

Tested-by: Tomi Sarvela <tomi.p.sarvela@intel.com>
Tested-by: Ye Xiaolong <xiaolong.ye@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-06-26 08:30:17 +08:00
Lv Zheng
73512384c9 Tables: Add sanity check in AcpiPutTable()
To avoid caller to trigger unexpected warning messages (Link #1):
  ACPI Warning: Table ffffffffbb461d20, Validation count is zero before decrement
Which is reported from AcpiTbPutTable(). When the table is validated, the
pointer must be non-zero. Thus the message is not suitable for invalidated
tables. This patch fixes the callee side based on this fact. Reported by
Cristian Aravena Romero, Fixed by Lv Zheng.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=191221 [#1]
Reported-by: Cristian Aravena Romero <caravena@gmail.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-06-26 08:30:17 +08:00
Lv Zheng
beb7833ef1 Tables: Mechanism to handle AcpiGetTable()/AcpiPutTable() imbalance better
On linux, 2 ioremap() mechanisms are implemented for 2 stages:
1. During early boot, before memory manager is fully initialized.
2. For late boot and runtime, after memory manager is fully
   initialized.
Maps mapped in the early stage cannot be used by late stage.

So for early stage, linux invokes AcpiGetTable()/AcpiPutTable() APIs to
free table mappings (means there is no imbalance), and for late stage,
linux mostly only invokes AcpiGetTable() table API (means there are
imbalances, and balances and imbalances co-exist).

The original mechanism is designed to allow:
1. early stage balances;
2. late stage co-existence of balances/imbalances.
But for the latter, it has a limitation, it doesn't allow balances to be
implemented for users who can easily increment ValidationCount to its
maximum value.

Considering this case:
 1. A program opens a sysfs table file 65535 times, it can increase
    ValidationCount and first increment causes the table to be mapped:
     ValidationCount = 65535
 2. AML execution causes "Load" to be executed on the same
    table, this time it cannot increase ValidationCount, so
    ValidationCount remains:
     ValidationCount = 65535
 3. The program closes sysfs table file 65535 times, it can decrease
    ValidationCount and the last decrement cause the table to be
    unmapped:
     ValidationCount = 0
 4. AML code still accessing the loaded table, kernel crash can be
    observed.
This is because the original mechanism is only prepared for late stage
users that won't invoke AcpiPutTable() so often (means can only handle
co-existence of balanced non-frequent AcpiPutTable() invocations and
imbalanced AcpiGetTable() invocations), and cannot handle the
co-existence of balanced frequent AcpiPutTable() invocations and
imbalanced AcpiGetTable() invocations.

To prevent that from happening, add a ValidationCount threashold. When it
is reached, the ValidationCount can no longer be incremented/decremented to
invalidate the table descriptor (means preventing table unmappings). Now
the improved mechanism can handle co-existence of any balances/imbalances.

Note that code added in AcpiTbPutTable() is actually a no-op but changes
the warning message into a "warn once" one. Since all warning messages can
only appear once for one table descriptor, it is safe now to add them back
without worrying about log flooding. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2017-06-26 08:30:17 +08:00
Lv Zheng
b7ab82151e Tables: Fix regression introduced by a too early mechanism enabling
On linux, 2 ioremap() mechanisms are implemented for 2 stages:
1. During early boot, before memory manager is fully initialized.
2. For late boot and runtime, after memory manager is fully
   initialized.
Maps mapped in the early stage can not be used by late stage.

So for early stage, linux implements get/put like table APIs to free table
mappings, and for late stage, linux only invokes get table APIs.

We merged 2 implementations into single style API set:
AcpiGetTable() and AcpiPutTable(). During early stage, we want the
"ValidationCount" based mechanism to fully work to release table mappings,
while for late stages, if get/put invocations are balanced, we can free
mappings, but if not (we'll reach the warnings in
AcpiTbGetTable()/AcpiTbPutTable()), we should stop unmapping tables.

The design should work but unfortunately, "return_ACPI_STAUS(AE_LIMIT)"
prevents AcpiGetTable() from returning mapped table pointer to the
callers and the error message can flood kernel logs.

Thus this patch removes the error value returned by AcpiTbGetTable()
in that case along with the accompanying error message to fix the
issue.

Reported-by: Anush Seetharaman <anush.seetharaman@intel.com>
Reported-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2017-06-26 08:30:17 +08:00
Robert Moore
3f35f8bfc1 Disassembler: Fix segfault during resource descriptor processing
Issue was related to the comments that are emitted when a
create* operator references a resource descriptor.

ACPICA bugzilla 1396
2017-06-23 09:51:29 -07:00
Robert Moore
2058b3bf5d Merge pull request #248 from kees/designated
Optionally use designated initializers for function pointers
2017-06-16 07:05:09 -07:00
Robert Moore
bd328647b6 Merge pull request #269 from rmurphy-arm/iort-smmu
IORT: Update SMMU models for revision C
2017-06-16 07:04:50 -07:00
Robert Moore
a411fd2d05 Merge pull request #271 from SchmErik/memleakfix001
Tools: Deallocate memory allocated by AcGetAllTablesFromFile
2017-06-16 07:04:28 -07:00
Robert Moore
b2bbdf665a Merge pull request #268 from zetalog/acpica-1705
acpisrc - related issues fixed
2017-06-15 19:29:08 -07:00
Lv Zheng
894e49ef22 linuxize: cleanup typedef definitions
acpisrc now has capability to convert both the followings:
1. Form 1:
  typedef struct/union foo {         struct/union foo {
     ....                       -->      ...
  } FOO;                             }
2. Form 2:
  typedef struct/union foo FOO; -->  typedef struct/union foo foo;
It becomes unable to handle the following:
3. Form3:
  typedef struct/union foo { /* comment */
      ...
  } FOO;
    -->
  strut/union foo { /* comment */
      ...
  };

As:
1. The purpose of acpisrc is to convert formatted code (ACPICA coding
   style) into linux coding style,
2. acpisrc is a very simple tool that doesn't fully handle C language.
This commit changes the definitions side in order not to regress and we
shall make "no comments in struct/union line" as a new ACPICA coding style
rule. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-06-16 09:42:56 +08:00
Lv Zheng
b5ae12eaef acpisrc: Add PinXxx related conversion identifiers
Adds conversion identifiers for the following missing structures:
 ACPI_RESOURCE_PIN_FUNCTION/AML_RESOURCE_PIN_FUNCTION
 ACPI_RESOURCE_PIN_CONFIG/AML_RESOURCE_PIN_CONFIG
 ACPI_RESOURCE_PIN_GROUP/AML_RESOURCE_PIN_GROUP
 ACPI_RESOURCE_PIN_GROUP_FUNCTION/AML_RESOURCE_PIN_GROUP_FUNCTION
 ACPI_RESOURCE_PIN_GROUP_CONFIG/AML_RESOURCE_PIN_GROUP_CONFIG
 ACPI_RESOURCE_LABEL

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-06-16 09:42:56 +08:00
Lv Zheng
56f919234a acpisrc: Add missing conversion for HMAT support
ACPI_HMAT_STRUCTURE is missing from identifier table, causing linuxize
failures. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-06-16 09:42:56 +08:00
Kees Cook
47538f5f07 Optionally use designated initializers for function pointers
Some projects use compiler plugins that support automatic
layout randomization of structures that are entirely function
pointers. To support this, static initializers need to use designated
initialization rather than ordered initialization. This provides a macro,
ACPI_STRUCT_INIT, to handle both cases, keeping ordered initialization
for builds using compilers that do not support designated initialization.

Signed-off-by: Kees Cook <keescook@google.com>
2017-06-15 16:51:55 -07:00
Robert Moore
f29a742129 Merge pull request #272 from SchmErik/iaslExternalFix01
Iasl external fix01
2017-06-14 11:05:53 -07:00
Robert Moore
5cc8b185ec acpiexec: Fix local exception handler for overrides
restore original logic for handler override.
Used for ASLTS.
2017-06-09 14:37:14 -07:00
Erik Schmauss
86bcb87e3c ASLTS: External: adding testcases from bz1389 by racerrehabman
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2017-06-09 10:50:18 -07:00
Erik Schmauss
9a25211419 iASL compiler: allow compilation of externals with paths that refer to existing names
This change allows compilation of code like the following:

DefinitionBlock (...)
{
    External (ABCD.EFGH)
    Device (ABCD)
    {
        Name (IJLK,0)
    }
}

but does not allow compilation of code like the following:

DefinitionBlock (...)
{
    External (ABCD)
    Device (ABCD)
    {
        Name (EFGH,0)
    }
}

Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2017-06-09 10:44:20 -07:00
Erik Schmauss
8521b98ebd Tools: Deallocate memory allocated by AcGetAllTablesFromFile via AcDeleteTableList
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2017-06-09 10:19:58 -07:00
Robert Moore
f05e1acc7e acpiexec: Remove some extraneous debug code
Remove debug code and add some comments. The debug code caused
issues with the ASLTS test suite.
2017-06-07 08:25:26 -07:00
Robin Murphy
d00a4eb86e IORT: Update SMMU models for revision C
IORT revision C has been published with a number of new SMMU
implementation identifiers; define them.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
2017-06-06 12:51:12 +01:00
Robert Moore
5b16148558 iASL: Resolve some naming inconsistencies
Fix some confusion between "parse op" and "parse node".
Adds a new file, aslparseop.c
Consistently use "parse op" to describe the elements of the
parse tree data structure.
An "Op" is the primary data structure element, even though
it sounds odd.
2017-06-02 10:26:16 -07:00
Robert Moore
bb457076d4 Small indentation changes, no functional change
Fix some alignment issues
2017-06-02 10:24:04 -07:00
Robert Moore
2b14d4034b iASL/Converter: Some code cleanup
A pass through to standardize the code a bit.
2017-06-01 13:19:08 -07:00
Robert Moore
fde696a3f0 Update version to 20170531
Version 20170531.
R05_31_17
2017-05-31 14:09:05 -07:00
Robert Moore
0934d2edb8 Logfile: Changes for version 20170531
Version 20170531.
2017-05-31 14:08:26 -07:00
Robert Moore
194f502d1f Merge pull request #267 from SchmErik/cvEdit003
ASLTS: misc: adding ASL/ASL+ converter sample
2017-05-31 10:42:36 -07:00
Erik Schmauss
a90d78b8d1 ASLTS: misc: adding ASL/ASL+ converter sample
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2017-05-31 10:29:50 -07:00
Robert Moore
e27ff8092d Documents: Miscellaneous changes for new features/bugs
Changes for the new features, some bug fixes, and
ACPI 6.2
2017-05-31 10:15:43 -07:00
Robert Moore
96700c7152 iASL: Update ACPI support level
Bump to 6.2
2017-05-31 09:27:15 -07:00
Robert Moore
9772245e51 acpidump: Update help screen
Fix a couple typos.
2017-05-30 12:50:14 -07:00
Robert Moore
9080cc89e8 iASL: Add copyright and version info to help (-h)
Adds the standard iASL signon
2017-05-30 09:01:15 -07:00
Robert Moore
537d4057c2 iASL: Update internal signal handling
Handle SIGSEGV in addition to SIGINT.
Handle unknown signals.
2017-05-30 08:47:03 -07:00
Robert Moore
5ddccbb444 iASL: Update help messages
Update/cleanup help screen (-h)
2017-05-30 07:21:54 -07:00
Robert Moore
84416b3e45 Merge pull request #252 from zetalog/acpica-aslts
Acpica aslts
2017-05-25 11:01:04 -07:00
Robert Moore
31330ed8fc Automated source cleanup, no functional change
Remove tabs, extraneous spaces, etc.
2017-05-25 08:06:13 -07:00
Robert Moore
8fef392bf2 acpiexec: Split exception/signal handlers to new file
new file is aeexception.c
2017-05-24 13:35:34 -07:00
Robert Moore
809c176659 Update a couple of debug output messages
Cleanup output.
2017-05-24 10:41:47 -07:00
Robert Moore
ffef4ae9a1 acpiexec: enhance local signal handler
Add support for SIGSEGV
Improve/cleanup SIGINT handling
2017-05-23 10:53:47 -07:00
Robert Moore
ea08cda985 Simplify output for the ACPI Debug Object
Cleanup the output, change [Acpi Debug] to Acpi Debug:
2017-05-23 10:42:05 -07:00
Robert Moore
dfbb87c3a9 Unix application OSL: Correctly handle control-c (EINTR)
Handle EINTR from a sem_wait operation. Ignore a control-c.
2017-05-22 12:57:40 -07:00
Robert Moore
c3f798b7b0 Improvements for debug output only
Changes to debug print and debug function tracing.
2017-05-11 08:47:54 -07:00
Robert Moore
f8f617f76c Merge pull request #263 from SchmErik/trivialFix006
disassembler: use memmove instead of malloc/free to move data
2017-05-11 08:42:18 -07:00
Robert Moore
eb6d1b15bf Merge pull request #261 from SchmErik/externalOpRefactor07
External op refactor07
2017-05-11 08:42:05 -07:00
Robert Moore
53f14b07a4 Merge pull request #260 from ColinIanKing/master
dmtbdump: remove redundant assigment to Length
2017-05-11 08:41:53 -07:00
Erik Schmauss
25886671ce disassembler: use memmove instead of malloc/free to move data
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2017-05-09 13:34:25 -07:00
Erik Schmauss
8cc341b3dd ASLTS: reverse the order of definition block declarations to test for a corner case
Reversing the order of defintion block declarations exposed an
issue in the compiler namespace loading. This issue has been fixed
and this change exercises the code involved in the bug fix.

Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2017-05-09 10:34:11 -07:00
Erik Schmauss
b9beef2abb iASL: fix namespace resolution for externals that refer to field units
This change allows the compilation of an external declaration that refers
to a field unit in a separate table.

Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2017-05-09 10:32:28 -07:00
Colin Ian King
2b944db5b7 dmtbdump: remove redundant assignment to Length
The assignment to Length is redundant as the stored value is
overwritten again before it is read. Issue detected by
CoverityScan CID#163885 ("Unused Value")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
2017-05-05 09:19:26 +01:00
Robert Moore
779cc529c3 Merge pull request #259 from ColinIanKing/master
Minor fixes, removal of rundandant assigments
2017-05-04 14:01:58 -07:00
Robert Moore
1a2fd848ac Merge pull request #258 from SchmErik/externalOpRefactor06
External op refactor06
2017-05-04 14:00:53 -07:00