Re: [PATCH igt] igt: Add a test to precheck status of kernel taints

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 11 Aug 2017, Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> wrote:
> 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.

Hmm, which flag is set for unsafe module params?

BR,
Jani.


>
> Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> ---
>  tests/Makefile.sources |  1 +
>  tests/kernel_taint.c   | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 75 insertions(+)
>  create mode 100644 tests/kernel_taint.c
>
> 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..7fd1f07a
> --- /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, "Tained by user request", WARN);
> +	CHECK(7, "System is on fire", ERROR);
> +	CHECK(8, "ACPI DSDT has been overriden 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);
> +}

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux