qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Overoptimization
@ 2004-05-28  1:19 Alexander E. Patrakov
  2004-05-28 10:13 ` Herbert Poetzl
  0 siblings, 1 reply; 8+ messages in thread
From: Alexander E. Patrakov @ 2004-05-28  1:19 UTC (permalink / raw)
  To: qemu-devel

The CFLAGS in Makefile.target are bad for gcc 3.3.2. This is not a my 
problem with my gcc, because it passes the "make check" testsuite except 
some known errors in libstdc++, which cannot affect qemu.

The victim is the tcp_input function in slirp. When compiling with the 
decault CFLAGS, for some reason all packets are dropped as having a 
wrong TCP checksum. I tried debugging this by placing some debug printfs 
in tcp_input.c file, but the problem disappeared after I inserted them. 
I concluded that it is very strange and compiled this tcp_input.c file 
without my debug statements, but with -O1 instead of -O2. The problem 
went away.

Will this workaround (use of -O1 instead of -O2 for tcp_input.c) enter 
the qemu CVS?

-- 
Alexander E. Patrakov

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

* Re: [Qemu-devel] Overoptimization
  2004-05-28  1:19 [Qemu-devel] Overoptimization Alexander E. Patrakov
@ 2004-05-28 10:13 ` Herbert Poetzl
  2004-05-28 10:58   ` Alexander E. Patrakov
  0 siblings, 1 reply; 8+ messages in thread
From: Herbert Poetzl @ 2004-05-28 10:13 UTC (permalink / raw)
  To: Alexander E. Patrakov; +Cc: qemu-devel

On Fri, May 28, 2004 at 07:19:35AM +0600, Alexander E. Patrakov wrote:
> The CFLAGS in Makefile.target are bad for gcc 3.3.2. This is not a my 
> problem with my gcc, because it passes the "make check" testsuite except 
> some known errors in libstdc++, which cannot affect qemu.
> 
> The victim is the tcp_input function in slirp. When compiling with the 
> decault CFLAGS, for some reason all packets are dropped as having a 
> wrong TCP checksum. I tried debugging this by placing some debug printfs 
> in tcp_input.c file, but the problem disappeared after I inserted them. 
> I concluded that it is very strange and compiled this tcp_input.c file 
> without my debug statements, but with -O1 instead of -O2. The problem 
> went away.

gcc isn't supposed to change the semantics of
a program based on the optimization level.

nevertheless several cases are known where this
happened, and not seldom the bug was in gcc

testing the same opts with 3.3.3 or 3.4 will
show if gcc is to blame or not.

best,
Herbert

> Will this workaround (use of -O1 instead of -O2 for tcp_input.c) enter 
> the qemu CVS?
> 
> -- 
> Alexander E. Patrakov
> 
> 
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://mail.nongnu.org/mailman/listinfo/qemu-devel

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

* Re: [Qemu-devel] Overoptimization
  2004-05-28 10:13 ` Herbert Poetzl
@ 2004-05-28 10:58   ` Alexander E. Patrakov
  2004-05-28 11:08     ` Herbert Poetzl
  0 siblings, 1 reply; 8+ messages in thread
From: Alexander E. Patrakov @ 2004-05-28 10:58 UTC (permalink / raw)
  To: Herbert Poetzl; +Cc: qemu-devel

Herbert Poetzl wrote:
> On Fri, May 28, 2004 at 07:19:35AM +0600, Alexander E. Patrakov wrote:
> 
>>The CFLAGS in Makefile.target are bad for gcc 3.3.2. This is not a my 
>>problem with my gcc, because it passes the "make check" testsuite except 
>>some known errors in libstdc++, which cannot affect qemu.
>>
>>The victim is the tcp_input function in slirp. When compiling with the 
>>decault CFLAGS, for some reason all packets are dropped as having a 
>>wrong TCP checksum. I tried debugging this by placing some debug printfs 
>>in tcp_input.c file, but the problem disappeared after I inserted them. 
>>I concluded that it is very strange and compiled this tcp_input.c file 
>>without my debug statements, but with -O1 instead of -O2. The problem 
>>went away.
> 
> 
> gcc isn't supposed to change the semantics of
> a program based on the optimization level.
> 
> nevertheless several cases are known where this
> happened, and not seldom the bug was in gcc
> 
> testing the same opts with 3.3.3 or 3.4 will
> show if gcc is to blame or not.

Done (with gcc 3.4.0). I used a truly minimal configuration of qemu in 
both cases to make sure that this is not an SDL/X/whatever else problem:

./configure --prefix=/usr --target-list=i386-softmmu --enable-slirp 
--disable-sdl

GCC 3.4.0, however, required one more file to be compiled with -O1 
(because of some register allocation error), and there were some "struct 
timezone" errors that were trivial to fix by including <time.h> where 
appropriate.

The result is the same. If I compile tcp_input.c with -O2, all tcp 
packets are rejected in user-net mode because of wrong tcp checksum. If 
tcp_input.c is compiled with -O1, qemu works.

-- 
Alexander E. Patrakov

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

* Re: [Qemu-devel] Overoptimization
  2004-05-28 10:58   ` Alexander E. Patrakov
@ 2004-05-28 11:08     ` Herbert Poetzl
  2004-05-28 13:50       ` [SOLVED] " Alexander E. Patrakov
  0 siblings, 1 reply; 8+ messages in thread
From: Herbert Poetzl @ 2004-05-28 11:08 UTC (permalink / raw)
  To: Alexander E. Patrakov; +Cc: qemu-devel

On Fri, May 28, 2004 at 04:58:33PM +0600, Alexander E. Patrakov wrote:
> Herbert Poetzl wrote:
> >On Fri, May 28, 2004 at 07:19:35AM +0600, Alexander E. Patrakov wrote:
> >
> >>The CFLAGS in Makefile.target are bad for gcc 3.3.2. This is not a my 
> >>problem with my gcc, because it passes the "make check" testsuite except 
> >>some known errors in libstdc++, which cannot affect qemu.
> >>
> >>The victim is the tcp_input function in slirp. When compiling with the 
> >>decault CFLAGS, for some reason all packets are dropped as having a 
> >>wrong TCP checksum. I tried debugging this by placing some debug printfs 
> >>in tcp_input.c file, but the problem disappeared after I inserted them. 
> >>I concluded that it is very strange and compiled this tcp_input.c file 
> >>without my debug statements, but with -O1 instead of -O2. The problem 
> >>went away.
> >
> >
> >gcc isn't supposed to change the semantics of
> >a program based on the optimization level.
> >
> >nevertheless several cases are known where this
> >happened, and not seldom the bug was in gcc
> >
> >testing the same opts with 3.3.3 or 3.4 will
> >show if gcc is to blame or not.
> 
> Done (with gcc 3.4.0). I used a truly minimal configuration of qemu in 
> both cases to make sure that this is not an SDL/X/whatever else problem:
> 
> ./configure --prefix=/usr --target-list=i386-softmmu --enable-slirp 
> --disable-sdl
> 
> GCC 3.4.0, however, required one more file to be compiled with -O1 
> (because of some register allocation error), and there were some "struct 
> timezone" errors that were trivial to fix by including <time.h> where 
> appropriate.
> 
> The result is the same. If I compile tcp_input.c with -O2, all tcp 
> packets are rejected in user-net mode because of wrong tcp checksum. If 
> tcp_input.c is compiled with -O1, qemu works.

okay, sounds like some 'broken' struct, which might
get misaligned or maybe a problem with the binutils ...

I'd suggest trying -Os and -O9 just to give some hints
to the developers, also the detailed error messages
of the specific code with -Wall might shed some light
on that ...

HTH,
Herbert

> -- 
> Alexander E. Patrakov

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

* [SOLVED] Re: [Qemu-devel] Overoptimization
  2004-05-28 11:08     ` Herbert Poetzl
@ 2004-05-28 13:50       ` Alexander E. Patrakov
  2004-05-28 22:15         ` Lionel Ulmer
  2004-05-29 18:18         ` [Qemu-devel] VNC patch, the 3rd version Johannes Schindelin
  0 siblings, 2 replies; 8+ messages in thread
From: Alexander E. Patrakov @ 2004-05-28 13:50 UTC (permalink / raw)
  To: Herbert Poetzl; +Cc: qemu-devel

Herbert Poetzl wrote:
> On Fri, May 28, 2004 at 04:58:33PM +0600, Alexander E. Patrakov wrote:
> 
>>Herbert Poetzl wrote:
>>
>>>On Fri, May 28, 2004 at 07:19:35AM +0600, Alexander E. Patrakov wrote:
>>>
>>>
>>>>The CFLAGS in Makefile.target are bad for gcc 3.3.2. This is not a my 
>>>>problem with my gcc, because it passes the "make check" testsuite except 
>>>>some known errors in libstdc++, which cannot affect qemu.
>>>>
>>>>The victim is the tcp_input function in slirp. When compiling with the 
>>>>decault CFLAGS, for some reason all packets are dropped as having a 
>>>>wrong TCP checksum. I tried debugging this by placing some debug printfs 
>>>>in tcp_input.c file, but the problem disappeared after I inserted them. 
>>>>I concluded that it is very strange and compiled this tcp_input.c file 
>>>>without my debug statements, but with -O1 instead of -O2. The problem 
>>>>went away.
>>>
>>>
>>>gcc isn't supposed to change the semantics of
>>>a program based on the optimization level.
>>>
>>>nevertheless several cases are known where this
>>>happened, and not seldom the bug was in gcc
>>>
>>>testing the same opts with 3.3.3 or 3.4 will
>>>show if gcc is to blame or not.
>>
>>Done (with gcc 3.4.0). I used a truly minimal configuration of qemu in 
>>both cases to make sure that this is not an SDL/X/whatever else problem:
>>
>>./configure --prefix=/usr --target-list=i386-softmmu --enable-slirp 
>>--disable-sdl
>>
>>GCC 3.4.0, however, required one more file to be compiled with -O1 
>>(because of some register allocation error), and there were some "struct 
>>timezone" errors that were trivial to fix by including <time.h> where 
>>appropriate.
>>
>>The result is the same. If I compile tcp_input.c with -O2, all tcp 
>>packets are rejected in user-net mode because of wrong tcp checksum. If 
>>tcp_input.c is compiled with -O1, qemu works.
> 
> 
> okay, sounds like some 'broken' struct, which might
> get misaligned or maybe a problem with the binutils ...

HJL binutils 2.15.90.0.3, there are 5 known failures during "make 
check", all are TLS-related and probably don't affect qemu.

> I'd suggest trying -Os and -O9 just to give some hints
> to the developers, also the detailed error messages
> of the specific code with -Wall might shed some light
> on that ...

In fact I just had to read the gcc info page and remove optimizations 
one by one. Result, with gcc 3.3.2:

-Wall -O2 -g -fomit-frame-pointer (defaults) = unsafe,
-Wall -O2 -g -fomit-frame-pointer -fno-strict-aliasing = safe.

So it looks like slirp code breaks strict aliasing rules assumed by -O2. 
Since the problem has been identified precisely, it has to be fixed in 
qemu CVS.

-- 
Alexander E. Patrakov

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

* Re: [SOLVED] Re: [Qemu-devel] Overoptimization
  2004-05-28 13:50       ` [SOLVED] " Alexander E. Patrakov
@ 2004-05-28 22:15         ` Lionel Ulmer
  2004-05-29 18:18         ` [Qemu-devel] VNC patch, the 3rd version Johannes Schindelin
  1 sibling, 0 replies; 8+ messages in thread
From: Lionel Ulmer @ 2004-05-28 22:15 UTC (permalink / raw)
  To: qemu-devel

> In fact I just had to read the gcc info page and remove optimizations 
> one by one. Result, with gcc 3.3.2:
> 
> -Wall -O2 -g -fomit-frame-pointer (defaults) = unsafe,
> -Wall -O2 -g -fomit-frame-pointer -fno-strict-aliasing = safe.
> 
> So it looks like slirp code breaks strict aliasing rules assumed by -O2. 
> Since the problem has been identified precisely, it has to be fixed in 
> qemu CVS.

I think this aliasing stuff will really provoke a LOT of bugs out there for
years to come...

For example, Wine switched to '-fno-strict-aliasing' a long time ago :-)

        Lionel

-- 
		 Lionel Ulmer - http://www.bbrox.org/

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

* [Qemu-devel] VNC patch, the 3rd version
  2004-05-28 13:50       ` [SOLVED] " Alexander E. Patrakov
  2004-05-28 22:15         ` Lionel Ulmer
@ 2004-05-29 18:18         ` Johannes Schindelin
  2004-05-31  2:00           ` Jim C. Brown
  1 sibling, 1 reply; 8+ messages in thread
From: Johannes Schindelin @ 2004-05-29 18:18 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1577 bytes --]

Hi,

in the attached patch you can find the support for VNC, which includes
portable keyboard support for SDL on non PC architectures.

Changes as compared to the 2nd version of the patch:
- cleanups (wine's keyboard support was dropped)
- keymaps from rdesktop are included
- SDL portable keyboard support added (you don't need LibVNCServer for
	that)
- incorporated Jim's synaptic patch
- applies cleanly against CVS as of now (use patch -p1, else the keymaps
	mess up your directory)

There is a problem with the synaptic patch: If I read it correctly, the
absolute flag cannot be set to 1. There is simply no line which can do
that.

Jim, if you read this, can you help a mediocre programmer and enlighten me
how to use your work?

Also, I was only able to test the SDL portable keyboard support using
DISPLAY=my_IRIX_machine. I had two problems with this IRIX machine: I
could not compile qemu on it, although I read something about MIPS
support, but then, I did not try very hard. The other problem I had: when
using "-vnc-and-sdl", SDL displayed everything more or less correctly, but
when I did not use vnc at all, SDL displayed only a black rectangle...
Strange. No such problem on my i386 Linux.

Another idea which hit me: I am not convinced that without guest drivers,
the synaptic patch helps VNC's mouse. So why not use the
graphical feedback when using the mouse to determine where the guest
cursor is now (and how far it lags behind/runs in front)? I know, it is
less than clean, but it would be fun! I think I will try it if nobody
yells at me.

Ciao,
Dscho



[-- Attachment #2: Type: APPLICATION/x-gunzip, Size: 22702 bytes --]

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

* Re: [Qemu-devel] VNC patch, the 3rd version
  2004-05-29 18:18         ` [Qemu-devel] VNC patch, the 3rd version Johannes Schindelin
@ 2004-05-31  2:00           ` Jim C. Brown
  0 siblings, 0 replies; 8+ messages in thread
From: Jim C. Brown @ 2004-05-31  2:00 UTC (permalink / raw)
  To: qemu-devel

On Sat, May 29, 2004 at 08:18:10PM +0200, Johannes Schindelin wrote:
> Hi,
> 
<s>
> There is a problem with the synaptic patch: If I read it correctly, the
> absolute flag cannot be set to 1. There is simply no line which can do
> that.
> 

Correct. To do that on a real touchpad you have to set bit 7 of the mode bit
to 1. My patch doesn't support setting the mode bit.

> Jim, if you read this, can you help a mediocre programmer and enlighten me
> how to use your work?
> 

For now what you need to do is:

The simple yet ugly hack would be to, on line 732 of pckbd.c, check if bit
7 of val is set. If so, set absolute mode on.

if (val & 0x80) s->touchpad.absolute = 1; /* TODO: real support for changing the mode byte */

I'm trying to figure out how to implement this elegantly and support all
possible modes. As you can tell by my silence, I haven't figured this out yet.

> Another idea which hit me: I am not convinced that without guest drivers,
> the synaptic patch helps VNC's mouse.

It doesn't. Without guest drivers, the real touchpad emulates a normal mouse.
Unless absolute mode is turned on, the patch doesn't add much.

With absolute mode, it still doesn't add much due to missing functionality
such as guestures. How would I emulate guestures with a 2-button mouse
is the question here. (Emulating a third button or scrolling with a real mouse
that has a real scrollwheel is not that hard, but with a mere 2 button mouse
the problem becomes much harder.)

> So why not use the
> graphical feedback when using the mouse to determine where the guest
> cursor is now (and how far it lags behind/runs in front)? I know, it is
> less than clean, but it would be fun! I think I will try it if nobody
> yells at me.

Good luck. This will not be easy at all (for example, what if the guest OS is
showing a screenshot, which happens to include the image of the mouse pointer
-- and remember that each GUI has a different looking mouse pointer, and most
have several, which can be swapped in at random from the viewpoint of qemu) but 
if you can pull it off it could be a useful feature.

> 
> Ciao,
> Dscho
> 
> 


> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel


-- 
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.

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

end of thread, other threads:[~2004-05-31  2:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-28  1:19 [Qemu-devel] Overoptimization Alexander E. Patrakov
2004-05-28 10:13 ` Herbert Poetzl
2004-05-28 10:58   ` Alexander E. Patrakov
2004-05-28 11:08     ` Herbert Poetzl
2004-05-28 13:50       ` [SOLVED] " Alexander E. Patrakov
2004-05-28 22:15         ` Lionel Ulmer
2004-05-29 18:18         ` [Qemu-devel] VNC patch, the 3rd version Johannes Schindelin
2004-05-31  2:00           ` Jim C. Brown

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).