On 1/20/25 17:38, Zhao Liu wrote:
Thanks for the reminder, yes it is currently full. I found I missed
a commnet from Paolo [*], that he suggested only convert `unspecified`
to a bool. My bad :-(

It still raises the size to 8 bytes but saves spare space, like:

typedef struct MemTxAttrs {
     unsigned int secure:1;
     unsigned int space:2;
     unsigned int user:1;
     unsigned int memory:1;
     unsigned int requester_id:16;
     unsigned int pid:8;
     bool unspecified;
     uint8_t _reserved1;
     uint16_t _reserved2;
} MemTxAttrs;

Similar to your comment above, to get pakced structure, I think I need
push `unspecified` field down to other bit fields.

Right, this would allow for a 16-bit PASID, 19 free bits and no QEMU_PACKED:

typedef struct MemTxAttrs {
    bool unspecified;
    uint8_t int secure:1;
    uint8_t int space:2;
    uint8_t int user:1;
    uint8_t memory:1;
    uint16_t requester_id;
    uint16_t pid;
    uint16_t _reserved;
} MemTxAttrs;
QEMU_BUILD_BUG_ON(sizeof(MemTxAttrs) > 8);

Together with const_zero!() that would be fine for both C and Rust, and a bit more efficient too.

Paolo


Reply via email to