13700 Commits

Author SHA1 Message Date
Erik Schmauss
a73816a2a2 ASLTS: changing the third argument of ERR to __LINE__ to print line numbers instead of indices.
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2017-07-21 16:54:23 -07:00
Erik Schmauss
6f3586d458 ASLTS: getting rid of unnecessary error reporting.
This error information is redundant.

Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2017-07-21 16:54:23 -07:00
Robert Moore
9764428654 Merge pull request #291 from al3xtjames/master
Unix makefiles: Add OPT_LDFLAGS and edit NOOPT parsing
2017-07-20 09:16:01 -07:00
Robert Moore
d2fd729f28 Merge pull request #293 from SchmErik/aslts_descriptor
ASLTS: descriptor: update test buffers to include shared bit in V2 de…
2017-07-20 09:14:27 -07:00
Robert Moore
30c7201369 Merge pull request #294 from SchmErik/iasl_feature001
iASL: add option to expect specific compilation remarks/warnings/errors
2017-07-20 09:13:53 -07:00
Seunghun Han
37f2c716f2 acpi: acpica: fix acpi operand cache leak in nseval.c
I found an ACPI cache leak in ACPI early termination and boot continuing case.

When early termination occurs due to malicious ACPI table, Linux kernel
terminates ACPI function and continues to boot process. While kernel terminates
ACPI function, kmem_cache_destroy() reports Acpi-Operand cache leak.

Boot log of ACPI operand cache leak is as follows:
>[    0.464168] ACPI: Added _OSI(Module Device)
>[    0.467022] ACPI: Added _OSI(Processor Device)
>[    0.469376] ACPI: Added _OSI(3.0 _SCP Extensions)
>[    0.471647] ACPI: Added _OSI(Processor Aggregator Device)
>[    0.477997] ACPI Error: Null stack entry at ffff880215c0aad8 (20170303/exresop-174)
>[    0.482706] ACPI Exception: AE_AML_INTERNAL, While resolving operands for [OpcodeName unavailable] (20170303/dswexec-461)
>[    0.487503] ACPI Error: Method parse/execution failed [\DBG] (Node ffff88021710ab40), AE_AML_INTERNAL (20170303/psparse-543)
>[    0.492136] ACPI Error: Method parse/execution failed [\_SB._INI] (Node ffff88021710a618), AE_AML_INTERNAL (20170303/psparse-543)
>[    0.497683] ACPI: Interpreter enabled
>[    0.499385] ACPI: (supports S0)
>[    0.501151] ACPI: Using IOAPIC for interrupt routing
>[    0.503342] ACPI Error: Null stack entry at ffff880215c0aad8 (20170303/exresop-174)
>[    0.506522] ACPI Exception: AE_AML_INTERNAL, While resolving operands for [OpcodeName unavailable] (20170303/dswexec-461)
>[    0.510463] ACPI Error: Method parse/execution failed [\DBG] (Node ffff88021710ab40), AE_AML_INTERNAL (20170303/psparse-543)
>[    0.514477] ACPI Error: Method parse/execution failed [\_PIC] (Node ffff88021710ab18), AE_AML_INTERNAL (20170303/psparse-543)
>[    0.518867] ACPI Exception: AE_AML_INTERNAL, Evaluating _PIC (20170303/bus-991)
>[    0.522384] kmem_cache_destroy Acpi-Operand: Slab cache still has objects
>[    0.524597] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.12.0-rc5 #26
>[    0.526795] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
>[    0.529668] Call Trace:
>[    0.530811]  ? dump_stack+0x5c/0x81
>[    0.532240]  ? kmem_cache_destroy+0x1aa/0x1c0
>[    0.533905]  ? acpi_os_delete_cache+0xa/0x10
>[    0.535497]  ? acpi_ut_delete_caches+0x3f/0x7b
>[    0.537237]  ? acpi_terminate+0xa/0x14
>[    0.538701]  ? acpi_init+0x2af/0x34f
>[    0.540008]  ? acpi_sleep_proc_init+0x27/0x27
>[    0.541593]  ? do_one_initcall+0x4e/0x1a0
>[    0.543008]  ? kernel_init_freeable+0x19e/0x21f
>[    0.546202]  ? rest_init+0x80/0x80
>[    0.547513]  ? kernel_init+0xa/0x100
>[    0.548817]  ? ret_from_fork+0x25/0x30
>[    0.550587] vgaarb: loaded
>[    0.551716] EDAC MC: Ver: 3.0.0
>[    0.553744] PCI: Probing PCI hardware
>[    0.555038] PCI host bridge to bus 0000:00
> ... Continue to boot and log is omitted ...

I analyzed this memory leak in detail and found AcpiNsEvaluate() function
only removes Info->ReturnObject in AE_CTRL_RETURN_VALUE case. But, when errors
occur, the status value is not AE_CTRL_RETURN_VALUE, and Info->ReturnObject is
also not null. Therefore, this causes acpi operand memory leak.

This cache leak causes a security threat because an old kernel (<= 4.9) shows
memory locations of kernel functions in stack dump. Some malicious users
could use this information to neutralize kernel ASLR.

I made a patch to fix ACPI operand cache leak.

Signed-off-by: Seunghun Han <kkamagui@gmail.com>
2017-07-19 17:32:11 +09:00
Erik Schmauss
2d27a12fde iASL: add option to expect specific compilation remarks/warnings/errors
The -vx [messageId] option, where the x stands for EXpect, allows the
compiler to expect that the compilation will result in an ASL exception
with a particular messageId. If this error is not raised. The
compilation will result in an error. This will help create a whole new
class of compilation tests in ASLTS.

Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2017-07-18 16:04:40 -07:00
Erik Schmauss
8c09a8784e ASLTS: descriptor: update test buffers to include shared bit in V2 descriptors
These tests compare a resource descriptor and an equivalent buffer to ensure
proper resource descriptor compilation. The buffer does not account for the
shared bit for V2 resource descriptors (see section 6.4.3.8.2.x in the ACPI
6.2 spec). This commit changes this test buffer to include the shared bit
(the 3rd bit of the 6th byte of V2 resource descriptors). The specification
is expected to reflect these changes (sections 6.4.3.8.2.1, 6.4.3.8.2.2, and
6.4.3.8.2.3).

Updated buffers include buffers equivalent to I2cSearialBusv2, SpiSerialBusv2,
and UartSerialBusv2

Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2017-07-17 14:29:33 -07:00
Lv Zheng
a7c6d65a5d EFI/EDK2: Enable /WX for MSVC builds
/WX turns warning into fatal erros for MSVC builds. We need /WX- during
EDK2 porting to allow agile development.

Now it is time to enable /WX. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-07-13 14:32:15 +08:00
Shao, Ming
f9450316d8 EFI/EDK2: Add support to compile acpidump.efi with StdLib
This patch ports acpidump EDKII build to the environment where EDKII
internal C-library StdLib is used. Shao Ming.

Signed-off-by: "Shao, Ming" <smbest163@163.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-07-13 14:21:48 +08:00
Lv Zheng
ae846edff2 EFI: Add AcpiOsStall()/AcpiOsSleep() support
This patch adds AcpiOsStall() and AcpiOsSleep() support.
Currently we do not support asynchronous polling of key stroke and timer,
so AcpiOsSleep() is simply an invocation of AcpiOsStall(). Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-07-13 14:21:46 +08:00
Lv Zheng
f610e149bc EFI: Add AcpiOsGetTimer() support
This patch adds AcpiOsGetTimer() support for EFI environment.
Note that currently we don't support timezone. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-07-13 14:15:06 +08:00
Lv Zheng
06eafca73d EFI: Add stubs for multi-threading OSLs to make EFI ported applications running
This patch only adds stub supports for multi-threading OSLs to make
EFI ported application running.

In order to fully support acpiexec in a non multi-threading environment,
ACPICA core itself need to be upgraded to contain full asynchrnous support.
Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-07-13 14:14:51 +08:00
Lv Zheng
45bb76a55a EFI: Add OSL supports for those can be empty
This patch adds OSLs that can be empty under EFI environment. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-07-13 14:14:43 +08:00
Lv Zheng
4683013633 EFI/EDK2: Allow StdLib target to use different inf/dsc files
This patch adds support in edksetup.sh to allow StdLib build target to
use different inf/dsc files. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-07-13 14:14:26 +08:00
Lv Zheng
343fc31840 acpidump: Add DSDT/FACS instance support for Linux and EFI
ACPI spec allows to configure different 32-bit/64-bit table addresses for
DSDT and FACS. And for FACS, it's meaningful to dump both of them as they
are used to support different suspend protocols.

While:
1. on Linux, only 1 instance is supported for DSDT/FACS; and
2. on EFI, the code in OslGetTable() is buggy with special table instances,
   causing endless file dump for such tables (reported by Shao Ming in link
   #2).

This patch adds DSDT/FACS instance support for Linux/EFI but doesn't cover
BSD as BSD acpidump needs a full refresh. Fixed by Lv Zheng.

Link: https://bugs.acpica.org/show_bug.cgi?id=1407 [#1]
Link: https://github.com/acpica/acpica/issues/285  [#2]
Reported-by: Shao Ming <smbest163@163.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-07-13 14:14:24 +08:00
Lv Zheng
01b8f5a235 CLib: Add short multiply/shift support
In order to build ACPICA EFI tools with EDK-II on Windows, 64-bit
multiply/shift supports are also required to be implemented. Otherwise,
MSVC complains:
 acpidump.lib(utstrtoul64.obj) : error LNK2001: unresolved external symbol __allmul
 acpidump.lib(uthex.obj) : error LNK2001: unresolved external symbol __aullshr

Note:
1. This patch also splits _EDK2_EFI from _GNU_EFI as they might have
   different math64 supports.
2. Support of gcc math64 is not included in this patch.
3. Support of EDK2 arch independent math64 is done via linking to BaseLib.

This patch fixes this issue. Reported by Shao Ming, fixed by Lv Zheng.

Tested-by: "Shao, Ming" <smbest163@163.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-07-13 14:14:20 +08:00
Shao Ming
43ff22215f EFI/EDK2: Add support to compile acpidump.efi on Windows
Several changes are needed to compile EDK-II port of acpidump on
Windows:
1. sort acpi.h inclusion: va_list is used before it's definition, we
   only need to ensure order of acenv.h/acenvex.h/actypes.h.
2. /GL-: enabling global optimization causes memset() to be linked by
   MSVC builds.
3. /DUSE_MS_ABI: to enable simpler uefi_call_wrapper().
4. /D__x86_64__|__i386__: they are strictly required by ACPICA headers,
   but not defined by MSVC.

Signed-off-by: "Shao, Ming" <smbest163@163.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-07-13 14:14:16 +08:00
Robert Moore
b542af9a4c iASL: Fix an incorrectly placed range check
Variable was being used before the range check.
From GitHub user dcb314.
2017-07-12 10:26:22 -07:00
Robert Moore
d586c29a02 Add a comment, no functional change
Describe 2nd byte of the EndTag resource descriptor.
2017-07-11 12:05:40 -07:00
Robert Moore
98bf1d6bac Merge branch 'master' of ssh://ssh.github.com/acpica/acpica 2017-07-11 10:35:13 -07:00
Robert Moore
edfdd7b591 Merge pull request #290 from zetalog/acpica-1706
Acpica 1706
2017-07-11 10:31:11 -07:00
Robert Moore
8b7fa979ef Namespace: Update/fix an error message
Was emitting an internal namestring without converting it to
the external format.
2017-07-11 09:18:09 -07:00
Alex James
e79e1133a9 Unix makefiles: Add OPT_LDFLAGS and edit NOOPT parsing
Add OPT_LDFLAGS to be specified during compilation for custom linker
flags. Disable optimization (adding -O0) when NOOPT is set to true.
2017-07-11 08:54:58 -05:00
James Morse
5ad4f0b7bf iASL: Add support for the SDEI table
ACPI 6.2 adds support for the Software Delegated Exception Interface,
which is described by "Software Delegated Exception Interface (SDEI)"
ARM DEN0054A.

Add the necessary types in the ACPICA header files and support for
compiling/decompiling the table.

Signed-off-by: James Morse <james.morse@arm.com>
2017-07-11 09:26:26 +01:00
James Morse
e3c74a3d69 iASL: Allow 'header only' simple tables
Today DtCompileTable() will return AE_BAD_PARAMETER if it has already
reached the end of the FieldList. This prevents it building the SDEI
table (which is only a table header) as a simple table.

Explicitly check whether there are more fields before calling
DtCompileTable() on the simple-table compile path.

Signed-off-by: James Morse <james.morse@arm.com>
2017-07-11 09:26:26 +01:00
Rafael J. Wysocki
0013cb824a Revert "Disassembler: Enhance resource descriptor detection"
Revert commit ba5020b2dbe (Disassembler: Enhance resource
descriptor detection) as it is based on an assumption that doesn't
hold all the time and causes problems to happen because of that.

Broken platform:
 HPE Moonshot ProLiant DL380Gen9
 HPE Moonshot M400 Server Cartridge

Reported-by: Linda Knippers <linda.knippers@hpe.com>
Reported-by: Graeme Gregory <graeme.gregory@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-07-10 13:59:56 +08:00
Lv Zheng
cf27b3c988 Divergences: reduce access size definitions
Linux guys start to define access size values for
ACPI_RESOURCE_GENERIC_REGISTER, while it should be better to just define
the access_size -> access_bit_width algorithm and deply it for both
ACPI_RESOURCE_GENERIC_REGISTER and ACPI_GENERIC_ADDRESS types. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-07-10 13:59:54 +08:00
Lv Zheng
04c28c7549 acpiexec: Add testability of deferred table verification
This patch adds testability of deferred table verification mechanism. As
acpiexec uses dynamically allocated root table list from its very early
stage, a change to AcpiReallocateRootTable() is required to allow deferred
table verification mechanism to be triggered in such an environment. Note
that AcpiGbl_EnableTableValidation is still TRUE by default, thus:
1. Developers need to manually set AcpiGbl_EnableTableValidation to FALSE
   for acpiexec to enable this test.
2. For all other OSPMs (Linux, BSDs, etc.), this commit is a no-op.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-07-10 10:17:29 +08:00
Robert Moore
41e7b3575c Merge pull request #287 from zetalog/acpica-tables
Acpica tables
2017-06-30 11:10:23 -07:00
Lv Zheng
ffddee6638 Tables: Enable duplication check for late stage
This patch enables duplication check for late stage. The previous fixes
only prepare mechanism for late stage table verification and checksum
verification is enabled by default. But an explicit !Null TableIndex is
required to enable duplication check for late stage. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-06-30 10:09:42 +08:00
Robert Moore
167e48f20c iASL: Add __METHOD__ predefined macro
Returns the name of the parent control method.
2017-06-29 13:27:57 -07:00
Robert Moore
7271c1c54c Update version to 20170629
Version 20170629
R06_29_17
2017-06-29 08:03:47 -07:00
Robert Moore
3aae6b031d Logfile: Changes for version 20170629
Version 20170629
2017-06-29 08:02:45 -07:00
Robert Moore
998836ef88 Revert "Executer: adapt buffer length for Field Attrib Raw Process in Ops Region"
This reverts commit d28f6c2927053d85f33780b66c0d9050f0e30d3a.

This appears to be a workaround for some bad ASL or other code. This
type of code should not be in the ACPICA code.
2017-06-28 13:33:35 -07:00
Robert Moore
eba92e4224 Merge pull request #284 from gpkulkarni/iort_smmuv3_update
iasl: Update to IORT SMMUv3 disassembling
2017-06-28 07:23:37 -07:00
Robert Moore
1ac9974b58 Merge pull request #282 from SchmErik/bz1391
Revert "Update resource descriptor handling"
2017-06-28 07:21:54 -07:00
Ganapatrao Kulkarni
8cadc4fb50 iasl: Update to IORT SMMUv3 disassembling
ARM IORT specification has provision to define Proximity domain
in SMMUv3 IORT table. Adding required changes to decode
Proximity domain of SMMUv3 IORT table.

Signed-off-by: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
2017-06-28 15:02:07 +05:30
Robert Moore
3c01b0951c Merge pull request #283 from SchmErik/iaslExternalFix02
Iasl external fix02
2017-06-27 16:04:52 -07:00
Erik Schmauss
5128595509 iasl: fix field unit compilation
Field unit objects now result in compilation error when
there is a declaration and an external declaration of the
field unit object within the same file.

Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2017-06-27 15:23:12 -07:00
Robert Moore
2dfcdca562 Merge pull request #281 from zetalog/acpica-tables2
Acpica tables2
2017-06-27 14:54:02 -07:00
Erik Schmauss
ed25461901 Disassembler: skip parsing of incorrect external declarations
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
2017-06-27 14:50:40 -07:00
Robert Moore
b4be602bc2 Merge pull request #280 from al3xtjames/master
iASL: Ensure that the target node is valid in AcpiExCreateAlias
2017-06-27 14:12:30 -07:00
Erik Schmauss
f3300640c6 Revert "Update resource descriptor handling"
This reverts commit c8eac10178b387f9eb1935694e509d4518da77bb.
2017-06-27 14:06:14 -07:00
Alex James
8b14afac65 iASL: Ensure that the target node is valid in AcpiExCreateAlias
The following ACPI table contains an invalid target node within the
Alias operator:

DefinitionBlock ("", "SSDT", 1, "Bug", "BugTable", 0x00001000)
{
    Scope (_SB)
    {
        Device (DEV0)
        {
            Name (_ADR, 1)

            Device (DEV1)
            {
                Alias (_ADR, _ADR)
            }
        }
    }
}

If an ACPI table contains such an invalid target node in an Alias
operator, a segmentation fault will occur when the target node is
dereferenced within AcpiExCreateAlias. Add a check for such an invalid
target node in AcpiExCreateAlias and return AE_NULL_OBJECT as suggested
by @acpibob.
2017-06-27 14:30:09 -05:00
Robert Moore
2bfbe707f1 Merge pull request #277 from bentiss/attribRawProcessBytes
Executer: adapt buffer length for Field Attrib Raw Process in Ops Region
2017-06-27 09:19:39 -07:00
Lv Zheng
2dd6c151d5 Tables: Add deferred table verification support
This patch allows tables not verified in early stage verfied in
AcpiReallocateRootTable(). This is useful for OSPMs like linux where tables
cannot be verified in early stage due to early ioremp limitations on some
architectures. Reported by Hans de Geode, fixed by Lv Zheng.

Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-06-26 08:30:18 +08:00
Lv Zheng
182bdffc06 Tables: Combine checksum/duplication verification together
They are all mechanisms used to verify if a table is qualified to be
installed and controlled by AcpiGbl_EnableTableValidation, so combine them
together. By doing so, table duplication check is applied to the statically
loaded tables (however whether it is actually enabled is still determined
by AcpiGbl_EnableTableValidation). Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-06-26 08:30:18 +08:00
Lv Zheng
3d837b5d4b Tables: Change table duplication check to be related to AcpiGbl_VerifyTableChecksum
AcpiGbl_VerifyTableChecksum is used to avoid validating (mapping) an entire
table in OS boot stage. 2nd "Reload" check in AcpiTbInstallStandardTable()
is prepared for the same purpose. So this patch combines them together
using a renamed AcpiGbl_EnableTableValidation flag. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-06-26 08:30:18 +08:00
Lv Zheng
d3c944f2cd Tables: Do not validate signature for dynamic table load
Windows seems to allow arbitrary table signatures for Load/LoadTable
opcodes:
  ACPI BIOS Error (bug): Table has invalid signature [PRAD] (0x44415250)
So this patch removes dynamic load signature checks. However we need to
find a way to avoid table loading against tables like MADT. This is not
covered by this commit.

This Windows behavior has been validated on link #1. An end user bug
report can also be found on link #2.

This patch also includes simple cleanup for static load signature check
code. Reported by Ye Xiaolong, Fixed by Lv Zheng.

Link: https://github.com/acpica/acpica/pull/121 [#1]
Link: https://bugzilla.kernel.org/show_bug.cgi?id=118601 [#2]
Reported-by: Ye Xiaolong <xiaolong.ye@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
2017-06-26 08:30:17 +08:00