[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] BIOS delay_ms optimized away with BX_QEMU enabled
From: |
David Wentzlaff |
Subject: |
[Qemu-devel] [PATCH] BIOS delay_ms optimized away with BX_QEMU enabled |
Date: |
Thu, 27 Mar 2008 22:12:43 -0400 (EDT) |
When performing SMP probing, smp_probe() waits for 10ms by executing
delay_ms(10). When compiling the BIOS for QEMU (BX_QEMU defined),
delay_ms() simply spins with a 'for' loop. Unfortunately rombios32.c is
compiled with -O2 with the default Makefile and when utilizing current
gcc's to compile this file (for instance gcc 4.1.2) this 'for' loop with
no side-effects gets dead code eliminated as the compiler should when
optimization is enabled. This has the side effect of the Bochs BIOS when
running on QEMU to not wait any time during SMP probing. The solution to
this problem is to have the 'for' loop perform some work that the compiler
will not optimize away such as writing a local volatile variable.
Attached is a patch which solves this problem. qemu-devel is CCed as this
is primarily a problem specific to QEMU compiled BIOSs.
Sincerely,
David Wentzlaff
Index: rombios32.c
===================================================================
RCS file: /cvsroot/bochs/bochs/bios/rombios32.c,v
retrieving revision 1.25
diff -d -u -r1.25 rombios32.c
--- rombios32.c 26 Mar 2008 16:21:46 -0000 1.25
+++ rombios32.c 28 Mar 2008 02:07:14 -0000
@@ -359,8 +359,11 @@
int i, j;
for(i = 0; i < n; i++) {
#ifdef BX_QEMU
+ volatile int k;
/* approximative ! */
- for(j = 0; j < 1000000; j++);
+ for(j = 0; j < 1000000; j++) {
+ k++;
+ }
#else
{
int r1, r2;
- [Qemu-devel] [PATCH] BIOS delay_ms optimized away with BX_QEMU enabled,
David Wentzlaff <=