xen: Header fixes
v2 cover xen: Header fixes
Split out of "[PATCH 0/8] xen: Untangle mm.h"
https://lore.kernel.org/xen-devel/[email protected]/
Andrew Cooper (3):
xen/elfstructs: Include xen/types.h
xen/livepatch: Fix include hierarchy
xen: Sort includes
xen/arch/arm/arm32/livepatch.c | 1 - xen/arch/arm/arm64/livepatch.c | 1 - xen/arch/arm/livepatch.c | 1 - xen/arch/arm/mmu/setup.c | 2 +- xen/arch/x86/alternative.c | 12 ++++++------ xen/arch/x86/livepatch.c | 9 ++++----- xen/common/memory.c | 4 +++- xen/common/page_alloc.c | 5 ++--- xen/include/xen/elfstructs.h | 8 +++++++- xen/include/xen/livepatch.h | 10 +++++----- xen/include/xen/livepatch_elf.h | 1 - xen/include/xen/mm.h | 6 +++--- xen/include/xen/version.h | 1 - 13 files changed, 31 insertions(+), 30 deletions(-)
Signature · 1 line
2.39.5
PATCH v2 1/3 xen/elfstructs: Include xen/types.h
elfstructs.h needs the stdint.h types. Two headers arrange this manually, but elf.h and livepatch.h do not, which breaks source files whose headers are properly sorted.
elfstructs.h is used by tools too, so use stdint directly outside of Xen.
Clean up trailing whitespace.
---
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: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>
CC: Ross Lagerwall <[email protected]>
v2:
* Include stdint outside of Xen.
--- xen/include/xen/elfstructs.h | 8 +++++++- xen/include/xen/livepatch_elf.h | 1 - xen/include/xen/version.h | 1 - 3 files changed, 7 insertions(+), 3 deletions(-)
xen/include/xen/elfstructs.h +7 -1
@@ -26,6 +26,12 @@* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef __XEN__ +#include <xen/stdint.h> +#else +#include <stdint.h> +#endif +typedef uint32_t Elf32_Addr ;/* Unsigned program address */ typedef uint32_t Elf32_Off ;/* Unsigned file offset */ typedef uint16_t Elf32_Half ;/* Unsigned medium integer */
@@ -45,7 +51,7 @@ typedef uint64_t Elf64_Xword;/* * e_ident[] identification indexes -* See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html +* See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html */ #define EI_MAG0 0/* file ID */ #define EI_MAG1 1/* file ID */
xen/include/xen/livepatch_elf.h +0 -1
@@ -5,7 +5,6 @@#ifndef __XEN_LIVEPATCH_ELF_H__#define __XEN_LIVEPATCH_ELF_H__ -#include <xen/types.h> #include <xen/elfstructs.h> /* The following describes an Elf file as consumed by Xen Live Patch. */
xen/include/xen/version.h +0 -1
@@ -1,7 +1,6 @@#ifndef __XEN_VERSION_H__#define __XEN_VERSION_H__ -#include <xen/types.h> #include <xen/elfstructs.h> const char *xen_compile_date (void );
Signature · 1 line
2.39.5
Re: [PATCH v2 1/3] xen/elfstructs: Include xen/types.h
Quoted 10 lines · Andrew Cooper
elfstructs.hneeds thestdint.htypes. Two headers arrange this manually, butelf.handlivepatch.hdo not, which breaks source files whose headers are properly sorted.
elfstructs.his used by tools too, so use stdint directly outside of Xen.Clean up trailing whitespace.
Signed-off-by Andrew Cooper <[email protected]>
Re: [PATCH v2 1/3] xen/elfstructs: Include xen/types.h
In reply to Andrew CooperQuoted 9 lines · Andrew Cooper
elfstructs.hneeds thestdint.htypes. Two headers arrange this manually, butelf.handlivepatch.hdo not, which breaks source files whose headers are properly sorted.
elfstructs.his used by tools too, so use stdint directly outside of Xen.Clean up trailing whitespace.
Signed-off-by Andrew Cooper <[email protected]>
PATCH v2 2/3 xen/livepatch: Fix include hierarchy
In reply to Andrew Cooperxen/livepatch.h includes public/sysctl.h twice, which can be deduplicated, and includes asm/livepatch.h meaning that each livepatch.c does not need to include both.
Comment the #else and #endif cases to aid legibility.
---
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: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>
CC: Ross Lagerwall <[email protected]>
--- xen/arch/arm/arm32/livepatch.c | 1 - xen/arch/arm/arm64/livepatch.c | 1 - xen/arch/arm/livepatch.c | 1 - xen/arch/x86/livepatch.c | 1 - xen/include/xen/livepatch.h | 10 +++++----- 5 files changed, 5 insertions(+), 9 deletions(-)
xen/arch/arm/arm32/livepatch.c +0 -1
@@ -9,7 +9,6 @@#include <xen/livepatch.h> #include <asm/page.h> -#include <asm/livepatch.h> void arch_livepatch_apply (const struct livepatch_func *func,struct livepatch_fstate *state)
xen/arch/arm/arm64/livepatch.c +0 -1
@@ -13,7 +13,6 @@#include <asm/bitops.h> #include <asm/insn.h> -#include <asm/livepatch.h> void arch_livepatch_apply (const struct livepatch_func *func,struct livepatch_fstate *state)
xen/arch/arm/livepatch.c +0 -1
@@ -11,7 +11,6 @@#include <xen/vmap.h> #include <asm/cpufeature.h> -#include <asm/livepatch.h> /* Override macros from asm/page.h to make them work with mfn_t */ #undef virt_to_mfn
xen/arch/x86/livepatch.c +0 -1
@@ -17,7 +17,6 @@#include <asm/endbr.h> #include <asm/fixmap.h> #include <asm/nmi.h> -#include <asm/livepatch.h> #include <asm/setup.h> static bool has_active_waitqueue (const struct vm_event_domain *ved)
xen/include/xen/livepatch.h +5 -5
@@ -14,12 +14,14 @@ struct xen_sysctl_livepatch_op;#include <xen/elfstructs.h> #include <xen/errno.h> /* For -ENOSYS or -EOVERFLOW */ -#include <public/sysctl.h> /* For LIVEPATCH_OPAQUE_SIZE */ +#include <public/sysctl.h> #ifdef CONFIG_LIVEPATCH #include <xen/lib.h> +#include <asm/livepatch.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
@@ -93,8 +95,6 @@ int arch_livepatch_secure(const void *va, unsigned int pages, enum va_type typesvoid arch_livepatch_init (void ); -#include <public/sysctl.h> /* For struct livepatch_func. */ -#include <asm/livepatch.h> int arch_livepatch_verify_func (const struct livepatch_func *func); static inline
@@ -143,7 +143,7 @@ struct payload;int revert_payload (struct payload *data);void revert_payload_tail (struct payload *data); -#else +#else /* !CONFIG_LIVEPATCH */ /* * If not compiling with Live Patch certain functionality should stay as
@@ -165,7 +165,7 @@ static inline bool is_patch(const void *addr) {return 0 ; } -#endif /* CONFIG_LIVEPATCH */ +#endif /* !CONFIG_LIVEPATCH */ #endif /* __XEN_LIVEPATCH_H__ */
Signature · 1 line
2.39.5
Re: [PATCH v2 2/3] xen/livepatch: Fix include hierarchy
Quoted 81 lines · Andrew Cooper
xen/livepatch.hincludespublic/sysctl.htwice, which can be deduplicated, and includesasm/livepatch.hmeaning that eachlivepatch.cdoes not need to include both.Comment the #else and #endif cases to aid legibility.
Signed-off-by Andrew Cooper <[email protected]>---
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: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>
CC: Ross Lagerwall <[email protected]>--- xen/arch/arm/arm32/livepatch.c | 1 - xen/arch/arm/arm64/livepatch.c | 1 - xen/arch/arm/livepatch.c | 1 - xen/arch/x86/livepatch.c | 1 - xen/include/xen/livepatch.h | 10 +++++----- 5 files changed, 5 insertions(+), 9 deletions(-)xen/arch/arm/arm32/livepatch.c +0
-1@@ -9,7 +9,6 @@#include <xen/livepatch.h> #include <asm/page.h> -#include <asm/livepatch.h> void arch_livepatch_apply (const struct livepatch_func *func,struct livepatch_fstate *state)xen/arch/arm/arm64/livepatch.c +0
-1@@ -13,7 +13,6 @@#include <asm/bitops.h> #include <asm/insn.h> -#include <asm/livepatch.h> void arch_livepatch_apply (const struct livepatch_func *func,struct livepatch_fstate *state)xen/arch/arm/livepatch.c +0
-1@@ -11,7 +11,6 @@#include <xen/vmap.h> #include <asm/cpufeature.h> -#include <asm/livepatch.h> /* Override macros from asm/page.h to make them work with mfn_t */ #undef virt_to_mfnxen/arch/x86/livepatch.c +0
-1@@ -17,7 +17,6 @@#include <asm/endbr.h> #include <asm/fixmap.h> #include <asm/nmi.h> -#include <asm/livepatch.h> #include <asm/setup.h> static bool has_active_waitqueue (const struct vm_event_domain *ved)xen/include/xen/livepatch.h +0
-0
xen/include/xen/livepatch.h struct xen_sysctl_livepatch_op; · line 20
Quoted 8 lines
xen/include/xen/livepatch.h +1
-1@@ -14,12 +14,14 @@ struct xen_sysctl_livepatch_op;#include <xen/elfstructs.h> #include <xen/errno.h> /* For -ENOSYS or -EOVERFLOW */ -#include <public/sysctl.h> /* For LIVEPATCH_OPAQUE_SIZE */ +#include <public/sysctl.h> #ifdef CONFIG_LIVEPATCH
Shouldn't the inclusion of sysctl.h be inside CONFIG_LIVEPATCH?
There is already a forward declaration for xen_sysctl_livepatch_op which should cover the !CONFIG_LIVEPATCH side of things.
Ross
PATCH v3 2/3 xen/livepatch: Fix include hierarchy
In reply to Andrew Cooperxen/livepatch.h includes public/sysctl.h twice, which can be deduplicated, and includes asm/livepatch.h meaning that each livepatch.c does not need to include both.
Comment the #else and #endif cases to aid legibility.
---
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: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Ross Lagerwall <[email protected]>
v3
* Limit public/sysctl.h to CONFIG_LIVEPATCH builds
--- xen/arch/arm/arm32/livepatch.c | 1 - xen/arch/arm/arm64/livepatch.c | 1 - xen/arch/arm/livepatch.c | 1 - xen/arch/x86/livepatch.c | 1 - xen/include/xen/livepatch.h | 12 ++++++------ 5 files changed, 6 insertions(+), 10 deletions(-)
xen/arch/arm/arm32/livepatch.c +0 -1
@@ -9,7 +9,6 @@#include <xen/livepatch.h> #include <asm/page.h> -#include <asm/livepatch.h> void arch_livepatch_apply (const struct livepatch_func *func,struct livepatch_fstate *state)
xen/arch/arm/arm64/livepatch.c +0 -1
@@ -13,7 +13,6 @@#include <asm/bitops.h> #include <asm/insn.h> -#include <asm/livepatch.h> void arch_livepatch_apply (const struct livepatch_func *func,struct livepatch_fstate *state)
xen/arch/arm/livepatch.c +0 -1
@@ -11,7 +11,6 @@#include <xen/vmap.h> #include <asm/cpufeature.h> -#include <asm/livepatch.h> /* Override macros from asm/page.h to make them work with mfn_t */ #undef virt_to_mfn
xen/arch/x86/livepatch.c +0 -1
@@ -17,7 +17,6 @@#include <asm/endbr.h> #include <asm/fixmap.h> #include <asm/nmi.h> -#include <asm/livepatch.h> #include <asm/setup.h> static bool has_active_waitqueue (const struct vm_event_domain *ved)
xen/include/xen/livepatch.h +6 -6
@@ -14,12 +14,14 @@ struct xen_sysctl_livepatch_op;#include <xen/elfstructs.h> #include <xen/errno.h> /* For -ENOSYS or -EOVERFLOW */ -#include <public/sysctl.h> /* For LIVEPATCH_OPAQUE_SIZE */ -#ifdef CONFIG_LIVEPATCH #include <xen/lib.h> +#include <asm/livepatch.h> + +#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
@@ -93,8 +95,6 @@ int arch_livepatch_secure(const void *va, unsigned int pages, enum va_type type)void arch_livepatch_init (void ); -#include <public/sysctl.h> /* For struct livepatch_func. */ -#include <asm/livepatch.h> int arch_livepatch_verify_func (const struct livepatch_func *func); static inline
@@ -143,7 +143,7 @@ struct payload;int revert_payload (struct payload *data);void revert_payload_tail (struct payload *data); -#else +#else /* !CONFIG_LIVEPATCH */ /* * If not compiling with Live Patch certain functionality should stay as
@@ -165,7 +165,7 @@ static inline bool is_patch(const void *addr) {return 0 ; } -#endif /* CONFIG_LIVEPATCH */ +#endif /* !CONFIG_LIVEPATCH */ #endif /* __XEN_LIVEPATCH_H__ */
Signature · 1 line
2.39.5
Re: [PATCH v3 2/3] xen/livepatch: Fix include hierarchy
Quoted 6 lines
From: Andrew Cooper <[email protected]>
Sent: Friday, July 31, 2026 4:44 PM
To: Xen-devel
Cc: Andrew Cooper; Anthony PERARD; Michal Orzel; Jan Beulich; Julien Grall; Roger Pau Monné; Stefano Stabellini; Volodymyr Babchuk; Bertrand Marquis; Oleksii Kurochko; Ross Lagerwall
Subject: [PATCH v3 2/3] xen/livepatch: Fix include hierarchy
Quoted 7 lines
xen/livepatch.hincludespublic/sysctl.htwice, which can be deduplicated, and includesasm/livepatch.hmeaning that eachlivepatch.cdoes not need to include both.Comment the #else and #endif cases to aid legibility.
Signed-off-by Andrew Cooper <[email protected]>
Thanks
PATCH v2 3/3 xen: Sort includes
In reply to Andrew Cooper... needing later adjustment. Drop types.h when it's clearly not needed.
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: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>
--- xen/arch/arm/mmu/setup.c | 2 +- xen/arch/x86/alternative.c | 12 ++++++------ xen/arch/x86/livepatch.c | 8 ++++---- xen/common/memory.c | 4 +++- xen/common/page_alloc.c | 5 ++--- xen/include/xen/mm.h | 6 +++--- 6 files changed, 19 insertions(+), 18 deletions(-)
xen/arch/arm/mmu/setup.c +1 -1
@@ -12,8 +12,8 @@#include <xen/sizes.h> #include <xen/vmap.h> -#include <asm/setup.h> #include <asm/fixmap.h> +#include <asm/setup.h> /* Override macros from asm/page.h to make them work with mfn_t */ #undef mfn_to_virt
xen/arch/x86/alternative.c +6 -6
@@ -4,18 +4,18 @@*/ #include <xen/delay.h> -#include <xen/types.h> +#include <xen/init.h> +#include <xen/livepatch.h> + +#include <asm/alternative.h> #include <asm/apic.h> #include <asm/endbr.h> +#include <asm/nmi.h> +#include <asm/nops.h> #include <asm/processor.h> -#include <asm/alternative.h> -#include <xen/init.h> #include <asm/setup.h> #include <asm/system.h> #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/livepatch.c +4 -4
@@ -5,14 +5,14 @@#include <xen/errno.h> #include <xen/init.h> #include <xen/lib.h> +#include <xen/livepatch.h> +#include <xen/livepatch_elf.h> #include <xen/mm.h> #include <xen/pfn.h> -#include <xen/vmap.h> -#include <xen/livepatch_elf.h> -#include <xen/livepatch.h> #include <xen/sched.h> -#include <xen/vm_event.h> #include <xen/virtual_region.h> +#include <xen/vm_event.h> +#include <xen/vmap.h> #include <asm/endbr.h> #include <asm/fixmap.h>
xen/common/memory.c +3 -1
@@ -25,12 +25,14 @@#include <xen/sched.h> #include <xen/sections.h> #include <xen/trace.h> -#include <xen/types.h> +#include <asm/current.h> #include <asm/hardirq.h> #include <asm/p2m.h> #include <asm/page.h> +#include <public/memory.h> +#include <xsm/xsm.h> #ifdef CONFIG_X86
xen/common/page_alloc.c +2 -3
@@ -133,7 +133,6 @@#include <xen/param.h> #include <xen/perfc.h> #include <xen/pfn.h> -#include <xen/types.h> #include <xen/sched.h> #include <xen/sections.h> #include <xen/softirq.h>
@@ -144,14 +143,14 @@#include <asm/flushtlb.h> #include <asm/page.h> -#include <public/sysctl.h> #include <public/sched.h> +#include <public/sysctl.h> #ifdef CONFIG_X86 #include <asm/guest.h> #include <asm/p2m.h> -#include <asm/setup.h> /* for highmem_start only */ #include <asm/paging.h> +#include <asm/setup.h> #else #define p2m_pod_offline_or_broken_hit (pg) 0#define p2m_pod_offline_or_broken_replace (pg) BUG_ON(pg)
xen/include/xen/mm.h +3 -3
@@ -63,12 +63,12 @@#include <xen/bug.h> #include <xen/compiler.h> +#include <xen/list.h> #include <xen/mm-frame.h> #include <xen/mm-types.h> -#include <xen/types.h> -#include <xen/list.h> -#include <xen/spinlock.h> #include <xen/perfc.h> +#include <xen/spinlock.h> +#include <public/memory.h> struct page_info ;
Signature · 1 line
2.39.5
Re: [PATCH v2 3/3] xen: Sort includes
Quoted 31 lines · Andrew Cooper
... needing later adjustment. Drop
types.hwhen it's clearly not needed.No functional change.
Signed-off-by Andrew Cooper <[email protected]>Acked-by Jan Beulich <[email protected]>---
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: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Oleksii Kurochko <[email protected]>
CC: Shawn Anastasio <[email protected]>--- xen/arch/arm/mmu/setup.c | 2 +- xen/arch/x86/alternative.c | 12 ++++++------ xen/arch/x86/livepatch.c | 8 ++++---- xen/common/memory.c | 4 +++- xen/common/page_alloc.c | 5 ++--- xen/include/xen/mm.h | 6 +++--- 6 files changed, 19 insertions(+), 18 deletions(-)xen/arch/arm/mmu/setup.c +0
-0
xen/arch/arm/mmu/setup.c line 17
Quoted 7 lines
xen/arch/arm/mmu/setup.c +1
-1@@ -12,8 +12,8 @@#include <xen/sizes.h> #include <xen/vmap.h> -#include <asm/setup.h> #include <asm/fixmap.h> +#include <asm/setup.h>
I'm timing out the ack for this, seeing as I've just hit the same build failure again.
~Andrew