1 /*
2  * Copyright (C) 2016 Citrix Systems R&D Ltd.
3  */
4 
5 #ifndef __XEN_LIVEPATCH_PAYLOAD_H__
6 #define __XEN_LIVEPATCH_PAYLOAD_H__
7 
8 /*
9  * The following definitions are to be used in patches. They are taken
10  * from kpatch.
11  */
12 typedef void livepatch_loadcall_t(void);
13 typedef void livepatch_unloadcall_t(void);
14 
15 /*
16  * LIVEPATCH_LOAD_HOOK macro
17  *
18  * Declares a function pointer to be allocated in a new
19  * .livepatch.hook.load section.  This livepatch_load_data symbol is later
20  * stripped by create-diff-object so that it can be declared in multiple
21  * objects that are later linked together, avoiding global symbol
22  * collision.  Since multiple hooks can be registered, the
23  * .livepatch.hook.load section is a table of functions that will be
24  * executed in series by the livepatch infrastructure at patch load time.
25  */
26 #define LIVEPATCH_LOAD_HOOK(_fn) \
27     livepatch_loadcall_t *__attribute__((weak)) \
28         const livepatch_load_data_##_fn __section(".livepatch.hooks.load") = _fn;
29 
30 /*
31  * LIVEPATCH_UNLOAD_HOOK macro
32  *
33  * Same as LOAD hook with s/load/unload/
34  */
35 #define LIVEPATCH_UNLOAD_HOOK(_fn) \
36      livepatch_unloadcall_t *__attribute__((weak)) \
37         const livepatch_unload_data_##_fn __section(".livepatch.hooks.unload") = _fn;
38 
39 #endif /* __XEN_LIVEPATCH_PAYLOAD_H__ */
40 
41 /*
42  * Local variables:
43  * mode: C
44  * c-file-style: "BSD"
45  * c-basic-offset: 4
46  * tab-width: 4
47  * indent-tabs-mode: nil
48  * End:
49  */
50