Introduce a new Kconfig option to pick the alignment for xen binary.
To retain original behaviour, the default pick for EFI build is 2M and
non-EFI build 4K.

Signed-off-by: Wei Liu <wei.l...@citrix.com>
---
 xen/arch/x86/Kconfig   | 26 ++++++++++++++++++++++++++
 xen/arch/x86/xen.lds.S | 16 ++++++++++++++--
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
index 5c2d1070b6..b15053cfbe 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -138,6 +138,32 @@ config TBOOT
 
          If unsure, say Y.
 
+choice
+       prompt "Alignment of Xen binary"
+       depends on X86
+       default XEN_ALIGN_DEFAULT
+       ---help---
+         Specify alignment for Xen binary.
+
+         If unsure, choose "default".
+
+config XEN_ALIGN_DEFAULT
+       bool "Default alignment"
+       ---help---
+         Pick alignment according to build variants.
+
+         For EFI build the default alignment is 2M. For non-EFI build
+         the default alignment is 4K due to syslinux failing to handle
+         2M alignment.
+
+config XEN_ALIGN_4K
+       bool "4K alignment"
+
+config XEN_ALIGN_2M
+       bool "2M alignment"
+
+endchoice
+
 config XEN_GUEST
        def_bool n
        prompt "Xen Guest"
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 6e9bda5109..163de31574 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -12,7 +12,6 @@
 #define FORMAT "pei-x86-64"
 #undef __XEN_VIRT_START
 #define __XEN_VIRT_START __image_base__
-#define SECTION_ALIGN MB(2)
 #define DECL_SECTION(x) x :
 
 ENTRY(efi_start)
@@ -20,13 +19,26 @@ ENTRY(efi_start)
 #else /* !EFI */
 
 #define FORMAT "elf64-x86-64"
-#define SECTION_ALIGN PAGE_SIZE
 #define DECL_SECTION(x) x : AT(ADDR(x) - __XEN_VIRT_START)
 
 ENTRY(start_pa)
 
 #endif /* EFI */
 
+#if defined CONFIG_XEN_ALIGN_2M
+#define SECTION_ALIGN MB(2)
+#elif defined CONFIG_XEN_ALIGN_4K
+#define SECTION_ALIGN PAGE_SIZE
+#elif defined CONFIG_XEN_ALIGN_DEFAULT
+    #ifdef EFI
+        #define SECTION_ALIGN MB(2)
+    #else
+        #define SECTION_ALIGN PAGE_SIZE
+    #endif
+#else
+#error "Section alignment undefined"
+#endif
+
 OUTPUT_FORMAT(FORMAT, FORMAT, FORMAT)
 
 OUTPUT_ARCH(i386:x86-64)
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to