public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Florian Weimer <fw@deneb.enyo.de>
Cc: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
Subject: Re: [PATCH] Add SYSCALL_LONG/SYSCALL_ULONG to pass long to syscall [BZ #25810]
Date: Sat, 11 Apr 2020 13:25:35 -0700	[thread overview]
Message-ID: <CAMe9rOq_B5vAQ==rEcUfqO+1MEubhUFxzq_SH2QOfMCNsYC_oQ@mail.gmail.com> (raw)
In-Reply-To: <87k12m82er.fsf@mid.deneb.enyo.de>

On Sat, Apr 11, 2020 at 8:31 AM Florian Weimer <fw@deneb.enyo.de> wrote:
>
> * H. J. Lu:
>
> > On Sat, Apr 11, 2020 at 8:10 AM Florian Weimer <fw@deneb.enyo.de> wrote:
> >>
> >> * H. J. Lu:
> >>
> >> > On Sat, Apr 11, 2020 at 7:45 AM Florian Weimer <fw@deneb.enyo.de> wrote:
> >> >>
> >> >> * H. J. Lu:
> >> >>
> >> >> > On Sat, Apr 11, 2020 at 3:01 AM Florian Weimer <fw@deneb.enyo.de> wrote:
> >> >> >>
> >> >> >> * H. J. Lu via Libc-alpha:
> >> >> >>
> >> >> >> > For inline syscalls, SYSCALL_LONG and SYSCALL_ULONG are introduced as
> >> >> >> > wrappers for long and unsigned long arguments.
> >> >> >>
> >> >> >> Do the arguments have the correct types?  Then I think you can do the
> >> >> >
> >> >> > Yes, they have correct types.  But it is not the problem.  Take this example:
> >> >> >
> >> >> > int munmap(void *addr, size_t length);
> >> >> >
> >> >> > The type of length is unsigned int (size_t) for x32 and is unsigned long
> >> >> > (64bit) in kernel.  We have no way to know the type which kernel expects.
> >> >>
> >> >> Is it possible to extend all 32-bit arguments?  Ot is this incorrect
> >> >> for negative int arguments, which must not have their upper bits set?
> >> >
> >> >       ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp,
> >> >                       int msgflg);
> >> >
> >> >       * If msgtyp is 0, then the first message in the queue is read.
> >> >
> >> >        * If  msgtyp  is greater than 0, then the first message in the queue of
> >> >          type msgtyp is read, unless MSG_EXCEPT was specified  in  msgflg,  in
> >> >          which case the first message in the queue of type not equal to msgtyp
> >> >          will be read.
> >> >
> >> >        * If msgtyp is less than 0, then the first message in  the  queue  with
> >> >          the  lowest  type  less than or equal to the absolute value of msgtyp
> >> >          will be read.
> >> >
> >> > In this syscall, msgtyp should be sign-extended to 64-bit.
> >>
> >> As far as I can tell, this is not a problematic exception.
> >
> > There is no need to extend int nor unsigned int passed to kernel.
> > Only long and unsigned long are the problem.
>
> But is there harm in sign-extending int?
>
> I'm not convinced to annotate INLINE_SYSCALLs in this way just to
> avoid argument extensions for a subset of the x32 system calls.

What x32 needs are

1. Pointer arguments: no cast.
2. 64-bit integer arguments:  no cast.
3. 32-bit integer arguments: extend to 64 bits.

I am having a very hard time to do it  in INLINE_SYSCALLs.   If
SYSCALL_LONG and SYSCALL_ULONG isn't an option, I can
duplicate the whole set of these functions and convert them in
x32 directory.

-- 
H.J.

  reply	other threads:[~2020-04-11 20:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-10 21:22 H.J. Lu
2020-04-11 10:01 ` Florian Weimer
2020-04-11 13:26   ` H.J. Lu
2020-04-11 14:45     ` Florian Weimer
2020-04-11 15:04       ` H.J. Lu
2020-04-11 15:10         ` Florian Weimer
2020-04-11 15:23           ` H.J. Lu
2020-04-11 15:31             ` Florian Weimer
2020-04-11 20:25               ` H.J. Lu [this message]
2020-04-11 20:47                 ` Florian Weimer
2020-04-11 21:58                   ` H.J. Lu
2020-04-12 20:44                     ` Florian Weimer
2020-04-12 22:42                       ` H.J. Lu
2020-04-13  8:23                         ` Florian Weimer
2020-04-13 11:44                           ` H.J. Lu
2020-04-13 11:54                             ` H.J. Lu
2020-04-13 14:26                               ` 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='CAMe9rOq_B5vAQ==rEcUfqO+1MEubhUFxzq_SH2QOfMCNsYC_oQ@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=fw@deneb.enyo.de \
    --cc=libc-alpha@sourceware.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).