All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Avi Kivity <avi@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Christoph Hellwig <hch@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"H.J. Lu" <hjl.tools@gmail.com>, Ingo Molnar <mingo@elte.hu>,
	Thomas Gleixner <tglx@linutronix.de>,
	Richard Kuo <rkuo@codeaurora.org>,
	Mark Salter <msalter@redhat.com>, Jonas Bonn <jonas@southpole.se>,
	Tobias Klauser <tklauser@distanz.ch>
Subject: Re: RFD: x32 ABI system call numbers
Date: Fri, 2 Sep 2011 09:42:06 +0100	[thread overview]
Message-ID: <201109020942.07312.pedro@codesourcery.com> (raw)
In-Reply-To: <4E6036A7.6090200@zytor.com>

On Friday 02 September 2011 02:51:35, H. Peter Anvin wrote:
> On 09/01/2011 05:49 PM, Pedro Alves wrote:
> >>>
> >>>       struct iovec
> >>>       {
> >>>           void __user *iov_base;    /* BSD uses caddr_t (1003.1g requires
> >>> void *) */
> >>>           __kernel_size_t iov_len; /* Must be size_t (1003.1g) */
> >>>       } __attribute__((x32_abi_64));
> >>>
> >>>       typedef long time_t __attribute__((x32_abi_64));
> >>>
> >>> The x32_abi_64 attribute converts pointers and longs back to 64-bit and
> >>> adjusts the alignment accordingly.  If we tag all userspace visible
> >>> structures with this attribute, we can use the 64-bit ABI without changes.
> >
> > I would expect no new gcc extension to be needed for that -- there's the
> > mode attribute (you can read DI as 64-bit):
> >
> >   typedef void * __kernel_ptr64 __attribute ((mode(DI)));
> >
> >   struct iovec
> >   {
> >     __kernel_ptr64 iov_base;
> >     ...
> >   };
> >
> 
> Does that work for *writing*, too?  That might be a very useful little 
> escape hatch for some particularly tight corners.

With a gcc trunk from earlier this month (that supports -mx32):

typedef void * ptr64 __attribute ((mode(DI)));

struct foo
{
  ptr64 p64;
};

int
foofunc (void)
{
  struct foo foo;
  int i;
  void *p32;
  ptr64 p64;

  p32 = &i;
  p32 = &foofunc;

  p64 = p32;
  p64 = &i;
  p64 = foofunc;

  foo.p64 = p32;

  void **ptrp64 = &p64;  /* gives "warning: initialization from incompatible pointer type [enabled by default]". */

  return (int) (void*) ptrp64;
}

With:

./cc1 ~/mode.c -o mode.o -mx32 -fverbose-asm

gives me:

/home/pedro/mode.c: In function ‘foofunc’:
/home/pedro/mode.c:25:19: warning: initialization from incompatible pointer type [enabled by default]

and produced (note, -O0):

foofunc:
.LFB0:
        .cfi_startproc
        pushq   %rbp    #
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp      #,
        .cfi_def_cfa_register 6
        leaq    -20(%rbp), %rax #, tmp61
        movl    %eax, -4(%rbp)  # tmp61, p32
        movl    $foofunc, -4(%rbp)      #, p32
        mov     -4(%rbp), %eax  # p32,
        movq    %rax, -32(%rbp) #, p64
        leaq    -20(%rbp), %rax #, tmp62
        movq    %rax, -32(%rbp) # tmp62, p64
        movq    $foofunc, -32(%rbp)     #, p64
        mov     -4(%rbp), %eax  # p32, tmp63
        movq    %rax, -16(%rbp) # tmp63, foo.p64
        leaq    -32(%rbp), %rax #, tmp64
        movl    %eax, -8(%rbp)  # tmp64, ptrp64
        movl    -8(%rbp), %eax  # ptrp64, D.2693
        popq    %rbp    #
        .cfi_def_cfa 7, 8
        ret
        .cfi_endproc

-- 
Pedro Alves

  parent reply	other threads:[~2011-09-02  8:42 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-26 23:00 RFD: x32 ABI system call numbers H. Peter Anvin
2011-08-26 23:13 ` Linus Torvalds
2011-08-26 23:39   ` H. Peter Anvin
2011-08-27  0:36     ` Linus Torvalds
2011-08-27  0:43       ` Linus Torvalds
2011-08-27  0:53         ` H. Peter Anvin
2011-08-27  1:18           ` Linus Torvalds
2011-08-27  1:35             ` H. Peter Anvin
2011-08-27  1:45               ` Linus Torvalds
2011-08-27  1:12         ` H. Peter Anvin
2011-08-27  1:42           ` Linus Torvalds
2011-08-29 19:01             ` Geert Uytterhoeven
2011-08-29 19:03               ` H. Peter Anvin
2011-08-30  1:17               ` Ted Ts'o
2011-08-30  1:48               ` Linus Torvalds
2011-08-30  2:16                 ` Kyle Moffett
2011-08-30  4:45                   ` H. Peter Anvin
2011-08-30  7:06                     ` Geert Uytterhoeven
2011-08-30 12:18                       ` Arnd Bergmann
2011-08-30  7:09                   ` Andi Kleen
2011-08-30  9:56                     ` Alan Cox
2011-08-30  7:00                 ` Geert Uytterhoeven
2011-09-20 18:37                   ` Jan Engelhardt
2011-09-06 20:40         ` Florian Weimer
2011-08-27  0:57       ` H. Peter Anvin
2011-08-27  4:40         ` Christoph Hellwig
2011-08-29 15:04           ` Arnd Bergmann
2011-08-29 18:31             ` H. Peter Anvin
2011-08-30 12:09               ` Arnd Bergmann
2011-08-30 16:35                 ` H. Peter Anvin
2011-08-31 16:14                   ` Arnd Bergmann
2011-08-31 16:25                     ` H. Peter Anvin
2011-08-31 16:39                       ` Arnd Bergmann
2011-08-31 16:48                         ` Linus Torvalds
2011-08-31 19:18                           ` Arnd Bergmann
2011-08-31 19:44                             ` H. Peter Anvin
2011-08-31 19:54                               ` Alan Cox
2011-08-31 20:02                                 ` H. Peter Anvin
2011-08-31 20:55                                   ` Arnd Bergmann
2011-08-31 20:58                                     ` H. Peter Anvin
2011-08-31 19:49                             ` Geert Uytterhoeven
2011-08-31 16:46                     ` Linus Torvalds
2011-08-31 17:05                       ` H.J. Lu
2011-09-03  2:56                         ` H.J. Lu
2011-09-03  3:04                           ` Linus Torvalds
2011-09-03  4:02                             ` H.J. Lu
2011-09-03  4:29                               ` H. Peter Anvin
2011-09-03  4:44                                 ` H.J. Lu
2011-09-03  5:16                                   ` H. Peter Anvin
2011-09-03 14:11                                     ` H.J. Lu
2011-09-03  5:29                                   ` H. Peter Anvin
2011-09-03  8:41                                     ` Arnd Bergmann
2011-09-03 14:04                                       ` Valdis.Kletnieks
2011-09-03 16:40                                         ` H. Peter Anvin
2011-09-03 17:16                                           ` Valdis.Kletnieks
2011-09-03 17:22                                             ` H.J. Lu
2011-09-03 17:28                                               ` H. Peter Anvin
2011-09-03 17:27                                             ` H. Peter Anvin
2011-09-04 13:51                                               ` Valdis.Kletnieks
2011-09-04 15:17                                               ` Arnd Bergmann
2011-09-04 17:08                                                 ` Linus Torvalds
2011-09-04 18:40                                                 ` H.J. Lu
2011-09-04 19:06                                                   ` Arnd Bergmann
2011-09-04 19:31                                                     ` H.J. Lu
2011-09-04 21:13                                                       ` Arnd Bergmann
2011-09-04 21:25                                                         ` H.J. Lu
2011-09-04 21:41                                                           ` Arnd Bergmann
2011-09-04 22:13                                                             ` H.J. Lu
2011-09-05  7:48                                                               ` Arnd Bergmann
2011-09-05 15:11                                                                 ` H.J. Lu
2011-09-05 17:21                                                                   ` Arnd Bergmann
2011-09-05 19:34                                                                     ` H.J. Lu
2011-09-05 19:54                                                                       ` H.J. Lu
2011-09-05 19:59                                                                         ` H. Peter Anvin
2011-09-05 20:27                                                                           ` Arnd Bergmann
2011-09-09 21:02                                                                   ` H.J. Lu
2011-09-04 20:11                                                     ` H. Peter Anvin
2011-09-04 19:31                                                   ` richard -rw- weinberger
2011-09-04 19:32                                                     ` H.J. Lu
2011-09-03 14:15                                     ` H.J. Lu
2011-08-31 17:09                       ` H. Peter Anvin
2011-08-31 17:19                         ` Linus Torvalds
2011-08-31 17:38                           ` H. Peter Anvin
2011-09-01 11:35                             ` Arnd Bergmann
2011-10-01 19:38                               ` Jonas Bonn
2012-02-08 21:36                           ` 64-bit time on 32-bit systems H. Peter Anvin
2011-09-01 13:30                         ` RFD: x32 ABI system call numbers Avi Kivity
2011-09-01 14:13                           ` H. Peter Anvin
2011-09-02  0:49                             ` Pedro Alves
2011-09-02  1:51                               ` H. Peter Anvin
2011-09-02  8:02                                 ` Arnd Bergmann
2011-09-02  8:42                                 ` Pedro Alves [this message]
2011-09-01  6:08                     ` Jonas Bonn
2011-09-02  6:17     ` Andy Lutomirski

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=201109020942.07312.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=arnd@arndb.de \
    --cc=avi@redhat.com \
    --cc=hch@infradead.org \
    --cc=hjl.tools@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jonas@southpole.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=msalter@redhat.com \
    --cc=rkuo@codeaurora.org \
    --cc=tglx@linutronix.de \
    --cc=tklauser@distanz.ch \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.