From 3807ec09dec04eb907e0343d4b51896d879796d5 Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Mon, 18 Nov 2019 16:33:19 -0500 Subject: [PATCH] memory: Align MemoryRegionSections fields MemoryRegionSection includes an Int128 'size' field; on some platforms the compiler causes an alignment of this to a 128bit boundary, leaving 8 bytes of dead space. This deadspace can be filled with junk. Move the size field to the top avoiding unnecessary alignment. Backports commit c0aca9352d51c102c55fe29ce5c1bf8e74a5183e from qemu --- qemu/include/exec/memory.h | 2 +- qemu/memory.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu/include/exec/memory.h b/qemu/include/exec/memory.h index d3d992d2..a270f4f4 100644 --- a/qemu/include/exec/memory.h +++ b/qemu/include/exec/memory.h @@ -262,10 +262,10 @@ FlatView *address_space_to_flatview(AddressSpace *as); * @nonvolatile: this section is non-volatile */ struct MemoryRegionSection { + Int128 size; MemoryRegion *mr; FlatView *fv; hwaddr offset_within_region; - Int128 size; hwaddr offset_within_address_space; bool readonly; bool nonvolatile; diff --git a/qemu/memory.c b/qemu/memory.c index 565163cb..4b6a2084 100644 --- a/qemu/memory.c +++ b/qemu/memory.c @@ -1818,7 +1818,7 @@ bool memory_region_is_mapped(MemoryRegion *mr) static MemoryRegionSection memory_region_find_rcu(MemoryRegion *mr, hwaddr addr, uint64_t size) { - MemoryRegionSection ret = { NULL }; + MemoryRegionSection ret = {}; MemoryRegion *root; AddressSpace *as; AddrRange range;