public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Oliver Smith-Denny" <osde@linux.microsoft.com>
To: devel@edk2.groups.io, rebecca@bsdio.com,
	Matthew Carlson <matthewfcarlson@gmail.com>
Subject: Re: [edk2-devel] Unable to build OvmfPkgX64.dsc with VS2022 ("PE image Section-Alignment and File-Alignment do not match")
Date: Wed, 31 Jul 2024 10:10:19 -0700	[thread overview]
Message-ID: <00c586e4-fd53-4c86-b64d-cb8e26e7c147@linux.microsoft.com> (raw)
In-Reply-To: <26155a79-7a3f-4b2b-9106-ea30ff9941d4@bsdio.com>

On 7/30/2024 9:50 PM, Rebecca Cran wrote:
> There appears to be a problem with the newly-added VS2022 toolchain. I 
> only just installed Windows after not using it for quite a while so I 
> don't know if it's user error, but I get the following failure with 
> "build -p OvmfPkg\OvmfPkgX64.dsc -a X64 -b RELEASE -t VS2022". Building 
> with VS2019 works.
> 
> I have VS2022 version 17.10.5 installed.
> 
> 
> Generating PEIFV FV
> ##### ['GenFv', '-a', 
> 'd:\\src\\tiano\\edk2\\Build\\OvmfX64\\RELEASE_VS2022\\FV\\Ffs\\PEIFV.inf', '-o', 'd:\\src\\tiano\\edk2\\Build\\OvmfX64\\RELEASE_VS2022\\FV\\PEIFV.Fv', '-i', 'd:\\src\\tiano\\edk2\\Build\\OvmfX64\\RELEASE_VS2022\\FV\\PEIFV.inf']
> Return Value = 2
> GenFv: ERROR 3000: Invalid
>    PE image Section-Alignment and File-Alignment do not match : 
> d:\src\tiano\edk2\Build\OvmfX64\RELEASE_VS2022\FV\Ffs\52C05B14-0B98-496c-BC3B-04B50211D680PeiCore\52C05B14-0B98-496c-BC3B-04B50211D680.ffs.
> GenFv: ERROR 3000: Invalid
>    Could not rebase 
> d:\src\tiano\edk2\Build\OvmfX64\RELEASE_VS2022\FV\Ffs\52C05B14-0B98-496c-BC3B-04B50211D680PeiCore\52C05B14-0B98-496c-BC3B-04B50211D680.ffs.
> 
> Not sure if it matters, but since I guess it might be fairly uncommon, 
> I'm building on a ReFS volume on Windows Server 2022.
> 
> 

Hi Rebecca,

You are seeing that because VS2022 has /ALIGN:4096 set and VS2019 does
not. VS2022 has the correct behavior here, we need 4k alignment for
memory protections (see upcoming PRs that will bring Project Mu
memory protection work to edk2, including updating the section
alignment).

What you are seeing is a very old GenFv bug:
https://bugzilla.tianocore.org/show_bug.cgi?id=1124. This has been
worked around by putting XIP modules in a separate FV than non-XIP
modules and setting FvForceRebase to False (or using compressed FVs)
for non-XIP modules. The problem is that GenFv only has the ability
to force rebase or not for an entire FV, not per module. Really we
would need to have an XIP marker that would tell GenFv how to rebase
per module. XIP modules are required to have file alignment match
section alignment and GenFv extends this to every module in the same
FV as an XIP module.

Until this bug is fixed, Ovmf will have to set FvForceRebase=False on
non-XIP module FVs and split XIP modules into their own FV.

But, without 4k section alignment we don't have image memory
protections.

Thanks,
Oliver


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#120156): https://edk2.groups.io/g/devel/message/120156
Mute This Topic: https://groups.io/mt/107641140/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



      reply	other threads:[~2024-07-31 17:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31  4:50 [edk2-devel] Unable to build OvmfPkgX64.dsc with VS2022 ("PE image Section-Alignment and File-Alignment do not match") Rebecca Cran
2024-07-31 17:10 ` Oliver Smith-Denny [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=00c586e4-fd53-4c86-b64d-cb8e26e7c147@linux.microsoft.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox