qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] BIOS delay_ms optimized away with BX_QEMU enabled
@ 2008-03-28  2:12 David Wentzlaff
  2008-03-30 15:41 ` [Qemu-devel] Re: [Bochs-developers] " Kevin O'Connor
  0 siblings, 1 reply; 4+ messages in thread
From: David Wentzlaff @ 2008-03-28  2:12 UTC (permalink / raw)
  To: bochs-developers; +Cc: qemu-devel

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;

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

end of thread, other threads:[~2008-03-30 17:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-28  2:12 [Qemu-devel] [PATCH] BIOS delay_ms optimized away with BX_QEMU enabled David Wentzlaff
2008-03-30 15:41 ` [Qemu-devel] Re: [Bochs-developers] " Kevin O'Connor
2008-03-30 16:48   ` Volker Ruppert
2008-03-30 17:07     ` [Qemu-devel] Re: [Bochs-developers] [PATCH] BIOS delay_ms optimized away with?BX_QEMU enabled Kevin O'Connor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).