On 12.12.2012, at 21:12, Christian Borntraeger wrote:

> On 12/12/12 19:31, Alexander Graf wrote:
> +static inline long do_kvm_notify(struct subchannel_id schid,
>>> +                 unsigned long queue_index)
>>> +{
>>> +    register unsigned long __nr asm("1") = KVM_S390_VIRTIO_CCW_NOTIFY;
>>> +    register struct subchannel_id __schid asm("2") = schid;
>> 
>> How does the compiler know that the struct fits within a register?
>> 
> 
> Well it knows that sizeof struct subchannel_id is 4.

How so? The asm/ccwdev.h header simply says

  struct subchannel_id;

with the actual implementation of that struct hidden in asm/schid.h. So either 
patch 3/4 exports the struct needlessly and should rather do an #include 
<asm/schid.h> or the compiler can do magic :).


Alex

> 
> then we have 
> "ELF Application Binary Interface Supplement Linux on zSeries"
> 
> [...]
> Parameter passing
> [...]
> - Structures with a size of 1, 2, 4, or 8 bytes are passed as integral 
> values.  <=============
> - All other structures are passed by reference. If needed, the called 
> function makes
>  a copy of the value.
> [...]
> 
> while not being a perfect match it gives a good indication that this will 
> work.
> 
> Furthermore, we know it is working at least since 
> commit 94c12cc7d196bab34aaa98d38521549fa1e5ef76
> Author: Martin Schwidefsky <[email protected]>
> Date:   Thu Sep 28 16:56:43 2006 +0200
>    [S390] Inline assembly cleanup.
> 
> in 
> drivers/s390/cio/ioasm.h
> 
> [...]
> 94c12cc7 (Martin Schwidefsky  2006-09-28 16:56:43 +0200  30)    register 
> struct subchannel_id reg1 asm ("1") = schid;
> 94c12cc7 (Martin Schwidefsky  2006-09-28 16:56:43 +0200  31)    int ccode = 
> -EIO;
> fb6958a5 (Cornelia Huck       2006-01-06 00:19:25 -0800  32) 
> 94c12cc7 (Martin Schwidefsky  2006-09-28 16:56:43 +0200  33)    asm volatile(
> [...]
> 
> So this complies with the coding style of the s390 maintainer :-)
> 
> Christian
> 

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to