virtio — archive
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
— [Date Index]
| [Thread Index]
| [Month Index]
| [List Home]
virtio_scsi_cmd_req_cmd alignment
Stefan Hajnoczi <[email protected]> writes:
> On Mon, Apr 07, 2014 at 12:33:16PM +0300, Michael S. Tsirkin wrote: >> I just noticed that without a pack directive, >> the following is likely to cause compiler to add padding: >> >> struct virtio_scsi_req_cmd { >>
// Device-readable part >>
u8 lun[8]; >>
le64 id; >>
u8 task_attr; >>
u8 prio; >>
u8 crn; >>
u8 cdb[cdb_size]; >>
u8 dataout[]; >>
// Device-writable part >>
le32 sense_len; >>
le32 residual; >>
le16 status_qualifier; >>
u8 status; >>
u8 response; >>
u8 sense[sense_size]; >>
u8 datain[]; >> }; >> >> >> if cdb_size is 32 and sense_size is 96 as spec suggests, >> and with no dataout and datain, padding will be added >> at the tail of structure unless suppressed e.g. using >> the packed directive. >> >> In practice this is pseudo-code, but implementations >> might copy bits of this. >> >> That's unfortunate, I really assumed balloon is the only >> instance where structure fields aren't naturally aligned. >> Should we do something with it for 1.0? >> Or is an implementation note in the spec enough? >
> I never worried about this since it's not valid C but an implementation
> note can't hurt. Yes, let's add a note. Cheers, Rusty.
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
— [Date Index]
| [Thread Index]
| [Month Index]
| [List Home]