public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ardb@kernel.org>
To: Rebecca Cran <rebecca@bsdio.com>,
	Leif Lindholm <quic_llindhol@quicinc.com>
Cc: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	 Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
Subject: Re: [edk2-devel] Alignment fault in __memcpy when SbsaQemu is built uncompressed
Date: Sat, 29 Jun 2024 17:26:37 +0200	[thread overview]
Message-ID: <CAMj1kXEOEzhFcC1cji_Lnb9936uAzZCUgm592VvizzFya7bq8w@mail.gmail.com> (raw)
In-Reply-To: <428c3293-3899-4794-a51b-7670331e58a2@bsdio.com>

On Sat, 22 Jun 2024 at 20:04, Rebecca Cran <rebecca@bsdio.com> wrote:
>
> I decided to do some testing around the cost of copying vs decompressing
> and moved all the drivers in SbsaQemu into the uncompressed section (as
> described in
> https://github.com/tianocore/tianocore.github.io/wiki/ArmPkg-Compression),
> but firmware built with CLANGDWARF causes an alignment fault when
> writing the last 64 bytes in __memcpy via FvReadFile -> AllocateCopyPool
> -> InternalAllocateCopyPool -> InternalMemCopyMem -> __memcpy
> (AArch64/CopyMem.S in BaseMemoryLibOptDxe).
>
>
> InternalAllocateCopyPool calls CopyMem with Memory=0x1000694d018,
> Buffer=0x10a71300, AllocationSize=274476.
>
> The instruction that causes the fault is:
>
> ldp x14, x15, [x4, #-64]
>
> Where x4=0x10ab432c
>

It looks like the FvReadFile() call is doing a memory copy from the
firmware volume (FV), which seems to be mapped with device attributes
rather than normal memory. With a compressed image, the FV will be
decompressed to normal RAM, so this can never happen at this stage in
the boot (BDS phase)

Looking at Platform/Qemu/SbsaQemu/SbsaQemu.fdf and
Silicon/Qemu/SbsaQemu/Library/SbsaQemuLib/SbsaQemuMem.c, the entire
flash device (FD) which should cover the uncompressed FV is mapped
with cacheable attributes, but the address in question ^^^ is outside
of the predefined window of

BaseAddress   = 0x10000000|gArmTokenSpaceGuid.PcdFdBaseAddress
Size          = 0x003C0000|gArmTokenSpaceGuid.PcdFdSize

Did you update PcdFdSize to account for the larger footprint of the FV?


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



  parent reply	other threads:[~2024-06-29 15:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-22 18:04 [edk2-devel] Alignment fault in __memcpy when SbsaQemu is built uncompressed Rebecca Cran
2024-06-24 16:47 ` Marcin Juszkiewicz
2024-06-29 15:26 ` Ard Biesheuvel [this message]
2024-06-29 17:42   ` Rebecca Cran

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=CAMj1kXEOEzhFcC1cji_Lnb9936uAzZCUgm592VvizzFya7bq8w@mail.gmail.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