Skip to content

Commit c4a2222

Browse files
KAGA-KOKOgregkh
authored andcommitted
x86/alternatives: Sync core before enabling interrupts
commit 3ea1704 upstream. text_poke_early() does: local_irq_save(flags); memcpy(addr, opcode, len); local_irq_restore(flags); sync_core(); That's not really correct because the synchronization should happen before interrupts are re-enabled to ensure that a pending interrupt observes the complete update of the opcodes. It's not entirely clear whether the interrupt entry provides enough serialization already, but moving the sync_core() invocation into interrupt disabled region does no harm and is obviously correct. Fixes: 6fffacb ("x86/alternatives, jumplabel: Use text_poke_early() before mm_init()") Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/ZT6narvE%2BLxX%[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7d407ef commit c4a2222

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kernel/alternative.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,8 @@ void __init_or_module text_poke_early(void *addr, const void *opcode,
10931093
} else {
10941094
local_irq_save(flags);
10951095
memcpy(addr, opcode, len);
1096-
local_irq_restore(flags);
10971096
sync_core();
1097+
local_irq_restore(flags);
10981098

10991099
/*
11001100
* Could also do a CLFLUSH here to speed up CPU recovery; but

0 commit comments

Comments
 (0)