Masami Hiramatsu | 540adea | 2018-01-13 02:55:03 +0900 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef _ASM_GENERIC_ERROR_INJECTION_H |
| 3 | #define _ASM_GENERIC_ERROR_INJECTION_H |
| 4 | |
| 5 | #if defined(__KERNEL__) && !defined(__ASSEMBLY__) |
Masami Hiramatsu | 663faf9 | 2018-01-13 02:55:33 +0900 | [diff] [blame] | 6 | enum { |
| 7 | EI_ETYPE_NONE, /* Dummy value for undefined case */ |
| 8 | EI_ETYPE_NULL, /* Return NULL if failure */ |
| 9 | EI_ETYPE_ERRNO, /* Return -ERRNO if failure */ |
| 10 | EI_ETYPE_ERRNO_NULL, /* Return -ERRNO or NULL if failure */ |
| 11 | }; |
| 12 | |
| 13 | struct error_injection_entry { |
| 14 | unsigned long addr; |
| 15 | int etype; |
| 16 | }; |
| 17 | |
Masami Hiramatsu | 540adea | 2018-01-13 02:55:03 +0900 | [diff] [blame] | 18 | #ifdef CONFIG_FUNCTION_ERROR_INJECTION |
| 19 | /* |
| 20 | * Whitelist ganerating macro. Specify functions which can be |
| 21 | * error-injectable using this macro. |
| 22 | */ |
Masami Hiramatsu | 663faf9 | 2018-01-13 02:55:33 +0900 | [diff] [blame] | 23 | #define ALLOW_ERROR_INJECTION(fname, _etype) \ |
| 24 | static struct error_injection_entry __used \ |
Masami Hiramatsu | 540adea | 2018-01-13 02:55:03 +0900 | [diff] [blame] | 25 | __attribute__((__section__("_error_injection_whitelist"))) \ |
Masami Hiramatsu | 663faf9 | 2018-01-13 02:55:33 +0900 | [diff] [blame] | 26 | _eil_addr_##fname = { \ |
| 27 | .addr = (unsigned long)fname, \ |
| 28 | .etype = EI_ETYPE_##_etype, \ |
| 29 | }; |
Masami Hiramatsu | 540adea | 2018-01-13 02:55:03 +0900 | [diff] [blame] | 30 | #else |
Masami Hiramatsu | 663faf9 | 2018-01-13 02:55:33 +0900 | [diff] [blame] | 31 | #define ALLOW_ERROR_INJECTION(fname, _etype) |
Masami Hiramatsu | 540adea | 2018-01-13 02:55:03 +0900 | [diff] [blame] | 32 | #endif |
| 33 | #endif |
| 34 | |
| 35 | #endif /* _ASM_GENERIC_ERROR_INJECTION_H */ |