Makefile.ksplice: Rewrite ksplice-cow-check as a wrapper function.
[ksplice.git] / kmodsrc / new_code_loader.c
blobfedfefe7e1945abaf9b30831b633f5a1c0dc168c
1 /* Copyright (C) 2007-2009 Ksplice, Inc.
2 * Authors: Jeff Arnold, Anders Kaseorg, Tim Abbott
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
15 * 02110-1301, USA.
18 #ifdef KSPLICE_STANDALONE
19 #include "ksplice.h"
20 #else
21 #include <linux/ksplice.h>
22 #endif
24 extern struct ksplice_reloc ksplice_relocs[], ksplice_relocs_end[];
25 extern struct ksplice_section ksplice_sections[], ksplice_sections_end[];
26 extern struct ksplice_symbol ksplice_symbols[], ksplice_symbols_end[];
27 extern struct ksplice_patch ksplice_patches[], ksplice_patches_end[];
28 extern const typeof(int (*)(void)) ksplice_call_pre_apply[],
29 ksplice_call_pre_apply_end[], ksplice_call_check_apply[],
30 ksplice_call_check_apply_end[];
31 extern const typeof(void (*)(void)) ksplice_call_apply[],
32 ksplice_call_apply_end[], ksplice_call_post_apply[],
33 ksplice_call_post_apply_end[], ksplice_call_fail_apply[],
34 ksplice_call_fail_apply_end[];
35 extern const typeof(int (*)(void)) ksplice_call_pre_reverse[],
36 ksplice_call_pre_reverse_end[], ksplice_call_check_reverse[],
37 ksplice_call_check_reverse_end[];
38 extern const typeof(void (*)(void)) ksplice_call_reverse[],
39 ksplice_call_reverse_end[], ksplice_call_post_reverse[],
40 ksplice_call_post_reverse_end[], ksplice_call_fail_reverse[],
41 ksplice_call_fail_reverse_end[];
43 #ifdef KSPLICE_NEED_PARAINSTRUCTIONS
44 extern struct paravirt_patch_site parainstructions[], parainstructions_end[];
45 #endif
46 #ifdef KSPLICE_STANDALONE
47 extern struct ksplice_system_map ksplice_system_map[], ksplice_system_map_end[];
48 #endif /* KSPLICE_STANDALONE */
50 #define change KSPLICE_UNIQ(change)
51 struct ksplice_mod_change change = {
52 .name = "ksplice_" __stringify(KSPLICE_MID),
53 .kid = __stringify(KSPLICE_KID),
54 .target_name = __stringify(KSPLICE_TARGET),
55 #ifdef KSPLICE_STANDALONE
56 .map_printk = MAP_PRINTK,
57 #endif /* KSPLICE_STANDALONE */
58 .new_code_mod = THIS_MODULE,
59 .new_code = {
60 .relocs = ksplice_relocs,
61 .relocs_end = ksplice_relocs_end,
62 .sections = ksplice_sections,
63 .sections_end = ksplice_sections_end,
64 .symbols = ksplice_symbols,
65 .symbols_end = ksplice_symbols_end,
66 #ifdef KSPLICE_NEED_PARAINSTRUCTIONS
67 .parainstructions = parainstructions,
68 .parainstructions_end = parainstructions_end,
69 #endif
70 #ifdef KSPLICE_STANDALONE
71 .system_map = ksplice_system_map,
72 .system_map_end = ksplice_system_map_end,
73 #endif /* KSPLICE_STANDALONE */
75 .patches = ksplice_patches,
76 .patches_end = ksplice_patches_end,
77 .hooks = {
78 [KS_APPLY] = {
79 .pre = ksplice_call_pre_apply,
80 .pre_end = ksplice_call_pre_apply_end,
81 .check = ksplice_call_check_apply,
82 .check_end = ksplice_call_check_apply_end,
83 .intra = ksplice_call_apply,
84 .intra_end = ksplice_call_apply_end,
85 .post = ksplice_call_post_apply,
86 .post_end = ksplice_call_post_apply_end,
87 .fail = ksplice_call_fail_apply,
88 .fail_end = ksplice_call_fail_apply_end,
90 [KS_REVERSE] = {
91 .pre = ksplice_call_pre_reverse,
92 .pre_end = ksplice_call_pre_reverse_end,
93 .check = ksplice_call_check_reverse,
94 .check_end = ksplice_call_check_reverse_end,
95 .intra = ksplice_call_reverse,
96 .intra_end = ksplice_call_reverse_end,
97 .post = ksplice_call_post_reverse,
98 .post_end = ksplice_call_post_reverse_end,
99 .fail = ksplice_call_fail_reverse,
100 .fail_end = ksplice_call_fail_reverse_end,
104 EXPORT_SYMBOL_GPL(change);
106 static int init_new_code(void)
108 return 0;
111 static void cleanup_new_code(void)
113 cleanup_ksplice_mod_change(&change);
116 module_init(init_new_code);
117 module_exit(cleanup_new_code);
119 MODULE_AUTHOR("Ksplice, Inc.");
120 MODULE_DESCRIPTION("Ksplice rebootless update new code module");
121 #ifdef KSPLICE_VERSION
122 MODULE_VERSION(KSPLICE_VERSION);
123 #endif
124 MODULE_LICENSE("GPL v2");