pcm: dmix: assembly: refactor the PIC mode

Newer versions of GCC (> 5.0) accept that ebx is declared
in the clobber list even in PIC mode. Meanwhile, even
unlikely, the compiler may use ebx as base address of
one of the memory entry, making subsequent access to
them unreliable ('size', 'dst_step', 'src_step', 'sum_step').

Adding ebx in the clobber solves the problem.
By the way, the entry 'old_ebx' is no longer required.

Signed-off-by: Frédéric Recoules <frederic.recoules@orange.fr>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Frédéric Recoules 2020-05-06 19:19:23 +02:00 committed by Takashi Iwai
parent 0fd7f0cdc5
commit 79c6ba99c4
2 changed files with 120 additions and 32 deletions

View file

@ -26,6 +26,10 @@
* *
*/ */
#if defined(__GNUC__) && __GNUC__ < 5 && defined(__PIC__)
# define BOUNDED_EBX
#endif
/* /*
* for plain i386 * for plain i386
*/ */
@ -34,8 +38,9 @@ static void MIX_AREAS_16(unsigned int size,
volatile signed int *sum, size_t dst_step, volatile signed int *sum, size_t dst_step,
size_t src_step, size_t sum_step) size_t src_step, size_t sum_step)
{ {
#ifdef BOUNDED_EBX
unsigned int old_ebx; unsigned int old_ebx;
#endif
/* /*
* ESI - src * ESI - src
* EDI - dst * EDI - dst
@ -46,8 +51,9 @@ static void MIX_AREAS_16(unsigned int size,
*/ */
__asm__ __volatile__ ( __asm__ __volatile__ (
"\n" "\n"
#ifdef BOUNDED_EBX
"\tmovl %%ebx, %[old_ebx]\n" /* ebx is GOT pointer (-fPIC) */ "\tmovl %%ebx, %[old_ebx]\n" /* ebx is GOT pointer (-fPIC) */
#endif
/* /*
* initialization, load ESI, EDI, EBX registers * initialization, load ESI, EDI, EBX registers
*/ */
@ -140,13 +146,20 @@ static void MIX_AREAS_16(unsigned int size,
"\tjnz 1b\n" "\tjnz 1b\n"
"7:" "7:"
#ifdef BOUNDED_EBX
"\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */ "\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */
#endif
: [size] "+m" (size), [old_ebx] "=m" (old_ebx) : [size] "+m" (size)
#ifdef BOUNDED_EBX
, [old_ebx] "=m" (old_ebx)
#endif
: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum), : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
[dst_step] "m" (dst_step), [src_step] "m" (src_step), [dst_step] "m" (dst_step), [src_step] "m" (src_step),
[sum_step] "m" (sum_step) [sum_step] "m" (sum_step)
: "esi", "edi", "edx", "ecx", "eax", "memory", "cc" : "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
#ifndef BOUNDED_EBX
, "ebx"
#endif
); );
} }
@ -158,8 +171,9 @@ static void MIX_AREAS_16_MMX(unsigned int size,
volatile signed int *sum, size_t dst_step, volatile signed int *sum, size_t dst_step,
size_t src_step, size_t sum_step) size_t src_step, size_t sum_step)
{ {
#ifdef BOUNDED_EBX
unsigned int old_ebx; unsigned int old_ebx;
#endif
/* /*
* ESI - src * ESI - src
* EDI - dst * EDI - dst
@ -170,8 +184,9 @@ static void MIX_AREAS_16_MMX(unsigned int size,
*/ */
__asm__ __volatile__ ( __asm__ __volatile__ (
"\n" "\n"
#ifdef BOUNDED_EBX
"\tmovl %%ebx, %[old_ebx]\n" /* ebx is GOT pointer (-fPIC) */ "\tmovl %%ebx, %[old_ebx]\n" /* ebx is GOT pointer (-fPIC) */
#endif
/* /*
* initialization, load ESI, EDI, EBX registers * initialization, load ESI, EDI, EBX registers
*/ */
@ -230,13 +245,20 @@ static void MIX_AREAS_16_MMX(unsigned int size,
"\tjnz 1b\n" "\tjnz 1b\n"
"\temms\n" "\temms\n"
"5:" "5:"
#ifdef BOUNDED_EBX
"\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */ "\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */
#endif
: [size] "+m" (size), [old_ebx] "=m" (old_ebx) : [size] "+m" (size)
#ifdef BOUNDED_EBX
, [old_ebx] "=m" (old_ebx)
#endif
: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum), : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
[dst_step] "m" (dst_step), [src_step] "m" (src_step), [dst_step] "m" (dst_step), [src_step] "m" (src_step),
[sum_step] "m" (sum_step) [sum_step] "m" (sum_step)
: "esi", "edi", "edx", "ecx", "eax", "memory", "cc" : "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
#ifndef BOUNDED_EBX
, "ebx"
#endif
#ifdef HAVE_MMX #ifdef HAVE_MMX
, "mm0" , "mm0"
#else #else
@ -254,8 +276,9 @@ static void MIX_AREAS_32(unsigned int size,
volatile signed int *sum, size_t dst_step, volatile signed int *sum, size_t dst_step,
size_t src_step, size_t sum_step) size_t src_step, size_t sum_step)
{ {
#ifdef BOUNDED_EBX
unsigned int old_ebx; unsigned int old_ebx;
#endif
/* /*
* ESI - src * ESI - src
* EDI - dst * EDI - dst
@ -266,8 +289,9 @@ static void MIX_AREAS_32(unsigned int size,
*/ */
__asm__ __volatile__ ( __asm__ __volatile__ (
"\n" "\n"
#ifdef BOUNDED_EBX
"\tmovl %%ebx, %[old_ebx]\n" /* ebx is GOT pointer (-fPIC) */ "\tmovl %%ebx, %[old_ebx]\n" /* ebx is GOT pointer (-fPIC) */
#endif
/* /*
* initialization, load ESI, EDI, EBX registers * initialization, load ESI, EDI, EBX registers
*/ */
@ -349,13 +373,20 @@ static void MIX_AREAS_32(unsigned int size,
"\tjmp 1b\n" "\tjmp 1b\n"
"6:" "6:"
#ifdef BOUNDED_EBX
"\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */ "\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */
#endif
: [size] "+m" (size), [old_ebx] "=m" (old_ebx) : [size] "+m" (size)
#ifdef BOUNDED_EBX
, [old_ebx] "=m" (old_ebx)
#endif
: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum), : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
[dst_step] "m" (dst_step), [src_step] "m" (src_step), [dst_step] "m" (dst_step), [src_step] "m" (src_step),
[sum_step] "m" (sum_step) [sum_step] "m" (sum_step)
: "esi", "edi", "edx", "ecx", "eax", "memory", "cc" : "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
#ifndef BOUNDED_EBX
, "ebx"
#endif
); );
} }
@ -367,8 +398,9 @@ static void MIX_AREAS_24(unsigned int size,
volatile signed int *sum, size_t dst_step, volatile signed int *sum, size_t dst_step,
size_t src_step, size_t sum_step) size_t src_step, size_t sum_step)
{ {
#ifdef BOUNDED_EBX
unsigned int old_ebx; unsigned int old_ebx;
#endif
/* /*
* ESI - src * ESI - src
* EDI - dst * EDI - dst
@ -379,8 +411,9 @@ static void MIX_AREAS_24(unsigned int size,
*/ */
__asm__ __volatile__ ( __asm__ __volatile__ (
"\n" "\n"
#ifdef BOUNDED_EBX
"\tmovl %%ebx, %[old_ebx]\n" /* ebx is GOT pointer (-fPIC) */ "\tmovl %%ebx, %[old_ebx]\n" /* ebx is GOT pointer (-fPIC) */
#endif
/* /*
* initialization, load ESI, EDI, EBX registers * initialization, load ESI, EDI, EBX registers
*/ */
@ -455,13 +488,20 @@ static void MIX_AREAS_24(unsigned int size,
"\tjmp 1b\n" "\tjmp 1b\n"
"6:" "6:"
#ifdef BOUNDED_EBX
"\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */ "\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */
#endif
: [size] "+m" (size), [old_ebx] "=m" (old_ebx) : [size] "+m" (size)
#ifdef BOUNDED_EBX
, [old_ebx] "=m" (old_ebx)
#endif
: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum), : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
[dst_step] "m" (dst_step), [src_step] "m" (src_step), [dst_step] "m" (dst_step), [src_step] "m" (src_step),
[sum_step] "m" (sum_step) [sum_step] "m" (sum_step)
: "esi", "edi", "edx", "ecx", "eax", "memory", "cc" : "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
#ifndef BOUNDED_EBX
, "ebx"
#endif
); );
} }
@ -473,8 +513,9 @@ static void MIX_AREAS_24_CMOV(unsigned int size,
volatile signed int *sum, size_t dst_step, volatile signed int *sum, size_t dst_step,
size_t src_step, size_t sum_step) size_t src_step, size_t sum_step)
{ {
#ifdef BOUNDED_EBX
unsigned int old_ebx; unsigned int old_ebx;
#endif
/* /*
* ESI - src * ESI - src
* EDI - dst * EDI - dst
@ -485,8 +526,9 @@ static void MIX_AREAS_24_CMOV(unsigned int size,
*/ */
__asm__ __volatile__ ( __asm__ __volatile__ (
"\n" "\n"
#ifdef BOUNDED_EBX
"\tmovl %%ebx, %[old_ebx]\n" /* ebx is GOT pointer (-fPIC) */ "\tmovl %%ebx, %[old_ebx]\n" /* ebx is GOT pointer (-fPIC) */
#endif
/* /*
* initialization, load ESI, EDI, EBX registers * initialization, load ESI, EDI, EBX registers
*/ */
@ -554,12 +596,23 @@ static void MIX_AREAS_24_CMOV(unsigned int size,
"\tjnz 1b\n" "\tjnz 1b\n"
"6:" "6:"
#ifdef BOUNDED_EBX
"\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */ "\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */
#endif
: [size] "+m" (size), [old_ebx] "=m" (old_ebx) : [size] "+m" (size)
#ifdef BOUNDED_EBX
, [old_ebx] "=m" (old_ebx)
#endif
: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum), : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
[dst_step] "m" (dst_step), [src_step] "m" (src_step), [dst_step] "m" (dst_step), [src_step] "m" (src_step),
[sum_step] "m" (sum_step) [sum_step] "m" (sum_step)
: "esi", "edi", "edx", "ecx", "eax", "memory", "cc" : "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
#ifndef BOUNDED_EBX
, "ebx"
#endif
); );
} }
#ifdef BOUNDED_EBX
# undef BOUNDED_EBX
#endif

View file

@ -27,6 +27,10 @@
* *
*/ */
#if defined(__GNUC__) && __GNUC__ < 5 && defined(__PIC__)
# define BOUNDED_RBX
#endif
/* /*
* MMX optimized * MMX optimized
*/ */
@ -35,8 +39,9 @@ static void MIX_AREAS_16(unsigned int size,
volatile signed int *sum, size_t dst_step, volatile signed int *sum, size_t dst_step,
size_t src_step, size_t sum_step) size_t src_step, size_t sum_step)
{ {
#ifdef BOUNDED_RBX
unsigned long long old_rbx; unsigned long long old_rbx;
#endif
/* /*
* RSI - src * RSI - src
* RDI - dst * RDI - dst
@ -47,8 +52,9 @@ static void MIX_AREAS_16(unsigned int size,
*/ */
__asm__ __volatile__ ( __asm__ __volatile__ (
"\n" "\n"
#ifdef BOUNDED_RBX
"\tmovq %%rbx, %[old_rbx]\n" "\tmovq %%rbx, %[old_rbx]\n"
#endif
/* /*
* initialization, load RSI, RDI, RBX registers * initialization, load RSI, RDI, RBX registers
*/ */
@ -112,13 +118,20 @@ static void MIX_AREAS_16(unsigned int size,
"6:" "6:"
"\temms\n" "\temms\n"
#ifdef BOUNDED_RBX
"\tmovq %[old_rbx], %%rbx\n" "\tmovq %[old_rbx], %%rbx\n"
#endif
: [size] "+m" (size), [old_rbx] "=m" (old_rbx) : [size] "+m" (size)
#ifdef BOUNDED_RBX
, [old_rbx] "=m" (old_rbx)
#endif
: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum), : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
[dst_step] "m" (dst_step), [src_step] "m" (src_step), [dst_step] "m" (dst_step), [src_step] "m" (src_step),
[sum_step] "m" (sum_step) [sum_step] "m" (sum_step)
: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc" : "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
#ifndef BOUNDED_RBX
, "rbx"
#endif
#ifdef HAVE_MMX #ifdef HAVE_MMX
, "mm0" , "mm0"
#else #else
@ -136,8 +149,9 @@ static void MIX_AREAS_32(unsigned int size,
volatile signed int *sum, size_t dst_step, volatile signed int *sum, size_t dst_step,
size_t src_step, size_t sum_step) size_t src_step, size_t sum_step)
{ {
#ifdef BOUNDED_RBX
unsigned long long old_rbx; unsigned long long old_rbx;
#endif
/* /*
* RSI - src * RSI - src
* RDI - dst * RDI - dst
@ -148,8 +162,9 @@ static void MIX_AREAS_32(unsigned int size,
*/ */
__asm__ __volatile__ ( __asm__ __volatile__ (
"\n" "\n"
#ifdef BOUNDED_RBX
"\tmovq %%rbx, %[old_rbx]\n" "\tmovq %%rbx, %[old_rbx]\n"
#endif
/* /*
* initialization, load RSI, RDI, RBX registers * initialization, load RSI, RDI, RBX registers
*/ */
@ -233,13 +248,20 @@ static void MIX_AREAS_32(unsigned int size,
"\tjnz 1b\n" "\tjnz 1b\n"
"6:" "6:"
#ifdef BOUNDED_RBX
"\tmovq %[old_rbx], %%rbx\n" "\tmovq %[old_rbx], %%rbx\n"
#endif
: [size] "+m" (size), [old_rbx] "=m" (old_rbx) : [size] "+m" (size)
#ifdef BOUNDED_RBX
, [old_rbx] "=m" (old_rbx)
#endif
: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum), : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
[dst_step] "m" (dst_step), [src_step] "m" (src_step), [dst_step] "m" (dst_step), [src_step] "m" (src_step),
[sum_step] "m" (sum_step) [sum_step] "m" (sum_step)
: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc" : "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
#ifndef BOUNDED_RBX
, "rbx"
#endif
); );
} }
@ -251,8 +273,9 @@ static void MIX_AREAS_24(unsigned int size,
volatile signed int *sum, size_t dst_step, volatile signed int *sum, size_t dst_step,
size_t src_step, size_t sum_step) size_t src_step, size_t sum_step)
{ {
#ifdef BOUNDED_RBX
unsigned long long old_rbx; unsigned long long old_rbx;
#endif
/* /*
* RSI - src * RSI - src
* RDI - dst * RDI - dst
@ -263,8 +286,9 @@ static void MIX_AREAS_24(unsigned int size,
*/ */
__asm__ __volatile__ ( __asm__ __volatile__ (
"\n" "\n"
#ifdef BOUNDED_RBX
"\tmovq %%rbx, %[old_rbx]\n" "\tmovq %%rbx, %[old_rbx]\n"
#endif
/* /*
* initialization, load RSI, RDI, RBX registers * initialization, load RSI, RDI, RBX registers
*/ */
@ -336,12 +360,23 @@ static void MIX_AREAS_24(unsigned int size,
"\tjnz 1b\n" "\tjnz 1b\n"
"6:" "6:"
#ifdef BOUNDED_RBX
"\tmovq %[old_rbx], %%rbx\n" "\tmovq %[old_rbx], %%rbx\n"
#endif
: [size] "+m" (size), [old_rbx] "=m" (old_rbx) : [size] "+m" (size)
#ifdef BOUNDED_RBX
, [old_rbx] "=m" (old_rbx)
#endif
: [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum), : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
[dst_step] "m" (dst_step), [src_step] "m" (src_step), [dst_step] "m" (dst_step), [src_step] "m" (src_step),
[sum_step] "m" (sum_step) [sum_step] "m" (sum_step)
: "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc" : "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
#ifndef BOUNDED_RBX
, "rbx"
#endif
); );
} }
#ifdef BOUNDED_RBX
# undef BOUNDED_RBX
#endif