diff options
author | Kevin Hao <haokexin@gmail.com> | 2013-05-11 19:26:22 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-12-01 22:06:54 -0500 |
commit | 1e8341ae0c0e117f0626cd6cf6732a0a9c8723f2 (patch) | |
tree | 61b9d4f33170120c060466bc4bc85586cddb3a26 | |
parent | e9419669faacf90e7a4e648d38f61c067a47c0ff (diff) |
powerpc: Move the patch_exception to a common place
So that it can be used by other codes. No function change.
Signed-off-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | arch/powerpc/include/asm/code-patching.h | 7 | ||||
-rw-r--r-- | arch/powerpc/lib/code-patching.c | 15 | ||||
-rw-r--r-- | arch/powerpc/mm/tlb_nohash.c | 19 |
3 files changed, 22 insertions, 19 deletions
diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h index a6f8c7a5cbb7..97e02f985df8 100644 --- a/arch/powerpc/include/asm/code-patching.h +++ b/arch/powerpc/include/asm/code-patching.h | |||
@@ -34,6 +34,13 @@ int instr_is_branch_to_addr(const unsigned int *instr, unsigned long addr); | |||
34 | unsigned long branch_target(const unsigned int *instr); | 34 | unsigned long branch_target(const unsigned int *instr); |
35 | unsigned int translate_branch(const unsigned int *dest, | 35 | unsigned int translate_branch(const unsigned int *dest, |
36 | const unsigned int *src); | 36 | const unsigned int *src); |
37 | #ifdef CONFIG_PPC_BOOK3E_64 | ||
38 | void __patch_exception(int exc, unsigned long addr); | ||
39 | #define patch_exception(exc, name) do { \ | ||
40 | extern unsigned int name; \ | ||
41 | __patch_exception((exc), (unsigned long)&name); \ | ||
42 | } while (0) | ||
43 | #endif | ||
37 | 44 | ||
38 | static inline unsigned long ppc_function_entry(void *func) | 45 | static inline unsigned long ppc_function_entry(void *func) |
39 | { | 46 | { |
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c index 17e5b2364312..d5edbeb8eb82 100644 --- a/arch/powerpc/lib/code-patching.c +++ b/arch/powerpc/lib/code-patching.c | |||
@@ -159,6 +159,21 @@ unsigned int translate_branch(const unsigned int *dest, const unsigned int *src) | |||
159 | return 0; | 159 | return 0; |
160 | } | 160 | } |
161 | 161 | ||
162 | #ifdef CONFIG_PPC_BOOK3E_64 | ||
163 | void __patch_exception(int exc, unsigned long addr) | ||
164 | { | ||
165 | extern unsigned int interrupt_base_book3e; | ||
166 | unsigned int *ibase = &interrupt_base_book3e; | ||
167 | |||
168 | /* Our exceptions vectors start with a NOP and -then- a branch | ||
169 | * to deal with single stepping from userspace which stops on | ||
170 | * the second instruction. Thus we need to patch the second | ||
171 | * instruction of the exception, not the first one | ||
172 | */ | ||
173 | |||
174 | patch_branch(ibase + (exc / 4) + 1, addr, 0); | ||
175 | } | ||
176 | #endif | ||
162 | 177 | ||
163 | #ifdef CONFIG_CODE_PATCHING_SELFTEST | 178 | #ifdef CONFIG_CODE_PATCHING_SELFTEST |
164 | 179 | ||
diff --git a/arch/powerpc/mm/tlb_nohash.c b/arch/powerpc/mm/tlb_nohash.c index 358d74303138..8805b7b87dc6 100644 --- a/arch/powerpc/mm/tlb_nohash.c +++ b/arch/powerpc/mm/tlb_nohash.c | |||
@@ -518,25 +518,6 @@ static void setup_page_sizes(void) | |||
518 | } | 518 | } |
519 | } | 519 | } |
520 | 520 | ||
521 | static void __patch_exception(int exc, unsigned long addr) | ||
522 | { | ||
523 | extern unsigned int interrupt_base_book3e; | ||
524 | unsigned int *ibase = &interrupt_base_book3e; | ||
525 | |||
526 | /* Our exceptions vectors start with a NOP and -then- a branch | ||
527 | * to deal with single stepping from userspace which stops on | ||
528 | * the second instruction. Thus we need to patch the second | ||
529 | * instruction of the exception, not the first one | ||
530 | */ | ||
531 | |||
532 | patch_branch(ibase + (exc / 4) + 1, addr, 0); | ||
533 | } | ||
534 | |||
535 | #define patch_exception(exc, name) do { \ | ||
536 | extern unsigned int name; \ | ||
537 | __patch_exception((exc), (unsigned long)&name); \ | ||
538 | } while (0) | ||
539 | |||
540 | static void setup_mmu_htw(void) | 521 | static void setup_mmu_htw(void) |
541 | { | 522 | { |
542 | /* Check if HW tablewalk is present, and if yes, enable it by: | 523 | /* Check if HW tablewalk is present, and if yes, enable it by: |