Commit 0e26e1de authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

context_tracking: Fix noinstr vs KASAN

Low level noinstr context-tracking code is calling out to instrumented
code on KASAN:

  vmlinux.o: warning: objtool: __ct_user_enter+0x72: call to __kasan_check_write() leaves .noinstr.text section
  vmlinux.o: warning: objtool: __ct_user_exit+0x47: call to __kasan_check_write() leaves .noinstr.text section

Use even lower level atomic methods to avoid the instrumentation.
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230112195542.458034262@infradead.org
parent 0e985e9d
...@@ -510,7 +510,7 @@ void noinstr __ct_user_enter(enum ctx_state state) ...@@ -510,7 +510,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
* In this we case we don't care about any concurrency/ordering. * In this we case we don't care about any concurrency/ordering.
*/ */
if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE))
atomic_set(&ct->state, state); arch_atomic_set(&ct->state, state);
} else { } else {
/* /*
* Even if context tracking is disabled on this CPU, because it's outside * Even if context tracking is disabled on this CPU, because it's outside
...@@ -527,7 +527,7 @@ void noinstr __ct_user_enter(enum ctx_state state) ...@@ -527,7 +527,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
*/ */
if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) { if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) {
/* Tracking for vtime only, no concurrent RCU EQS accounting */ /* Tracking for vtime only, no concurrent RCU EQS accounting */
atomic_set(&ct->state, state); arch_atomic_set(&ct->state, state);
} else { } else {
/* /*
* Tracking for vtime and RCU EQS. Make sure we don't race * Tracking for vtime and RCU EQS. Make sure we don't race
...@@ -535,7 +535,7 @@ void noinstr __ct_user_enter(enum ctx_state state) ...@@ -535,7 +535,7 @@ void noinstr __ct_user_enter(enum ctx_state state)
* RCU only requires RCU_DYNTICKS_IDX increments to be fully * RCU only requires RCU_DYNTICKS_IDX increments to be fully
* ordered. * ordered.
*/ */
atomic_add(state, &ct->state); arch_atomic_add(state, &ct->state);
} }
} }
} }
...@@ -630,12 +630,12 @@ void noinstr __ct_user_exit(enum ctx_state state) ...@@ -630,12 +630,12 @@ void noinstr __ct_user_exit(enum ctx_state state)
* In this we case we don't care about any concurrency/ordering. * In this we case we don't care about any concurrency/ordering.
*/ */
if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE))
atomic_set(&ct->state, CONTEXT_KERNEL); arch_atomic_set(&ct->state, CONTEXT_KERNEL);
} else { } else {
if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) { if (!IS_ENABLED(CONFIG_CONTEXT_TRACKING_IDLE)) {
/* Tracking for vtime only, no concurrent RCU EQS accounting */ /* Tracking for vtime only, no concurrent RCU EQS accounting */
atomic_set(&ct->state, CONTEXT_KERNEL); arch_atomic_set(&ct->state, CONTEXT_KERNEL);
} else { } else {
/* /*
* Tracking for vtime and RCU EQS. Make sure we don't race * Tracking for vtime and RCU EQS. Make sure we don't race
...@@ -643,7 +643,7 @@ void noinstr __ct_user_exit(enum ctx_state state) ...@@ -643,7 +643,7 @@ void noinstr __ct_user_exit(enum ctx_state state)
* RCU only requires RCU_DYNTICKS_IDX increments to be fully * RCU only requires RCU_DYNTICKS_IDX increments to be fully
* ordered. * ordered.
*/ */
atomic_sub(state, &ct->state); arch_atomic_sub(state, &ct->state);
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment