[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [patch] Stack problem
From: |
Piotr Krysik |
Subject: |
Re: [Qemu-devel] [patch] Stack problem |
Date: |
Thu, 23 Sep 2004 14:00:52 -0700 (PDT) |
Hi!
Please test attached patch. For another solution
check the list archive:
http://lists.gnu.org/archive/html/qemu-devel/2004-08/msg00277.html
Regards,
Piotrek
--- Johannes Schindelin <address@hidden>
wrote:
> Hi,
>
> while trying to port QEmu to an IRIX host,
> I found a problem with the implementation of
> jcxw_im, which is also present with x86 on x86:
>
> 00005db0 <op_jz_ecxw_im>:
> 5db0: 83 ec 04 sub
$0x4,%esp
> [...]
> 5de0: 31 db xor
%ebx,%ebx
> 5de2: c3 ret
> 5de3: 59 pop %ecx
> 5de4: c3 ret
>
> Note the "ret" at 5de2, which is an EXIT_TB(),
> and the "pop %ecx" just after it. So, $ecx is
> not properly reset, and what is worse: QEmu will
> jump to a wrong address (the value $ecx should
> have).
>
> This will be a problem *anytime* a function
> takes some heap from the stack, but calls EXIT_TB
> (which is a "ret" on most platforms) without
> giving it back. I only found another one,
> jz_ecxl_im (for obvious reasons it has the same
> flaw).
>
> Two methods spring to my mind:
> - We could try to find out how many bytes were
> reserved, and add them to the stack in EXIT_TB(),
> - or we could try to force gcc not to reserve
> a chunk from the stack (e.g. by calling another
> function for the complicated things, which
> returns whether to EXIT_TB() or not,
> - or we introduce op_exit_tb_T0, which does only
> EXIT_TB() if T0!=0, and rewrite the
> op_jz_ecx{SUFFIX}_im function.
>
> Comments? Suggestions?
>
> Ciao,
> Dscho
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
diff -ru qemu-snapshot-2004-08-04_23/Makefile.target
qemu-snapshot-2004-08-04_23-fast-stack/Makefile.target
--- qemu-snapshot-2004-08-04_23/Makefile.target 2004-08-03 23:42:45.000000000
+0200
+++ qemu-snapshot-2004-08-04_23-fast-stack/Makefile.target 2004-09-23
22:38:48.000000000 +0200
@@ -71,7 +71,7 @@
ifeq ($(ARCH),i386)
CFLAGS+=-fomit-frame-pointer
-OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
+OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2 -mno-accumulate-outgoing-args
ifeq ($(HAVE_GCC3_OPTIONS),yes)
OP_CFLAGS+= -falign-functions=0 -fno-gcse
else