Skip to content

Commit

Permalink
x86/alternatives: Let __text_poke() acquire the pte lock with enabled…
Browse files Browse the repository at this point in the history
… interrupts

The pte lock is never acquired from an IRQ-off region so it does not
require the interrupts to be disabled.
RT complains here because the spinlock_t must not be acquired with
disabled interrupts.

use_temporary_mm() expects interrupts to be off because it invokes
switch_mm_irqs_off() and uses per-CPU (current active mm) data.

Move local_irq_save() after the the pte lock has been acquired. Move
local_irq_restore() after the pte lock has been released.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
  • Loading branch information
Sebastian Andrzej Siewior authored and intel-lab-lkp committed Jul 6, 2020
1 parent 1c14587 commit e7ef425
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arch/x86/kernel/alternative.c
Expand Up @@ -873,8 +873,6 @@ static void *__text_poke(void *addr, const void *opcode, size_t len)
*/
BUG_ON(!pages[0] || (cross_page_boundary && !pages[1]));

local_irq_save(flags);

/*
* Map the page without the global bit, as TLB flushing is done with
* flush_tlb_mm_range(), which is intended for non-global PTEs.
Expand All @@ -891,6 +889,8 @@ static void *__text_poke(void *addr, const void *opcode, size_t len)
*/
VM_BUG_ON(!ptep);

local_irq_save(flags);

pte = mk_pte(pages[0], pgprot);
set_pte_at(poking_mm, poking_addr, ptep, pte);

Expand Down Expand Up @@ -940,8 +940,8 @@ static void *__text_poke(void *addr, const void *opcode, size_t len)
*/
BUG_ON(memcmp(addr, opcode, len));

pte_unmap_unlock(ptep, ptl);
local_irq_restore(flags);
pte_unmap_unlock(ptep, ptl);
return addr;
}

Expand Down

0 comments on commit e7ef425

Please sign in to comment.