Skip to content

Commit ea8596b

Browse files
mhiramathitachiingomolnar
authored andcommitted
kprobes/x86: Remove unused text_poke_smp() and text_poke_smp_batch() functions
Since introducing the text_poke_bp() for all text_poke_smp*() callers, text_poke_smp*() are now unused. This patch basically reverts: 3d55cc8 ("x86: Add text_poke_smp for SMP cross modifying code") 7deb18d ("x86: Introduce text_poke_smp_batch() for batch-code modifying") and related commits. This patch also fixes a Kconfig dependency issue on STOP_MACHINE in the case of CONFIG_SMP && !CONFIG_MODULE_UNLOAD. Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Reviewed-by: Jiri Kosina <jkosina@suse.cz> Cc: H. Peter Anvin <hpa@linux.intel.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Jason Baron <jbaron@akamai.com> Cc: yrl.pp-manager.tt@hitachi.com Cc: Borislav Petkov <bpetkov@suse.de> Link: http://lkml.kernel.org/r/20130718114753.26675.18714.stgit@mhiramat-M0-7522 Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent a7b0133 commit ea8596b

3 files changed

Lines changed: 2 additions & 112 deletions

File tree

‎arch/x86/Kconfig‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ config X86
8181
select HAVE_USER_RETURN_NOTIFIER
8282
select ARCH_BINFMT_ELF_RANDOMIZE_PIE
8383
select HAVE_ARCH_JUMP_LABEL
84-
select HAVE_TEXT_POKE_SMP
8584
select HAVE_GENERIC_HARDIRQS
8685
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
8786
select SPARSE_IRQ
@@ -2332,10 +2331,6 @@ config HAVE_ATOMIC_IOMAP
23322331
def_bool y
23332332
depends on X86_32
23342333

2335-
config HAVE_TEXT_POKE_SMP
2336-
bool
2337-
select STOP_MACHINE if SMP
2338-
23392334
config X86_DEV_DMA_OPS
23402335
bool
23412336
depends on X86_64 || STA2X11

‎arch/x86/include/asm/alternative.h‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,21 +220,10 @@ extern void *text_poke_early(void *addr, const void *opcode, size_t len);
220220
* no thread can be preempted in the instructions being modified (no iret to an
221221
* invalid instruction possible) or if the instructions are changed from a
222222
* consistent state to another consistent state atomically.
223-
* More care must be taken when modifying code in the SMP case because of
224-
* Intel's errata. text_poke_smp() takes care that errata, but still
225-
* doesn't support NMI/MCE handler code modifying.
226223
* On the local CPU you need to be protected again NMI or MCE handlers seeing an
227224
* inconsistent instruction while you patch.
228225
*/
229-
struct text_poke_param {
230-
void *addr;
231-
const void *opcode;
232-
size_t len;
233-
};
234-
235226
extern void *text_poke(void *addr, const void *opcode, size_t len);
236227
extern void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler);
237-
extern void *text_poke_smp(void *addr, const void *opcode, size_t len);
238-
extern void text_poke_smp_batch(struct text_poke_param *params, int n);
239228

240229
#endif /* _ASM_X86_ALTERNATIVE_H */

‎arch/x86/kernel/alternative.c‎

Lines changed: 2 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,8 @@ static int int3_notify(struct notifier_block *self, unsigned long val, void *dat
633633
* @handler: address to jump to when the temporary breakpoint is hit
634634
*
635635
* Modify multi-byte instruction by using int3 breakpoint on SMP.
636-
* In contrary to text_poke_smp(), we completely avoid stop_machine() here,
637-
* and achieve the synchronization using int3 breakpoint.
636+
* We completely avoid stop_machine() here, and achieve the
637+
* synchronization using int3 breakpoint.
638638
*
639639
* The way it is done:
640640
* - add a int3 trap to the address that will be patched
@@ -702,97 +702,3 @@ static int __init int3_init(void)
702702
}
703703

704704
arch_initcall(int3_init);
705-
/*
706-
* Cross-modifying kernel text with stop_machine().
707-
* This code originally comes from immediate value.
708-
*/
709-
static atomic_t stop_machine_first;
710-
static int wrote_text;
711-
712-
struct text_poke_params {
713-
struct text_poke_param *params;
714-
int nparams;
715-
};
716-
717-
static int __kprobes stop_machine_text_poke(void *data)
718-
{
719-
struct text_poke_params *tpp = data;
720-
struct text_poke_param *p;
721-
int i;
722-
723-
if (atomic_xchg(&stop_machine_first, 0)) {
724-
for (i = 0; i < tpp->nparams; i++) {
725-
p = &tpp->params[i];
726-
text_poke(p->addr, p->opcode, p->len);
727-
}
728-
smp_wmb(); /* Make sure other cpus see that this has run */
729-
wrote_text = 1;
730-
} else {
731-
while (!wrote_text)
732-
cpu_relax();
733-
smp_mb(); /* Load wrote_text before following execution */
734-
}
735-
736-
for (i = 0; i < tpp->nparams; i++) {
737-
p = &tpp->params[i];
738-
flush_icache_range((unsigned long)p->addr,
739-
(unsigned long)p->addr + p->len);
740-
}
741-
/*
742-
* Intel Archiecture Software Developer's Manual section 7.1.3 specifies
743-
* that a core serializing instruction such as "cpuid" should be
744-
* executed on _each_ core before the new instruction is made visible.
745-
*/
746-
sync_core();
747-
return 0;
748-
}
749-
750-
/**
751-
* text_poke_smp - Update instructions on a live kernel on SMP
752-
* @addr: address to modify
753-
* @opcode: source of the copy
754-
* @len: length to copy
755-
*
756-
* Modify multi-byte instruction by using stop_machine() on SMP. This allows
757-
* user to poke/set multi-byte text on SMP. Only non-NMI/MCE code modifying
758-
* should be allowed, since stop_machine() does _not_ protect code against
759-
* NMI and MCE.
760-
*
761-
* Note: Must be called under get_online_cpus() and text_mutex.
762-
*/
763-
void *__kprobes text_poke_smp(void *addr, const void *opcode, size_t len)
764-
{
765-
struct text_poke_params tpp;
766-
struct text_poke_param p;
767-
768-
p.addr = addr;
769-
p.opcode = opcode;
770-
p.len = len;
771-
tpp.params = &p;
772-
tpp.nparams = 1;
773-
atomic_set(&stop_machine_first, 1);
774-
wrote_text = 0;
775-
/* Use __stop_machine() because the caller already got online_cpus. */
776-
__stop_machine(stop_machine_text_poke, (void *)&tpp, cpu_online_mask);
777-
return addr;
778-
}
779-
780-
/**
781-
* text_poke_smp_batch - Update instructions on a live kernel on SMP
782-
* @params: an array of text_poke parameters
783-
* @n: the number of elements in params.
784-
*
785-
* Modify multi-byte instruction by using stop_machine() on SMP. Since the
786-
* stop_machine() is heavy task, it is better to aggregate text_poke requests
787-
* and do it once if possible.
788-
*
789-
* Note: Must be called under get_online_cpus() and text_mutex.
790-
*/
791-
void __kprobes text_poke_smp_batch(struct text_poke_param *params, int n)
792-
{
793-
struct text_poke_params tpp = {.params = params, .nparams = n};
794-
795-
atomic_set(&stop_machine_first, 1);
796-
wrote_text = 0;
797-
__stop_machine(stop_machine_text_poke, (void *)&tpp, cpu_online_mask);
798-
}

0 commit comments

Comments
 (0)