diff options
author | Leo Yan <leo.yan@linaro.org> | 2019-08-06 06:00:13 -0400 |
---|---|---|
committer | Will Deacon <will@kernel.org> | 2019-08-07 08:52:43 -0400 |
commit | 45880f7b7b19e043ce0aaa4cb7d05369425c82fa (patch) | |
tree | 8ff0173a799d6a03edc118f9ce8c9a57861d3a80 | |
parent | e21a712a9685488f5ce80495b37b9fdbe96c230d (diff) |
error-injection: Consolidate override function definition
The function override_function_with_return() is defined separately for
each architecture and every architecture's definition is almost same
with each other. E.g. x86 and powerpc both define function in its own
asm/error-injection.h header and override_function_with_return() has
the same definition, the only difference is that x86 defines an extra
function just_return_func() but it is specific for x86 and is only used
by x86's override_function_with_return(), so don't need to export this
function.
This patch consolidates override_function_with_return() definition into
asm-generic/error-injection.h header, thus all architectures can use the
common definition. As result, the architecture specific headers are
removed; the include/linux/error-injection.h header also changes to
include asm-generic/error-injection.h header rather than architecture
header, furthermore, it includes linux/compiler.h for successful
compilation.
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r-- | arch/powerpc/include/asm/error-injection.h | 13 | ||||
-rw-r--r-- | arch/x86/include/asm/error-injection.h | 13 | ||||
-rw-r--r-- | include/asm-generic/error-injection.h | 6 | ||||
-rw-r--r-- | include/linux/error-injection.h | 6 |
4 files changed, 9 insertions, 29 deletions
diff --git a/arch/powerpc/include/asm/error-injection.h b/arch/powerpc/include/asm/error-injection.h deleted file mode 100644 index 62fd24739852..000000000000 --- a/arch/powerpc/include/asm/error-injection.h +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0+ */ | ||
2 | |||
3 | #ifndef _ASM_ERROR_INJECTION_H | ||
4 | #define _ASM_ERROR_INJECTION_H | ||
5 | |||
6 | #include <linux/compiler.h> | ||
7 | #include <linux/linkage.h> | ||
8 | #include <asm/ptrace.h> | ||
9 | #include <asm-generic/error-injection.h> | ||
10 | |||
11 | void override_function_with_return(struct pt_regs *regs); | ||
12 | |||
13 | #endif /* _ASM_ERROR_INJECTION_H */ | ||
diff --git a/arch/x86/include/asm/error-injection.h b/arch/x86/include/asm/error-injection.h deleted file mode 100644 index 47b7a1296245..000000000000 --- a/arch/x86/include/asm/error-injection.h +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | #ifndef _ASM_ERROR_INJECTION_H | ||
3 | #define _ASM_ERROR_INJECTION_H | ||
4 | |||
5 | #include <linux/compiler.h> | ||
6 | #include <linux/linkage.h> | ||
7 | #include <asm/ptrace.h> | ||
8 | #include <asm-generic/error-injection.h> | ||
9 | |||
10 | asmlinkage void just_return_func(void); | ||
11 | void override_function_with_return(struct pt_regs *regs); | ||
12 | |||
13 | #endif /* _ASM_ERROR_INJECTION_H */ | ||
diff --git a/include/asm-generic/error-injection.h b/include/asm-generic/error-injection.h index 95a159a4137f..80ca61058dd2 100644 --- a/include/asm-generic/error-injection.h +++ b/include/asm-generic/error-injection.h | |||
@@ -16,6 +16,8 @@ struct error_injection_entry { | |||
16 | int etype; | 16 | int etype; |
17 | }; | 17 | }; |
18 | 18 | ||
19 | struct pt_regs; | ||
20 | |||
19 | #ifdef CONFIG_FUNCTION_ERROR_INJECTION | 21 | #ifdef CONFIG_FUNCTION_ERROR_INJECTION |
20 | /* | 22 | /* |
21 | * Whitelist ganerating macro. Specify functions which can be | 23 | * Whitelist ganerating macro. Specify functions which can be |
@@ -28,8 +30,12 @@ static struct error_injection_entry __used \ | |||
28 | .addr = (unsigned long)fname, \ | 30 | .addr = (unsigned long)fname, \ |
29 | .etype = EI_ETYPE_##_etype, \ | 31 | .etype = EI_ETYPE_##_etype, \ |
30 | }; | 32 | }; |
33 | |||
34 | void override_function_with_return(struct pt_regs *regs); | ||
31 | #else | 35 | #else |
32 | #define ALLOW_ERROR_INJECTION(fname, _etype) | 36 | #define ALLOW_ERROR_INJECTION(fname, _etype) |
37 | |||
38 | static inline void override_function_with_return(struct pt_regs *regs) { } | ||
33 | #endif | 39 | #endif |
34 | #endif | 40 | #endif |
35 | 41 | ||
diff --git a/include/linux/error-injection.h b/include/linux/error-injection.h index 280c61ecbf20..635a95caf29f 100644 --- a/include/linux/error-injection.h +++ b/include/linux/error-injection.h | |||
@@ -2,16 +2,16 @@ | |||
2 | #ifndef _LINUX_ERROR_INJECTION_H | 2 | #ifndef _LINUX_ERROR_INJECTION_H |
3 | #define _LINUX_ERROR_INJECTION_H | 3 | #define _LINUX_ERROR_INJECTION_H |
4 | 4 | ||
5 | #ifdef CONFIG_FUNCTION_ERROR_INJECTION | 5 | #include <linux/compiler.h> |
6 | #include <asm-generic/error-injection.h> | ||
6 | 7 | ||
7 | #include <asm/error-injection.h> | 8 | #ifdef CONFIG_FUNCTION_ERROR_INJECTION |
8 | 9 | ||
9 | extern bool within_error_injection_list(unsigned long addr); | 10 | extern bool within_error_injection_list(unsigned long addr); |
10 | extern int get_injectable_error_type(unsigned long addr); | 11 | extern int get_injectable_error_type(unsigned long addr); |
11 | 12 | ||
12 | #else /* !CONFIG_FUNCTION_ERROR_INJECTION */ | 13 | #else /* !CONFIG_FUNCTION_ERROR_INJECTION */ |
13 | 14 | ||
14 | #include <asm-generic/error-injection.h> | ||
15 | static inline bool within_error_injection_list(unsigned long addr) | 15 | static inline bool within_error_injection_list(unsigned long addr) |
16 | { | 16 | { |
17 | return false; | 17 | return false; |