* [PATCH] xen/livepatch: Move init_or_livepatch_* into xen/init.h
@ 2026-08-03 15:09 Andrew Cooper
2026-08-03 15:28 ` Jan Beulich
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Andrew Cooper @ 2026-08-03 15:09 UTC (permalink / raw)
To: Xen-devel
Cc: Andrew Cooper, Anthony PERARD, Michal Orzel, Jan Beulich,
Julien Grall, Roger Pau Monné, Stefano Stabellini,
Oleksii Kurochko, Ross Lagerwall
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.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger@xenproject.org>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
CC: Ross Lagerwall <ross.lagerwall@citrix.com>
---
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(-)
diff --git a/xen/arch/riscv/extable.c b/xen/arch/riscv/extable.c
index 77e5e9e89439..5b89c4278c65 100644
--- a/xen/arch/riscv/extable.c
+++ b/xen/arch/riscv/extable.c
@@ -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>
diff --git a/xen/arch/x86/alternative.c b/xen/arch/x86/alternative.c
index 5ed0c2672589..4c09dc55c684 100644
--- a/xen/arch/x86/alternative.c
+++ b/xen/arch/x86/alternative.c
@@ -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)
diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index e1c8c9fab811..1425ea176570 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -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>
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 511de4cc38a8..b158742408f9 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -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>
diff --git a/xen/common/vsprintf.c b/xen/common/vsprintf.c
index 612751c90f43..90192fd9e8b9 100644
--- a/xen/common/vsprintf.c
+++ b/xen/common/vsprintf.c
@@ -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>
diff --git a/xen/include/xen/init.h b/xen/include/xen/init.h
index 0c921672c196..2e5bea2bff93 100644
--- a/xen/include/xen/init.h
+++ b/xen/include/xen/init.h
@@ -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
diff --git a/xen/include/xen/livepatch.h b/xen/include/xen/livepatch.h
index 45c8924f3412..416eecb70045 100644
--- a/xen/include/xen/livepatch.h
+++ b/xen/include/xen/livepatch.h
@@ -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;
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] xen/livepatch: Move init_or_livepatch_* into xen/init.h
2026-08-03 15:09 [PATCH] xen/livepatch: Move init_or_livepatch_* into xen/init.h Andrew Cooper
@ 2026-08-03 15:28 ` Jan Beulich
2026-08-03 15:38 ` Ross Lagerwall
2026-08-05 11:20 ` Oleksii Kurochko
2 siblings, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2026-08-03 15:28 UTC (permalink / raw)
To: Andrew Cooper
Cc: Anthony PERARD, Michal Orzel, Julien Grall, Roger Pau Monné,
Stefano Stabellini, Oleksii Kurochko, Ross Lagerwall, Xen-devel
On 03.08.2026 17:09, Andrew Cooper wrote:
> 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.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xen/livepatch: Move init_or_livepatch_* into xen/init.h
2026-08-03 15:09 [PATCH] xen/livepatch: Move init_or_livepatch_* into xen/init.h Andrew Cooper
2026-08-03 15:28 ` Jan Beulich
@ 2026-08-03 15:38 ` Ross Lagerwall
2026-08-05 11:20 ` Oleksii Kurochko
2 siblings, 0 replies; 4+ messages in thread
From: Ross Lagerwall @ 2026-08-03 15:38 UTC (permalink / raw)
To: Andrew Cooper, Xen-devel
Cc: Anthony PERARD, Michal Orzel, Jan Beulich, Julien Grall,
Roger Pau Monné, Stefano Stabellini, Oleksii Kurochko
> From: Andrew Cooper <andrew.cooper3@citrix.com>
> 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_* 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.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xen/livepatch: Move init_or_livepatch_* into xen/init.h
2026-08-03 15:09 [PATCH] xen/livepatch: Move init_or_livepatch_* into xen/init.h Andrew Cooper
2026-08-03 15:28 ` Jan Beulich
2026-08-03 15:38 ` Ross Lagerwall
@ 2026-08-05 11:20 ` Oleksii Kurochko
2 siblings, 0 replies; 4+ messages in thread
From: Oleksii Kurochko @ 2026-08-05 11:20 UTC (permalink / raw)
To: Andrew Cooper, Xen-devel
Cc: Anthony PERARD, Michal Orzel, Jan Beulich, Julien Grall,
Roger Pau Monné, Stefano Stabellini, Ross Lagerwall
On 8/3/26 5:09 PM, Andrew Cooper wrote:
> 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.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Anthony PERARD <anthony.perard@vates.tech>
> CC: Michal Orzel <michal.orzel@amd.com>
> CC: Jan Beulich <jbeulich@suse.com>
> CC: Julien Grall <julien@xen.org>
> CC: Roger Pau Monné <roger@xenproject.org>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> CC: Ross Lagerwall <ross.lagerwall@citrix.com>
> ---
Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Thanks.
~ Oleksii
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-05 11:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-03 15:09 [PATCH] xen/livepatch: Move init_or_livepatch_* into xen/init.h Andrew Cooper
2026-08-03 15:28 ` Jan Beulich
2026-08-03 15:38 ` Ross Lagerwall
2026-08-05 11:20 ` Oleksii Kurochko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.