public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>,
	"H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
Cc: Andreas Schwab <schwab@linux-m68k.org>, "H.J. Lu" <hjl.tools@gmail.com>
Subject: Re: V3 [PATCH] Add a C wrapper for prctl [BZ #25896]
Date: Thu, 10 Nov 2022 08:49:24 -0300	[thread overview]
Message-ID: <183d6add-a82f-8d3e-6669-b5f9f78c2d45@linaro.org> (raw)
In-Reply-To: <875yfnw6n6.fsf@oldenburg.str.redhat.com>



On 10/11/22 05:33, Florian Weimer via Libc-alpha wrote:
> * H. J. Lu via Libc-alpha:
> 
>> From ee8672af3ef5f3db438c0abb39b2673944181292 Mon Sep 17 00:00:00 2001
>> From: "H.J. Lu" <hjl.tools@gmail.com>
>> Date: Wed, 29 Apr 2020 07:38:49 -0700
>> Subject: [PATCH] Add a C wrapper for prctl [BZ #25896]
>>
>> Add a C wrapper to pass arguments in
>>
>> /* Control process execution.  */
>> extern int prctl (int __option, ...) __THROW;
>>
>> to prctl syscall:
>>
>> extern int prctl (int, unsigned long int, unsigned long int,
>> 		  unsigned long int, unsigned long int);
>>
>> On Linux/x86, since the prctl syscall interface:
>>
>> extern int prctl (int, unsigned long int, unsigned long int,
>> 		  unsigned long int, unsigned long int);
>>
>> and the glibc prctl interface:
>>
>> extern int prctl (int option, ...);
>>
>> pass the arguments identically, the assembly verion:
>>
>> PSEUDO (__prctl, prctl, 5)
>> 	ret
>> PSEUDO_END (__prctl)
>>
>> is used.
> 
> This broke ABI on powerpc64le-linux-gnu because the calling convention
> is not identical.  The manual page specifies the second prototype.
> 
> I filed a GCC RFE so that we can deal with this in a more elegant
> manner:
> 
>   rs6000: Option not to use parameter save area in variadic function
>   implementations
>   <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107606>
> 
> I don't know whether we should restrict the C prctl wrapper to x86 x32,
> or if we should add an assembler wrapper on powerpc64le-linux-gnu.
> 
> Thanks,
> Florian
> 

The previous syscalls.list entry marked the function as 5 argument one
instead of variadic, so I think it would be better to add a way each
ABI to use this instead of the variadic one. Something like:

  #if PRCTL_VARIADIC_OK
  int
  __prctl (int option, ...)
  {
    va_list arg;
    va_start (arg, option);
    unsigned long int arg2 = va_arg (arg, unsigned long int);
    unsigned long int arg3 = va_arg (arg, unsigned long int);
    unsigned long int arg4 = va_arg (arg, unsigned long int);
    unsigned long int arg5 = va_arg (arg, unsigned long int);
    va_end (arg);
    return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
  }
  #else
  int
  __prctl (int option, int arg1, int arg2, int arg3, int arg4, int arg5)
  {
    return INLINE_SYSCALL_CALL (prctl, option, arg2, arg3, arg4, arg5);
  }
  #endif

Or if powerpc64le is the only affected add a specific C implementation for
it.  I think we should really move away from assembler wrappers.

  reply	other threads:[~2022-11-10 11:49 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29 20:52 H.J. Lu
2020-04-30  7:26 ` Florian Weimer
2020-04-30 13:03   ` V2 " H.J. Lu
2020-04-30 13:41     ` Andreas Schwab
2020-04-30 13:43       ` Florian Weimer
2020-04-30 13:50         ` H.J. Lu
2020-04-30 13:51         ` Andreas Schwab
2020-04-30 13:53           ` H.J. Lu
2020-04-30 14:04             ` Andreas Schwab
2020-04-30 15:27               ` V3 " H.J. Lu
2020-04-30 16:53                 ` Florian Weimer
2020-04-30 17:20                   ` [PATCH] Add a " H.J. Lu
2020-04-30 20:01                 ` V3 [PATCH] Add a C " Florian Weimer
2022-11-10  8:33                 ` Florian Weimer
2022-11-10 11:49                   ` Adhemerval Zanella Netto [this message]
2022-11-10 12:03                     ` Florian Weimer
2022-11-10 12:25                       ` Adhemerval Zanella Netto
2022-11-10 13:17                         ` Florian Weimer
2020-04-30 13:54           ` V2 " Florian Weimer
2020-04-30 14:51     ` Adhemerval Zanella
2020-04-30 16:35       ` H.J. Lu
2020-04-30 16:51         ` Florian Weimer
2020-04-30 17:24           ` Adhemerval Zanella
2020-04-30 17:29             ` V4 " H.J. Lu
     [not found]               ` <c2a821bf-fd2a-0ed9-2ad9-c4bd1231b2a7@linux.ibm.com>
     [not found]                 ` <CAMe9rOq60aAKujxFF=bSyN5yPZVWSa-KWKWXKHpB8uOKu5V-7w@mail.gmail.com>
2020-04-30 22:57                   ` Bad LOADARGS_N on PPC H.J. Lu
2020-05-01  2:03                     ` Tulio Magno Quites Machado Filho
2020-05-01  2:18                       ` [PATCH] powerpc: Rename argN to _argN in LOADARGS_N [BZ #25902] H.J. Lu
2020-05-01 23:11                         ` Please test: [2.31/2.30] " H.J. Lu
2020-05-04 16:00                           ` Matheus Castanho
2020-05-04 19:11                             ` H.J. Lu

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=183d6add-a82f-8d3e-6669-b5f9f78c2d45@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@linux-m68k.org \
    /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).