xen/livepatch: Move init_or_livepatch_* into xen/init.h
PATCH 1/1 xen/livepatch: Move init_or_livepatch_* into xen/init.h
xen/livepatch.h is a fairly heavyweight header pulling in public/sysctl.h, and a reasonable number of users care only for the init_or_livepatch_* tags only.
They're arguably more init than livepatch anyway, and by moving them to init.h, we can remove a number of includes.
The include in vsprintf was leftover from early versions of the work. In the version committed, d5ccf4482e4f ("x86, xsplice: Print payload's symbol name and payload name in backtraces"), symbol_lookup() had been adjusted to handle the livepatch symbol names properly.
No functional change.
---
CC: Anthony PERARD <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Ross Lagerwall <[email protected]>
--- xen/arch/riscv/extable.c | 1 - xen/arch/x86/alternative.c | 1 - xen/arch/x86/extable.c | 1 - xen/arch/x86/mm.c | 1 - xen/common/vsprintf.c | 1 - xen/include/xen/init.h | 19 +++++++++++++++++++ xen/include/xen/livepatch.h | 21 --------------------- 7 files changed, 19 insertions(+), 26 deletions(-)
xen/arch/riscv/extable.c +0 -1
@@ -3,7 +3,6 @@#include <xen/init.h> #include <xen/bsearch.h> #include <xen/lib.h> -#include <xen/livepatch.h> #include <xen/sort.h> #include <xen/virtual_region.h>
xen/arch/x86/alternative.c +0 -1
@@ -16,7 +16,6 @@#include <asm/traps.h> #include <asm/nmi.h> #include <asm/nops.h> -#include <xen/livepatch.h> #define MAX_PATCH_LEN (255-1)
xen/arch/x86/extable.c +0 -1
@@ -2,7 +2,6 @@#include <xen/domain_page.h> #include <xen/init.h> #include <xen/list.h> -#include <xen/livepatch.h> #include <xen/perfc.h> #include <xen/rcupdate.h> #include <xen/sort.h>
xen/arch/x86/mm.c +0 -1
@@ -101,7 +101,6 @@#include <xen/irq.h> #include <xen/kernel.h> #include <xen/lib.h> -#include <xen/livepatch.h> #include <xen/mm.h> #include <xen/param.h> #include <xen/perfc.h>
xen/common/vsprintf.c +0 -1
@@ -20,7 +20,6 @@#include <xen/symbols.h> #include <xen/lib.h> #include <xen/sched.h> -#include <xen/livepatch.h> #include <asm/div64.h> #include <asm/page.h>
xen/include/xen/init.h +19 -0
@@ -19,6 +19,25 @@#define __initdata_cf_clobber __section(".init.data.cf_clobber")#define __initconst_cf_clobber __section(".init.rodata.cf_clobber") +/* +* Various pieces of functionality are needed at runtime only if livepatching +* is enabled. Provide tags which resolve to the appropriate section +* annotation in either configuration. +*/ +#ifdef CONFIG_LIVEPATCH +# define init_or_livepatch_const +# define init_or_livepatch_constrel +# define init_or_livepatch_data +# define init_or_livepatch_read_mostly __read_mostly +# define init_or_livepatch +#else /* !CONFIG_LIVEPATCH */ +# define init_or_livepatch_const __initconst +# define init_or_livepatch_constrel __initconstrel +# define init_or_livepatch_data __initdata +# define init_or_livepatch_read_mostly __initdata +# define init_or_livepatch __init +#endif /* !CONFIG_LIVEPATCH */ +/* These macros are used to mark some functions or * initialized data (doesn't apply to uninitialized data) * as `initialization' functions. The kernel can take this
xen/include/xen/livepatch.h +0 -21
@@ -20,17 +20,6 @@ struct xen_sysctl_livepatch_op;#include <xen/lib.h> -/* -* We use alternative and exception table code - which by default are __init -* only, however we need them during runtime. These macros allows us to build -* the image with these functions built-in. (See the #else below). -*/ -#define init_or_livepatch_const -#define init_or_livepatch_constrel -#define init_or_livepatch_data -#define init_or_livepatch_read_mostly __read_mostly -#define init_or_livepatch -/* Convenience define for printk. */ #define LIVEPATCH "livepatch: "/* ELF payload special section names. */
@@ -145,16 +134,6 @@ void revert_payload_tail(struct payload *data);#else -/* -* If not compiling with Live Patch certain functionality should stay as -* __init. -*/ -#define init_or_livepatch_const __initconst -#define init_or_livepatch_constrel __initconstrel -#define init_or_livepatch_data __initdata -#define init_or_livepatch_read_mostly __initdata -#define init_or_livepatch __init -static inline int livepatch_op (struct xen_sysctl_livepatch_op *op) {return -ENOSYS ;
Signature · 1 line
2.39.5
Quoted 6 lines · Andrew Cooper
xen/livepatch.his a fairly heavyweight header pulling inpublic/sysctl.h, and a reasonable number of users care only for the init_or_livepatch_* tags only.They're arguably more init than livepatch anyway, and by moving them to
init.h, we can remove a number of includes.
Quoted 8 lines
The include in vsprintf was leftover from early versions of the work. In the version committed,
d5ccf4482e4f("x86, xsplice: Print payload's symbol name and payload name in backtraces"),symbol_lookup()had been adjusted to handle the livepatch symbol names properly.No functional change.
Signed-off-by Andrew Cooper <[email protected]>
Quoted 12 lines
From: Andrew Cooper <[email protected]>
Sent: Monday, August 3, 2026 4:09 PM
To: Xen-devel
Cc: Andrew Cooper; Anthony PERARD; Michal Orzel; Jan Beulich; Julien Grall; Roger Pau Monné; Stefano Stabellini; Oleksii Kurochko; Ross Lagerwall
Subject: [PATCH] xen/livepatch: Move init_or_livepatch_* intoxen/init.h
xen/livepatch.his a fairly heavyweight header pulling inpublic/sysctl.h, and a reasonable number of users care only for the init_or_livepatch_* tags only.They're arguably more init than livepatch anyway, and by moving them to
init.h, we can remove a number of includes.
Quoted 8 lines
The include in vsprintf was leftover from early versions of the work. In the version committed,
d5ccf4482e4f("x86, xsplice: Print payload's symbol name and payload name in backtraces"),symbol_lookup()had been adjusted to handle the livepatch symbol names properly.No functional change.
Signed-off-by Andrew Cooper <[email protected]>
Thanks
Quoted 14 lines · Andrew Cooper
xen/livepatch.his a fairly heavyweight header pulling inpublic/sysctl.h, and a reasonable number of users care only for the init_or_livepatch_* tags only.They're arguably more init than livepatch anyway, and by moving them to
init.h, we can remove a number of includes.The include in vsprintf was leftover from early versions of the work. In the version committed,
d5ccf4482e4f("x86, xsplice: Print payload's symbol name and payload name in backtraces"),symbol_lookup()had been adjusted to handle the livepatch symbol names properly.No functional change.
Signed-off-by Andrew Cooper <[email protected]>
Quoted 10 lines
---
CC: Anthony PERARD <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Ross Lagerwall <[email protected]>
---
Thanks.
~ Oleksii