All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@kernel.org>
To: Jeff Garzik <jeff@garzik.org>
Cc: LKML <linux-kernel@vger.kernel.org>, x86@kernel.org
Subject: Re: [x86] Strange 64-bit put_user ?
Date: Tue, 28 Apr 2009 17:31:43 -0700	[thread overview]
Message-ID: <49F79FEF.80508@kernel.org> (raw)
In-Reply-To: <49F73D96.2090801@garzik.org>

Jeff Garzik wrote:
> In arch/x86/include/asm/uaccess.h, if !CONFIG_X86_32, we see
> 
>> #define __put_user_x8(x, ptr, __ret_pu) \
>>         ({ u64 __ret_pu; __put_user_x(8, x, ptr, __ret_pu);
>> (int)__ret_pu; })
> 
> which was preceded by
> 
>> #define __put_user_x(size, x, ptr, __ret_pu)                    \
>>         asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
>>                      :"0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
> 
> 
> My question, from an admitted inline asm newbie:
> 
> Why is 32-bit register 'ebx' being used for a 64-bit put_user?
> 
> And a dumb-question follow-up, probably easy, for any x86 expert:  why
> are registers 'bl' and 'bx' not used for 8-bit and 16-bit put_user,
> respectively?
> 

The answer is simply that gcc doesn't make a distinction between bl, bx,
ebx, and rbx -- it considers it a single regioster which can contain an
8-, 16-, 32- or 64-bit number.  In particular, gcc can't use ah, bh, ch,
and dh as independent registers at all.

	-hpa


  reply	other threads:[~2009-04-29  0:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-28 17:32 [x86] Strange 64-bit put_user ? Jeff Garzik
2009-04-29  0:31 ` H. Peter Anvin [this message]
2009-04-29 20:00   ` Jeff Garzik

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=49F79FEF.80508@kernel.org \
    --to=hpa@kernel.org \
    --cc=jeff@garzik.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 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.