On Wed, Oct 16, 2019 at 03:18:05PM -0700, Xing, Cedric wrote: > On 10/10/2019 4:59 PM, Sean Christopherson wrote: > >On Thu, Oct 10, 2019 at 10:49:59AM -0700, Xing, Cedric wrote: > >>On 10/9/2019 12:10 PM, Sean Christopherson wrote: > >>>On Wed, Oct 09, 2019 at 11:00:55AM -0700, Xing, Cedric wrote: > >>>>On 10/7/2019 9:46 PM, Sean Christopherson wrote: > >>>>>- /* Align stack per x86_64 ABI. The original %rsp is saved in %rbx to be > >>>>>- * restored after the exit handler returns. */ > >>>>>+ > >>>>>+ /* Invoke userspace's exit handler if one was provided. */ > >>>>>+.Lhandle_exit: > >>>>>+ cmp $0, 0x20(%rbp) > >>>>>+ jne .Linvoke_userspace_handler > >>>>>+ > >>>>>+.Lout: > >>>>>+ leave > >>>>>+ .cfi_def_cfa %rsp, 8 > >>>>>+ ret > >>>>>+ > >>>>>+.Linvalid_leaf: > >>>> > >>>>Please set frame pointer back to %rbp here, or stack unwinding will fail. > >>> > >>>Sorry, coffee isn't doing it's job, what's getting crushed, and where? > >> > >>The frame pointer was %rbp but you changed it to %rsp 3 lines ago. That's > >>correct after "leave" and execution won't pass "ret". But the unwinder > >>doesn't know. So you have to restore frame pointer after "ret", by > >> .cfi_def_cfa %rbp, 16 > > > >Isn't the proper fix to move ".cfi_endproc" here? Which I incorrectly > >left after the RET for the retpoline. > > No. .cfi_endproc is used by the unwinder to determine if an address falls > within a function. Its location has nothing to do with where RET is but > shall always be at the end of the whole function. > > .cfi_def_cfa tells the unwinder where the call frame starts. At here, the > call frame starts at %rbp+16 but not %rsp+8, so ".cfi_def_cfa %rbp, 16" is a > must. Ahh, I understand now, hopefully. I was thinking the .cfi directives would magically understand the control flow. Thanks! > >>>>>+.Lhandle_exception: > >>>>>+ mov 0x18(%rbp), %rcx > >>>>>+ test %rcx, %rcx > >>>>>+ je .Lskip_exception_info > >>>>