public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH igt] igt: Add a test to precheck status of	kernel taints
Date: Fri, 11 Aug 2017 16:15:50 +0300	[thread overview]
Message-ID: <87efsidz3t.fsf@nikula.org> (raw)
In-Reply-To: <20170811124633.5929-1-chris@chris-wilson.co.uk>

On Fri, 11 Aug 2017, Chris Wilson <chris@chris-wilson.co.uk> 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@chris-wilson.co.uk>
> ---
>  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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-08-11 13:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-11 12:46 [PATCH igt] igt: Add a test to precheck status of kernel taints Chris Wilson
2017-08-11 13:15 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-08-11 13:15 ` Jani Nikula [this message]
2017-08-11 13:17   ` [PATCH igt] " Chris Wilson
2017-08-11 14:33     ` Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87efsidz3t.fsf@nikula.org \
    --to=jani.nikula@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox