All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH kexec-tools] x86: re-order includes to avoid duplicate struct e820entry
@ 2019-07-03  8:04 Simon Horman
  2019-07-03  8:34 ` Dave Young
  2019-07-10  8:10 ` Simon Horman
  0 siblings, 2 replies; 6+ messages in thread
From: Simon Horman @ 2019-07-03  8:04 UTC (permalink / raw)
  To: kexec; +Cc: Simon Horman, Dave Young, Kairui Song, Baoquan He, Lianbo Jiang

xenctrl.h defines struct e820entry as:

	if defined(__i386__) || defined(__x86_64__)
	...
	#define E820_RAM	1
	...
	struct e820entry {
		uint64_t addr;
		uint64_t size;
		uint32_t type;
	} __attribute__((packed));
	...
	#endif

 $ dpkg-query -S /usr/include/xenctrl.h
 libxen-dev:amd64: /usr/include/xenctrl.h
 $  dpkg-query -W libxen-dev:amd64
 libxen-dev:amd64	4.8.5+shim4.10.2+xsa282-1+deb9u11

./include/x86/x86-linux.h defines struct e820entry as:

	#ifndef E820_RAM
	struct e820entry {
		uint64_t addr;  /* start of memory segment */
		uint64_t size;  /* size of memory segment */
		uint32_t type;  /* type of memory segment */
		#define E820_RAM    1
		...
	} __attribute__((packed));
	#endif

Since cedeee0a3007 ("x86: Introduce helpers for getting RSDP address")
./kexec/arch/i386/kexec-x86-common.c includes

	+#include "x86-linux-setup.h"
	 #include "../../kexec-xen.h"

When xenctrl.h is present the above results in:

 $ gcc
 ...
 In file included from kexec/arch/i386/../../kexec-xen.h:5:0,
                  from kexec/arch/i386/kexec-x86-common.c:43:
 /usr/include/xenctrl.h:1271:8: error: redefinition of 'struct e820entry'
  struct e820entry {
         ^~~~~~~~~

 In file included from kexec/arch/i386/x86-linux-setup.h:3:0,
                  from kexec/arch/i386/kexec-x86-common.c:42:
 ./include/x86/x86-linux.h:16:8: note: originally defined here
  struct e820entry {
         ^~~~~~~~~
 ...
 $ gcc --version | head -1
 gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516

To militate this this problem re-order the includes so that
x86-linux.h is included after xenctrl.h and thus
struct e820entry will only be defined once due to it
being devined conditionally in x86-linux.h.

In practice the definitions are the same so it should
not matter which is chosen.

It also seems rather unpleasent to me to need to play
with include ordering. Perhaps a better solution in the longer
term would be to rename the local definition of struct e820entry.

Fixes: cedeee0a3007 ("x86: Introduce helpers for getting RSDP address")
Signed-off-by: Simon Horman <horms@verge.net.au>
---
 kexec/arch/i386/kexec-x86-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kexec/arch/i386/kexec-x86-common.c b/kexec/arch/i386/kexec-x86-common.c
index 5c55ec8a2cd3..61ea19380ab2 100644
--- a/kexec/arch/i386/kexec-x86-common.c
+++ b/kexec/arch/i386/kexec-x86-common.c
@@ -38,9 +38,9 @@
 #include "../../kexec-syscall.h"
 #include "../../firmware_memmap.h"
 #include "../../crashdump.h"
+#include "../../kexec-xen.h"
 #include "kexec-x86.h"
 #include "x86-linux-setup.h"
-#include "../../kexec-xen.h"
 
 /* Used below but not present in (older?) xenctrl.h */
 #ifndef E820_PMEM
-- 
2.11.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-07-10  9:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-03  8:04 [PATCH kexec-tools] x86: re-order includes to avoid duplicate struct e820entry Simon Horman
2019-07-03  8:34 ` Dave Young
2019-07-03  9:08   ` Kairui Song
2019-07-05  2:28     ` Dave Young
2019-07-10  8:10 ` Simon Horman
2019-07-10  8:55   ` Kairui Song

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.