Message ID | 1435213617-4515-1-git-send-email-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
On 2015年06月25日 14:26, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > This checks for errors in the ACPI CPEP > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/Makefile.am | 1 + > src/acpi/cpep/cpep.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 129 insertions(+) > create mode 100644 src/acpi/cpep/cpep.c > > diff --git a/src/Makefile.am b/src/Makefile.am > index 3829d09..05170c1 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -36,6 +36,7 @@ fwts_SOURCES = main.c \ > acpi/brightness/brightness.c \ > acpi/brightness/autobrightness.c \ > acpi/checksum/checksum.c \ > + acpi/cpep/cpep.c \ > acpi/crsdump/crsdump.c \ > acpi/crsdump/prsdump.c \ > acpi/cstates/cstates.c \ > diff --git a/src/acpi/cpep/cpep.c b/src/acpi/cpep/cpep.c > new file mode 100644 > index 0000000..6b717c4 > --- /dev/null > +++ b/src/acpi/cpep/cpep.c > @@ -0,0 +1,128 @@ > +/* > + * 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> > +#include <ctype.h> > + > +static fwts_acpi_table_info *table; > + > +static int cpep_init(fwts_framework *fw) > +{ > + if (fwts_acpi_find_table(fw, "CPEP", 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 CPEP table does not exist, skipping test"); > + return FWTS_SKIP; > + } > + return FWTS_OK; > +} > + > +/* > + * CPEP Corrected Platform Error Polling Table > + */ > +static int cpep_test1(fwts_framework *fw) > +{ > + fwts_acpi_table_cpep *cpep = (fwts_acpi_table_cpep*)table->data; > + bool passed = true; > + uint32_t i, n; > + > + fwts_log_info_verbatum(fw, "CPEP Corrected Platform Error Polling Table:"); > + fwts_log_info_verbatum(fw, " Reserved: " > + " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 > + " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 , > + cpep->reserved[0], cpep->reserved[1], cpep->reserved[2], cpep->reserved[3], > + cpep->reserved[4], cpep->reserved[4], cpep->reserved[6], cpep->reserved[7]); > + > + if (cpep->reserved[0] | cpep->reserved[1] | > + cpep->reserved[2] | cpep->reserved[3] | > + cpep->reserved[4] | cpep->reserved[5] | > + cpep->reserved[6] | cpep->reserved[7]) { > + passed = false; > + fwts_failed(fw, LOG_LEVEL_MEDIUM, > + "CPEPNonZeroReserved", > + "CPEP: Reserved field contains a non-zero value"); > + } > + n = (table->length - sizeof(fwts_acpi_table_cpep)) / > + sizeof(fwts_acpi_cpep_processor_info); > + > + for (i = 0; i < n; i++) { > + bool cpep_passed = true; > + fwts_acpi_cpep_processor_info *info = &cpep->cpep_info[i]; > + > + if (info->type != 0) { > + cpep_passed = false; > + fwts_failed(fw, LOG_LEVEL_HIGH, > + "CPEPInvalidProcStructureType", > + "CPEP: Processor Structure %" PRIu32 > + " Type field is 0x%" PRIx8 > + " and was expected to be 0x00", > + i, info->type); > + } > + if (info->length != 8) { > + cpep_passed = false; > + fwts_failed(fw, LOG_LEVEL_MEDIUM, > + "CPEPInvalidProcStructureType", > + "CPEP: Processor Structure %" PRIu32 > + " Length field is 0x%" PRIx8 > + " and was expected to be 0x08", > + i, info->length); > + } > + /* Should probably sanity check processor UID, EIDs at a later date */ > + > + /* Some feedback if polling interval is very short */ > + if (info->polling_interval < 5) { > + fwts_warning(fw, "CPEP Processor Structure %" PRIu32 > + " Polling Interval of %" PRIu32 > + " milliseconds is relatively short and may " > + "cause excessive polling CPU load", > + i, info->polling_interval); > + } > + if (cpep_passed) > + fwts_log_info(fw, "CPEP Processor Structure %" PRIu32 " looks sane.", i); > + passed &= cpep_passed; > + } > + > + > + if (passed) > + fwts_passed(fw, "No issues found in CPEP table."); > + > + return FWTS_OK; > +} > + > +static fwts_framework_minor_test cpep_tests[] = { > + { cpep_test1, "CPEP Corrected Platform Error Polling Table test." }, > + { NULL, NULL } > +}; > + > +static fwts_framework_ops cpep_ops = { > + .description = "CPEP Corrected Platform Error Polling Table test.", > + .init = cpep_init, > + .minor_tests = cpep_tests > +}; > + > +FWTS_REGISTER("cpep", &cpep_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_BATCH | FWTS_FLAG_TEST_ACPI) Acked-by: Ivan Hu<ivan.hu@canonical.com>
On 06/25/2015 02:26 PM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > This checks for errors in the ACPI CPEP > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/Makefile.am | 1 + > src/acpi/cpep/cpep.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 129 insertions(+) > create mode 100644 src/acpi/cpep/cpep.c > > diff --git a/src/Makefile.am b/src/Makefile.am > index 3829d09..05170c1 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -36,6 +36,7 @@ fwts_SOURCES = main.c \ > acpi/brightness/brightness.c \ > acpi/brightness/autobrightness.c \ > acpi/checksum/checksum.c \ > + acpi/cpep/cpep.c \ > acpi/crsdump/crsdump.c \ > acpi/crsdump/prsdump.c \ > acpi/cstates/cstates.c \ > diff --git a/src/acpi/cpep/cpep.c b/src/acpi/cpep/cpep.c > new file mode 100644 > index 0000000..6b717c4 > --- /dev/null > +++ b/src/acpi/cpep/cpep.c > @@ -0,0 +1,128 @@ > +/* > + * 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> > +#include <ctype.h> > + > +static fwts_acpi_table_info *table; > + > +static int cpep_init(fwts_framework *fw) > +{ > + if (fwts_acpi_find_table(fw, "CPEP", 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 CPEP table does not exist, skipping test"); > + return FWTS_SKIP; > + } > + return FWTS_OK; > +} > + > +/* > + * CPEP Corrected Platform Error Polling Table > + */ > +static int cpep_test1(fwts_framework *fw) > +{ > + fwts_acpi_table_cpep *cpep = (fwts_acpi_table_cpep*)table->data; > + bool passed = true; > + uint32_t i, n; > + > + fwts_log_info_verbatum(fw, "CPEP Corrected Platform Error Polling Table:"); > + fwts_log_info_verbatum(fw, " Reserved: " > + " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 > + " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 , > + cpep->reserved[0], cpep->reserved[1], cpep->reserved[2], cpep->reserved[3], > + cpep->reserved[4], cpep->reserved[4], cpep->reserved[6], cpep->reserved[7]); > + > + if (cpep->reserved[0] | cpep->reserved[1] | > + cpep->reserved[2] | cpep->reserved[3] | > + cpep->reserved[4] | cpep->reserved[5] | > + cpep->reserved[6] | cpep->reserved[7]) { > + passed = false; > + fwts_failed(fw, LOG_LEVEL_MEDIUM, > + "CPEPNonZeroReserved", > + "CPEP: Reserved field contains a non-zero value"); > + } > + n = (table->length - sizeof(fwts_acpi_table_cpep)) / > + sizeof(fwts_acpi_cpep_processor_info); > + > + for (i = 0; i < n; i++) { > + bool cpep_passed = true; > + fwts_acpi_cpep_processor_info *info = &cpep->cpep_info[i]; > + > + if (info->type != 0) { > + cpep_passed = false; > + fwts_failed(fw, LOG_LEVEL_HIGH, > + "CPEPInvalidProcStructureType", > + "CPEP: Processor Structure %" PRIu32 > + " Type field is 0x%" PRIx8 > + " and was expected to be 0x00", > + i, info->type); > + } > + if (info->length != 8) { > + cpep_passed = false; > + fwts_failed(fw, LOG_LEVEL_MEDIUM, > + "CPEPInvalidProcStructureType", > + "CPEP: Processor Structure %" PRIu32 > + " Length field is 0x%" PRIx8 > + " and was expected to be 0x08", > + i, info->length); > + } > + /* Should probably sanity check processor UID, EIDs at a later date */ > + > + /* Some feedback if polling interval is very short */ > + if (info->polling_interval < 5) { > + fwts_warning(fw, "CPEP Processor Structure %" PRIu32 > + " Polling Interval of %" PRIu32 > + " milliseconds is relatively short and may " > + "cause excessive polling CPU load", > + i, info->polling_interval); > + } > + if (cpep_passed) > + fwts_log_info(fw, "CPEP Processor Structure %" PRIu32 " looks sane.", i); > + passed &= cpep_passed; > + } > + > + > + if (passed) > + fwts_passed(fw, "No issues found in CPEP table."); > + > + return FWTS_OK; > +} > + > +static fwts_framework_minor_test cpep_tests[] = { > + { cpep_test1, "CPEP Corrected Platform Error Polling Table test." }, > + { NULL, NULL } > +}; > + > +static fwts_framework_ops cpep_ops = { > + .description = "CPEP Corrected Platform Error Polling Table test.", > + .init = cpep_init, > + .minor_tests = cpep_tests > +}; > + > +FWTS_REGISTER("cpep", &cpep_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_BATCH | FWTS_FLAG_TEST_ACPI) > Acked-by: Alex Hung <alex.hung@canonical.com>
diff --git a/src/Makefile.am b/src/Makefile.am index 3829d09..05170c1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -36,6 +36,7 @@ fwts_SOURCES = main.c \ acpi/brightness/brightness.c \ acpi/brightness/autobrightness.c \ acpi/checksum/checksum.c \ + acpi/cpep/cpep.c \ acpi/crsdump/crsdump.c \ acpi/crsdump/prsdump.c \ acpi/cstates/cstates.c \ diff --git a/src/acpi/cpep/cpep.c b/src/acpi/cpep/cpep.c new file mode 100644 index 0000000..6b717c4 --- /dev/null +++ b/src/acpi/cpep/cpep.c @@ -0,0 +1,128 @@ +/* + * 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> +#include <ctype.h> + +static fwts_acpi_table_info *table; + +static int cpep_init(fwts_framework *fw) +{ + if (fwts_acpi_find_table(fw, "CPEP", 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 CPEP table does not exist, skipping test"); + return FWTS_SKIP; + } + return FWTS_OK; +} + +/* + * CPEP Corrected Platform Error Polling Table + */ +static int cpep_test1(fwts_framework *fw) +{ + fwts_acpi_table_cpep *cpep = (fwts_acpi_table_cpep*)table->data; + bool passed = true; + uint32_t i, n; + + fwts_log_info_verbatum(fw, "CPEP Corrected Platform Error Polling Table:"); + fwts_log_info_verbatum(fw, " Reserved: " + " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 + " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 " 0x%2.2" PRIx8 , + cpep->reserved[0], cpep->reserved[1], cpep->reserved[2], cpep->reserved[3], + cpep->reserved[4], cpep->reserved[4], cpep->reserved[6], cpep->reserved[7]); + + if (cpep->reserved[0] | cpep->reserved[1] | + cpep->reserved[2] | cpep->reserved[3] | + cpep->reserved[4] | cpep->reserved[5] | + cpep->reserved[6] | cpep->reserved[7]) { + passed = false; + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "CPEPNonZeroReserved", + "CPEP: Reserved field contains a non-zero value"); + } + n = (table->length - sizeof(fwts_acpi_table_cpep)) / + sizeof(fwts_acpi_cpep_processor_info); + + for (i = 0; i < n; i++) { + bool cpep_passed = true; + fwts_acpi_cpep_processor_info *info = &cpep->cpep_info[i]; + + if (info->type != 0) { + cpep_passed = false; + fwts_failed(fw, LOG_LEVEL_HIGH, + "CPEPInvalidProcStructureType", + "CPEP: Processor Structure %" PRIu32 + " Type field is 0x%" PRIx8 + " and was expected to be 0x00", + i, info->type); + } + if (info->length != 8) { + cpep_passed = false; + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "CPEPInvalidProcStructureType", + "CPEP: Processor Structure %" PRIu32 + " Length field is 0x%" PRIx8 + " and was expected to be 0x08", + i, info->length); + } + /* Should probably sanity check processor UID, EIDs at a later date */ + + /* Some feedback if polling interval is very short */ + if (info->polling_interval < 5) { + fwts_warning(fw, "CPEP Processor Structure %" PRIu32 + " Polling Interval of %" PRIu32 + " milliseconds is relatively short and may " + "cause excessive polling CPU load", + i, info->polling_interval); + } + if (cpep_passed) + fwts_log_info(fw, "CPEP Processor Structure %" PRIu32 " looks sane.", i); + passed &= cpep_passed; + } + + + if (passed) + fwts_passed(fw, "No issues found in CPEP table."); + + return FWTS_OK; +} + +static fwts_framework_minor_test cpep_tests[] = { + { cpep_test1, "CPEP Corrected Platform Error Polling Table test." }, + { NULL, NULL } +}; + +static fwts_framework_ops cpep_ops = { + .description = "CPEP Corrected Platform Error Polling Table test.", + .init = cpep_init, + .minor_tests = cpep_tests +}; + +FWTS_REGISTER("cpep", &cpep_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_BATCH | FWTS_FLAG_TEST_ACPI)