public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Meyer <thomas@m3y3r.de>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: viro@zeniv.linux.org.uk, mingo@redhat.com
Subject: Re: a question regarding sys_poll() on x86_64 via tha ia32 layer
Date: Thu, 15 Sep 2011 13:40:55 +0200	[thread overview]
Message-ID: <1316086860.6545.66.camel@localhost.localdomain> (raw)

cc'ed some people on this assumed bug.

Am Dienstag, den 13.09.2011, 14:04 +0200 schrieb Thomas Meyer:
> Hello,
> 
> the ia32 poll system call is routed through the "standard" function
> sys_poll().
> 
> This function is defined as:
> 
> SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds,
> 		long, timeout_msecs)
> 
> in fs/select.c
> 
> timeout_msecs is of type long which is AFAIK is 4 bytes on x86 and 8
> bytes on x86_64.
> 
> the test for sign (i.e. < 0) in the objdump is done against the 64 bit
> register (here %rbx):
> 
> ffffffff811313e0 <sys_poll>:
> ffffffff811313e0:       55                      push   %rbp
> ffffffff811313e1:       48 89 e5                mov    %rsp,%rbp
> ffffffff811313e4:       48 83 ec 30             sub    $0x30,%rsp
> ffffffff811313e8:       48 89 5d e8             mov    %rbx,-0x18(%rbp)
> ffffffff811313ec:       48 89 d3                mov    %rdx,%rbx
> ffffffff811313ef:       31 d2                   xor    %edx,%edx
> ffffffff811313f1:       48 85 db                test   %rbx,%rbx
> ffffffff811313f4:       4c 89 65 f0             mov    %r12,-0x10(%rbp)
> ffffffff811313f8:       4c 89 6d f8             mov    %r13,-0x8(%rbp)
> ffffffff811313fc:       41 89 f4                mov    %esi,%r12d
> ffffffff811313ff:       49 89 fd                mov    %rdi,%r13
> ffffffff81131402:       78 42                   js     ffffffff81131446 <sys_poll+0x66>
> 
> on an x86 kernel the test is done against %ebx
> 
> so when the system call is called with %rbx = 00000000ffffffff (i.e. -1
> from %ebx) on an x86_64 kernel via the ia32 layer the test for sign will
> fail and the timer will be set.
> 
> btw. <sys/poll.h> seems to define the function as
> 
> extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
> 
> what am I overloking?
> 
> mfg
> thomas



             reply	other threads:[~2011-09-15 11:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-15 11:40 Thomas Meyer [this message]
2011-09-15 12:23 ` a question regarding sys_poll() on x86_64 via tha ia32 layer Eric Dumazet
2011-09-15 13:00   ` Thomas Meyer
2011-09-15 14:37     ` Eric Dumazet
2011-09-15 17:44   ` Andi Kleen
  -- strict thread matches above, loose matches on Subject: below --
2011-09-13 12:04 Thomas Meyer

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=1316086860.6545.66.camel@localhost.localdomain \
    --to=thomas@m3y3r.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /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