All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] [qemugl] fix opengl calling failure
@ 2011-09-22  5:51 edwin.zhai
  2011-09-22  5:51 ` [PATCH 1/1] qemugl: Use local variable rather than "push" to save register edwin.zhai
  0 siblings, 1 reply; 3+ messages in thread
From: edwin.zhai @ 2011-09-22  5:51 UTC (permalink / raw)
  To: openembedded-core

From: Zhai Edwin <edwin.zhai@intel.com>

All,
This is one fix for [YOCTO #1442] to avoid opengl calling failure led by stack
index disorder.

Pls. help to review and pull.

Thanks,
Edwin

The following changes since commit ff8f0ea563ba3e9d6f8b8e770cfbf4dca8ad5288:

  libxml2: reinclude a -staticdev package (2011-09-22 05:12:31 +0100)

are available in the git repository at:
  git://git.pokylinux.org/poky-contrib gzhai/master2
  http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=gzhai/master2

Zhai Edwin (1):
  qemugl: Use local variable rather than "push" to save register

 .../mesa/qemugl/call_opengl_fix.patch              |   58 ++++++++++++++++++++
 meta/recipes-graphics/mesa/qemugl_git.bb           |    5 +-
 2 files changed, 61 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-graphics/mesa/qemugl/call_opengl_fix.patch




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

* [PATCH 1/1] qemugl: Use local variable rather than "push" to save register
  2011-09-22  5:51 [PATCH 0/1] [qemugl] fix opengl calling failure edwin.zhai
@ 2011-09-22  5:51 ` edwin.zhai
  2011-09-22  6:47   ` Richard Purdie
  0 siblings, 1 reply; 3+ messages in thread
From: edwin.zhai @ 2011-09-22  5:51 UTC (permalink / raw)
  To: openembedded-core

From: Zhai Edwin <edwin.zhai@intel.com>

New gcc uses "%esp" rather than "%ebp" to index local variable in stack, and
push between save-to/restore-from stack decrease "%esp", which leads wrong
index. Saving registers via local variables to make gcc aware of this and avoid
stack disorder.

[YOCTO #1442] got fixed

Signed-off-by: Zhai Edwin <edwin.zhai@intel.com>
---
 .../mesa/qemugl/call_opengl_fix.patch              |   58 ++++++++++++++++++++
 meta/recipes-graphics/mesa/qemugl_git.bb           |    5 +-
 2 files changed, 61 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-graphics/mesa/qemugl/call_opengl_fix.patch

diff --git a/meta/recipes-graphics/mesa/qemugl/call_opengl_fix.patch b/meta/recipes-graphics/mesa/qemugl/call_opengl_fix.patch
new file mode 100644
index 0000000..c5e3592
--- /dev/null
+++ b/meta/recipes-graphics/mesa/qemugl/call_opengl_fix.patch
@@ -0,0 +1,58 @@
+Save registers via local variables instead of simple "push", so that gcc become
+aware of this operation and avoid stack disorder.
+
+opengl calling (in call_opengl_qemu) includes 4 steps:
+1. prepare opengl parameters on stack
+2. save some "input" register by push
+3. load "input" register with parameters on stack via same index as step 1
+4. issue "int 0x99" to trap into qemu, who will get parameter in the registers
+
+New gcc uses "%esp" rather than "%ebp" to index local variable in stack, which
+leads wrong index in step 3, as push decrease "%esp" automatically. Saving
+registers via local variables to fix it.
+
+Upstream-Status: Pending
+
+Signed-off-by: Zhai Edwin <edwin.zhai@intel.com>
+Index: git/opengl_client.c
+===================================================================
+--- git.orig/opengl_client.c	2011-09-19 19:44:51.000000000 +0800
++++ git/opengl_client.c	2011-09-22 10:11:04.000000000 +0800
+@@ -1076,23 +1076,29 @@
+ {
+ #if defined(__i386__)
+   int ret;
++  int bx, cx, dx, si;
+ #ifdef WIN32
+   __asm__ ("pushl %0;pushl %%fs:0;movl %%esp,%%fs:0;" : : "g" (win32_sigsegv_handler));
+ #endif
+-  __asm__ ("push %ebx");
+-  __asm__ ("push %ecx");
+-  __asm__ ("push %edx");
+-  __asm__ ("push %esi");
++  /* save registers before opengl call */
++  __asm__ ("mov %%ebx, %0"::"m"(bx));
++  __asm__ ("mov %%ecx, %0"::"m"(cx));
++  __asm__ ("mov %%edx, %0"::"m"(dx));
++  __asm__ ("mov %%esi, %0"::"m"(si));
++
+   __asm__ ("mov %0, %%eax"::"m"(func_number));
+   __asm__ ("mov %0, %%ebx"::"m"(pid));
+   __asm__ ("mov %0, %%ecx"::"m"(ret_string));
+   __asm__ ("mov %0, %%edx"::"m"(args));
+   __asm__ ("mov %0, %%esi"::"m"(args_size));
+   __asm__ ("int $0x99");
+-  __asm__ ("pop %esi");
+-  __asm__ ("pop %edx");
+-  __asm__ ("pop %ecx");
+-  __asm__ ("pop %ebx");
++
++  /* restore registers */
++  __asm__ ("mov %0, %%ebx"::"m"(bx));
++  __asm__ ("mov %0, %%ecx"::"m"(cx));
++  __asm__ ("mov %0, %%edx"::"m"(dx));
++  __asm__ ("mov %0, %%esi"::"m"(si));
++
+   __asm__ ("mov %%eax, %0"::"m"(ret));
+ #ifdef WIN32
+   __asm__ ("movl (%%esp),%%ecx;movl %%ecx,%%fs:0;addl $8,%%esp;" : : : "%ecx");
diff --git a/meta/recipes-graphics/mesa/qemugl_git.bb b/meta/recipes-graphics/mesa/qemugl_git.bb
index 9d5115f..1658759 100644
--- a/meta/recipes-graphics/mesa/qemugl_git.bb
+++ b/meta/recipes-graphics/mesa/qemugl_git.bb
@@ -11,13 +11,14 @@ COMPATIBLE_HOST = '(x86_64.*|i.86.*)-(linux|freebsd.*)'
 
 SRC_URI = "git://git.o-hand.com/qemugl.git;protocol=git \
            file://versionfix.patch \
-           file://remove-x11r6-lib-dir.patch"
+           file://remove-x11r6-lib-dir.patch \
+           file://call_opengl_fix.patch"
 S = "${WORKDIR}/git"
 
 SRCREV = "d888bbc723c00d197d34a39b5b7448660ec1b1c0"
 
 PV = "0.0+git${SRCPV}"
-PR = "r7"
+PR = "r8"
 
 DEFAULT_PREFERENCE = "-1"
 
-- 
1.7.1




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

* Re: [PATCH 1/1] qemugl: Use local variable rather than "push" to save register
  2011-09-22  5:51 ` [PATCH 1/1] qemugl: Use local variable rather than "push" to save register edwin.zhai
@ 2011-09-22  6:47   ` Richard Purdie
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Purdie @ 2011-09-22  6:47 UTC (permalink / raw)
  To: Patches and discussions about the oe-core layer

On Thu, 2011-09-22 at 13:51 +0800, edwin.zhai@intel.com wrote:
> From: Zhai Edwin <edwin.zhai@intel.com>
> 
> New gcc uses "%esp" rather than "%ebp" to index local variable in stack, and
> push between save-to/restore-from stack decrease "%esp", which leads wrong
> index. Saving registers via local variables to make gcc aware of this and avoid
> stack disorder.
> 
> [YOCTO #1442] got fixed
> 
> Signed-off-by: Zhai Edwin <edwin.zhai@intel.com>

Merged to master, good catch!

Cheers,

Richard




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

end of thread, other threads:[~2011-09-22  6:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-22  5:51 [PATCH 0/1] [qemugl] fix opengl calling failure edwin.zhai
2011-09-22  5:51 ` [PATCH 1/1] qemugl: Use local variable rather than "push" to save register edwin.zhai
2011-09-22  6:47   ` Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.