Skip to contentSkip to conversation

x86: Drop duplicate declaration of emulator state

PATCH New Simon Glass 4 participants 5 messages Sep 5, 2020 – Sep 22, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Drop duplicate declaration of emulator state

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-10 this causes a 'multiple definitions' error on boards with CONFIG_BIOSEMU.

Drop the emulator definition, except for 64-bit builds.

Also drop inclusion of the emulator in 64-bit U-Boot since this does not work at present, and generally isn't needed if 32-bit code has already set up the option ROMs.

---

 drivers/bios_emulator/x86emu/sys.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/bios_emulator/x86emu/sys.c +4 -0
index c2db1213fe6..146586b3ceb 100644
@@ -44,7 +44,11 @@
 
 /*------------------------- Global Variables ------------------------------*/
 
+/* Definite this here since the emulator is not present on 64-bit */
+#ifdef CONFIG_X86_64
 X86EMU_sysEnv _X86EMU_env;	/* Global emulator machine state */
+#endif
+
 X86EMU_intrFuncs _X86EMU_intrTab[256];
 
 int debug_intr;
Signature · 1 line
2.28.0.526.ge36021eeef-goog
#1 lore raw

PATCH 1/1 x86: Drop duplicate declaration of emulator state

Hi Simon,

-----"U-Boot" <[email protected]> schrieb: -----

Quoted 19 lines

Betreff: [PATCH] x86: Drop duplicate declaration of emulator state

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-10 this causes a 'multiple definitions' error on boards with CONFIG_BIOSEMU.

Drop the emulator definition, except for 64-bit builds.

Also drop inclusion of the emulator in 64-bit U-Boot since this does not work at present, and generally isn't needed if 32-bit code has already set up the option ROMs.

Quoted 6 lines

---

 drivers/bios_emulator/x86emu/sys.c | 4 ++++
 1 file changed, 4 insertions(+)

Tested by building chromebook_coral_defconfig on an Arch Linux with GCC 10.1.0

regards, Wolfgang

#2 lore raw

PATCH 1/1 x86: Drop duplicate declaration of emulator state

In reply to Simon Glass

Hi Simon,

Quoted 30 lines · Simon Glass

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-10 this causes a 'multiple definitions' error on boards with CONFIG_BIOSEMU.

Drop the emulator definition, except for 64-bit builds.

Also drop inclusion of the emulator in 64-bit U-Boot since this does not work at present, and generally isn't needed if 32-bit code has already set up the option ROMs.

---

 drivers/bios_emulator/x86emu/sys.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/bios_emulator/x86emu/sys.c +0 -0
index c2db1213fe6..146586b3ceb 100644

drivers/bios_emulator/x86emu/sys.c line 48

Quoted 5 lines
drivers/bios_emulator/x86emu/sys.c +2 -0
@@ -44,7 +44,11 @@
 
 /*------------------------- Global Variables ------------------------------*/
 
+/* Definite this here since the emulator is not present on 64-bit */
+#ifdef CONFIG_X86_64

I believe the correct fix is to drop the one in arch/x86/lib/bios.c

drivers/bios_emulator/x86emu/sys.c

Quoted 7 lines
drivers/bios_emulator/x86emu/sys.c +2 -1
 X86EMU_sysEnv _X86EMU_env;     /* Global emulator machine state */
+#endif
+
 X86EMU_intrFuncs _X86EMU_intrTab[256];
 
 int debug_intr;
--

Regards,
Bin

#3 lore raw

PATCH 1/1 x86: Drop duplicate declaration of emulator state

Am 21. September 2020 03:58:31 MESZ schrieb Bin Meng <[email protected]>:

Quoted 34 lines

Hi Simon,

Quoted 2 lines · Simon Glass

With x86 we can execute an option ROM either natively or using the

x86

Quoted 2 lines

emulator (if enabled with CONFIG_BIOSEMU). Both of these share the _X86EMU_env variable, with the native code using it to hold register

state

Quoted 11 lines

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-10 this causes a 'multiple definitions' error on boards with CONFIG_BIOSEMU.

Drop the emulator definition, except for 64-bit builds.

Also drop inclusion of the emulator in 64-bit U-Boot since this does

not

Quoted 1 line

work at present, and generally isn't needed if 32-bit code has

already set

Review

Quoted 10 lines

up the option ROMs.

---

 drivers/bios_emulator/x86emu/sys.c | 4 ++++
 1 file changed, 4 insertions(+)
(quoted diff) +0 -0

b/drivers/bios_emulator/x86emu/sys.c

Quoted 9 lines

drivers/bios_emulator/x86emu/sys.c line 45

Quoted 6 lines

index c2db1213fe6..146586b3ceb 100644

drivers/bios_emulator/x86emu/sys.c +0 -0
@@ -44,7 +44,11 @@
 
 /*------------------------- Global Variables

------------------------------*/

Quoted 2 lines
drivers/bios_emulator/x86emu/sys.c +1 -0
+/* Definite this here since the emulator is not present on 64-bit */

%s/Definite/Define/

Quoted 14 lines

drivers/bios_emulator/x86emu/sys.c line 48

Quoted 1 line
drivers/bios_emulator/x86emu/sys.c +1 -0
+#ifdef CONFIG_X86_64

I believe the correct fix is to drop the one in arch/x86/lib/bios.c

drivers/bios_emulator/x86emu/sys.c

Quoted 7 lines
drivers/bios_emulator/x86emu/sys.c +2 -1
 X86EMU_sysEnv _X86EMU_env;     /* Global emulator machine state */
+#endif
+
 X86EMU_intrFuncs _X86EMU_intrTab[256];
 
 int debug_intr;
--

Regards,
Bin

#4 lore raw

PATCH 1/1 x86: Drop duplicate declaration of emulator state

In reply to Bin Meng

Hi Bin,

Quoted 42 lines · Bin Meng

Hi Simon,

Quoted 30 lines · Simon Glass

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-10 this causes a 'multiple definitions' error on boards with CONFIG_BIOSEMU.

Drop the emulator definition, except for 64-bit builds.

Also drop inclusion of the emulator in 64-bit U-Boot since this does not work at present, and generally isn't needed if 32-bit code has already set up the option ROMs.

---

 drivers/bios_emulator/x86emu/sys.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/bios_emulator/x86emu/sys.c +0 -0
index c2db1213fe6..146586b3ceb 100644

drivers/bios_emulator/x86emu/sys.c line 48

Quoted 5 lines
drivers/bios_emulator/x86emu/sys.c +2 -0
@@ -44,7 +44,11 @@
 
 /*------------------------- Global Variables ------------------------------*/
 
+/* Definite this here since the emulator is not present on 64-bit */
+#ifdef CONFIG_X86_64

I believe the correct fix is to drop the one in arch/x86/lib/bios.c

Quoted 6 lines

drivers/bios_emulator/x86emu/sys.c line 54

Quoted 6 lines
drivers/bios_emulator/x86emu/sys.c +2 -0
 X86EMU_sysEnv _X86EMU_env;     /* Global emulator machine state */
+#endif
+
 X86EMU_intrFuncs _X86EMU_intrTab[256];
 
 int debug_intr;

This currently causes a build error though, which is why I went with the other approach.

Regards,
Simon