summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-08-11 13:43:53 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2017-08-12 13:39:57 +0100
commit3452b36a2b1dea0c04437b7cb18a428454e93043 (patch)
tree5209e2a2c13b5b6ca2ba7c7280aee82dc93031d7
parente9fde5b3b37a0ac624b065b7f05c3ff32dc934a9 (diff)
igt: Add a test to precheck status of kernel taints
Many times an error may occur before the start of igt, leaving the system in a less-than-optimal debugging state (e.g. an oops turning off lockdep). Flag such occasions by checking /proc/sys/kernel/tainted. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--tests/Makefile.sources1
-rw-r--r--tests/kernel_taint.c74
2 files changed, 75 insertions, 0 deletions
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 3352aad4..4dc89517 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -168,6 +168,7 @@ TESTS_progs = \
gen3_render_tiledy_blits \
gen7_forcewake_mt \
gvt_basic \
+ kernel_taint \
kms_3d \
kms_addfb_basic \
kms_atomic \
diff --git a/tests/kernel_taint.c b/tests/kernel_taint.c
new file mode 100644
index 00000000..bb125abf
--- /dev/null
+++ b/tests/kernel_taint.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "igt.h"
+#include "igt_sysfs.h"
+
+#define BIT(x) (1ul << (x))
+
+igt_simple_main
+{
+ unsigned long taint;
+ unsigned int errors = 0;
+ int dir;
+
+ dir = open("/proc/sys/kernel", O_RDONLY);
+ igt_require_f(dir != -1, "No /proc/sys/kernel found");
+ igt_require(igt_sysfs_scanf(dir, "tainted", "%lu", &taint) == 1);
+ close(dir);
+
+#define CHECK(bit, message, flags) do { \
+ if (taint & BIT(bit)) { \
+ if (flags & (WARN | ERROR)) { \
+ igt_warn("\t%08lx - " message "\n", BIT(bit)); \
+ errors += !!(flags & ERROR); \
+ } else { \
+ igt_info("\t%08lx - " message "\n", BIT(bit)); \
+ } \
+ } \
+} while (0)
+#define WARN BIT(0)
+#define ERROR BIT(1)
+
+ igt_info("Kernel taint: %08lx\n", taint);
+ CHECK(0, "Non-GPL module loaded", 0);
+ CHECK(1, "Forced module load", 0);
+ CHECK(2, "Unsafe SMP processor", 0);
+ CHECK(3, "Forced module unload", 0);
+ CHECK(4, "Machine Check Exception", WARN);
+ CHECK(5, "Bad page detected", ERROR);
+ CHECK(6, "Tainted by user request", WARN);
+ CHECK(7, "System is on fire", ERROR);
+ CHECK(8, "ACPI DSDT has been overridden by user", 0);
+ CHECK(9, "OOPS", ERROR);
+ CHECK(10, "Staging driver loaded; are you mad?", 0);
+ CHECK(11, "Severe firmware bug workaround active", WARN);
+ CHECK(12, "Out-of-tree module loaded", 0);
+ CHECK(13, "Unsigned module loaded", 0);
+ CHECK(14, "Soft-lockup detected", WARN);
+ CHECK(15, "Kernel has been live patched", 0);
+ igt_assert_eq(errors, 0);
+}