Obvious bug in /sys/i386/include/bus.h (was: bus_at386.h)

gerarra at tin.it gerarra at tin.it
Mon Jun 13 12:26:18 GMT 2005


>http://www.freebsd.org/cgi/query-pr.cgi?pr=80980
>
>In FreeBSD 6-current the code for "bus_space_write_multi_1()" says:
>
>                __asm __volatile("                              \n\
>                        cld                                     \n\
>                1:      lodsb                                   \n\
>                        movb %%al,(%2)                          \n\
>                        loop 1b"                                :
>                    "=S" (addr), "=c" (count)                   :
>                    "r" (bsh + offset), "0" (addr), "1" (count) :
>                    "%eax", "memory", "cc");
>
>This is equivalent to:
>
>while(--count)
>{
>  /* I/O */
>}
>
>which is obviously wrong, because it doesn't check for count equal to zero.
>So 
>how can I fix this in assembly. I am not an expert with inlined assembly,
>so 
>maybe someone can correct me if I am wrong, but something like this needs
>to 
>be added:
>
>or %ecx, %ecx
>jz 2
>
>2:

This is wrong beacause the result is stored in ecx. Better using JECXZ instruction
before the loop.

Greeting,
rookie




More information about the freebsd-hackers mailing list