On 07/09/15 10:06, Ruiyu Ni wrote:
> PeiCore hang when loads a PEIM whose section alignment requirement is
> 0x40 but the actual base address is 0x20 aligned.

> The issue is caused by the following facts, in order:

> 1. GCC49 requires the section alignment of .data to be 0x40. So a new
> link script gcc4.9-ld-script was added for GCC49 to specify the 0x40
> alignment.

> 2. GenFw tool was enhanced to sync ELF's section alignment to PE
> header. Before the enhancement, the section alignment of converted PE
> image always equals to 0x20.
> 
> If only with #1 change, GCC49 build image won't hang in PeiCore
> because the converted PE image still claims 0x20 section alignment
> which is aligned to the align setting set in FDF file. But later with
> #2 change, the converted PE image starts to claims 0x40 section
> alignment, while build tool still puts the PEIM in 0x20 aligned
> address, resulting the PeCoffLoaderLoadImage() reports
> IMAGE_ERROR_INVALID_SECTION_ALIGNMENT error.

Perfect!

So, ultimately, the alignment at which the build tool places the PEI
modules, controlled by the Align=... directive, must satisfy the
alignment that the PE header itself states. And currently, the alignment
in the PE header comes from the ELF linker script, because the updated
GenFw tool sets the PE header based on the ELF values.

Therefore the Align=... directive in the FDF rules must match the
alignment in the ELF linker script. And, apparently, the simplest way to
ensure this is to convince the build tool to grab the PEIMs alignment
from the PE header, with Align=Auto.

Now the question emerges if *other* module rules in the OVMF FDF files
should see their Align=... directives updated. However, there are no
other Align=... directives; the patch updates them all (apparently only
PEI_CORE and PEIM rules spell out Align=whatever).

Superb work!

Reviewed-by: Laszlo Ersek <ler...@redhat.com>

I'm going to commit your patch right away (I'll just rewrap the commit
message to 74 characters first).

Thank you!
Laszlo

> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu...@intel.com>
> Reviewed-by: Liming Gao <liming....@intel.com>
> ---
>  OvmfPkg/OvmfPkgIa32.fdf    | 4 ++--
>  OvmfPkg/OvmfPkgIa32X64.fdf | 4 ++--
>  OvmfPkg/OvmfPkgX64.fdf     | 4 ++--
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
> index 24ad0bf..d11325e 100644
> --- a/OvmfPkg/OvmfPkgIa32.fdf
> +++ b/OvmfPkg/OvmfPkgIa32.fdf
> @@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
>  
>  [Rule.Common.PEI_CORE]
>    FILE PEI_CORE = $(NAMED_GUID) {
> -    PE32     PE32   Align=32    $(INF_OUTPUT)/$(MODULE_NAME).efi
> +    PE32     PE32   Align=Auto    $(INF_OUTPUT)/$(MODULE_NAME).efi
>      UI       STRING ="$(MODULE_NAME)" Optional
>      VERSION  STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
>    }
> @@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
>  [Rule.Common.PEIM]
>    FILE PEIM = $(NAMED_GUID) {
>       PEI_DEPEX PEI_DEPEX Optional        $(INF_OUTPUT)/$(MODULE_NAME).depex
> -     PE32      PE32   Align=32           $(INF_OUTPUT)/$(MODULE_NAME).efi
> +     PE32      PE32   Align=Auto         $(INF_OUTPUT)/$(MODULE_NAME).efi
>       UI       STRING="$(MODULE_NAME)" Optional
>       VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
>    }
> diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
> index 5f98be8..015aca4 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.fdf
> +++ b/OvmfPkg/OvmfPkgIa32X64.fdf
> @@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
>  
>  [Rule.Common.PEI_CORE]
>    FILE PEI_CORE = $(NAMED_GUID) {
> -    PE32     PE32   Align=32    $(INF_OUTPUT)/$(MODULE_NAME).efi
> +    PE32     PE32   Align=Auto    $(INF_OUTPUT)/$(MODULE_NAME).efi
>      UI       STRING ="$(MODULE_NAME)" Optional
>      VERSION  STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
>    }
> @@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
>  [Rule.Common.PEIM]
>    FILE PEIM = $(NAMED_GUID) {
>       PEI_DEPEX PEI_DEPEX Optional        $(INF_OUTPUT)/$(MODULE_NAME).depex
> -     PE32      PE32   Align=32           $(INF_OUTPUT)/$(MODULE_NAME).efi
> +     PE32      PE32   Align=Auto         $(INF_OUTPUT)/$(MODULE_NAME).efi
>       UI       STRING="$(MODULE_NAME)" Optional
>       VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
>    }
> diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
> index 11e74e7..f43d3dd 100644
> --- a/OvmfPkg/OvmfPkgX64.fdf
> +++ b/OvmfPkg/OvmfPkgX64.fdf
> @@ -389,7 +389,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
>  
>  [Rule.Common.PEI_CORE]
>    FILE PEI_CORE = $(NAMED_GUID) {
> -    PE32     PE32   Align=32    $(INF_OUTPUT)/$(MODULE_NAME).efi
> +    PE32     PE32   Align=Auto    $(INF_OUTPUT)/$(MODULE_NAME).efi
>      UI       STRING ="$(MODULE_NAME)" Optional
>      VERSION  STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
>    }
> @@ -397,7 +397,7 @@ FILE FV_IMAGE = 9E21FD93-9C72-4c15-8C4B-E77F1DB2D792 {
>  [Rule.Common.PEIM]
>    FILE PEIM = $(NAMED_GUID) {
>       PEI_DEPEX PEI_DEPEX Optional        $(INF_OUTPUT)/$(MODULE_NAME).depex
> -     PE32      PE32   Align=32           $(INF_OUTPUT)/$(MODULE_NAME).efi
> +     PE32      PE32   Align=Auto         $(INF_OUTPUT)/$(MODULE_NAME).efi
>       UI       STRING="$(MODULE_NAME)" Optional
>       VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
>    }
> 


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to