public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@gmail.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: mingo@elte.hu, linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org
Subject: Re: [PATCH 1/1] X86: use explicit register name for get/put_user
Date: Mon, 07 Dec 2009 13:37:21 +0100	[thread overview]
Message-ID: <4B1CF701.3070805@gmail.com> (raw)
In-Reply-To: <4B1C01F4.8020304@zytor.com>

On 12/06/2009 08:11 PM, H. Peter Anvin wrote:
> On 12/06/2009 01:30 AM, Jiri Slaby wrote:
>>
>> I don't know if this could ever cause any problems, but changing
>> the input to an explicit register ("a") makes it cleaner in my eyes.
>> There is no need of the back reference.
>>
> 
> It can't: the backreference refers to only the information that is in
> the register constraint, not to anything else.

Is this documented somewhere? Or do we rely on an undocumented feature?
I mean it doesn't refer only to the constraint but also to a concrete
register allocation. As far as I understand it (from the gcc 4.4
documentation), if one does
 "insn %0" : "=r" (out) : "0" (in)
the "0" constraint corresponds to the concrete register allocated for
out, not to any register (which is the constraint "r").

In the document they write only about the "same location" occupied by in
and out, nothing is said about size (and hence I think we cannot
mismatch size of operands). And I couldn't find any other
restrictions/documentation about inline assembly, hence the patch,
because nothing assured me this cannot change in the future.

Now I tried different compilers (clang, llvm-gcc) and they choke on that:
$ cat c.c
void x(void)
{
        unsigned long in;
        int out;
        asm("insn %0" : "=r" (out) : "0" (in));
}
$ clang c.c -S -o -
c.c:5:36: error: unsupported inline asm: input with type 'unsigned long'
      matching output with type 'int'
        asm("insn %0" : "=r" (out) : "0" (in));
                              ~~~         ^~
1 diagnostic generated.
$ llvm-gcc c.c -S -o -
c.c: In function 'x':
c.c:5: error: unsupported inline asm: input constraint with a matching
output constraint of incompatible type!

thanks for the review,
-- 
js

  reply	other threads:[~2009-12-07 12:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-06  9:30 [PATCH 1/1] X86: use explicit register name for get/put_user Jiri Slaby
2009-12-06 19:11 ` H. Peter Anvin
2009-12-07 12:37   ` Jiri Slaby [this message]
2009-12-07 18:35     ` H. Peter Anvin
2009-12-09 20:03       ` Jiri Slaby

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=4B1CF701.3070805@gmail.com \
    --to=jirislaby@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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