From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: Stack issue after warm UEFI reset and MMU enabling on an Armv8 platform
Date: Wed, 19 Sep 2018 16:38:06 -0700 [thread overview]
Message-ID: <CAKv+Gu-7Yyo=yK=KmN+BCUs7NrzbZ_F8x_GiU+zghpTY5ioWuQ@mail.gmail.com> (raw)
In-Reply-To: <CACmgjayLJQYx_rqRA8sug0YnR5TKt0CMQh7tOrPjQJ0La9PQVQ@mail.gmail.com>
On 19 September 2018 at 15:55, Vladimir Olovyannikov <
vladimir.olovyannikov@broadcom.com> wrote:
> Hi All,
>
>
>
> I need UEFI experts help on the problem with Armv8 board on warm UEFI
> reset.
>
> Cold reset works fine.
>
>
>
> Here is how I set up a warm reset:
>
>
>
> STATIC
>
> EFI_STATUS
>
> ShutdownUefiBootServices (
>
> VOID
>
> )
>
> {
>
> EFI_STATUS Status;
>
> UINTN MemoryMapSize;
>
> EFI_MEMORY_DESCRIPTOR *MemoryMap;
>
> UINTN MapKey;
>
> UINTN DescriptorSize;
>
> UINT32 DescriptorVersion;
>
> UINTN Pages;
>
>
>
> MemoryMap = NULL;
>
> MemoryMapSize = 0;
>
> Pages = 0;
>
>
>
> do {
>
> Status = gBS->GetMemoryMap (
>
> &MemoryMapSize,
>
> MemoryMap,
>
> &MapKey,
>
> &DescriptorSize,
>
> &DescriptorVersion
>
> );
>
> if (Status == EFI_BUFFER_TOO_SMALL) {
>
>
>
> Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1;
>
> MemoryMap = AllocatePages (Pages);
>
>
>
> //
>
> // Get System MemoryMap
>
> //
>
> Status = gBS->GetMemoryMap (
>
> &MemoryMapSize,
>
> MemoryMap,
>
> &MapKey,
>
> &DescriptorSize,
>
> &DescriptorVersion
>
> );
>
> }
>
>
>
> // Don't do anything between the GetMemoryMap() and ExitBootServices()
>
> if (!EFI_ERROR(Status)) {
>
> Status = gBS->ExitBootServices (gImageHandle, MapKey);
>
> if (EFI_ERROR(Status)) {
>
> FreePages (MemoryMap, Pages);
>
> MemoryMap = NULL;
>
> MemoryMapSize = 0;
>
> }
>
> }
>
> } while (EFI_ERROR(Status));
>
>
>
> return Status;
>
> }
>
>
>
> Then perform
>
> ArmCleanDataCache ();
>
> ArmInvalidateDataCache ();
>
> ArmDisableInstructionCache ();
>
> ArmInvalidateInstructionCache ();
>
These don't do anything useful on ARM. You can only reliably perform cache
maintenance by virtual address.
ArmDisableMmu ();
>
>
>
... so after this call returns, all bets are off with regards to whether
what is popped from the stack is actually what we pushed when we entered
the function.
> Then jump to start of FV:
>
>
>
> typedef
>
> VOID
>
> (EFIAPI *START_FV)(
>
> VOID
>
> );
>
> StartOfFv = (START_FV)(UINTN)PcdGet64(PcdFvBaseAddress);
>
> StartOfFv ();
>
>
>
> Now this is what happens on warm reset:
>
> reset -c warm
>
> 1. Until ArmEnableMmu() gets called, everything works as expected.
>
> Here is the stack right before ArmEnableMmu() is called:
>
> ArmConfigureMmu+0x4f8
>
> InitMmu+0x24
>
> MemoryPeim+0x440
>
> PrePiMain+0x114
>
> PrimaryMain+0x68
>
> CEntryPoint+0xC4
>
> EL2:0x00000000800008BC
>
> ----- End of stack info -----
>
>
>
> 2. Here is the stack as soon as Mmu is enabled with ArmEnableMmu() :
>
> ArmConfigureMmu+0x4fc <-- This one is correct, at line 745 in
> ArmConfigureMmu() in ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
> (return EFI_SUCCESS)
>
> _ModuleEntryPoint+0x24 <-- Wrong. This points directly to
> ASSERT(FALSE); and to CpuDeadLoop() in DxeCoreEntryPoint.c, lines 59-60.
>
> El2:0x000000008E5E8300 <-- Absolutely bogus
>
> --- End of stack info ---
>
>
>
> So, as soon as ArmEnableMmu() exits, execution jumps directly to
> CpuDeadLoop() in DxeCoreEntryPoint of _ModuleEntryPoint().
>
>
>
> Would be grateful for any advice.
>
>
>
> Thank you,
>
> Vladimir
>
>
>
next prev parent reply other threads:[~2018-09-19 23:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-19 22:55 Stack issue after warm UEFI reset and MMU enabling on an Armv8 platform Vladimir Olovyannikov
2018-09-19 23:38 ` Ard Biesheuvel [this message]
2018-09-19 23:58 ` Vladimir Olovyannikov
2018-09-19 23:56 ` Bill Paul
2018-09-20 0:09 ` Ard Biesheuvel
-- strict thread matches above, loose matches on Subject: below --
2018-09-20 21:52 Vladimir Olovyannikov
2018-09-21 23:24 ` Vladimir Olovyannikov
2018-09-21 23:57 ` Andrew Fish
2018-09-22 0:14 ` Ard Biesheuvel
2018-09-24 17:44 ` Vladimir Olovyannikov
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='CAKv+Gu-7Yyo=yK=KmN+BCUs7NrzbZ_F8x_GiU+zghpTY5ioWuQ@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