Skip to contentSkip to conversation

kexec: x86: struct x86_linux_param_header should be packed

PATCH In review Vivek Goyal 3 participants 4 messages Aug 5, 2013 – Sep 5, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kexec: x86: struct x86_linux_param_header should be packed

I think struct x86_linux_param_header should be packed. Strange that we did not do it so far.

Without packing struct size was 3824 (decimal) on my x86_64 machine. With packing it is 3820. I think there was a padding of 4 bytes at the end. So it should be harmless.

I tried to introduce more fields and that introduced padding in the middle of structure and kexec stopped working and that's how I got to know that bootparam is not packed.

---
 include/x86/x86-linux.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/x86/x86-linux.h +1 -1
Index: kexec-tools/include/x86/x86-linux.h
===================================================================
@@ -198,7 +198,7 @@ struct x86_linux_param_header {
 	struct 	edd_info eddbuf[EDDMAXNR];	/* 0xd00 */
 						/* 0xeec */
 #define COMMAND_LINE_SIZE 2048
-};
+} __attribute__ ((packed));
 
 struct x86_linux_faked_param_header {
 	struct x86_linux_param_header hdr;	/* 0x00 */

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#1 lore raw
Quoted 10 lines · Vivek Goyal

I think struct x86_linux_param_header should be packed. Strange that we did not do it so far.

Without packing struct size was 3824 (decimal) on my x86_64 machine. With packing it is 3820. I think there was a padding of 4 bytes at the end. So it should be harmless.

I tried to introduce more fields and that introduced padding in the middle of structure and kexec stopped working and that's how I got to know that bootparam is not packed.

In this case that's true and x86_linux_param_header should be packed.

One more thing is,
in include/x86/x86-linux.h, we already define PACKED macro:
#define PACKED __attribute__((packed))
But within x86-linux.h, both PACKED_and __attribute__((packed)) are used.

PACKED isn't used much time and __attribute__((packed)) is quite simple and straightforward. Maybe it's time we can remove the macro and use __attribute__((packed)) directly.

I can send another patch to address this if anyone thinks it's a good idea.

Thanks
WANG Chao

Quoted 18 lines
---
 include/x86/x86-linux.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: kexec-tools/include/x86/x86-linux.h
===================================================================

include/x86/x86-linux.h +1 -1
@@ -198,7 +198,7 @@ struct x86_linux_param_header {
 	struct 	edd_info eddbuf[EDDMAXNR];	/* 0xd00 */
 						/* 0xeec */
 #define COMMAND_LINE_SIZE 2048
-};
+} __attribute__ ((packed));
 
 struct x86_linux_faked_param_header {
 	struct x86_linux_param_header hdr;	/* 0x00 */
Quoted 4 lines

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#2 lore raw
Quoted 19 lines · WANG Chao
Quoted 10 lines · Vivek Goyal

I think struct x86_linux_param_header should be packed. Strange that we did not do it so far.

Without packing struct size was 3824 (decimal) on my x86_64 machine. With packing it is 3820. I think there was a padding of 4 bytes at the end. So it should be harmless.

I tried to introduce more fields and that introduced padding in the middle of structure and kexec stopped working and that's how I got to know that bootparam is not packed.

In this case that's true and x86_linux_param_header should be packed.

One more thing is,
in include/x86/x86-linux.h, we already define PACKED macro:
#define PACKED __attribute__((packed))
But within x86-linux.h, both PACKED_and __attribute__((packed)) are used.

Quoted 6 lines

PACKED isn't used much time and __attribute__((packed)) is quite simple and straightforward. Maybe it's time we can remove the macro and use __attribute__((packed)) directly.

I can send another patch to address this if anyone thinks it's a good idea.

Unifying this should be OK, I think.

Quoted 32 lines

Thanks
WANG Chao

Quoted 18 lines
---
 include/x86/x86-linux.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: kexec-tools/include/x86/x86-linux.h
===================================================================

include/x86/x86-linux.h +1 -1
@@ -198,7 +198,7 @@ struct x86_linux_param_header {
 	struct 	edd_info eddbuf[EDDMAXNR];	/* 0xd00 */
 						/* 0xeec */
 #define COMMAND_LINE_SIZE 2048
-};
+} __attribute__ ((packed));
 
 struct x86_linux_faked_param_header {
 	struct x86_linux_param_header hdr;	/* 0x00 */
Quoted 4 lines

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Signature · 7 lines
Thanks.
Zhang Yanfei

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#3 lore raw
In reply to WANG Chao
Quoted 19 lines · WANG Chao
Quoted 10 lines · Vivek Goyal

I think struct x86_linux_param_header should be packed. Strange that we did not do it so far.

Without packing struct size was 3824 (decimal) on my x86_64 machine. With packing it is 3820. I think there was a padding of 4 bytes at the end. So it should be harmless.

I tried to introduce more fields and that introduced padding in the middle of structure and kexec stopped working and that's how I got to know that bootparam is not packed.

In this case that's true and x86_linux_param_header should be packed.

One more thing is,
in include/x86/x86-linux.h, we already define PACKED macro:
#define PACKED __attribute__((packed))
But within x86-linux.h, both PACKED_and __attribute__((packed)) are used.

Quoted 6 lines

PACKED isn't used much time and __attribute__((packed)) is quite simple and straightforward. Maybe it's time we can remove the macro and use __attribute__((packed)) directly.

I can send another patch to address this if anyone thinks it's a good idea.

I think there is really no need to use macro PACKED. So making the code uniform does not hurt.

Thanks
Vivek

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec