[CRIU] [PATCHv2 9/9] compel: Explicitely align all containers of i387_fxsave_struct

Dmitry Safonov dima at arista.com
Wed Feb 7 15:48:54 MSK 2018


As it's aligned to 16, all structures that contain it should be
also aligned to 16. In the kernel there is no such align as
there two separate definitions of i387_fxsave_struct:
one for ia32 and another for x86_64.
Fixes newly introduced align warning in gcc-8.1:
In file included from compel/include/uapi/compel/asm/sigframe.h:7,
                 from compel/plugins/std/infect.c:13:
compel/include/uapi/compel/asm/fpu.h:89:1: error: alignment 1 of 'struct xsave_struct_ia32' is less than 16 [-Werror=packed-not-aligned]
 } __packed;
 ^

It doesn't change the current align of the struct, as containing
structures are __packed and it aligned already *by fact*.
It only affects the function users of the struct's local variables:
now they lay aligned on a stack.

Signed-off-by: Dmitry Safonov <dima at arista.com>
---
 compel/arch/x86/src/lib/include/uapi/asm/fpu.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/compel/arch/x86/src/lib/include/uapi/asm/fpu.h b/compel/arch/x86/src/lib/include/uapi/asm/fpu.h
index f60112b9ba50..dca280bdb61d 100644
--- a/compel/arch/x86/src/lib/include/uapi/asm/fpu.h
+++ b/compel/arch/x86/src/lib/include/uapi/asm/fpu.h
@@ -8,6 +8,7 @@
 #include <compel/common/compiler.h>
 
 #define FP_MIN_ALIGN_BYTES		64
+#define FXSAVE_ALIGN_BYTES		16
 
 #define FP_XSTATE_MAGIC1		0x46505853U
 #define FP_XSTATE_MAGIC2		0x46505845U
@@ -61,7 +62,7 @@ struct i387_fxsave_struct {
 		uint32_t		sw_reserved[12];
 	};
 
-} __aligned(16);
+} __aligned(FXSAVE_ALIGN_BYTES);
 
 struct xsave_hdr_struct {
 	uint64_t			xstate_bv;
@@ -86,7 +87,7 @@ struct xsave_struct_ia32 {
 	struct i387_fxsave_struct	i387;
 	struct xsave_hdr_struct		xsave_hdr;
 	struct ymmh_struct		ymmh;
-} __packed;
+} __aligned(FXSAVE_ALIGN_BYTES) __packed;
 
 typedef struct {
 	/*
@@ -123,8 +124,8 @@ typedef struct {
 	union {
 		struct xsave_struct_ia32	xsave;
 		uint8_t				__pad[sizeof(struct xsave_struct) + FP_XSTATE_MAGIC2_SIZE];
-	} __packed;
-}  __packed fpu_state_ia32_t;
+	} __aligned(FXSAVE_ALIGN_BYTES) __packed;
+} __aligned(FXSAVE_ALIGN_BYTES) __packed fpu_state_ia32_t;
 
 /*
  * This one is used in restorer.
-- 
2.13.6



More information about the CRIU mailing list