]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
x86/alternatives: Simplify smp_text_poke_single() by using tp_vec and existing APIs
authorIngo Molnar <mingo@kernel.org>
Fri, 11 Apr 2025 05:40:36 +0000 (07:40 +0200)
committerIngo Molnar <mingo@kernel.org>
Fri, 11 Apr 2025 09:01:34 +0000 (11:01 +0200)
Instead of constructing a vector on-stack, just use the already
available batch-patching vector - which should always be empty
at this point.

This will allow subsequent simplifications.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Juergen Gross <jgross@suse.com>
Cc: "H . Peter Anvin" <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250411054105.2341982-25-mingo@kernel.org
arch/x86/kernel/alternative.c

index 16a41e29db1792e0e842e7f0ad4b07625391c614..b4cb8676c2f042ba70ce507210b906a0306bd410 100644 (file)
@@ -2904,8 +2904,13 @@ void __ref smp_text_poke_batch_add(void *addr, const void *opcode, size_t len, c
  */
 void __ref smp_text_poke_single(void *addr, const void *opcode, size_t len, const void *emulate)
 {
-       struct smp_text_poke_loc tp;
+       struct smp_text_poke_loc *tp;
+
+       /* Batch-patching should not be mixed with single-patching: */
+       WARN_ON_ONCE(tp_vec_nr != 0);
+
+       tp = &tp_vec[tp_vec_nr++];
+       text_poke_int3_loc_init(tp, addr, opcode, len, emulate);
 
-       text_poke_int3_loc_init(&tp, addr, opcode, len, emulate);
-       smp_text_poke_batch_process(&tp, 1);
+       smp_text_poke_batch_finish();
 }