[PATCH kexec-tools] x86: re-order includes to avoid duplicate struct e820entry

Kairui Song kasong at redhat.com
Wed Jul 10 01:55:57 PDT 2019


On Wed, Jul 10, 2019 at 4:11 PM Simon Horman <horms at verge.net.au> wrote:
>
> On Wed, Jul 03, 2019 at 10:04:32AM +0200, Simon Horman wrote:
> > 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 at verge.net.au>
>
> I have applied this change.
>

Thanks for the fix, it looks good, so the "move the helpers to
x86-linux-setup.c" patch should be not needed now.

-- 
Best Regards,
Kairui Song



More information about the kexec mailing list