]> git.karo-electronics.de Git - linux-beck.git/commitdiff
x86/MCE/AMD: Fix thinko about thresholding_en
authorBorislav Petkov <bp@suse.de>
Sat, 19 Nov 2016 10:34:02 +0000 (11:34 +0100)
committerIngo Molnar <mingo@kernel.org>
Mon, 21 Nov 2016 10:02:12 +0000 (11:02 +0100)
So adding thresholding_en et al was a good thing for removing the
per-CPU thresholding callback, i.e., threshold_cpu_callback.

But, in order for it to work and especially that test in
mce_threshold_create_device() so that all thresholding banks get
properly created and not the whole thing to fail with a NULL ptr
dereference at mce_cpu_pre_down() when we offline the CPUs, we need to
set the thresholding_en flag *before* we start creating the devices.

Yap, it failed because thresholding_en wasn't set at the time
we were creating the banks so we didn't create any and then at
mce_cpu_pre_down() -> mce_threshold_remove_device() time, we would blow
up.

And the fix is actually easy: we have thresholding on the system when we
have managed to set the thresholding vector to amd_threshold_interrupt()
earlier in mce_amd_feature_init() while we were picking apart the
thresholding banks and what is set and what not.

So let's do that.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yazen Ghannam <Yazen.Ghannam@amd.com>
Fixes: 4d7b02d58c40 ("x86/mcheck: Split threshold_cpu_callback into two callbacks")
Link: http://lkml.kernel.org/r/20161119103402.5227-1-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/cpu/mcheck/mce_amd.c

index c33a3ee2e3834172aeafc24ba1145b14dedf0ab7..4e82e5324063c4f883bf4537cadf79f6799b7a56 100644 (file)
@@ -1134,6 +1134,9 @@ static __init int threshold_init_device(void)
 {
        unsigned lcpu = 0;
 
+       if (mce_threshold_vector == amd_threshold_interrupt)
+               thresholding_en = true;
+
        /* to hit CPUs online before the notifier is up */
        for_each_online_cpu(lcpu) {
                int err = mce_threshold_create_device(lcpu);
@@ -1142,8 +1145,6 @@ static __init int threshold_init_device(void)
                        return err;
        }
 
-       thresholding_en = true;
-
        return 0;
 }
 /*