Re: [PATCH] treewide: remove current_text_addr

2018-08-31 Thread Nick Desaulniers
On Mon, Aug 27, 2018 at 6:34 AM H. Peter Anvin wrote: > > On 08/27/18 06:11, Peter Zijlstra wrote: > > On Mon, Aug 27, 2018 at 05:26:53AM -0700, H. Peter Anvin wrote: > > > >> _THIS_IP_, however, is completely ill-defined, other than being an > >> address *somewhere* in the same global function (n

Re: [PATCH] treewide: remove current_text_addr

2018-08-27 Thread H. Peter Anvin
On 08/27/18 06:11, Peter Zijlstra wrote: > On Mon, Aug 27, 2018 at 05:26:53AM -0700, H. Peter Anvin wrote: > >> _THIS_IP_, however, is completely ill-defined, other than being an >> address *somewhere* in the same global function (not even necessarily >> the same function if the function is static

Re: [PATCH] treewide: remove current_text_addr

2018-08-27 Thread Peter Zijlstra
On Mon, Aug 27, 2018 at 05:26:53AM -0700, H. Peter Anvin wrote: > _THIS_IP_, however, is completely ill-defined, other than being an > address *somewhere* in the same global function (not even necessarily > the same function if the function is static!) As my experiment show, in > many (nearly) ca

Re: [PATCH] treewide: remove current_text_addr

2018-08-27 Thread H. Peter Anvin
On 08/27/18 00:33, Peter Zijlstra wrote: > > What problem are we trying to solve? _THIS_IP_ and _RET_IP_ work fine. > We're 'good' at dealing with text addresses, we use them for call stacks > and all sorts. Why does this need changing? > _RET_IP_ works fine, with the following two caveats: 1.

Re: [PATCH] treewide: remove current_text_addr

2018-08-27 Thread Nicholas Piggin
[ Trimmed the cc list because my SMTP didn't accept that many addresses. ] On Sun, 26 Aug 2018 13:25:14 -0700 Linus Torvalds wrote: > On Sun, Aug 26, 2018 at 12:32 PM H. Peter Anvin wrote: > > > > Here is a full-blown (user space) test program demonstrating the whole > > technique and how to us

Re: [PATCH] treewide: remove current_text_addr

2018-08-27 Thread Peter Zijlstra
On Sun, Aug 26, 2018 at 07:52:59PM -0700, Nick Desaulniers wrote: > On Sun, Aug 26, 2018 at 1:25 PM Linus Torvalds > > Instead, maybe we could encourage something like > > > > struct kernel_loc { const char *file; const char *fn; int line; }; > > > > #define __GEN_LOC__(n) \ > > ({ sta

Re: [PATCH] treewide: remove current_text_addr

2018-08-26 Thread Nick Desaulniers
On Sun, Aug 26, 2018 at 1:25 PM Linus Torvalds wrote: > Honestly, I'd suggest: > > - just do the current_text_addr() to _THIS_IP_ conversion > > - keep _THIS_IP_ and make it be the generic one, and screw the whole > "some architectures might implement is better" issue. Nobody cares. And mention

Re: [PATCH] treewide: remove current_text_addr

2018-08-26 Thread H. Peter Anvin
On 08/26/18 12:30, H. Peter Anvin wrote: > Here is a full-blown (user space) test program demonstrating the whole > technique and how to use it. > > -hpa Incidentally, it looks like _RET_IP_ really should be defined as: /* * Is there any reason whatsoever to have _RET_IP_ an unsigned int

Re: [PATCH] treewide: remove current_text_addr

2018-08-26 Thread Linus Torvalds
On Sun, Aug 26, 2018 at 12:32 PM H. Peter Anvin wrote: > > Here is a full-blown (user space) test program demonstrating the whole > technique and how to use it. So while I agree that some _THIS_IP_ users might be better off being converted to __builtin_return_address(0) at the caller, I also thin

Re: [PATCH] treewide: remove current_text_addr

2018-08-26 Thread H. Peter Anvin
Here is a full-blown (user space) test program demonstrating the whole technique and how to use it. -hpa #include #include #define _RET_IP_ ((unsigned long)__builtin_return_address(0)) #define noinline __attribute__((noinline)) #define used __attribute__((used)) /* __always_inline is d

Re: [PATCH] treewide: remove current_text_addr

2018-08-25 Thread H. Peter Anvin
On 08/25/18 20:16, H. Peter Anvin wrote: > On 08/25/18 19:38, H. Peter Anvin wrote: >> >> If it was worthwhile it would make more sense to at least force this >> into the rodata section with the string, something like the attached >> file for an example; however, I have a hunch it doesn't matter. >

Re: [PATCH] treewide: remove current_text_addr

2018-08-25 Thread H. Peter Anvin
On 08/25/18 19:38, H. Peter Anvin wrote: > > If it was worthwhile it would make more sense to at least force this > into the rodata section with the string, something like the attached > file for an example; however, I have a hunch it doesn't matter. > An even nuttier version which avoids the ext

Re: [PATCH] treewide: remove current_text_addr

2018-08-25 Thread H. Peter Anvin
On 08/25/18 03:48, Helge Deller wrote: > > Currently alpha, s390, sparc, sh, c6x, ia64 and parisc provide an > inline assembly function to get the current instruction pointer. > As mentioned in an earlier thread, I personally would *prefer* if > _THIS_IP_ would use those inline assembly instruct

Re: [PATCH] treewide: remove current_text_addr

2018-08-25 Thread Linus Torvalds
On Tue, Aug 21, 2018 at 1:31 PM Nick Desaulniers wrote: > > I suspect that current_text_addr predated GNU C extensions for statement > expressions and/or taking the address of a label, then the macro was > reimplemented for every new archs include/asm/processor.h, even though > there were very few

Re: [PATCH] treewide: remove current_text_addr

2018-08-25 Thread Helge Deller
On 21.08.2018 22:28, Nick Desaulniers wrote: > Prefer _THIS_IP_ defined in linux/kernel.h. > > Most definitions of current_text_addr were the same as _THIS_IP_, but > a few archs had inline assembly instead. > > This patch removes the final call site of current_text_addr, making all > of the defi