From: David Wentzlaff <wentzlaf@cag.csail.mit.edu>
To: bochs-developers@lists.sourceforge.net
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] BIOS delay_ms optimized away with BX_QEMU enabled
Date: Thu, 27 Mar 2008 22:12:43 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0803272140500.29308@uncle-of-god.csail.mit.edu> (raw)
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;
next reply other threads:[~2008-03-28 2:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-28 2:12 David Wentzlaff [this message]
2008-03-30 15:41 ` [Qemu-devel] Re: [Bochs-developers] [PATCH] BIOS delay_ms optimized away with BX_QEMU enabled 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0803272140500.29308@uncle-of-god.csail.mit.edu \
--to=wentzlaf@cag.csail.mit.edu \
--cc=bochs-developers@lists.sourceforge.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).