The harden_branch_predictor function uses smp_processor_id, which complains about being used in a preemptible context: BUG: using smp_processor_id() in preemptible [00000000] code: trie_map_rand.e/4938 caller is debug_smp_processor_id+0x18/0x24 CPU: 0 PID: 4938 Comm: trie_map_rand.e Not tainted 4.14.93-rt53-g74e4d87 #1 Hardware name: Altera SOCFPGA [<8011162c>] (unwind_backtrace) from [<8010bfd4>] (show_stack+0x20/0x24) [<8010bfd4>] (show_stack) from [<806732e8>] (dump_stack+0x78/0x94) [<806732e8>] (dump_stack) from [<8041c254>] (check_preemption_disabled+0xec/0x128) [<8041c254>] (check_preemption_disabled) from [<8041c2a8>] (debug_smp_processor_id+0x18/0x24) [<8041c2a8>] (debug_smp_processor_id) from [<8011518c>] (__do_user_fault+0x34/0x100) [<8011518c>] (__do_user_fault) from [<801155d0>] (do_page_fault+0x2f4/0x328) [<801155d0>] (do_page_fault) from [<80101268>] (do_DataAbort+0x48/0xc8) [<80101268>] (do_DataAbort) from [<8010d300>] (__dabt_usr+0x40/0x60) Exception stack(0xae2fdfb0 to 0xae2fdff8) dfa0: c31b0fc6 76c8f7d8 00000000 00000001 dfc0: 00000001 00c79780 0004f7f4 00c79780 7ea2e550 7ea2e408 7ea2e58c 3fc99999 dfe0: 00000100 7ea2e3d0 00033d24 00018edc 600c0010 ffffffff Work around the issue by disabling preemption while clearing the branch predictor table. Signed-off-by: Bernd Edlinger <bernd.edlinger@xxxxxxxxxx> --- arch/arm/include/asm/system_misc.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/system_misc.h b/arch/arm/include/asm/system_misc.h index 8e76db8..82128a8 100644 --- a/arch/arm/include/asm/system_misc.h +++ b/arch/arm/include/asm/system_misc.h @@ -21,10 +21,13 @@ typedef void (*harden_branch_predictor_fn_t)(void); DECLARE_PER_CPU(harden_branch_predictor_fn_t, harden_branch_predictor_fn); static inline void harden_branch_predictor(void) { - harden_branch_predictor_fn_t fn = per_cpu(harden_branch_predictor_fn, - smp_processor_id()); + harden_branch_predictor_fn_t fn; + + preempt_disable(); + fn = per_cpu(harden_branch_predictor_fn, smp_processor_id()); if (fn) fn(); + preempt_enable(); } #else #define harden_branch_predictor() do { } while (0) -- 2.7.4