Author: mjg
Date: Tue Oct  8 21:14:11 2019
New Revision: 353327
URL: https://svnweb.freebsd.org/changeset/base/353327

Log:
  amd64: plug spurious cld instructions
  
  ABI already guarantees the direction is forward. Note this does not take care
  of i386-specific cld's.
  
  Reviewed by:  kib
  Sponsored by: The FreeBSD Foundation
  Differential Revision:        https://reviews.freebsd.org/D21906

Modified:
  head/sys/amd64/include/cpufunc.h
  head/sys/x86/include/bus.h

Modified: head/sys/amd64/include/cpufunc.h
==============================================================================
--- head/sys/amd64/include/cpufunc.h    Tue Oct  8 21:14:09 2019        
(r353326)
+++ head/sys/amd64/include/cpufunc.h    Tue Oct  8 21:14:11 2019        
(r353327)
@@ -231,7 +231,7 @@ inl(u_int port)
 static __inline void
 insb(u_int port, void *addr, size_t count)
 {
-       __asm __volatile("cld; rep; insb"
+       __asm __volatile("rep; insb"
                         : "+D" (addr), "+c" (count)
                         : "d" (port)
                         : "memory");
@@ -240,7 +240,7 @@ insb(u_int port, void *addr, size_t count)
 static __inline void
 insw(u_int port, void *addr, size_t count)
 {
-       __asm __volatile("cld; rep; insw"
+       __asm __volatile("rep; insw"
                         : "+D" (addr), "+c" (count)
                         : "d" (port)
                         : "memory");
@@ -249,7 +249,7 @@ insw(u_int port, void *addr, size_t count)
 static __inline void
 insl(u_int port, void *addr, size_t count)
 {
-       __asm __volatile("cld; rep; insl"
+       __asm __volatile("rep; insl"
                         : "+D" (addr), "+c" (count)
                         : "d" (port)
                         : "memory");
@@ -285,7 +285,7 @@ outl(u_int port, u_int data)
 static __inline void
 outsb(u_int port, const void *addr, size_t count)
 {
-       __asm __volatile("cld; rep; outsb"
+       __asm __volatile("rep; outsb"
                         : "+S" (addr), "+c" (count)
                         : "d" (port));
 }
@@ -293,7 +293,7 @@ outsb(u_int port, const void *addr, size_t count)
 static __inline void
 outsw(u_int port, const void *addr, size_t count)
 {
-       __asm __volatile("cld; rep; outsw"
+       __asm __volatile("rep; outsw"
                         : "+S" (addr), "+c" (count)
                         : "d" (port));
 }
@@ -301,7 +301,7 @@ outsw(u_int port, const void *addr, size_t count)
 static __inline void
 outsl(u_int port, const void *addr, size_t count)
 {
-       __asm __volatile("cld; rep; outsl"
+       __asm __volatile("rep; outsl"
                         : "+S" (addr), "+c" (count)
                         : "d" (port));
 }

Modified: head/sys/x86/include/bus.h
==============================================================================
--- head/sys/x86/include/bus.h  Tue Oct  8 21:14:09 2019        (r353326)
+++ head/sys/x86/include/bus.h  Tue Oct  8 21:14:11 2019        (r353327)
@@ -280,7 +280,6 @@ bus_space_read_multi_1(bus_space_tag_t tag, bus_space_
        else {
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                1:      movb (%2),%%al                          \n\
                        stosb                                   \n\
                        loop 1b"                                :
@@ -301,7 +300,6 @@ bus_space_read_multi_2(bus_space_tag_t tag, bus_space_
        else {
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                1:      movw (%2),%%ax                          \n\
                        stosw                                   \n\
                        loop 1b"                                :
@@ -322,7 +320,6 @@ bus_space_read_multi_4(bus_space_tag_t tag, bus_space_
        else {
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                1:      movl (%2),%%eax                         \n\
                        stosl                                   \n\
                        loop 1b"                                :
@@ -367,7 +364,6 @@ bus_space_read_region_1(bus_space_tag_t tag, bus_space
                int _port_ = bsh + offset;
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                1:      inb %w2,%%al                            \n\
                        stosb                                   \n\
                        incl %2                                 \n\
@@ -380,7 +376,6 @@ bus_space_read_region_1(bus_space_tag_t tag, bus_space
                bus_space_handle_t _port_ = bsh + offset;
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                        repne                                   \n\
                        movsb"                                  :
                    "=D" (addr), "=c" (count), "=S" (_port_)    :
@@ -399,7 +394,6 @@ bus_space_read_region_2(bus_space_tag_t tag, bus_space
                int _port_ = bsh + offset;
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                1:      inw %w2,%%ax                            \n\
                        stosw                                   \n\
                        addl $2,%2                              \n\
@@ -412,7 +406,6 @@ bus_space_read_region_2(bus_space_tag_t tag, bus_space
                bus_space_handle_t _port_ = bsh + offset;
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                        repne                                   \n\
                        movsw"                                  :
                    "=D" (addr), "=c" (count), "=S" (_port_)    :
@@ -431,7 +424,6 @@ bus_space_read_region_4(bus_space_tag_t tag, bus_space
                int _port_ = bsh + offset;
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                1:      inl %w2,%%eax                           \n\
                        stosl                                   \n\
                        addl $4,%2                              \n\
@@ -444,7 +436,6 @@ bus_space_read_region_4(bus_space_tag_t tag, bus_space
                bus_space_handle_t _port_ = bsh + offset;
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                        repne                                   \n\
                        movsl"                                  :
                    "=D" (addr), "=c" (count), "=S" (_port_)    :
@@ -559,7 +550,6 @@ bus_space_write_multi_1(bus_space_tag_t tag, bus_space
        else {
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                1:      lodsb                                   \n\
                        movb %%al,(%2)                          \n\
                        loop 1b"                                :
@@ -580,7 +570,6 @@ bus_space_write_multi_2(bus_space_tag_t tag, bus_space
        else {
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                1:      lodsw                                   \n\
                        movw %%ax,(%2)                          \n\
                        loop 1b"                                :
@@ -601,7 +590,6 @@ bus_space_write_multi_4(bus_space_tag_t tag, bus_space
        else {
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                1:      lodsl                                   \n\
                        movl %%eax,(%2)                         \n\
                        loop 1b"                                :
@@ -647,7 +635,6 @@ bus_space_write_region_1(bus_space_tag_t tag, bus_spac
                int _port_ = bsh + offset;
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                1:      lodsb                                   \n\
                        outb %%al,%w0                           \n\
                        incl %0                                 \n\
@@ -660,7 +647,6 @@ bus_space_write_region_1(bus_space_tag_t tag, bus_spac
                bus_space_handle_t _port_ = bsh + offset;
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                        repne                                   \n\
                        movsb"                                  :
                    "=D" (_port_), "=S" (addr), "=c" (count)    :
@@ -679,7 +665,6 @@ bus_space_write_region_2(bus_space_tag_t tag, bus_spac
                int _port_ = bsh + offset;
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                1:      lodsw                                   \n\
                        outw %%ax,%w0                           \n\
                        addl $2,%0                              \n\
@@ -692,7 +677,6 @@ bus_space_write_region_2(bus_space_tag_t tag, bus_spac
                bus_space_handle_t _port_ = bsh + offset;
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                        repne                                   \n\
                        movsw"                                  :
                    "=D" (_port_), "=S" (addr), "=c" (count)    :
@@ -711,7 +695,6 @@ bus_space_write_region_4(bus_space_tag_t tag, bus_spac
                int _port_ = bsh + offset;
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                1:      lodsl                                   \n\
                        outl %%eax,%w0                          \n\
                        addl $4,%0                              \n\
@@ -724,7 +707,6 @@ bus_space_write_region_4(bus_space_tag_t tag, bus_spac
                bus_space_handle_t _port_ = bsh + offset;
 #ifdef __GNUCLIKE_ASM
                __asm __volatile("                              \n\
-                       cld                                     \n\
                        repne                                   \n\
                        movsl"                                  :
                    "=D" (_port_), "=S" (addr), "=c" (count)    :
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to