Skip to content

Commit 7a7a8f5

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
arm/patch: Fix !MMU compile
Now that patch.o is unconditionally selected for ftrace, it can also get compiled for !MMU kernels. These (obviously) lack {set,clear}_fixmap() support. Also remove the superfluous __acquire/__release nonsense. Fixes: 42e51f1 ("arm/ftrace: Use __patch_text()") Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent be993e4 commit 7a7a8f5

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

arch/arm/kernel/patch.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ struct patch {
1616
unsigned int insn;
1717
};
1818

19+
#ifdef CONFIG_MMU
1920
static DEFINE_RAW_SPINLOCK(patch_lock);
2021

2122
static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags)
22-
__acquires(&patch_lock)
2323
{
2424
unsigned int uintaddr = (uintptr_t) addr;
2525
bool module = !core_kernel_text(uintaddr);
@@ -34,24 +34,26 @@ static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags)
3434

3535
if (flags)
3636
raw_spin_lock_irqsave(&patch_lock, *flags);
37-
else
38-
__acquire(&patch_lock);
3937

4038
set_fixmap(fixmap, page_to_phys(page));
4139

4240
return (void *) (__fix_to_virt(fixmap) + (uintaddr & ~PAGE_MASK));
4341
}
4442

4543
static void __kprobes patch_unmap(int fixmap, unsigned long *flags)
46-
__releases(&patch_lock)
4744
{
4845
clear_fixmap(fixmap);
4946

5047
if (flags)
5148
raw_spin_unlock_irqrestore(&patch_lock, *flags);
52-
else
53-
__release(&patch_lock);
5449
}
50+
#else
51+
static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags)
52+
{
53+
return addr;
54+
}
55+
static void __kprobes patch_unmap(int fixmap, unsigned long *flags) { }
56+
#endif
5557

5658
void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap)
5759
{
@@ -64,8 +66,6 @@ void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap)
6466

6567
if (remap)
6668
waddr = patch_map(addr, FIX_TEXT_POKE0, &flags);
67-
else
68-
__acquire(&patch_lock);
6969

7070
if (thumb2 && __opcode_is_thumb16(insn)) {
7171
*(u16 *)waddr = __opcode_to_mem_thumb16(insn);
@@ -102,8 +102,7 @@ void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap)
102102
if (waddr != addr) {
103103
flush_kernel_vmap_range(waddr, twopage ? size / 2 : size);
104104
patch_unmap(FIX_TEXT_POKE0, &flags);
105-
} else
106-
__release(&patch_lock);
105+
}
107106

108107
flush_icache_range((uintptr_t)(addr),
109108
(uintptr_t)(addr) + size);

0 commit comments

Comments
 (0)