Re: [PATCH] uprobes/core: handle breakpoint and signal stepexception.

From: Srikar Dronamraju
Date: Thu Mar 08 2012 - 08:21:00 EST


> >
> > #include <linux/kdebug.h>
> > #include <asm/insn.h>
> >
> > +#ifdef CONFIG_X86_32
> > +#define is_32bit_app(tsk) 1
> > +#else
> > +#define is_32bit_app(tsk) (test_tsk_thread_flag(tsk, TIF_IA32))
> > +#endif
>
> Small detail, we prefer to use this variant:
>
> #ifdef X
> # define foo()
> #else
> # define bar()
> #endif
>
> to give the construct more visual structure.
>
> Also, please put it into asm/compat.h and use it at other places
> within arch/x86/ as well, there's half a dozen similar patterns
> of TIP_IA32 tests in arch/x86/. Please make this a separate
> patch, preceding this patch.

I am facing a problem doing the above.
I did some changes in arch/x86/kernel/signal.c and included compat.h
and compilation fails on tip tree that the commit
d1a797f388

In file included from ../arch/x86/kernel/signal.c:42:
../arch/x86/include/asm/compat.h: In function â??arch_compat_alloc_user_spaceâ??:
../arch/x86/include/asm/compat.h:238: error: â??old_rspâ?? undeclared (first use in this function)
../arch/x86/include/asm/compat.h:238: error: (Each undeclared identifier is reported only once
../arch/x86/include/asm/compat.h:238: error: for each function it appears in.)
../arch/x86/include/asm/compat.h:238: warning: type defaults to â??intâ?? in declaration of â??pfo_ret__â??


I see old_rsp declared only under CONFIG_X86_64 in asm/processor.h

The below helps resolve the problem.
---------
diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
index 9c9b6dc..147e790 100644
--- a/arch/x86/include/asm/compat.h
+++ b/arch/x86/include/asm/compat.h
@@ -233,9 +233,11 @@ static inline void __user *arch_compat_alloc_user_space(long len)

if (test_thread_flag(TIF_IA32)) {
sp = task_pt_regs(current)->sp;
+#ifdef CONFIG_X86_64
} else {
/* -128 for the x32 ABI redzone */
sp = __this_cpu_read(old_rsp) - 128;
+#endif
}

return (void __user *)round_down(sp - len, 16);


-----------

But I wanted to check if there is any reason why we cant include asm/compat.h in arch/x86/kernel/signal.c.

--
Thanks and Regards
Srikar

--
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/