On Mon 2022-11-28 17:57:06, Song Liu wrote:
quoted hunk ↗ jump to hunk
On Fri, Nov 18, 2022 at 8:24 AM Petr Mladek [off-list ref] wrote:
--- a/arch/x86/kernel/module.c
+++ b/arch/x86/kernel/module.c
quoted
This duplicates a lot of code. Please, rename apply_relocate_add() the
same way as __apply_clear_relocate_add() and add the "apply" parameter.
Then add the wrappers for this:
int write_relocate_add(Elf64_Shdr *sechdrs,
const char *strtab,
unsigned int symindex,
unsigned int relsec,
struct module *me,
bool apply)
{
int ret;
bool early = me->state == MODULE_STATE_UNFORMED;
void *(*write)(void *, const void *, size_t) = memcpy;
if (!early) {
write = text_poke;
mutex_lock(&text_mutex);
}
How about we move the "early" logic into __write_relocate_add()?
If I get it correctly then __write_relocate_add() has three different
return paths. I am not sure if this could be moved there a reasonable
way.
Anyway, I do not resist on the above proposal. Feel free to find
another solution that reduces the duplicated code and looks
reasonable. I am sure that there are more possibilities.
Best Regards,
Petr