public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: Change SDT argument constraint
@ 2017-10-05  9:11 Sandipan Das
  2017-10-05 10:16 ` Mark Wielaard
  0 siblings, 1 reply; 4+ messages in thread
From: Sandipan Das @ 2017-10-05  9:11 UTC (permalink / raw)
  To: systemtap; +Cc: naveen.n.rao, segher, mjw, fche

With the 'o' memory constraint, any memory operand which
has an offsettable address is allowed. However, for some
architectures such as powerpc, this allows operands like
the ones shown below in the readelf output from Fedora 26
to be generated.

  $ readelf -n /lib64/libc.so.6 | grep memory_mallopt_mmap_max -A2 -B2
    stapsdt              0x0000006c	NT_STAPSDT (SystemTap probe descriptors)
      Provider: libc
      Name: memory_mallopt_mmap_max
      Location: 0x00000000000a0274, Base: 0x00000000001ccb90, Semaphore: 0x0000000000000000
      Arguments: -4@9 -4@.LANCHOR0+44@toc@l(8) -4@.LANCHOR0+52@toc@l(7)

The second and third argument shown above are both having
operands which are pointers to static data anchors. Since
these static anchors are not included in the symbol table,
they cannot be resolved from the binary itself. So, such
arguments cannot be read via their corresponding markers.

Using the 'Z' memory constraint instead solves this issue
as it will only allow a memory operand that is an indexed
or indirect from a register.

So, for powerpc, we set STAP_SDT_ARG_CONSTRAINT to 'nZr'
but keep it as 'nor' for all other architectures.

Signed-off-by: Sandipan Das <sandipan@linux.vnet.ibm.com>
---
 includes/sys/sdt.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/includes/sys/sdt.h b/includes/sys/sdt.h
index f85045851..940f74483 100644
--- a/includes/sys/sdt.h
+++ b/includes/sys/sdt.h
@@ -84,8 +84,12 @@
 # define _SDT_ARGFMT(no)		%n[_SDT_S##no]@_SDT_ARGTMPL(_SDT_A##no)
 
 # ifndef STAP_SDT_ARG_CONSTRAINT
+# if defined __powerpc__
+# define STAP_SDT_ARG_CONSTRAINT        nZr
+# else
 # define STAP_SDT_ARG_CONSTRAINT        nor
 # endif
+# endif
 
 # define _SDT_STRINGIFY(x)              #x
 # define _SDT_ARG_CONSTRAINT_STRING(x)  _SDT_STRINGIFY(x)
-- 
2.13.6

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc: Change SDT argument constraint
  2017-10-05  9:11 [PATCH] powerpc: Change SDT argument constraint Sandipan Das
@ 2017-10-05 10:16 ` Mark Wielaard
  2017-10-05 12:40   ` Segher Boessenkool
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Wielaard @ 2017-10-05 10:16 UTC (permalink / raw)
  To: Sandipan Das, systemtap; +Cc: naveen.n.rao, segher, fche

On Thu, 2017-10-05 at 14:39 +0530, Sandipan Das wrote:
> With the 'o' memory constraint, any memory operand which
> has an offsettable address is allowed. However, for some
> architectures such as powerpc, this allows operands like
> the ones shown below in the readelf output from Fedora 26
> to be generated.
> 
>   $ readelf -n /lib64/libc.so.6 | grep memory_mallopt_mmap_max -A2
> -B2
>     stapsdt              0x0000006c	NT_STAPSDT (SystemTap
> probe descriptors)
>       Provider: libc
>       Name: memory_mallopt_mmap_max
>       Location: 0x00000000000a0274, Base: 0x00000000001ccb90,
> Semaphore: 0x0000000000000000
>       Arguments: -4@9 -4@.LANCHOR0+44@toc@l(8) -4@.LANCHOR0+52@toc@l(
> 7)
> 
> The second and third argument shown above are both having
> operands which are pointers to static data anchors. Since
> these static anchors are not included in the symbol table,
> they cannot be resolved from the binary itself. So, such
> arguments cannot be read via their corresponding markers.
> 
> Using the 'Z' memory constraint instead solves this issue
> as it will only allow a memory operand that is an indexed
> or indirect from a register.
> 
> So, for powerpc, we set STAP_SDT_ARG_CONSTRAINT to 'nZr'
> but keep it as 'nor' for all other architectures.

I haven't tested it, but just reading the machine constraints page
https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html it looks
correct to me.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc: Change SDT argument constraint
  2017-10-05 10:16 ` Mark Wielaard
@ 2017-10-05 12:40   ` Segher Boessenkool
  2017-10-05 15:59     ` Frank Ch. Eigler
  0 siblings, 1 reply; 4+ messages in thread
From: Segher Boessenkool @ 2017-10-05 12:40 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: Sandipan Das, systemtap, naveen.n.rao, fche

On Thu, Oct 05, 2017 at 12:16:23PM +0200, Mark Wielaard wrote:
> On Thu, 2017-10-05 at 14:39 +0530, Sandipan Das wrote:
> > With the 'o' memory constraint, any memory operand which
> > has an offsettable address is allowed. However, for some
> > architectures such as powerpc, this allows operands like
> > the ones shown below in the readelf output from Fedora 26
> > to be generated.
> > 
> >   $ readelf -n /lib64/libc.so.6 | grep memory_mallopt_mmap_max -A2
> > -B2
> >     stapsdt              0x0000006c	NT_STAPSDT (SystemTap
> > probe descriptors)
> >       Provider: libc
> >       Name: memory_mallopt_mmap_max
> >       Location: 0x00000000000a0274, Base: 0x00000000001ccb90,
> > Semaphore: 0x0000000000000000
> >       Arguments: -4@9 -4@.LANCHOR0+44@toc@l(8) -4@.LANCHOR0+52@toc@l(
> > 7)
> > 
> > The second and third argument shown above are both having
> > operands which are pointers to static data anchors. Since
> > these static anchors are not included in the symbol table,
> > they cannot be resolved from the binary itself. So, such
> > arguments cannot be read via their corresponding markers.
> > 
> > Using the 'Z' memory constraint instead solves this issue
> > as it will only allow a memory operand that is an indexed
> > or indirect from a register.
> > 
> > So, for powerpc, we set STAP_SDT_ARG_CONSTRAINT to 'nZr'
> > but keep it as 'nor' for all other architectures.
> 
> I haven't tested it, but just reading the machine constraints page
> https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html it looks
> correct to me.

I wonder why only PowerPC is hitting this problem though?


Segher

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc: Change SDT argument constraint
  2017-10-05 12:40   ` Segher Boessenkool
@ 2017-10-05 15:59     ` Frank Ch. Eigler
  0 siblings, 0 replies; 4+ messages in thread
From: Frank Ch. Eigler @ 2017-10-05 15:59 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Mark Wielaard, Sandipan Das, systemtap, naveen.n.rao


segher wrote:

> [...]
>> >       Arguments: -4@9 -4@.LANCHOR0+44@toc@l(8) -4@.LANCHOR0+52@toc@l(
>> > 7)
>> > 
>> > The second and third argument shown above are both having
>> > operands which are pointers to static data anchors. Since
>> > these static anchors are not included in the symbol table,
>> > they cannot be resolved from the binary itself. So, such
>> > arguments cannot be read via their corresponding markers.

By the way, such local symbols would be saved rather dropped if the
assembler flags included -L.  Then stap should be able to resolve them.


> [...]
> I wonder why only PowerPC is hitting this problem though?

Analogous problems hit other platforms too.  Addressing mode
availability, register set sizes, or GOT-like policies seem to
affect the exact degree.


- FChE

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-10-05 15:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-05  9:11 [PATCH] powerpc: Change SDT argument constraint Sandipan Das
2017-10-05 10:16 ` Mark Wielaard
2017-10-05 12:40   ` Segher Boessenkool
2017-10-05 15:59     ` Frank Ch. Eigler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).