From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=17.171.2.72; helo=ma1-aaemail-dr-lapp03.apple.com; envelope-from=afish@apple.com; receiver=edk2-devel@lists.01.org Received: from ma1-aaemail-dr-lapp03.apple.com (ma1-aaemail-dr-lapp03.apple.com [17.171.2.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9BCD220886F3E for ; Sat, 16 Feb 2019 12:23:43 -0800 (PST) Received: from pps.filterd (ma1-aaemail-dr-lapp03.apple.com [127.0.0.1]) by ma1-aaemail-dr-lapp03.apple.com (8.16.0.27/8.16.0.27) with SMTP id x1GKHRo0039051; Sat, 16 Feb 2019 12:23:41 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=mime-version : content-type : sender : from : message-id : subject : date : in-reply-to : cc : to : references; s=20180706; bh=cQn7XJyrFNpyWzJdUnvRS3G186IlHBXlAXe0ZgeMzH4=; b=w+yTt6fdTdZe/uUWhXJneyNYjo1VUuWu6KO22rs3yGyt0ZXAN3PBTVCiegwWBV+ZJVFb BaXsFFXC+WNuSF5gJMNOL0oQbpZ2yv5ut0//e+IQs1GhEFg9kIYXAsbTfkxQEj0qxzx3 kRTaka51by+gfkuklEsCZBwEeVtfjh/S8AJiraSIbIuPJvVe3584qW+DNAdi5broiXwH ev1JXwipKuFOUxuFMHA2iiu+OPLwVtHP9hf2iqF54KKyIDM07mSfEF/ttNKcF5nkPbhs Ix2jy+0ZqNruj0iQDoriTp630irtD9OnijHhHKwvWGdX4fkKSKwPzLmpAvaOyhFocwcn 7w== Received: from ma1-mtap-s01.corp.apple.com (ma1-mtap-s01.corp.apple.com [17.40.76.5]) by ma1-aaemail-dr-lapp03.apple.com with ESMTP id 2qpjd27pm2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Sat, 16 Feb 2019 12:23:40 -0800 MIME-version: 1.0 Received: from ma1-mmpp-sz09.apple.com (ma1-mmpp-sz09.apple.com [17.171.128.183]) by ma1-mtap-s01.corp.apple.com (Oracle Communications Messaging Server 8.0.2.3.20181024 64bit (built Oct 24 2018)) with ESMTPS id <0PN100DPOCNGVZ40@ma1-mtap-s01.corp.apple.com>; Sat, 16 Feb 2019 12:23:40 -0800 (PST) Received: from process_viserion-daemon.ma1-mmpp-sz09.apple.com by ma1-mmpp-sz09.apple.com (Oracle Communications Messaging Server 8.0.2.3.20181024 64bit (built Oct 24 2018)) id <0PN100300BYGNL00@ma1-mmpp-sz09.apple.com>; Sat, 16 Feb 2019 12:23:40 -0800 (PST) X-Va-A: X-Va-T-CD: 81ca60fce39c2560b6c4a7e5841f9b8f X-Va-E-CD: 63889f024351edad8b341b5de07fb5d9 X-Va-R-CD: 1b31b8f27f74d69e316e535bfbff9601 X-Va-CD: 0 X-Va-ID: ffd39b31-be20-4e78-a5c0-ddc314e32913 X-V-A: X-V-T-CD: 81ca60fce39c2560b6c4a7e5841f9b8f X-V-E-CD: 63889f024351edad8b341b5de07fb5d9 X-V-R-CD: 1b31b8f27f74d69e316e535bfbff9601 X-V-CD: 0 X-V-ID: 18e7b36b-27fb-44ce-a6e1-3610b809658e Received: from process_milters-daemon.ma1-mmpp-sz09.apple.com by ma1-mmpp-sz09.apple.com (Oracle Communications Messaging Server 8.0.2.3.20181024 64bit (built Oct 24 2018)) id <0PN100100CGYVR00@ma1-mmpp-sz09.apple.com>; Sat, 16 Feb 2019 12:23:40 -0800 (PST) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-02-16_16:,, signatures=0 Received: from [17.234.140.136] (unknown [17.234.140.136]) by ma1-mmpp-sz09.apple.com (Oracle Communications Messaging Server 8.0.2.3.20181024 64bit (built Oct 24 2018)) with ESMTPSA id <0PN100HHWCNE0F10@ma1-mmpp-sz09.apple.com>; Sat, 16 Feb 2019 12:23:40 -0800 (PST) Sender: afish@apple.com From: Andrew Fish Message-id: <3FEC4F26-B649-4E51-815C-3D79F088578F@apple.com> Date: Sat, 16 Feb 2019 12:23:36 -0800 In-reply-to: <4ed773fe-7a1a-8434-b8b4-bed2b9f24f26@Intel.com> Cc: Liu Yu , afish@apple.com, jordan.l.justen@intel.com, "edk2-devel@lists.01.org" To: "Ni, Ray" References: <4ed773fe-7a1a-8434-b8b4-bed2b9f24f26@Intel.com> X-Mailer: Apple Mail (2.3445.6.18) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-02-16_16:, , signatures=0 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: EmulatorPkg Unix Host Segmentation fault. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Feb 2019 20:23:44 -0000 Content-Type: text/plain; CHARSET=US-ASCII Content-Transfer-Encoding: 7BIT > On Feb 15, 2019, at 11:40 PM, Ni, Ray > wrote: > > 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. > Ray, Sorry I don't remember if it was due to the code being so old, or if I was trying to better emulate a real platform. Thanks, Andrew Fish > > > -- > Thanks, > Ray > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel