Skip to content

Commit 29562a9

Browse files
chleroympe
authored andcommitted
powerpc/code-patching: Move patch_exception() outside code-patching.c
patch_exception() is dedicated to book3e/64 is nothing more than a normal use of patch_branch(), so move it into a place dedicated to book3e/64. Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/0968622b98b1fb51838c35b844c42ad6609de62e.1638446239.git.christophe.leroy@csgroup.eu
1 parent ff14a9c commit 29562a9

File tree

5 files changed

+25
-23
lines changed

5 files changed

+25
-23
lines changed

arch/powerpc/include/asm/code-patching.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ int instr_is_relative_link_branch(ppc_inst_t instr);
6363
unsigned long branch_target(const u32 *instr);
6464
int translate_branch(ppc_inst_t *instr, const u32 *dest, const u32 *src);
6565
bool is_conditional_branch(ppc_inst_t instr);
66-
#ifdef CONFIG_PPC_BOOK3E_64
67-
void __patch_exception(int exc, unsigned long addr);
68-
#define patch_exception(exc, name) do { \
69-
extern unsigned int name; \
70-
__patch_exception((exc), (unsigned long)&name); \
71-
} while (0)
72-
#endif
7366

7467
#define OP_RT_RA_MASK 0xffff0000UL
7568
#define LIS_R2 (PPC_RAW_LIS(_R2, 0))

arch/powerpc/include/asm/exception-64e.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ exc_##label##_book3e:
149149
addi r11,r13,PACA_EXTLB; \
150150
TLB_MISS_RESTORE(r11)
151151

152+
#ifndef __ASSEMBLY__
153+
extern unsigned int interrupt_base_book3e;
154+
#endif
155+
152156
#define SET_IVOR(vector_number, vector_offset) \
153157
LOAD_REG_ADDR(r3,interrupt_base_book3e);\
154158
ori r3,r3,vector_offset@l; \

arch/powerpc/include/asm/nohash/64/pgtable.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ extern int __meminit vmemmap_create_mapping(unsigned long start,
313313
unsigned long phys);
314314
extern void vmemmap_remove_mapping(unsigned long start,
315315
unsigned long page_size);
316+
void __patch_exception(int exc, unsigned long addr);
317+
#define patch_exception(exc, name) do { \
318+
extern unsigned int name; \
319+
__patch_exception((exc), (unsigned long)&name); \
320+
} while (0)
321+
316322
#endif /* __ASSEMBLY__ */
317323

318324
#endif /* _ASM_POWERPC_NOHASH_64_PGTABLE_H */

arch/powerpc/lib/code-patching.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -370,22 +370,6 @@ int translate_branch(ppc_inst_t *instr, const u32 *dest, const u32 *src)
370370
return 1;
371371
}
372372

373-
#ifdef CONFIG_PPC_BOOK3E_64
374-
void __patch_exception(int exc, unsigned long addr)
375-
{
376-
extern unsigned int interrupt_base_book3e;
377-
unsigned int *ibase = &interrupt_base_book3e;
378-
379-
/* Our exceptions vectors start with a NOP and -then- a branch
380-
* to deal with single stepping from userspace which stops on
381-
* the second instruction. Thus we need to patch the second
382-
* instruction of the exception, not the first one
383-
*/
384-
385-
patch_branch(ibase + (exc / 4) + 1, addr, 0);
386-
}
387-
#endif
388-
389373
#ifdef CONFIG_CODE_PATCHING_SELFTEST
390374

391375
static int __init instr_is_branch_to_addr(const u32 *instr, unsigned long addr)

arch/powerpc/mm/nohash/book3e_pgtable.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <asm/pgalloc.h>
1111
#include <asm/tlb.h>
1212
#include <asm/dma.h>
13+
#include <asm/code-patching.h>
1314

1415
#include <mm/mmu_decl.h>
1516

@@ -115,3 +116,17 @@ int __ref map_kernel_page(unsigned long ea, unsigned long pa, pgprot_t prot)
115116
smp_wmb();
116117
return 0;
117118
}
119+
120+
void __patch_exception(int exc, unsigned long addr)
121+
{
122+
unsigned int *ibase = &interrupt_base_book3e;
123+
124+
/*
125+
* Our exceptions vectors start with a NOP and -then- a branch
126+
* to deal with single stepping from userspace which stops on
127+
* the second instruction. Thus we need to patch the second
128+
* instruction of the exception, not the first one.
129+
*/
130+
131+
patch_branch(ibase + (exc / 4) + 1, addr, 0);
132+
}

0 commit comments

Comments
 (0)