Re: [PATCH v12 01/11] x86: text_poke() may access uninitialized struct pages

From: Pavel Tatashin
Date: Mon Jun 25 2018 - 10:07:00 EST


> Also, I think the better condition is @early_boot_irqs_disabled, until
> we enable IRQs for the first time, text_poke_early() should be fine. And
> once we enable interrupts, all that other crud should really be working.

Sure, I will use early_boot_irqs_disabled flag. I think, we still want
to have BUG_ON(!after_bootmem); in text_poke(). I could do
BUG_ON(early_boot_irqs_disabled), but I am worried that there are call
sites that might be using text_poke() between mem_init() and
local_irq_enable() in start_kernel().

>
> This gives:
>
> diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
> index e56c95be2808..425ba6102828 100644
> --- a/arch/x86/kernel/jump_label.c
> +++ b/arch/x86/kernel/jump_label.c
> @@ -46,6 +46,9 @@ static void __jump_label_transform(struct jump_entry *entry,
> const unsigned char default_nop[] = { STATIC_KEY_INIT_NOP };
> const unsigned char *ideal_nop = ideal_nops[NOP_ATOMIC5];
>
> + if (early_boot_irqs_disabled)
> + poker = text_poke_early;
> +
> if (type == JUMP_LABEL_JMP) {
> if (init) {
> /*
>
> > Also, modify text_poke_early to call sync_core().

Also, we still need to add __ref to __jump_label_transform as
text_poke_early() is __init