On Tue, Feb 07, 2017 at 06:30:36PM +0100, Peter Zijlstra wrote:
> On Tue, Feb 07, 2017 at 04:03:01PM +0000, Mark Rutland wrote:
> > For x86 it's a little painful due to '%' in the register names, but it looks
> > possible. The below appears to do the mangling correctly (then screams due 
> > to
> > the mangled result being nonexistent).
> 
> > asm(
> > "   .macro  reg_to_offset   r\n"
> > "   .irp rs,eax,ebx,ecx,edx\n"
> > "   .ifc \\r, %\\rs\n"
> > "   __offset_of_\\rs\n"
> > "   .endif\n"
> > "   .endr\n"
> > "   .endm\n"
> > );
> > 
> > #define asm_sym(var)                asm volatile("reg_to_offset %0\n" : : 
> > "r" (var))
> 
> Oh gawd that's a most gnarly hack.

:)

> Do we want to go do that for all archs or somehow cook a generic
> fallback that ends up doing a full function call or something?

Given the arch-specific reg->blah mapping is so "fun", I guess a generic
fallback would be a good start.

I haven't figured out all the plumbing details. It'd be nice to reuse
the bug infrastructure so that arches don't have to implement another
trap and callback pair, but I guess the reg details need to live in
another data structure.

Thanks,
Mark.

Reply via email to