[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] xen/livepatch: Move init_or_livepatch_* into xen/init.h



commit 4ee301544edee3ec1a87894717511cc47b36dc0d
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Mon Aug 3 15:46:45 2026 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Tue Aug 4 17:32:23 2026 +0100

    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.
    
    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@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
---
 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 77e5e9e894..5b89c4278c 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 95960b4a46..c87665bffe 100644
--- a/xen/arch/x86/alternative.c
+++ b/xen/arch/x86/alternative.c
@@ -5,7 +5,6 @@
 
 #include <xen/delay.h>
 #include <xen/init.h>
-#include <xen/livepatch.h>
 
 #include <asm/alternative.h>
 #include <asm/apic.h>
diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index e1c8c9fab8..1425ea1765 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 511de4cc38..b158742408 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 612751c90f..90192fd9e8 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 0c921672c1..2e5bea2bff 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 b40928c3e6..5dc8c61d37 100644
--- a/xen/include/xen/livepatch.h
+++ b/xen/include/xen/livepatch.h
@@ -22,17 +22,6 @@ struct xen_sysctl_livepatch_op;
 
 #include <public/sysctl.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 /* !CONFIG_LIVEPATCH */
 
-/*
- * 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;
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.