x86/microcode/AMD: Change load_microcode_amd()'s param to bool to fix preemptibility bug
commitdac6ca243c4c49a9ca7507d3d66140ebfac8b04b
authorBorislav Petkov <bp@suse.de>
Sun, 28 May 2017 20:04:14 +0000 (28 22:04 +0200)
committerIngo Molnar <mingo@kernel.org>
Mon, 29 May 2017 06:22:48 +0000 (29 08:22 +0200)
tree5dc4ba53f80a4be6a5c66291de2b81b418911e09
parent5ed02dbb497422bf225783f46e6eadd237d23d6b
x86/microcode/AMD: Change load_microcode_amd()'s param to bool to fix preemptibility bug

With CONFIG_DEBUG_PREEMPT enabled, I get:

  BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1
  caller is debug_smp_processor_id
  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.12.0-rc2+ #2
  Call Trace:
   dump_stack
   check_preemption_disabled
   debug_smp_processor_id
   save_microcode_in_initrd_amd
   ? microcode_init
   save_microcode_in_initrd
   ...

because, well, it says it above, we're using smp_processor_id() in
preemptible code.

But passing the CPU number is not really needed. It is only used to
determine whether we're on the BSP, and, if so, to save the microcode
patch for early loading.

 [ We don't absolutely need to do it on the BSP but we do that
   customarily there. ]

Instead, convert that function parameter to a boolean which denotes
whether the patch should be saved or not, thereby avoiding the use of
smp_processor_id() in preemptible code.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170528200414.31305-1-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/cpu/microcode/amd.c