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.68; helo=ma1-aaemail-dr-lapp02.apple.com; envelope-from=afish@apple.com; receiver=edk2-devel@lists.01.org Received: from ma1-aaemail-dr-lapp02.apple.com (ma1-aaemail-dr-lapp02.apple.com [17.171.2.68]) (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 821C621A02937 for ; Mon, 19 Nov 2018 15:40:12 -0800 (PST) Received: from pps.filterd (ma1-aaemail-dr-lapp02.apple.com [127.0.0.1]) by ma1-aaemail-dr-lapp02.apple.com (8.16.0.22/8.16.0.22) with SMTP id wAJNaeuo014351; Mon, 19 Nov 2018 15:40:09 -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=ugul7/Is96fXQz2cOJPfIFUue/1RSW7rZ6rTVuQtRvA=; b=VZYwrN1C+IZsN79XneVDMR5zvnacaQ7Re0dsGqkxxsLSpU6Q2YZKp/7hedRM8N1GfnVP rIuC3rh+ELavKt4cfdWrE8z5r8LEDLkLQvkA8H5hFdXucEbZZGTgdIvHUS9/1FZQF+7i XNpm0sc5Ddh9lDylErd1eJduLdv/2PioSbgRJjfNJuA8+ardiKGVooi4hyD5j9rDZCxN gjTvvP8h4d6DwPt4SWYtL5p1G+Qa2pTNJmolZU5yzAM/wh0BbQpe2ZTLA1jGnhe/BQQ6 PL63rGR+qkwxa1g7w6vCRARtBoTXiwahoHhKzUYTFjQagthTb8WACoylORCX0Trn/biQ aQ== Received: from ma1-mtap-s02.corp.apple.com (ma1-mtap-s02.corp.apple.com [17.40.76.6]) by ma1-aaemail-dr-lapp02.apple.com with ESMTP id 2ntgj1msua-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Mon, 19 Nov 2018 15:40:09 -0800 MIME-version: 1.0 Received: from ma1-mmpp-sz11.apple.com (ma1-mmpp-sz11.apple.com [17.171.128.33]) by ma1-mtap-s02.corp.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) with ESMTPS id <0PIG00KSCSEVJJ80@ma1-mtap-s02.corp.apple.com>; Mon, 19 Nov 2018 15:40:07 -0800 (PST) Received: from process_viserion-daemon.ma1-mmpp-sz11.apple.com by ma1-mmpp-sz11.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) id <0PIG00600SAQ5S00@ma1-mmpp-sz11.apple.com>; Mon, 19 Nov 2018 15:40:07 -0800 (PST) X-Va-A: X-Va-T-CD: 07a9f7dd315dc6000695a0402a47d12d X-Va-E-CD: 63889f024351edad8b341b5de07fb5d9 X-Va-R-CD: 1b31b8f27f74d69e316e535bfbff9601 X-Va-CD: 0 X-Va-ID: 5ebfca34-13dd-4bb0-bf8c-0192abf7eed2 X-V-A: X-V-T-CD: 13715775cfe6ed78bc954dbcb503dbb2 X-V-E-CD: 63889f024351edad8b341b5de07fb5d9 X-V-R-CD: 1b31b8f27f74d69e316e535bfbff9601 X-V-CD: 0 X-V-ID: d6115118-6623-4595-8e86-e32a62256027 Received: from process_milters-daemon.ma1-mmpp-sz11.apple.com by ma1-mmpp-sz11.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) id <0PIG00300S3CAZ00@ma1-mmpp-sz11.apple.com>; Mon, 19 Nov 2018 15:40:07 -0800 (PST) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-19_09:,, signatures=0 Received: from [17.234.252.196] (unknown [17.234.252.196]) by ma1-mmpp-sz11.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) with ESMTPSA id <0PIG00HHQSESOX70@ma1-mmpp-sz11.apple.com>; Mon, 19 Nov 2018 15:40:07 -0800 (PST) Sender: afish@apple.com From: Andrew Fish Message-id: <157B5519-8953-4710-B7E8-20289DBCD7A8@apple.com> Date: Mon, 19 Nov 2018 15:39:02 -0800 In-reply-to: <69b2d50f-3aec-186e-61ae-b8f7ab8f143e@redhat.com> Cc: Jordan Justen , Mike Kinney , Liu Yu , "edk2-devel@lists.01.org" , Leif Lindholm To: Laszlo Ersek References: <154253322290.3729.10762860453718631884@jljusten-skl> <81FDCF97-4145-4A7D-93B9-70A4D8B505FF@apple.com> <154259000092.7306.2206833534307673295@jljusten-skl> <154265500096.11985.13073430907870235751@jljusten-skl> <69b2d50f-3aec-186e-61ae-b8f7ab8f143e@redhat.com> X-Mailer: Apple Mail (2.3445.6.18) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-19_09:, , 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: Mon, 19 Nov 2018 23:40:12 -0000 Content-Type: text/plain; CHARSET=US-ASCII Content-Transfer-Encoding: 7BIT > On Nov 19, 2018, at 2:12 PM, Laszlo Ersek wrote: > > Jordan wrote: > >>>> So, is it safe to adjust rbp? Unknown. It may not be if rbp is not >>>> used as a frame pointer. Is it safe to *not* adjust rbp and >>>> potentially allow the old temp ram stack to be used? Unknown. > > Andrew wrote: > >> Looks like OvmfPkg uses SetJump()/LongJump() to change the stack. >> >> // >> // Use SetJump()/LongJump() to switch to a new stack. >> // >> if (SetJump (&JumpBuffer) == 0) { >> #if defined (MDE_CPU_IA32) >> JumpBuffer.Esp = JumpBuffer.Esp + DebugAgentContext.StackMigrateOffset; >> JumpBuffer.Ebp = JumpBuffer.Ebp + DebugAgentContext.StackMigrateOffset; >> #endif >> #if defined (MDE_CPU_X64) >> JumpBuffer.Rsp = JumpBuffer.Rsp + DebugAgentContext.StackMigrateOffset; >> JumpBuffer.Rbp = JumpBuffer.Rbp + DebugAgentContext.StackMigrateOffset; >> #endif >> LongJump (&JumpBuffer, (UINTN)-1); >> } >> >> SaveAndSetDebugTimerInterrupt (OldStatus); >> >> return EFI_SUCCESS; >> } >> >> But given the above code is C code RBP is going to be restored on return. This would seem to imply that the adjusting of the callers RBP is not required? [...] > > The Ebp/Rbp assignments were added in a separate bugfix, namely > > https://github.com/tianocore/edk2/commit/89796c69d9fd > Laszlo, This makes sense since as the post-amble when using frame pointers is either: addq $288, %rsp ## imm = 0x120 popq %rbp retq or > 0x00000000fffcd42f <+403>: c9 leaveq > 0x00000000fffcd430 <+404>: c3 retq I've noticed that clang does not seem to be a big fan of the leave function and it adjusts the stack pointer using math rather than using %rbp. The stack unwind algorithm implies that the frame point, %rbp in our case, is valid while the function is running. Even for the clang code gen not switching the frame point would break the stack unwind. Thanks, Andrew Fish > Laszlo