Commit fdfd4289 authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Peter Zijlstra
Browse files

jump_label: mips: move module NOP patching into arch code



MIPS is the only remaining architecture that needs to patch jump label
NOP encodings to initialize them at load time. So let's move the module
patching part of that from generic code into arch/mips, and drop it from
the others.

Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220615154142.1574619-3-ardb@kernel.org
parent 0c3b61e0
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -88,3 +88,22 @@ void arch_jump_label_transform(struct jump_entry *e,

	mutex_unlock(&text_mutex);
}

#ifdef CONFIG_MODULES
void jump_label_apply_nops(struct module *mod)
{
	struct jump_entry *iter_start = mod->jump_entries;
	struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
	struct jump_entry *iter;

	/* if the module doesn't have jump label entries, just return */
	if (iter_start == iter_stop)
		return;

	for (iter = iter_start; iter < iter_stop; iter++) {
		/* Only write NOPs for arch_branch_static(). */
		if (jump_label_init_type(iter) == JUMP_LABEL_NOP)
			arch_jump_label_transform(iter, JUMP_LABEL_NOP);
	}
}
#endif
+3 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <linux/spinlock.h>
#include <linux/jump_label.h>

extern void jump_label_apply_nops(struct module *mod);

struct mips_hi16 {
	struct mips_hi16 *next;
@@ -428,7 +429,7 @@ int module_finalize(const Elf_Ehdr *hdr,
	const Elf_Shdr *s;
	char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;

	/* Make jump label nops. */
	if (IS_ENABLED(CONFIG_JUMP_LABEL))
		jump_label_apply_nops(me);

	INIT_LIST_HEAD(&me->arch.dbe_list);
+0 −1
Original line number Diff line number Diff line
@@ -548,6 +548,5 @@ int module_finalize(const Elf_Ehdr *hdr,
#endif /* CONFIG_FUNCTION_TRACER */
	}

	jump_label_apply_nops(me);
	return 0;
}
+0 −3
Original line number Diff line number Diff line
@@ -208,9 +208,6 @@ int module_finalize(const Elf_Ehdr *hdr,
		    const Elf_Shdr *sechdrs,
		    struct module *me)
{
	/* make jump label nops */
	jump_label_apply_nops(me);

	do_patch_sections(hdr, sechdrs);

	/* Cheetah's I-cache is fully coherent.  */
+0 −3
Original line number Diff line number Diff line
@@ -304,9 +304,6 @@ int module_finalize(const Elf_Ehdr *hdr,
					    tseg, tseg + text->sh_size);
	}

	/* make jump label nops */
	jump_label_apply_nops(me);

	if (orc && orc_ip)
		unwind_module_init(me, (void *)orc_ip->sh_addr, orc_ip->sh_size,
				   (void *)orc->sh_addr, orc->sh_size);
Loading