public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: rth@twiddle.net (Richard Henderson)
Cc: libffi-discuss@sourceware.org, Ulrich.Weigand@de.ibm.com,
	       vogt@linux.vnet.ibm.com, krebbel@linux.vnet.ibm.com
Subject: Re: [PATCH 0/4] s390 improvements
Date: Fri, 19 Dec 2014 15:07:00 -0000	[thread overview]
Message-ID: <201412191506.sBJF6pil005079@d03av02.boulder.ibm.com> (raw)
In-Reply-To: <1418938403-15836-1-git-send-email-rth@twiddle.net> from "Richard Henderson" at Dec 18, 2014 03:33:19 PM

Richard Henderson wrote:

> This is relative to Dominik's patch from the 16th.  The complete
> tree can be found at
> 
> 	git://github.com/rth7680/libffi.git s390
> 
> Mostly relevant is patch 3, which converts the s390 port to the
> more modern arrangement where there's no callback into ffi_prep_args.

This is a bit confusing to me.  The assembler routine now does:

        lg      %r15,120(%r2)                   # Set up outgoing stack

without ever restoring the initial stack pointer before returning
to its caller.  This probably works right now since the value loaded
here is determined like that:

  /* Pass the outgoing stack frame in the r15 save slot.  */
  frame->gpr_save[8] = (unsigned long)(stack - sizeof(struct call_frame));

and since "stack" was allocated via alloca and ffi_call_int does not
require an argument save area when calling any of its subroutines,
the stack pointer value computed here should always in fact be
identical to the value %r15 already has at the above location.

Using the 160 bytes below "stack" as register save area for use of the
target function called by ffi_call_SYSV is also only safe if those bytes
are in fact the register save area ffi_call_int provides for its caller,
e.g. again if the value is already identical to %r15.  (If this were
any other value, we might clobber parts of ffi_call_int's stack frame
that it conceivably might still access.)

However, if the procedure only works if the "lg" is a nop, why is it
even done?   Also, the whole setup seems a bit fragile since changes
to ffi_call_int might cause it to need an argument save area ...

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com

  parent reply	other threads:[~2014-12-19 15:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-18 21:33 Richard Henderson
2014-12-18 21:33 ` [PATCH 3/4] s390: Reorganize assembly Richard Henderson
2014-12-22 12:12   ` Dominik Vogt
2014-12-22 12:25     ` Dominik Vogt
2014-12-22 16:30       ` Richard Henderson
2014-12-23  9:54         ` Dominik Vogt
2014-12-18 21:33 ` [PATCH 1/4] s390: Kill trailing whitespace Richard Henderson
2014-12-18 21:33 ` [PATCH 4/4] s390: Use pc-relative insns in 31-bit mode Richard Henderson
2014-12-18 21:33 ` [PATCH 2/4] s390: Avoid aliasing warnings Richard Henderson
2014-12-19 15:07 ` Ulrich Weigand [this message]
2014-12-19 15:33   ` [PATCH 0/4] s390 improvements Richard Henderson
2014-12-19 16:15     ` Ulrich Weigand
2014-12-19 16:37       ` Richard Henderson
2014-12-19 17:08         ` Ulrich Weigand
2014-12-19 16:43 ` [PATCH 5/4] s390: Inline and tidy ffi_prep_args Richard Henderson
2014-12-22 11:34 ` [PATCH 0/4] s390 improvements Dominik Vogt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201412191506.sBJF6pil005079@d03av02.boulder.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=krebbel@linux.vnet.ibm.com \
    --cc=libffi-discuss@sourceware.org \
    --cc=rth@twiddle.net \
    --cc=vogt@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).