diff mbox series

[2/2] x86/boot: Align .compat virtual size

Message ID 9b99e3e3c2c6c32a674ffa3272f85fa9443e33a0.1707141974.git.baskov@ispras.ru
State New
Headers show
Series x86/boot: EFISTUB section alignment | expand

Commit Message

Evgeniy Baskov Feb. 5, 2024, 2:44 p.m. UTC
Even if this section is discardable, it still needs to have virtual memory
size aligned on section alignment to be compliant.

Align compat section on section alignment. This adds ~4k of memory after
the kernel image during EFISTUB execution but, it's not a problem on
x86 architecture.

Signed-off-by: Evgeniy Baskov <baskov@ispras.ru>
---
 arch/x86/boot/header.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ard Biesheuvel Feb. 5, 2024, 2:50 p.m. UTC | #1
On Mon, 5 Feb 2024 at 14:44, Evgeniy Baskov <baskov@ispras.ru> wrote:
>
> Even if this section is discardable, it still needs to have virtual memory
> size aligned on section alignment to be compliant.
>

It does not. The PE/COFF spec does not require a section to end on an
address that is aligned to the section alignment of the image.

> Align compat section on section alignment. This adds ~4k of memory after
> the kernel image during EFISTUB execution but, it's not a problem on
> x86 architecture.
>
> Signed-off-by: Evgeniy Baskov <baskov@ispras.ru>
> ---
>  arch/x86/boot/header.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
> index 097b84ab288c..128e35f5c89b 100644
> --- a/arch/x86/boot/header.S
> +++ b/arch/x86/boot/header.S
> @@ -184,7 +184,7 @@ section_table:
>  #ifdef CONFIG_EFI_MIXED
>         .asciz  ".compat"
>
> -       .long   8                               # VirtualSize
> +       .long   pecompat_vsize                  # VirtualSize
>         .long   setup_size + ZO__end            # VirtualAddress
>         .long   pecompat_fsize                  # SizeOfRawData
>         .long   pecompat_fstart                 # PointerToRawData
> --
> 2.43.0
>
diff mbox series

Patch

diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index 097b84ab288c..128e35f5c89b 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -184,7 +184,7 @@  section_table:
 #ifdef CONFIG_EFI_MIXED
 	.asciz	".compat"
 
-	.long	8				# VirtualSize
+	.long	pecompat_vsize			# VirtualSize
 	.long	setup_size + ZO__end		# VirtualAddress
 	.long	pecompat_fsize			# SizeOfRawData
 	.long	pecompat_fstart			# PointerToRawData