Fix size of reserved field and add asserts to check struct sizes.
Bug: 132420445
Change-Id: I352cb3a38ce9ce4d8c333526f2dd96da987890a2
diff --git a/inc/vmapi/hf/spci.h b/inc/vmapi/hf/spci.h
index da3ad48..d8bfd67 100644
--- a/inc/vmapi/hf/spci.h
+++ b/inc/vmapi/hf/spci.h
@@ -295,7 +295,7 @@
*/
uint32_t attribute_count;
/** Reserved field, must be 0. */
- uint16_t reserved_1;
+ uint32_t reserved_1;
/**
* An array of `attribute_count` memory region attribute descriptors.
* Each one specifies an endpoint and the attributes with which this
diff --git a/src/spci_memory.c b/src/spci_memory.c
index dba4961..afd6315 100644
--- a/src/spci_memory.c
+++ b/src/spci_memory.c
@@ -24,6 +24,15 @@
#include "hf/std.h"
#include "hf/vm.h"
+static_assert(sizeof(struct spci_memory_region_constituent) % 16 == 0,
+ "struct spci_memory_region_constituent must be a multiple of 16 "
+ "bytes long.");
+static_assert(sizeof(struct spci_memory_region_attributes) % 16 == 0,
+ "struct spci_memory_region_attributes must be a multiple of 16 "
+ "bytes long.");
+static_assert(sizeof(struct spci_memory_region) % 16 == 0,
+ "struct spci_memory_region must be a multiple of 16 bytes long.");
+
struct spci_mem_transitions {
uint32_t orig_from_mode;
uint32_t orig_to_mode;