Tables: Fix invalid pointer accesses in AcpiTbParseRootTable().

The commit of back porting Linux XSDT validation mechanism has introduced
a regreession:
  Commit: 4e917154c46af024a011ac90ca2f7782ae0a97da
  Subject: Add validation of the XSDT root table if present.
There is a pointer still accessed after unmapping.

This patch fixes this issue.  Lv Zheng.

Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=73911
Buglink: https://bugs.archlinux.org/task/39811
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Reported-and-tested-by: Bruce Chiarelli <mano155@gmail.com>
Reported-and-tested-by: Spyros Stathopoulos <spystath@gmail.com>
acpidump: Add support to force using RSDT.

This patch adds "-x" and "-x -x" options to disable XSDT for acpidump.

The single "-x" can be used to stop using XSDT, RSDT will be forced to find
static tables, note that XSDT will still be dumped. The double "-x" can
stop dumping XSDT, which is useful when the XSDT address reported by RSDP
is pointing to an invalid address.

It is reported there are platforms having broken XSDT shipped, acpidump
will stop working while accessing such XSDT. This patch adds new option so
that users can force acpidump to dump tables listed in the RSDT. Lv Zheng.

Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=73911
Buglink: https://bugs.archlinux.org/task/39811
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Reported-and-tested-by: Bruce Chiarelli <mano155@gmail.com>
Reported-and-tested-by: Spyros Stathopoulos <spystath@gmail.com>
Tables: Add new mechanism to skip NULL entries in RSDT and XSDT.

It is reported that there are buggy BIOSes in the world: AMI uses an XSDT
compiler for early BIOSes, this compiler will generate XSDT with a NULL
entry.  The affected BIOS versions are "AMI BIOS F2-F4".

Original solution on Linux is to use an alternative heathy root table
instead of the ill one.  This commit is:
  Commit: 4e917154c46af024a011ac90ca2f7782ae0a97da
  Subject: Add validation of the XSDT root table if present.

This is an example of such XSDT dumped from B85-HD3 (AMI F3 BIOS):
[000h 0000   4]                    Signature : "XSDT"    [Extended System Description Table]
[004h 0004   4]                 Table Length : 00000074
[008h 0008   1]                     Revision : 01
[009h 0009   1]                     Checksum : 18
[00Ah 0010   6]                       Oem ID : "ALASKA"
[010h 0016   8]                 Oem Table ID : "A M I"
[018h 0024   4]                 Oem Revision : 01072009
[01Ch 0028   4]              Asl Compiler ID : "AMI "
[020h 0032   4]        Asl Compiler Revision : 00010013

[024h 0036   8]       ACPI Table Address   0 : 00000000BA5F8180
[02Ch 0044   8]       ACPI Table Address   1 : 00000000BA5F8290
[034h 0052   8]       ACPI Table Address   2 : 00000000BA5F8308
[03Ch 0060   8]       ACPI Table Address   3 : 00000000BA5F8848
[044h 0068   8]       ACPI Table Address   4 : 00000000BA5F9320
[04Ch 0076   8]       ACPI Table Address   5 : 00000000BA5F9360
[054h 0084   8]       ACPI Table Address   6 : 00000000BA5F9398
[05Ch 0092   8]       ACPI Table Address   7 : 00000000BA5F9708
[064h d100   8]       ACPI Table Address   8 : 00000000BA5FC9A8
[06Ch 0108   8]       ACPI Table Address   9 : 0000000000000000

But according to the bug report, the XSDT in fact is not broken. In the
above XSDT, ACPI Table Address 1-8 contains the same value as RSDT.  The
differences can only be seen on the following 2 entries:
1. The first entry points to a FADT whose Revision is 5 while the first
   entry in RSDT points to a FADT whose Revision is 2.
   The FADT dumped from the address indicated by the first entry of XSDT:
    FACP @ 0x00000000BA5F8180
      0000: 46 41 43 50 0C 01 00 00<05>4B 41 4C 41 53 4B 41  FACP.....KALASKA
      ...
   The FADT dumped from the address indicated by the first entry of RSDT:
    FACP @ 0x00000000BA5ED0F0
      0000: 46 41 43 50 84 00 00 00<02>A7 41 4C 41 53 4B 41  FACP......ALASKA
      ...
2. The last entry is a NULL terminator.
According to the test result, the Revision 5 FADT is accessible.  Thus the
original solution turns out to be a work around that is preventing the
higher revision tables to be used for such platforms (they are all x86-64
platforms, and should use XSDT and higher revision FADT).

This patch offers a new solution, where a sanity check is performed before
installing a table address from XSDT. If the entry is NULL, it is simply
discarded.

Note that, this patch doesn't remove the original solution, so for Linux
kernel, this commit is actually a no-op, but it allows acpidump to be
working on such platforms. By doing so, we allow another easy revertable
commit to enable this feature so that when that commit is reverted, the
useful sanity check will not be affected. Lv Zheng.

Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=73911
Buglink: https://bugs.archlinux.org/task/39811
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Reported-and-tested-by: Bruce Chiarelli <mano155@gmail.com>
Reported-and-tested-by: Spyros Stathopoulos <spystath@gmail.com>
Cc: Zhao Yakui <yakui.zhao@intel.com>
Tables: Remove old mechanism to validate if XSDT contains NULL entries.

With the NULL entry sanity check implemented, the XSDT validation is
useless because:
1. If XSDT contains NULL entries, it can be bypassed by the new sanity
   check mechanism;
2. If RSDP contains a bad XSDT address, invoking XSDT validation will still
   lead to a kernel crash.

This patch deletes the old XSDT validation solution and thus enables the
new NULL entry sanity check solution.

Note that if there are reports reporting regressions caused by the enabling
of the new feature and disabling of the old feature, this commit should be
bisected and reverted. Lv Zheng.

Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=73911
Buglink: https://bugs.archlinux.org/task/39811
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Reported-and-tested-by: Bruce Chiarelli <mano155@gmail.com>
Reported-and-tested-by: Spyros Stathopoulos <spystath@gmail.com>
Cc: Zhao Yakui <yakui.zhao@intel.com>
Remove extraneous error message for large number of GPEs.

Fixes a problem where an extraneous error message was emitted during
initialization if there is a GPE block larger than 255 bits. Any
GPE block larger than 120 GPEs could generate the error.
Debugger: For GPE command, make GpeBlock optional.

The default is to use the FADT GPE blocks 0 and 1.
AcpiExec: Add tests for large number of GPEs.

Exercise code that supports GPEs > 120.
Events: Update GPE handling and initialization code.

1) Eliminate most use of GAS structs, since they are not needed
for GPEs.
2) Allow raw GPE numbers > 255.
Merge pull request #28 from zetalog/acpica-xsdt

Acpica xsdt
Update build.txt readme file for SSH.

Add some additional info about SSH access to the git tree.
Comment/format update, no functional change.

Add some additional commenting the the public acpixf.h file.
ACPICA Reference: Add section describing maximum number of GPEs.

New section answers questions about the maximum number of GPEs
that can be described by the FADT.
Logfile: Changes for version 20140424.

Version 20140424.
Update version to 20140424.

Version 20140424.
acpisrc: Add LPIT table conversions.

The following commit hasn't correctly updated acpisrc, which breaks Linux
builds after the linuxized result has been merged by Linux kernel.
  Commit: 6d8ce6539f40de7b6259ca882d8b4fbcfac65708
  Subject: Add support for LPIT table.
This patch fixes this issue.  Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Executer: Fix buffer allocation issue for GenericSerialBus region field accesses.

The size of the buffer allocated for GenericSerialBus region access
is not correct.  This patch introduces AcpiExGetSerialAccessLength()
to be invoked to obtain correct data buffer length.  Reported by
Lan Tianyu, Fixed by Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Merge pull request #29 from zetalog/acpica-201404

Merge from Lv Zheng's Acpica 201404 tree.
Debugger: free Pathname on error return path

Fix a memory leak on Pathname on an error return path.
bugs.acpica.org, bug #1086.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Utilities: Fix memory leak in AcpiUtCopyIobjectToIobject

Adds return status check on copy routines to delete the allocated destination
object if either copy fails. Reported by Colin Ian King on bugs.acpica.org,
Bug 1087.

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
acpidump: Fix repetitive table dump in -n mode.

In "-n" mode, reserved tables (RSDP/RSDT/XSDT/DSDT/FACS) are dumped
multiple times due a missing instance check in OslGetBiosTable().
This patch fixes this issue.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>