diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2017-08-11 13:43:53 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2018-03-15 10:52:37 +0000 |
commit | 9d216ab4db28f5b7755d42d899221ac3c91f2610 (patch) | |
tree | ffc10b6d2930eff09355f4c4eaff49644957bafb | |
parent | 1d61387c2f3dd29aab00b5d5b875dcbdbcbb464a (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.sources | 1 | ||||
-rw-r--r-- | tests/kernel_taint.c | 74 |
2 files changed, 75 insertions, 0 deletions
diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 34c0347d..4e9ddc6a 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -173,6 +173,7 @@ TESTS_progs = \ gen3_render_tiledy_blits \ gvt_basic \ i915_query \ + 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); +} |