From: "Ni, Ray" <ray.ni@Intel.com>
To: Liu Yu <pedroa.liu@outlook.com>,
"afish@apple.com; jordan.l.justen"@intel.com
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: EmulatorPkg Unix Host Segmentation fault.
Date: Sat, 16 Feb 2019 15:40:47 +0800 [thread overview]
Message-ID: <4ed773fe-7a1a-8434-b8b4-bed2b9f24f26@Intel.com> (raw)
In-Reply-To: <TY2PR02MB28317A7BB9ADD94DB5B385A98FDF0@TY2PR02MB2831.apcprd02.prod.outlook.com>
I also met this issue.
I found three solutions:
1. Forcing PeiMain CC flag to "-O0" works.
2. Changing EmulatorPkg/Sec to not produce TemporaryRamSupportPpi also
works.
3. Implement the temporary migration routine as below in EmulatorPkg/Sec
module.
EFI_STATUS
EFIAPI
SecTemporaryRamSupport (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
IN UINTN CopySize
)
{
VOID *OldHeap;
VOID *NewHeap;
VOID *OldStack;
VOID *NewStack;
UINTN StackMigrateOffset;
BASE_LIBRARY_JUMP_BUFFER JumpBuffer;
DEBUG ((EFI_D_INFO,
"TemporaryRamMigration(0x%Lx, 0x%Lx, 0x%Lx)\n",
TemporaryMemoryBase,
PermanentMemoryBase,
(UINT64)CopySize
));
//
// Assume Host prepare the stack and heap in the temprary ram that stack
// is below heap (stack is in smaller address).
// Stack/heap migration depends on the stack/heap location information
// in the temporary ram.
//
OldStack = (VOID*)(UINTN)TemporaryMemoryBase;
NewStack = (VOID*)((UINTN)PermanentMemoryBase);
OldHeap = (VOID*)((UINTN)TemporaryMemoryBase + (CopySize >> 1));
NewHeap = (VOID*)((UINTN)PermanentMemoryBase + (CopySize >> 1));
StackMigrateOffset = (UINTN)NewStack - (UINTN)OldStack;
//
// Migrate Heap and Stack
//
CopyMem (NewHeap, OldHeap, CopySize >> 1);
CopyMem (NewStack, OldStack, CopySize >> 1);
//
// Use SetJump()/LongJump() to switch to a new stack.
//
if (SetJump (&JumpBuffer) == 0) {
#if defined (MDE_CPU_IA32)
JumpBuffer.Esp = JumpBuffer.Esp + StackMigrateOffset;
JumpBuffer.Ebp = JumpBuffer.Ebp + StackMigrateOffset;
#endif
#if defined (MDE_CPU_X64)
JumpBuffer.Rsp = JumpBuffer.Rsp + StackMigrateOffset;
JumpBuffer.Rbp = JumpBuffer.Rbp + StackMigrateOffset;
#endif
LongJump (&JumpBuffer, (UINTN)-1);
}
ZeroMem ((VOID *)(UINTN) TemporaryMemoryBase, CopySize);
return EFI_SUCCESS;
}
Andrew,
I'd like to know why you chose to produce the migration PPI from
EmulatorPkg/Sec module.
Based on PI spec and current PeiCore implementation, PeiCore can do the
migration when PPI is absent.
--
Thanks,
Ray
next prev parent reply other threads:[~2019-02-16 7:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-18 4:51 EmulatorPkg Unix Host Segmentation fault Liu Yu
2018-11-18 9:27 ` Jordan Justen
2018-11-18 12:07 ` Liu Yu
2018-11-18 22:37 ` Andrew Fish
2018-11-19 1:13 ` Jordan Justen
2018-11-19 19:16 ` Jordan Justen
2018-11-19 21:22 ` Andrew Fish
2018-11-19 22:12 ` Laszlo Ersek
2018-11-19 23:39 ` Andrew Fish
2018-11-19 22:29 ` Jordan Justen
2018-11-20 0:54 ` Andrew Fish
2018-11-20 8:57 ` Laszlo Ersek
2019-02-16 7:29 ` Ni, Ray
2019-02-16 7:40 ` Ni, Ray [this message]
2019-02-16 20:23 ` Andrew Fish
2019-02-16 7:43 ` Ni, Ray
2019-02-16 8:05 ` Ni, Ray
2019-02-16 9:11 ` Jordan Justen
2019-02-18 2:25 ` Ni, Ray
2019-02-18 2:45 ` Jordan Justen
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=4ed773fe-7a1a-8434-b8b4-bed2b9f24f26@Intel.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