rvmi-kvm
rvmi-kvm copied to clipboard
ABI alignment
A related issue to ABI types is ABI alignment. Different compilers may decide to align struct members differently if they are not the same width and there are holes. While using compiler directives on the struct like __attribute__((packed))
can help deal with that, not all compilers recognize them. So usually you want to add padding fields to align everything to 8-byte. A useful tool for checking this is pahole
And for example in this struct:
struct kvm_vmi_event_debug {
__u32 type;
__u8 single_step;
__u8 watchpoint; // There is a 2 byte hole after this member, you want a __u16 _pad member added.
__u64 watchpoint_gva;
int32_t watchpoint_flags;
int32_t exception;
};`