Message ID | 4a63c996-6c86-c298-dd9c-34b77afc6f27@suse.cz (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 05/17/2017, 03:23 PM, Jiri Slaby wrote: >> So the initial CFI state is different between the two types of >> "functions". And there are a lot of other differences. C-type >> functions have to follow frame pointer conventions, for example. So >> your FUNC_START macro (and objtool) would have to somehow figure out a >> way to make a distinction between the two. So it would probably work >> out better if we kept the distinction between C-type functions and other >> code. > > Ok, that makes a lot of sense. A quick question: Do you consider these to be C-type functions? ENTRY(function_hook) ret END(function_hook) or this? ENTRY(native_load_gs_index) pushfq DISABLE_INTERRUPTS(CLBR_ANY & ~CLBR_RDI) SWAPGS movl %edi, %gs SWAPGS popfq ret END(native_load_gs_index) Both are called from C, but they do not setup frame pointer etc. thanks,
On Fri, May 19, 2017 at 11:17:24AM +0200, Jiri Slaby wrote: > On 05/17/2017, 03:23 PM, Jiri Slaby wrote: > >> So the initial CFI state is different between the two types of > >> "functions". And there are a lot of other differences. C-type > >> functions have to follow frame pointer conventions, for example. So > >> your FUNC_START macro (and objtool) would have to somehow figure out a > >> way to make a distinction between the two. So it would probably work > >> out better if we kept the distinction between C-type functions and other > >> code. > > > > Ok, that makes a lot of sense. > > A quick question: > Do you consider these to be C-type functions? > > ENTRY(function_hook) > ret > END(function_hook) > > or this? > > ENTRY(native_load_gs_index) > pushfq > DISABLE_INTERRUPTS(CLBR_ANY & ~CLBR_RDI) > SWAPGS > movl %edi, %gs > SWAPGS > popfq > ret > END(native_load_gs_index) > > Both are called from C, but they do not setup frame pointer etc. Yeah, those are valid C-type functions. Setting up the frame pointer is optional for leaf functions (i.e. functions which don't call other functions).
--- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -463,6 +463,7 @@ SYM_FUNC_END(irq_entries_start) ALLOC_PT_GPREGS_ON_STACK SAVE_C_REGS SAVE_EXTRA_REGS + DW_CFI(.cfi_rel_offset rbp, RBP+8) ENCODE_FRAME_POINTER testb $3, CS(%rsp) @@ -497,7 +498,17 @@ SYM_FUNC_END(irq_entries_start) movq %rsp, %rdi incl PER_CPU_VAR(irq_count) cmovzq PER_CPU_VAR(irq_stack_ptr), %rsp + DW_CFI(.cfi_def_cfa_register rdi) + pushq %rdi + DW_CFI(.cfi_escape 0x0f /* DW_CFA_def_cfa_expression */, 6 /* block len */, \ + 0x77 /* DW_OP_breg7 (rsp) */, 0 /* offset */, \ + 0x06 /* DW_OP_deref */, \ + 0x08 /* DW_OP_const1u */, SIZEOF_PTREGS, \ + 0x22 /* DW_OP_plus */) + DW_CFI(.cfi_offset rsp, -2*8) + DW_CFI(.cfi_offset rip, -5*8) + /* We entered an interrupt context - irqs are off: */ TRACE_IRQS_OFF