diff mbox series

x86: Drop _X86EMU_env definition when CONFIG_BIOSEMU is used

Message ID 20210707073626.1743-1-bmeng.cn@gmail.com
State Accepted
Commit cfa5189811e29e4a24ed41a814e2feb41e79b52e
Delegated to: Tom Rini
Headers show
Series x86: Drop _X86EMU_env definition when CONFIG_BIOSEMU is used | expand

Commit Message

Bin Meng July 7, 2021, 7:36 a.m. UTC
With x86 we can execute an option ROM either natively or using the
x86 emulator (if enabled with CONFIG_BIOSEMU). Both of these share
the _X86EMU_env variable, with the native code using it to hold
register state during interrupt processing.

At present, in 32-bit U-Boot, the variable is declared twice, once
in common code and once in code only compiled with CONFIG_BIOSEMU.

With GCC 11 this causes a 'multiple definitions' error on boards
with CONFIG_BIOSEMU.

Drop the emulator definition when CONFIG_BIOSEMU is used.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 arch/x86/lib/bios.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Tom Rini July 7, 2021, 5:33 p.m. UTC | #1
On Wed, Jul 07, 2021 at 03:36:26PM +0800, Bin Meng wrote:

> With x86 we can execute an option ROM either natively or using the
> x86 emulator (if enabled with CONFIG_BIOSEMU). Both of these share
> the _X86EMU_env variable, with the native code using it to hold
> register state during interrupt processing.
> 
> At present, in 32-bit U-Boot, the variable is declared twice, once
> in common code and once in code only compiled with CONFIG_BIOSEMU.
> 
> With GCC 11 this causes a 'multiple definitions' error on boards
> with CONFIG_BIOSEMU.
> 
> Drop the emulator definition when CONFIG_BIOSEMU is used.
> 
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

Applied to u-boot/master, thanks!
Simon Glass July 7, 2021, 5:35 p.m. UTC | #2
Hi Bin,

On Wed, 7 Jul 2021 at 01:36, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> With x86 we can execute an option ROM either natively or using the
> x86 emulator (if enabled with CONFIG_BIOSEMU). Both of these share
> the _X86EMU_env variable, with the native code using it to hold
> register state during interrupt processing.
>
> At present, in 32-bit U-Boot, the variable is declared twice, once
> in common code and once in code only compiled with CONFIG_BIOSEMU.
>
> With GCC 11 this causes a 'multiple definitions' error on boards
> with CONFIG_BIOSEMU.
>
> Drop the emulator definition when CONFIG_BIOSEMU is used.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
>  arch/x86/lib/bios.c | 2 ++
>  1 file changed, 2 insertions(+)

This seems a bit hacky. Should we define a new Kconfig that both use,
then put this declaration in a common file?
>
> diff --git a/arch/x86/lib/bios.c b/arch/x86/lib/bios.c
> index fbdc3b04e3..98cc05de2e 100644
> --- a/arch/x86/lib/bios.c
> +++ b/arch/x86/lib/bios.c
> @@ -23,7 +23,9 @@
>  static int (*int_handler[256])(void);
>
>  /* to have a common register file for interrupt handlers */
> +#ifndef CONFIG_BIOSEMU
>  X86EMU_sysEnv _X86EMU_env;
> +#endif
>
>  asmlinkage void (*realmode_call)(u32 addr, u32 eax, u32 ebx, u32 ecx, u32 edx,
>                                  u32 esi, u32 edi);
> --
> 2.25.1
>

Regards,
Simon
Bin Meng July 7, 2021, 11:36 p.m. UTC | #3
Hi Simon,

On Thu, Jul 8, 2021 at 1:35 AM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Bin,
>
> On Wed, 7 Jul 2021 at 01:36, Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > With x86 we can execute an option ROM either natively or using the
> > x86 emulator (if enabled with CONFIG_BIOSEMU). Both of these share
> > the _X86EMU_env variable, with the native code using it to hold
> > register state during interrupt processing.
> >
> > At present, in 32-bit U-Boot, the variable is declared twice, once
> > in common code and once in code only compiled with CONFIG_BIOSEMU.
> >
> > With GCC 11 this causes a 'multiple definitions' error on boards
> > with CONFIG_BIOSEMU.
> >
> > Drop the emulator definition when CONFIG_BIOSEMU is used.
> >
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > ---
> >
> >  arch/x86/lib/bios.c | 2 ++
> >  1 file changed, 2 insertions(+)
>
> This seems a bit hacky. Should we define a new Kconfig that both use,
> then put this declaration in a common file?

Yes, that's what I thought so. We can do this later. Currently this is
to unblock the GCC 11 CI testing.

Regards,
Bin
diff mbox series

Patch

diff --git a/arch/x86/lib/bios.c b/arch/x86/lib/bios.c
index fbdc3b04e3..98cc05de2e 100644
--- a/arch/x86/lib/bios.c
+++ b/arch/x86/lib/bios.c
@@ -23,7 +23,9 @@ 
 static int (*int_handler[256])(void);
 
 /* to have a common register file for interrupt handlers */
+#ifndef CONFIG_BIOSEMU
 X86EMU_sysEnv _X86EMU_env;
+#endif
 
 asmlinkage void (*realmode_call)(u32 addr, u32 eax, u32 ebx, u32 ecx, u32 edx,
 				 u32 esi, u32 edi);