From fa43c5d49e09c9bab2f2e2dd2e895a81297a20aa Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Tue, 8 Oct 2019 21:14:11 +0000 Subject: [PATCH] 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 --- sys/amd64/include/cpufunc.h | 12 ++++++------ sys/x86/include/bus.h | 18 ------------------ 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h index cf514cb65b7..61959f12a95 100644 --- a/sys/amd64/include/cpufunc.h +++ b/sys/amd64/include/cpufunc.h @@ -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)); } diff --git a/sys/x86/include/bus.h b/sys/x86/include/bus.h index 2427ae512cc..d8e0d6ac20d 100644 --- a/sys/x86/include/bus.h +++ b/sys/x86/include/bus.h @@ -280,7 +280,6 @@ bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh, 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_handle_t bsh, 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_handle_t bsh, 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_handle_t bsh, 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_handle_t bsh, 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_handle_t bsh, 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_handle_t bsh, 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_handle_t bsh, 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_handle_t bsh, 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_handle_t bsh, 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_handle_t bsh, 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_handle_t bsh, 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_space_handle_t bsh, 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_space_handle_t bsh, 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_space_handle_t bsh, 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_space_handle_t bsh, 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_space_handle_t bsh, 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_space_handle_t bsh, bus_space_handle_t _port_ = bsh + offset; #ifdef __GNUCLIKE_ASM __asm __volatile(" \n\ - cld \n\ repne \n\ movsl" : "=D" (_port_), "=S" (addr), "=c" (count) :