memattrs: Check the size of MemTxAttrs
authorZhao Liu <zhao1.liu@intel.com>
Tue, 21 Jan 2025 15:13:22 +0000 (23:13 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 23 Jan 2025 10:50:53 +0000 (11:50 +0100)
Make sure MemTxAttrs is packed into 8 bytes and does not exceed 8 bytes.

Suggested-by: Philippe Mathieu-Daudà <philmd@linaro.org>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20250121151322.171832-3-zhao1.liu@intel.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/exec/memattrs.h

index 4fde4eee84397479e338c766828bf4d86c5121bd..060b7e713149b3682ca45659656304cf144cf3ce 100644 (file)
@@ -64,6 +64,8 @@ typedef struct MemTxAttrs {
     uint16_t _reserved2;
 } MemTxAttrs;
 
+QEMU_BUILD_BUG_ON(sizeof(MemTxAttrs) > 8);
+
 /* Bus masters which don't specify any attributes will get this,
  * which has all attribute bits clear except the topmost one
  * (so that we can distinguish "all attributes deliberately clear"