]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: dmix: assembly: fix the interface for safety
authorFrédéric Recoules <frederic.recoules@orange.fr>
Wed, 6 May 2020 17:19:21 +0000 (19:19 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 6 May 2020 20:25:15 +0000 (22:25 +0200)
- move 'size' and 'old_ebx' in the output section
  since they are clobbered;
- add the "memory" clobber since input pointers
  are accessed;
- (minor) add the "cc" clobber since flags are
  clobbered.

  The compiler is missing some dataflow information
  about the execution of the assembly chunks.
  For instance, it assumes that 'size' remains unchanged
  and that no input pointer is accessed.
  The compiler optimizer may take advantage of these
  assumption and produce a wrong code.

Note: currently produces the same binary output.

Signed-off-by: Frédéric Recoules <frederic.recoules@orange.fr>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm_dmix_i386.h
src/pcm/pcm_dmix_x86_64.h

index e816d5e0d23a66d357033ac92d336d8273b14f1b..3ea0737d71f53bbfba074adddaaa42bdbaa3d400 100644 (file)
@@ -142,12 +142,11 @@ static void MIX_AREAS_16(unsigned int size,
                "7:"
                "\tmovl %[old_ebx], %%ebx\n"    /* ebx is GOT pointer (-fPIC) */
 
-               : /* no output regs */
-               : [size] "m" (size),
-                 [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+               : [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+               : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
                  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-                 [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
-               : "esi", "edi", "edx", "ecx", "eax"
+                 [sum_step] "m" (sum_step)
+               : "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
        );
 }
 
@@ -233,12 +232,11 @@ static void MIX_AREAS_16_MMX(unsigned int size,
                 "5:"
                "\tmovl %[old_ebx], %%ebx\n"    /* ebx is GOT pointer (-fPIC) */
 
-               : /* no output regs */
-               : [size] "m" (size),
-                 [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+               : [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+               : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
                  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-                 [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
-               : "esi", "edi", "edx", "ecx", "eax"
+                 [sum_step] "m" (sum_step)
+               : "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
        );
 }
 
@@ -347,12 +345,11 @@ static void MIX_AREAS_32(unsigned int size,
                "6:"
                "\tmovl %[old_ebx], %%ebx\n"    /* ebx is GOT pointer (-fPIC) */
 
-               : /* no output regs */
-               : [size] "m" (size),
-                 [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+               : [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+               : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
                  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-                 [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
-               : "esi", "edi", "edx", "ecx", "eax"
+                 [sum_step] "m" (sum_step)
+               : "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
        );
 }
 
@@ -454,12 +451,11 @@ static void MIX_AREAS_24(unsigned int size,
                "6:"
                "\tmovl %[old_ebx], %%ebx\n"    /* ebx is GOT pointer (-fPIC) */
 
-               : /* no output regs */
-               : [size] "m" (size),
-                 [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+               : [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+               : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
                  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-                 [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
-               : "esi", "edi", "edx", "ecx", "eax"
+                 [sum_step] "m" (sum_step)
+               : "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
        );
 }
 
@@ -554,11 +550,10 @@ static void MIX_AREAS_24_CMOV(unsigned int size,
                "6:"
                "\tmovl %[old_ebx], %%ebx\n"    /* ebx is GOT pointer (-fPIC) */
 
-               : /* no output regs */
-               : [size] "m" (size),
-                 [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+               : [size] "+m" (size), [old_ebx] "=m" (old_ebx)
+               : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
                  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-                 [sum_step] "m" (sum_step), [old_ebx] "m" (old_ebx)
-               : "esi", "edi", "edx", "ecx", "eax"
+                 [sum_step] "m" (sum_step)
+               : "esi", "edi", "edx", "ecx", "eax", "memory", "cc"
        );
 }
index dc433b350fdcd2794fbad9775fde203c7a5106f9..7f711547d0f3a5515e489b09adfb358e9eb3c83e 100644 (file)
@@ -114,12 +114,11 @@ static void MIX_AREAS_16(unsigned int size,
                "\temms\n"
                "\tmovq %[old_rbx], %%rbx\n"
 
-               : /* no output regs */
-               : [size] "m" (size),
-                 [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+               : [size] "+m" (size), [old_rbx] "=m" (old_rbx)
+               : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
                  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-                 [sum_step] "m" (sum_step), [old_rbx] "m" (old_rbx)
-               : "rsi", "rdi", "edx", "ecx", "eax"
+                 [sum_step] "m" (sum_step)
+               : "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
        );
 }
 
@@ -230,12 +229,11 @@ static void MIX_AREAS_32(unsigned int size,
                "6:"
                "\tmovq %[old_rbx], %%rbx\n"
 
-               : /* no output regs */
-               : [size] "m" (size),
-                 [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+               : [size] "+m" (size), [old_rbx] "=m" (old_rbx)
+               : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
                  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-                 [sum_step] "m" (sum_step), [old_rbx] "m" (old_rbx)
-               : "rsi", "rdi", "edx", "ecx", "eax"
+                 [sum_step] "m" (sum_step)
+               : "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
        );
 }
 
@@ -334,11 +332,10 @@ static void MIX_AREAS_24(unsigned int size,
                "6:"
                "\tmovq %[old_rbx], %%rbx\n"
 
-               : /* no output regs */
-               : [size] "m" (size),
-                 [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
+               : [size] "+m" (size), [old_rbx] "=m" (old_rbx)
+               : [dst] "m" (dst), [src] "m" (src), [sum] "m" (sum),
                  [dst_step] "m" (dst_step),  [src_step] "m" (src_step),
-                 [sum_step] "m" (sum_step), [old_rbx] "m" (old_rbx)
-               : "rsi", "rdi", "edx", "ecx", "eax"
+                 [sum_step] "m" (sum_step)
+               : "rsi", "rdi", "edx", "ecx", "eax", "memory", "cc"
        );
 }