Skip to content

Commit a6d996c

Browse files
Sebastian Andrzej SiewiorKAGA-KOKO
Sebastian Andrzej Siewior
authored andcommitted
x86/alternatives: Acquire pte lock with interrupts enabled
pte lock is never acquired in-IRQ context so it does not require interrupts to be disabled. The lock is a regular spinlock which cannot be acquired with interrupts disabled on RT. RT complains about pte_lock() in __text_poke() because it's invoked after disabling interrupts. __text_poke() has to disable interrupts as use_temporary_mm() expects interrupts to be off because it invokes switch_mm_irqs_off() and uses per-CPU (current active mm) data. Move the PTE lock handling outside the interrupt disabled region. Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by; Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f29dfa5 commit a6d996c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/x86/kernel/alternative.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,6 @@ static void *__text_poke(void *addr, const void *opcode, size_t len)
874874
*/
875875
BUG_ON(!pages[0] || (cross_page_boundary && !pages[1]));
876876

877-
local_irq_save(flags);
878-
879877
/*
880878
* Map the page without the global bit, as TLB flushing is done with
881879
* flush_tlb_mm_range(), which is intended for non-global PTEs.
@@ -892,6 +890,8 @@ static void *__text_poke(void *addr, const void *opcode, size_t len)
892890
*/
893891
VM_BUG_ON(!ptep);
894892

893+
local_irq_save(flags);
894+
895895
pte = mk_pte(pages[0], pgprot);
896896
set_pte_at(poking_mm, poking_addr, ptep, pte);
897897

@@ -941,8 +941,8 @@ static void *__text_poke(void *addr, const void *opcode, size_t len)
941941
*/
942942
BUG_ON(memcmp(addr, opcode, len));
943943

944-
pte_unmap_unlock(ptep, ptl);
945944
local_irq_restore(flags);
945+
pte_unmap_unlock(ptep, ptl);
946946
return addr;
947947
}
948948

0 commit comments

Comments
 (0)