Hello all,
attached a try to minmize the testcase to just the affected instruction.

Kind regards,
Bernhard
/*
bernhard@rechner:~$ uname -a
Linux rechner 4.18.0-1-amd64 #1 SMP Debian 4.18.6-1 (2018-09-06) x86_64 GNU/Linux
bernhard@rechner:~$ gcc -m32 -g -O0 -static 910571_test_2.c -o 910571_test_2
*/

#include <stdio.h>
#include <stdint.h>

int main(void)
{
    uint8_t in[7];
    uint8_t out[7];
    
    in[0] = 'A';
    in[1] = 'B';
    in[2] = 'C';
    in[3] = 'D';
    in[4] = 'E';
    in[5] = 'F';
    in[6] = 0;
    out[0] = 'A';
    out[1] = 'B';
    out[2] = ' ';
    out[3] = ' ';
    out[4] = 'E';
    out[5] = 'F';
    out[6] = 0;
    
    __asm (
        "movsw  %%ds:(%%esi),%%es:(%%edi)\n"
        : 
        : "S" (in+2), "D" (out+2)
        : "memory");

    printf((char*)in);
    printf("\n");
    printf((char*)out);
    printf("\n");
    return 0;
}


/*
On amd64/i386:
    bernhard@rechner:~$ uname -a
    Linux rechner 4.18.0-1-amd64 #1 SMP Debian 4.18.6-1 (2018-09-06) x86_64 GNU/Linux
    
    bernhard@rechner:~$ ./910571_test_2
    ABCDEF
    ABCDEF

    bernhard@rechner:~$ qemu-i386-static --version
    qemu-i386 version 2.12.0 (Debian 1:2.12+dfsg-3)

    bernhard@rechner:~$ qemu-i386-static ./910571_test_2
    ABCDEF
    ABCDEF

    gdb -q --args 910571_test_2
        ...
        1: x/i $pc
        => 0x80497dc <main+103>:        movsw  %ds:(%esi),%es:(%edi)
        2: x/s in  0xffffd0f9:  "ABCDEF"
        3: x/s out  0xffffd0f2: "AB  EF"
        (gdb) nexti
        37          printf((char*)in);
        1: x/i $pc
        => 0x80497de <main+105>:        sub    $0xc,%esp
        2: x/s in  0xffffd0f9:  "ABCDEF"
        3: x/s out  0xffffd0f2: "ABCDEF"


On armel:
    root@nas3c3b5d:/home# uname -a
    Linux nas3c3b5d 3.16.0-4-kirkwood #1 Debian 3.16.43-2+deb8u1 (2017-06-18) armv5tel GNU/Linux
    
    bernhard@nas3c3b5d:~$ qemu-i386-static -version
    qemu-i386 version 2.1.2 (Debian 1:2.1+dfsg-12+deb8u7), Copyright (c) 2003-2008 Fabrice Bellard
    
    bernhard@nas3c3b5d:~$ qemu-i386-static 910571_test_2 
    ABCDEF
    BCEFEF
    --> printf iself looks like being affected already.

    bernhard@nas3c3b5d:~$ qemu-i386-static -g 50000 910571_test_2 
    bernhard@rechner:~$ gdb -q --args 910571_test_2
        (gdb) target remote nas3c3b5d:50000
        ...
        1: x/i $pc
        => 0x80497dc <main+103>:        movsw  %ds:(%esi),%es:(%edi)
        2: x/s in  0x40800699:  "ABCDEF"
        3: x/s out  0x40800692: "AB  EF"
        (gdb) nexti
        37          printf((char*)in);
        1: x/i $pc
        => 0x80497de <main+105>:        sub    $0xc,%esp
        2: x/s in  0x40800699:  "ABCDEF"
        3: x/s out  0x40800692: "ABBCEF"

*/

Reply via email to