Commit 50af4036 authored by Thomas Hellstrom's avatar Thomas Hellstrom Committed by Greg Kroah-Hartman

drm/vmwgfx: Fix 32-bit VMW_PORT_HB_[IN|OUT] macros

commit 938ae725 upstream.

Depending on whether the kernel is compiled with frame-pointer or not,
the temporary memory location used for the bp parameter in these macros
is referenced relative to the stack pointer or the frame pointer.
Hence we can never reference that parameter when we've modified either
the stack pointer or the frame pointer, because then the compiler would
generate an incorrect stack reference.

Fix this by pushing the temporary memory parameter on a known location on
the stack before modifying the stack- and frame pointers.

Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: default avatarBrian Paul <brianp@vmware.com>
Reviewed-by: default avatarSinclair Yeh <syeh@vmware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3246d2e5
...@@ -135,17 +135,24 @@ ...@@ -135,17 +135,24 @@
#else #else
/* In the 32-bit version of this macro, we use "m" because there is no /*
* more register left for bp * In the 32-bit version of this macro, we store bp in a memory location
* because we've ran out of registers.
* Now we can't reference that memory location while we've modified
* %esp or %ebp, so we first push it on the stack, just before we push
* %ebp, and then when we need it we read it from the stack where we
* just pushed it.
*/ */
#define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di, \ #define VMW_PORT_HB_OUT(cmd, in_ecx, in_si, in_di, \
port_num, magic, bp, \ port_num, magic, bp, \
eax, ebx, ecx, edx, si, di) \ eax, ebx, ecx, edx, si, di) \
({ \ ({ \
asm volatile ("push %%ebp;" \ asm volatile ("push %12;" \
"mov %12, %%ebp;" \ "push %%ebp;" \
"mov 0x04(%%esp), %%ebp;" \
"rep outsb;" \ "rep outsb;" \
"pop %%ebp;" : \ "pop %%ebp;" \
"add $0x04, %%esp;" : \
"=a"(eax), \ "=a"(eax), \
"=b"(ebx), \ "=b"(ebx), \
"=c"(ecx), \ "=c"(ecx), \
...@@ -167,10 +174,12 @@ ...@@ -167,10 +174,12 @@
port_num, magic, bp, \ port_num, magic, bp, \
eax, ebx, ecx, edx, si, di) \ eax, ebx, ecx, edx, si, di) \
({ \ ({ \
asm volatile ("push %%ebp;" \ asm volatile ("push %12;" \
"mov %12, %%ebp;" \ "push %%ebp;" \
"mov 0x04(%%esp), %%ebp;" \
"rep insb;" \ "rep insb;" \
"pop %%ebp" : \ "pop %%ebp;" \
"add $0x04, %%esp;" : \
"=a"(eax), \ "=a"(eax), \
"=b"(ebx), \ "=b"(ebx), \
"=c"(ecx), \ "=c"(ecx), \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment