x86, bts: add selftest for BTS
PATCH 2/5 x86, bts: add selftest for BTS
Perform a selftest of branch trace store when a cpu is initialized.
WARN and disable branch trace store support if the selftest fails.
---
arch/x86/kernel/ds.c +21 -0
@@ -29,6 +29,7 @@#include <linux/mm.h> #include <linux/kernel.h> +#include "ds_selftest.h" /* * The configuration for a particular DS hardware implementation.
@@ -940,6 +941,26 @@ ds_configure(const struct ds_configuratiprintk (KERN_INFO "[ds] pebs not available\n" ); } +if (ds_cfg.sizeof_rec[ds_bts]) { +int error; + + error =ds_selftest_bts (); +if (error) { +WARN (1 ,"[ds] selftest failed. disabling bts.\n" ); + ds_cfg.sizeof_rec[ds_bts] =0 ; + } + } + +if (ds_cfg.sizeof_rec[ds_pebs]) { +int error; + + error =ds_selftest_pebs (); +if (error) { +WARN (1 ,"[ds] selftest failed. disabling pebs.\n" ); + ds_cfg.sizeof_rec[ds_pebs] =0 ; + } + } +printk (KERN_INFO "[ds] sizes: address: %u bit, " ,8 * ds_cfg.sizeof_ptr_field); printk("bts/pebs record: %u/%u bytes\n",
arch/x86/Kconfig.debug +9 -0
@@ -176,6 +176,15 @@ config IOMMU_LEAK Add a simple leak tracer to the IOMMU code. This is useful when you are debugging a buggy device driver that leaks IOMMU mappings. +config X86_DS_SELFTEST + bool "DS selftest" + default y + depends on DEBUG_KERNEL + depends on X86_DS + ---help--- + Perform Debug Store selftests at boot time. + If in doubt, say "N". + config HAVE_MMIOTRACE_SUPPORT def_bool y
arch/x86/kernel/ds_selftest.c new file +241 -0
241 lines not on this page · raw message
arch/x86/kernel/ds_selftest.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* Debug Store support - selftest +* +* +* Copyright (C) 2009 Intel Corporation. +* Markus Metzger <[email protected]>, 2009 +*/ + +#ifdef CONFIG_X86_DS_SELFTEST +extern int ds_selftest_bts (void ); +extern int ds_selftest_pebs (void ); +#else +static inline int ds_selftest_bts (void ) {return 0 ; } +static inline int ds_selftest_pebs (void ) {return 0 ; } +#endif /* CONFIG_X86_DS_SELFTEST */
arch/x86/kernel/Makefile +1 -0
@@ -44,6 +44,7 @@ obj-y += process.o obj-y += i387.o xsave.o obj-y += ptrace.o obj-$(CONFIG_X86_DS) += ds.o +obj-$(CONFIG_X86_DS_SELFTEST) += ds_selftest.o obj-$(CONFIG_X86_32) += tls.o obj-$(CONFIG_IA32_EMULATION) += tls.o obj-y += step.o
---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
Commit-ID: 8a327f6d1b05f5ce16572b4413a5df1d0e872283 Gitweb: http://git.kernel.org/tip/8a327f6d1b05f5ce16572b4413a5df1d0e872283 Author: Markus Metzger <[email protected]> AuthorDate: Fri, 13 Mar 2009 10:45:07 +0100 Commit: Ingo Molnar <[email protected]> CommitDate: Fri, 13 Mar 2009 11:57:20 +0100
x86, bts: add selftest for BTS
Perform a selftest of branch trace store when a cpu is initialized.
WARN and disable branch trace store support if the selftest fails.
LKML-Reference: <[email protected]>
--- arch/x86/Kconfig.debug | 9 ++ arch/x86/kernel/Makefile | 1 + arch/x86/kernel/ds.c | 21 ++++ arch/x86/kernel/ds_selftest.c | 241 +++++++++++++++++++++++++++++++++++++++++ arch/x86/kernel/ds_selftest.h | 15 +++ 5 files changed, 287 insertions(+), 0 deletions(-)
arch/x86/Kconfig.debug +9 -0
@@ -175,6 +175,15 @@ config IOMMU_LEAK Add a simple leak tracer to the IOMMU code. This is useful when you are debugging a buggy device driver that leaks IOMMU mappings. +config X86_DS_SELFTEST + bool "DS selftest" + default y + depends on DEBUG_KERNEL + depends on X86_DS + ---help--- + Perform Debug Store selftests at boot time. + If in doubt, say "N". + config HAVE_MMIOTRACE_SUPPORT def_bool y
arch/x86/kernel/Makefile +1 -0
@@ -44,6 +44,7 @@ obj-y += process.o obj-y += i387.o xsave.o obj-y += ptrace.o obj-$(CONFIG_X86_DS) += ds.o +obj-$(CONFIG_X86_DS_SELFTEST) += ds_selftest.o obj-$(CONFIG_X86_32) += tls.o obj-$(CONFIG_IA32_EMULATION) += tls.o obj-y += step.o
arch/x86/kernel/ds.c +21 -0
@@ -29,6 +29,7 @@#include <linux/mm.h> #include <linux/kernel.h> +#include "ds_selftest.h" /* * The configuration for a particular DS hardware implementation.
@@ -940,6 +941,26 @@ ds_configure(const struct ds_configuration *cfg,printk (KERN_INFO "[ds] pebs not available\n" ); } +if (ds_cfg.sizeof_rec[ds_bts]) { +int error; + + error =ds_selftest_bts (); +if (error) { +WARN (1 ,"[ds] selftest failed. disabling bts.\n" ); + ds_cfg.sizeof_rec[ds_bts] =0 ; + } + } + +if (ds_cfg.sizeof_rec[ds_pebs]) { +int error; + + error =ds_selftest_pebs (); +if (error) { +WARN (1 ,"[ds] selftest failed. disabling pebs.\n" ); + ds_cfg.sizeof_rec[ds_pebs] =0 ; + } + } +printk (KERN_INFO "[ds] sizes: address: %u bit, " ,8 * ds_cfg.sizeof_ptr_field); printk("bts/pebs record: %u/%u bytes\n",
arch/x86/kernel/ds_selftest.c new file +241 -0
241 lines not on this page · raw message
arch/x86/kernel/ds_selftest.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* Debug Store support - selftest +* +* +* Copyright (C) 2009 Intel Corporation. +* Markus Metzger <[email protected]>, 2009 +*/ + +#ifdef CONFIG_X86_DS_SELFTEST +extern int ds_selftest_bts (void ); +extern int ds_selftest_pebs (void ); +#else +static inline int ds_selftest_bts (void ) {return 0 ; } +static inline int ds_selftest_pebs (void ) {return 0 ; } +#endif /* CONFIG_X86_DS_SELFTEST */