diff mbox series

[v2,1/2] x86: decouple xen alignment setting from EFI/ELF build

Message ID 20190319130550.32570-2-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show
Series x86: more flexible alignment handling for xen image | expand

Commit Message

Wei Liu March 19, 2019, 1:05 p.m. UTC
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
ELF build 4K.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 xen/arch/x86/Kconfig   | 23 +++++++++++++++++++++++
 xen/arch/x86/xen.lds.S | 12 ++++++++++--
 2 files changed, 33 insertions(+), 2 deletions(-)

Comments

Andrew Cooper March 19, 2019, 1:09 p.m. UTC | #1
On 19/03/2019 13:05, Wei Liu wrote:
> @@ -20,13 +19,22 @@ 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 */
>  
> +#ifdef CONFIG_XEN_ALIGN_2M
> +#define SECTION_ALIGN MB(2)
> +#else /* Default alignment */
> +#ifdef EFI
> +#define SECTION_ALIGN MB(2)
> +#else
> +#define SECTION_ALIGN PAGE_SIZE
> +#endif
> +#endif

As a trivial change, can this please be:

#ifdef CONFIG_XEN_ALIGN_2M
# define SECTION_ALIGN MB(2)
#else /* Default alignment */
# ifdef EFI
#  define SECTION_ALIGN MB(2)
# else
#  define SECTION_ALIGN PAGE_SIZE
# endif
#endif

To help highlight the nesting levels.

~Andrew
Jan Beulich March 19, 2019, 1:40 p.m. UTC | #2
>>> On 19.03.19 at 14:09, <andrew.cooper3@citrix.com> wrote:
> On 19/03/2019 13:05, Wei Liu wrote:
>> @@ -20,13 +19,22 @@ 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 */
>>  
>> +#ifdef CONFIG_XEN_ALIGN_2M
>> +#define SECTION_ALIGN MB(2)
>> +#else /* Default alignment */
>> +#ifdef EFI
>> +#define SECTION_ALIGN MB(2)
>> +#else
>> +#define SECTION_ALIGN PAGE_SIZE
>> +#endif
>> +#endif
> 
> As a trivial change, can this please be:
> 
> #ifdef CONFIG_XEN_ALIGN_2M
> # define SECTION_ALIGN MB(2)
> #else /* Default alignment */
> # ifdef EFI
> #  define SECTION_ALIGN MB(2)
> # else
> #  define SECTION_ALIGN PAGE_SIZE
> # endif
> #endif
> 
> To help highlight the nesting levels.

#if defined(CONFIG_XEN_ALIGN_2M) || defined(EFI)
# define SECTION_ALIGN MB(2)
#else
# define SECTION_ALIGN PAGE_SIZE
#endif

? Then
Reviewed-by: Jan Beulich <jbeulich@suse.com>
(but I can live with Andrew's variant too, if need be)

Jan
Wei Liu March 19, 2019, 1:44 p.m. UTC | #3
On Tue, Mar 19, 2019 at 01:09:35PM +0000, Andrew Cooper wrote:
> On 19/03/2019 13:05, Wei Liu wrote:
> > @@ -20,13 +19,22 @@ 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 */
> >  
> > +#ifdef CONFIG_XEN_ALIGN_2M
> > +#define SECTION_ALIGN MB(2)
> > +#else /* Default alignment */
> > +#ifdef EFI
> > +#define SECTION_ALIGN MB(2)
> > +#else
> > +#define SECTION_ALIGN PAGE_SIZE
> > +#endif
> > +#endif
> 
> As a trivial change, can this please be:
> 
> #ifdef CONFIG_XEN_ALIGN_2M
> # define SECTION_ALIGN MB(2)
> #else /* Default alignment */
> # ifdef EFI
> #  define SECTION_ALIGN MB(2)
> # else
> #  define SECTION_ALIGN PAGE_SIZE
> # endif
> #endif
> 
> To help highlight the nesting levels.

Sure.

Wei.
Jan Beulich March 19, 2019, 1:44 p.m. UTC | #4
>>> On 19.03.19 at 14:05, <wei.liu2@citrix.com> wrote:
> --- a/xen/arch/x86/Kconfig
> +++ b/xen/arch/x86/Kconfig
> @@ -138,6 +138,29 @@ config TBOOT
>  
>  	  If unsure, say Y.
>  
> +choice
> +	prompt "Alignment of Xen image"
> +	depends on X86

Sorry, noticed only while looking at patch 2 again: This line seems
unnecessary, considering the file we're in. I notice TBOOT has a
similar pointless dependency.

Jan
Wei Liu March 19, 2019, 1:52 p.m. UTC | #5
On Tue, Mar 19, 2019 at 07:44:33AM -0600, Jan Beulich wrote:
> >>> On 19.03.19 at 14:05, <wei.liu2@citrix.com> wrote:
> > --- a/xen/arch/x86/Kconfig
> > +++ b/xen/arch/x86/Kconfig
> > @@ -138,6 +138,29 @@ config TBOOT
> >  
> >  	  If unsure, say Y.
> >  
> > +choice
> > +	prompt "Alignment of Xen image"
> > +	depends on X86
> 
> Sorry, noticed only while looking at patch 2 again: This line seems
> unnecessary, considering the file we're in. I notice TBOOT has a
> similar pointless dependency.

Will fix -- I added this dep after looking at TBOOT. :p

Wei.

> 
> Jan
> 
>
diff mbox series

Patch

diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
index 5c2d1070b6..1f115c1e40 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -138,6 +138,29 @@  config TBOOT
 
 	  If unsure, say Y.
 
+choice
+	prompt "Alignment of Xen image"
+	depends on X86
+	default XEN_ALIGN_DEFAULT
+	---help---
+	  Specify alignment for Xen image.
+
+	  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 ELF build
+	  the default alignment is 4K due to syslinux failing to handle
+	  the increment of image size induced by 2M 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..5a0c1004f5 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,22 @@  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 */
 
+#ifdef CONFIG_XEN_ALIGN_2M
+#define SECTION_ALIGN MB(2)
+#else /* Default alignment */
+#ifdef EFI
+#define SECTION_ALIGN MB(2)
+#else
+#define SECTION_ALIGN PAGE_SIZE
+#endif
+#endif
+
 OUTPUT_FORMAT(FORMAT, FORMAT, FORMAT)
 
 OUTPUT_ARCH(i386:x86-64)