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: V2 [PATCH 2/2] Add a syscall test for [BZ #25810]
Date: Wed, 22 Apr 2020 06:42:11 -0700	[thread overview]
Message-ID: <CAMe9rOpMsEqy+G-vzw=J4z8Q2bk=Zd0LU8Q2pch95_1ohY3RBA@mail.gmail.com> (raw)
In-Reply-To: <87k127k7qc.fsf@mid.deneb.enyo.de>

On Wed, Apr 22, 2020 at 5:47 AM Florian Weimer <fw@deneb.enyo.de> wrote:
>
> * H. J. Lu:
>
> > On Wed, Apr 22, 2020 at 5:25 AM Florian Weimer <fw@deneb.enyo.de> wrote:
> >>
> >> * H. J. Lu via Libc-alpha:
> >>
> >> > Add a test to pass 64-bit long arguments to syscall with undefined upper
> >> > 32 bits on ILP32 systems.
> >>
> >> What does this test, exactly?  How does it ensure that the upper bits
> >> are indeed non-zero, to exercise the zero-extension case?
> >
> > On x32,
> >
> > struct Array
> > {
> >   size_t length;
> >   void *ptr;
> > };
> >
> > can be passed in a single 64-bit integer register.  When a 32-bit
> > integer is passed in
> > a 64-bit integer, its upper 32 bits can contain undefined value:
> >
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94541
> >
> > This testcase arranges syscalls in such a way that the upper 32 bits
> > of 64 big integer
> > register, which is used to pass unsigned long to kernel, contains the
> > "ptr" value passed in
> > function arguments.   If the upper 32 bits aren't cleared, syscall
> > will fail since long in kernel
> > is 64 bits, not 32 bits.
>
> Would you please add this as a comment to the patch, and one-line
> comments where the clobbers happen?

I will add

+/* On x32, this can be passed in a single 64-bit integer register.  */
 struct Array
 {
   size_t length;
@@ -50,6 +51,9 @@ __attribute__ ((noclone, noinline))
 void
 deallocate (struct Array b)
 {
+  /* On x32, the 64-bit integer register containing `b' may be copied
+     to another 64-bit integer register to pass the second argument to
+     munmap.  */
   if (b.length && munmap (b.ptr, b.length))
     {
       printf ("munmap error: %m\n");

> And say that the test is in this formulation likely x32-specific, but
> that it is expected to work on other architectures as well.



-- 
H.J.

  reply	other threads:[~2020-04-22 13:42 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-13 17:51 V2 [PATCH 0/2] x32: Properly pass long to syscall " H.J. Lu
2020-04-13 17:51 ` V2 [PATCH 1/2] Add SYSCALL_ULONG_ARG_[12] to " H.J. Lu
2020-04-22 10:42   ` Florian Weimer
2020-04-22 11:44     ` Adhemerval Zanella
2020-04-22 22:01       ` Joseph Myers
2020-04-23 21:34         ` Adhemerval Zanella
2020-04-22 16:09     ` V3 " H.J. Lu
2020-04-25 13:56       ` PING: " H.J. Lu
2020-04-28 13:27         ` PING^2: " H.J. Lu
2020-04-29 12:14       ` Florian Weimer
2020-04-29 12:43         ` H.J. Lu
2020-04-29 12:56           ` Florian Weimer
2020-04-29 12:57             ` H.J. Lu
2020-04-29 13:15         ` H.J. Lu
2020-04-29 13:30           ` Florian Weimer
2020-04-13 17:51 ` V2 [PATCH 2/2] Add a syscall test for " H.J. Lu
2020-04-22 12:25   ` Florian Weimer
2020-04-22 12:43     ` H.J. Lu
2020-04-22 12:47       ` Florian Weimer
2020-04-22 13:42         ` H.J. Lu [this message]
2020-04-22 13:46           ` Florian Weimer
2020-04-22 15:52             ` V3 " H.J. Lu
2020-04-22 15:55               ` Florian Weimer
2020-04-16 12:52 ` PING: V2 [PATCH 0/2] x32: Properly pass long to syscall " H.J. Lu
2020-04-20 14:15   ` PING^2: " 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='CAMe9rOpMsEqy+G-vzw=J4z8Q2bk=Zd0LU8Q2pch95_1ohY3RBA@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).