[PATCH] ACPI: Add ASPT test
Colin King
colin.king at canonical.com
Tue Dec 8 14:32:51 UTC 2015
From: Colin Ian King <colin.king at canonical.com>
This table is not well described anywhere, however it is a frequently
used table on AMD machines and the format is relatively simple set of
4 32 bit addresses. This table has been discussed on the ACPICA
devel mailing list:
https://lists.acpica.org/pipermail/devel/2015-November/000850.html
and this description matches the various acpi dumps of this table
on AMD machines that I have access too. I believe the table refers
to an AMD performance monitoring feature.
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
Makefile.am | 2 +
.../arg-show-tests-0001/arg-show-tests-0001.log | 2 +
.../arg-show-tests-full-0001.log | 4 +
fwts-test/aspt-0001/acpidump-0001.log | 30 ++++++
fwts-test/aspt-0001/acpidump-0002.log | 30 ++++++
fwts-test/aspt-0001/aspt-0001.log | 15 +++
fwts-test/aspt-0001/aspt-0002.log | 18 ++++
fwts-test/aspt-0001/test-0001.sh | 17 ++++
fwts-test/aspt-0001/test-0002.sh | 17 ++++
src/Makefile.am | 1 +
src/acpi/aspt/aspt.c | 113 +++++++++++++++++++++
src/lib/include/fwts_acpi.h | 12 +++
12 files changed, 261 insertions(+)
create mode 100644 fwts-test/aspt-0001/acpidump-0001.log
create mode 100644 fwts-test/aspt-0001/acpidump-0002.log
create mode 100644 fwts-test/aspt-0001/aspt-0001.log
create mode 100644 fwts-test/aspt-0001/aspt-0002.log
create mode 100755 fwts-test/aspt-0001/test-0001.sh
create mode 100755 fwts-test/aspt-0001/test-0002.sh
create mode 100644 src/acpi/aspt/aspt.c
diff --git a/Makefile.am b/Makefile.am
index 40b6025..86146da 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -51,6 +51,8 @@ TESTS = fwts-test/acpidump-0001/test-0001.sh \
fwts-test/arg-width-0001/test-0008.sh \
fwts-test/asf-0001/test-0001.sh \
fwts-test/asf-0001/test-0002.sh \
+ fwts-test/aspt-0001/test-0001.sh \
+ fwts-test/aspt-0001/test-0002.sh \
fwts-test/bert-0001/test-0001.sh \
fwts-test/bert-0001/test-0002.sh \
fwts-test/bgrt-0001/test-0001.sh \
diff --git a/fwts-test/arg-show-tests-0001/arg-show-tests-0001.log b/fwts-test/arg-show-tests-0001/arg-show-tests-0001.log
index a971cfe..0ef421e 100644
--- a/fwts-test/arg-show-tests-0001/arg-show-tests-0001.log
+++ b/fwts-test/arg-show-tests-0001/arg-show-tests-0001.log
@@ -3,6 +3,7 @@ ACPI tests:
acpitables ACPI table headers sanity tests.
apicinstance Test for single instance of APIC/MADT table.
asf ASF! Alert Standard Format Table test.
+ aspt ASPT Table test.
bert BERT Boot Error Record Table test.
bgrt BGRT Boot Graphics Resource Table test.
boot BOOT Table test.
@@ -54,6 +55,7 @@ Batch tests:
apicinstance Test for single instance of APIC/MADT table.
asf ASF! Alert Standard Format Table test.
aspm PCIe ASPM test.
+ aspt ASPT Table test.
autobrightness Automated LCD brightness test.
bert BERT Boot Error Record Table test.
bgrt BGRT Boot Graphics Resource Table test.
diff --git a/fwts-test/arg-show-tests-full-0001/arg-show-tests-full-0001.log b/fwts-test/arg-show-tests-full-0001/arg-show-tests-full-0001.log
index c2c73a6..e829b5c 100644
--- a/fwts-test/arg-show-tests-full-0001/arg-show-tests-full-0001.log
+++ b/fwts-test/arg-show-tests-full-0001/arg-show-tests-full-0001.log
@@ -9,6 +9,8 @@ ACPI tests:
Test for single instance of APIC/MADT table.
asf (1 test):
ASF! Alert Standard Format Table test.
+ aspt (1 test):
+ ASPT Table test.
bert (1 test):
BERT Boot Error Record Table test.
bgrt (1 test):
@@ -307,6 +309,8 @@ Batch tests:
aspm (2 tests):
PCIe ASPM ACPI test.
PCIe ASPM registers test.
+ aspt (1 test):
+ ASPT Table test.
autobrightness (2 tests):
Test for maximum and actual brightness.
Change actual brightness.
diff --git a/fwts-test/aspt-0001/acpidump-0001.log b/fwts-test/aspt-0001/acpidump-0001.log
new file mode 100644
index 0000000..130172c
--- /dev/null
+++ b/fwts-test/aspt-0001/acpidump-0001.log
@@ -0,0 +1,30 @@
+FACS @ 0x00000000
+ 0000: 46 41 43 53 40 00 00 00 00 00 00 00 00 00 00 00 FACS at ...........
+ 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0020: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+
+FACP @ 0x00000000
+ 0000: 46 41 43 50 f4 00 00 00 03 f9 41 4d 44 20 20 20 FACP......AMD
+ 0010: 47 55 41 4d 20 20 20 20 00 00 04 06 41 4d 44 20 GUAM ....AMD
+ 0020: 40 42 0f 00 c0 2f e9 af 92 47 e8 af 00 02 09 00 @B.../...G......
+ 0030: b0 00 00 00 f0 f1 00 00 00 80 00 00 00 00 00 00 ................
+ 0040: 04 80 00 00 00 00 00 00 00 82 00 00 08 80 00 00 ................
+ 0050: 20 80 00 00 00 00 00 00 04 02 01 04 08 00 00 00 ...............
+ 0060: 65 00 e9 03 00 00 00 00 01 00 0d 00 32 00 00 00 e...........2...
+ 0070: a5 c1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0080: 00 00 00 00 c0 2f e9 af 00 00 00 00 92 47 e8 af ...../.......G..
+ 0090: 00 00 00 00 01 20 00 00 00 80 00 00 00 00 00 00 ..... ..........
+ 00a0: 00 00 00 00 00 00 00 00 00 00 00 00 01 10 00 00 ................
+ 00b0: 04 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 00c0: 00 00 00 00 01 08 00 00 00 82 00 00 00 00 00 00 ................
+ 00d0: 01 20 00 00 08 80 00 00 00 00 00 00 01 40 00 00 . ........... at ..
+ 00e0: 20 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...............
+ 00f0: 00 00 00 00 ....
+
+ASPT @ 0x00000000
+ 0000: 41 53 50 54 34 00 00 00 04 8b 41 43 52 53 59 53 ASPT4.....ACRSYS
+ 0010: 41 43 52 50 52 44 43 54 01 00 00 00 31 30 32 35 ACRPRDCT....1025
+ 0020: 13 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0030: 00 00 00 00
diff --git a/fwts-test/aspt-0001/acpidump-0002.log b/fwts-test/aspt-0001/acpidump-0002.log
new file mode 100644
index 0000000..17ab117
--- /dev/null
+++ b/fwts-test/aspt-0001/acpidump-0002.log
@@ -0,0 +1,30 @@
+FACS @ 0x00000000
+ 0000: 46 41 43 53 40 00 00 00 00 00 00 00 00 00 00 00 FACS at ...........
+ 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0020: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+
+FACP @ 0x00000000
+ 0000: 46 41 43 50 f4 00 00 00 03 f9 41 4d 44 20 20 20 FACP......AMD
+ 0010: 47 55 41 4d 20 20 20 20 00 00 04 06 41 4d 44 20 GUAM ....AMD
+ 0020: 40 42 0f 00 c0 2f e9 af 92 47 e8 af 00 02 09 00 @B.../...G......
+ 0030: b0 00 00 00 f0 f1 00 00 00 80 00 00 00 00 00 00 ................
+ 0040: 04 80 00 00 00 00 00 00 00 82 00 00 08 80 00 00 ................
+ 0050: 20 80 00 00 00 00 00 00 04 02 01 04 08 00 00 00 ...............
+ 0060: 65 00 e9 03 00 00 00 00 01 00 0d 00 32 00 00 00 e...........2...
+ 0070: a5 c1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 0080: 00 00 00 00 c0 2f e9 af 00 00 00 00 92 47 e8 af ...../.......G..
+ 0090: 00 00 00 00 01 20 00 00 00 80 00 00 00 00 00 00 ..... ..........
+ 00a0: 00 00 00 00 00 00 00 00 00 00 00 00 01 10 00 00 ................
+ 00b0: 04 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+ 00c0: 00 00 00 00 01 08 00 00 00 82 00 00 00 00 00 00 ................
+ 00d0: 01 20 00 00 08 80 00 00 00 00 00 00 01 40 00 00 . ........... at ..
+ 00e0: 20 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...............
+ 00f0: 00 00 00 00 ....
+
+ASPT @ 0x00000000
+ 0000: 41 53 50 54 34 00 00 00 04 8b 41 43 52 53 59 53 ASPT4.....ACRSYS
+ 0010: 41 43 52 50 52 44 43 54 01 00 00 00 31 30 32 35 ACRPRDCT....1025
+ 0020: 13 00 00 01 20 00 00 f0 00 00 00 f0 10 00 00 e0 ................
+ 0030: 00 00 00 e0
diff --git a/fwts-test/aspt-0001/aspt-0001.log b/fwts-test/aspt-0001/aspt-0001.log
new file mode 100644
index 0000000..b35c02e
--- /dev/null
+++ b/fwts-test/aspt-0001/aspt-0001.log
@@ -0,0 +1,15 @@
+aspt aspt: ASPT Table test.
+aspt ----------------------------------------------------------
+aspt Test 1 of 1: ASPT Table test.
+aspt ASPT Table:
+aspt SPTT Start Address: 0x00000000
+aspt SPTT End Address: 0x00000000
+aspt AMRT Start Address: 0x00000000
+aspt AMRT End Address: 0x00000000
+aspt
+aspt PASSED: Test 1, No issues found in ASPT table.
+aspt
+aspt ==========================================================
+aspt 1 passed, 0 failed, 0 warning, 0 aborted, 0 skipped, 0
+aspt info only.
+aspt ==========================================================
diff --git a/fwts-test/aspt-0001/aspt-0002.log b/fwts-test/aspt-0001/aspt-0002.log
new file mode 100644
index 0000000..4ceb3ad
--- /dev/null
+++ b/fwts-test/aspt-0001/aspt-0002.log
@@ -0,0 +1,18 @@
+aspt aspt: ASPT Table test.
+aspt ----------------------------------------------------------
+aspt Test 1 of 1: ASPT Table test.
+aspt ASPT Table:
+aspt SPTT Start Address: 0xf0000020
+aspt SPTT End Address: 0xf0000000
+aspt AMRT Start Address: 0xe0000010
+aspt AMRT End Address: 0xe0000000
+aspt
+aspt FAILED [HIGH] ASPTSpttEndError: Test 1, ASPT SPTT end
+aspt address is less than the APTT start address.
+aspt FAILED [HIGH] ASPTAmrtEndError: Test 1, ASPT AMRT end
+aspt address is less than the AMRT start address.
+aspt
+aspt ==========================================================
+aspt 0 passed, 2 failed, 0 warning, 0 aborted, 0 skipped, 0
+aspt info only.
+aspt ==========================================================
diff --git a/fwts-test/aspt-0001/test-0001.sh b/fwts-test/aspt-0001/test-0001.sh
new file mode 100755
index 0000000..1aa316b
--- /dev/null
+++ b/fwts-test/aspt-0001/test-0001.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+TEST="Test apcitables against ASPT"
+NAME=test-0001.sh
+TMPLOG=$TMP/aspt.log.$$
+
+$FWTS --log-format="%line %owner " -w 80 --dumpfile=$FWTSTESTDIR/aspt-0001/acpidump-0001.log aspt - | cut -c7- | grep "^aspt" > $TMPLOG
+diff $TMPLOG $FWTSTESTDIR/aspt-0001/aspt-0001.log >> $FAILURE_LOG
+ret=$?
+if [ $ret -eq 0 ]; then
+ echo PASSED: $TEST, $NAME
+else
+ echo FAILED: $TEST, $NAME
+fi
+
+rm $TMPLOG
+exit $ret
diff --git a/fwts-test/aspt-0001/test-0002.sh b/fwts-test/aspt-0001/test-0002.sh
new file mode 100755
index 0000000..3c379bd
--- /dev/null
+++ b/fwts-test/aspt-0001/test-0002.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+TEST="Test apcitables against invalid ASPT"
+NAME=test-0001.sh
+TMPLOG=$TMP/aspt.log.$$
+
+$FWTS --log-format="%line %owner " -w 80 --dumpfile=$FWTSTESTDIR/aspt-0001/acpidump-0002.log aspt - | cut -c7- | grep "^aspt" > $TMPLOG
+diff $TMPLOG $FWTSTESTDIR/aspt-0001/aspt-0002.log >> $FAILURE_LOG
+ret=$?
+if [ $ret -eq 0 ]; then
+ echo PASSED: $TEST, $NAME
+else
+ echo FAILED: $TEST, $NAME
+fi
+
+rm $TMPLOG
+exit $ret
diff --git a/src/Makefile.am b/src/Makefile.am
index 6336b7d..f257a7f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,6 +30,7 @@ fwts_SOURCES = main.c \
acpi/acpitables/acpitables.c \
acpi/apicinstance/apicinstance.c \
acpi/asf/asf.c \
+ acpi/aspt/aspt.c \
acpi/battery/battery.c \
acpi/bert/bert.c \
acpi/bgrt/bgrt.c \
diff --git a/src/acpi/aspt/aspt.c b/src/acpi/aspt/aspt.c
new file mode 100644
index 0000000..29c0cc5
--- /dev/null
+++ b/src/acpi/aspt/aspt.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2015 Canonical
+ *
+ * Portions of this code original from the Linux-ready Firmware Developer Kit
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#include "fwts.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <inttypes.h>
+#include <string.h>
+
+static fwts_acpi_table_info *table;
+
+static int aspt_init(fwts_framework *fw)
+{
+
+ if (fwts_acpi_find_table(fw, "ASPT", 0, &table) != FWTS_OK) {
+ fwts_log_error(fw, "Cannot read ACPI tables.");
+ return FWTS_ERROR;
+ }
+ if (table == NULL || (table && table->length == 0)) {
+ fwts_log_error(fw, "ACPI ASPT table does not exist, skipping test");
+ return FWTS_SKIP;
+ }
+
+ return FWTS_OK;
+}
+
+/*
+ * ASPT Table
+ * (reverse engineered, table is common on AMD machines)
+ */
+static int aspt_test1(fwts_framework *fw)
+{
+ bool passed = true;
+ fwts_acpi_table_aspt *aspt = (fwts_acpi_table_aspt *)table->data;
+
+ if (table->length < sizeof(fwts_acpi_table_aspt)) {
+ passed = false;
+ fwts_failed(fw, LOG_LEVEL_HIGH,
+ "ASPTTooShort",
+ "ASPT table too short, expecting %zu bytes, "
+ "instead got %zu bytes",
+ sizeof(fwts_acpi_table_aspt), table->length);
+ goto done;
+ }
+
+ fwts_log_info_verbatum(fw, "ASPT Table:");
+ fwts_log_info_verbatum(fw, " SPTT Start Address: 0x%8.8" PRIx32,
+ aspt->sptt_addr_start);
+ fwts_log_info_verbatum(fw, " SPTT End Address: 0x%8.8" PRIx32,
+ aspt->sptt_addr_end);
+ fwts_log_info_verbatum(fw, " AMRT Start Address: 0x%8.8" PRIx32,
+ aspt->amrt_addr_start);
+ fwts_log_info_verbatum(fw, " AMRT End Address: 0x%8.8" PRIx32,
+ aspt->amrt_addr_end);
+ fwts_log_nl(fw);
+
+ /*
+ * Without a specification to work with there is very
+ * little we can do to validate this apart from the
+ * simplest sanity check
+ */
+ if (aspt->sptt_addr_end < aspt->sptt_addr_start) {
+ fwts_failed(fw, LOG_LEVEL_HIGH,
+ "ASPTSpttEndError",
+ "ASPT SPTT end address is less than the APTT start "
+ "address.");
+ passed = false;
+ }
+ if (aspt->amrt_addr_end < aspt->amrt_addr_start) {
+ fwts_failed(fw, LOG_LEVEL_HIGH,
+ "ASPTAmrtEndError",
+ "ASPT AMRT end address is less than the AMRT start "
+ "address.");
+ passed = false;
+ }
+done:
+ if (passed)
+ fwts_passed(fw, "No issues found in ASPT table.");
+
+ return FWTS_OK;
+}
+
+static fwts_framework_minor_test aspt_tests[] = {
+ { aspt_test1, "ASPT Table test." },
+ { NULL, NULL }
+};
+
+static fwts_framework_ops aspt_ops = {
+ .description = "ASPT Table test.",
+ .init = aspt_init,
+ .minor_tests = aspt_tests
+};
+
+FWTS_REGISTER("aspt", &aspt_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_BATCH | FWTS_FLAG_TEST_ACPI)
diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h
index cf8f4b8..a0f26e5 100644
--- a/src/lib/include/fwts_acpi.h
+++ b/src/lib/include/fwts_acpi.h
@@ -1410,4 +1410,16 @@ typedef struct {
fwts_acpi_table_wdat_instr_entries entries[0];
} __attribute__ ((packed)) fwts_acpi_table_wdat;
+/*
+ * ACPI ASPT
+ * determined by reverse engineering
+ */
+typedef struct {
+ fwts_acpi_table_header header;
+ uint32_t sptt_addr_start;
+ uint32_t sptt_addr_end;
+ uint32_t amrt_addr_start;
+ uint32_t amrt_addr_end;
+} __attribute__ ((packed)) fwts_acpi_table_aspt;
+
#endif
--
2.6.2
More information about the fwts-devel
mailing list