Strange 64-bit put_user ?
In arch/x86/include/asm/uaccess.h, if !CONFIG_X86_32, we see
Quoted 2 lines
#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
Quoted 3 lines
#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?
Thanks,
Jeff
Quoted 13 lines · Jeff Garzik
In
arch/x86/include/asm/uaccess.h, if !CONFIG_X86_32, we seeQuoted 3 lines
#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
Quoted 3 lines
#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")
Quoted 8 lines
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
Quoted 21 lines · H. Peter Anvin
Quoted 11 lines · Jeff Garzik
In
arch/x86/include/asm/uaccess.h, if !CONFIG_X86_32, we seeQuoted 3 lines
#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
Quoted 3 lines
#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")Quoted 8 lines
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?
Quoted 4 lines
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.
So, it isn't really referring to 'ebx' register specifically, it is referring to the hardware register that contains 'ebx'. Gotcha.
Thanks!
Jeff