Re: [PATCH] x86: introduce push/pop macros which generate CFI_REL_OFFSET and CFI_RESTORE

From: Andy Lutomirski
Date: Mon Jan 12 2015 - 15:14:59 EST


On Mon, Jan 12, 2015 at 12:11 PM, Borislav Petkov <bp@xxxxxxxxx> wrote:
> On Mon, Jan 12, 2015 at 11:46:53AM -0800, Andy Lutomirski wrote:
>> Dumb example:
>>
>> pushq_cfi $__KERNEL_DS /* ss */
>>
>> This doesn't save anything that the unwinder would care about.
>
> And? The unwinder or whatever looks at that info simply ignores stuff it
> is not interested in, no?

But CFI_REL_OFFSET $__KERNEL_DS, 0 probably isn't even well-formed and
won't build.

>
>> Better example:
>>
>> pushq_cfi \child_rip /* rip */
>> CFI_REL_OFFSET rip,0
>>
>> Doing this with a macro would need a fancier macro.
>
> I'd ask first whether we really need this at all.
>
>> Then there's crap like:
>>
>> pushq_cfi %rdi
>> SCHEDULE_USER
>> popq_cfi %rdi
>
> I guess we can add a gas regname argument optional and if it is set, use
> it and if not, use the reg itself... Or something like that in the best
> effort type of approach.
>
>> I would need to look a lot more carefully to figure out whether this
>> would need CFI_REL_OFFSET.
>>
>> If we actually had a DWARF unwinder in the kernel, maybe we could have
>> real test cases :-/
>
> I don't think that's ever going to happen.
>
> I'd say we do the CFI annotation on a best effort basis but not
> sacrifice readability in the process. If it can't be annotated, well,
> tough luck.
>

This stuff is at least useful (in theory) for debugging with gdb. And
I wouldn't mind an optional DWARF unwinder to get higher quality
backtraces. Obviously any such thing would need to be quite robust.
I think SuSE has one.

> --
> Regards/Gruss,
> Boris.
>
> Sent from a fat crate under my desk. Formatting is fine.
> --



--
Andy Lutomirski
AMA Capital Management, LLC
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/