target/i386: Fix calculation of LOCK NEG eflags
commit121531751087ad3f8d87ad17068835bbcd14fb02
authorQi Hu <huqi@loongson.cn>
Mon, 24 Oct 2022 08:41:55 +0000 (24 10:41 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 31 Oct 2022 08:46:34 +0000 (31 09:46 +0100)
tree6e68c6f3e37f7d642645b284d9df227ed05697d3
parent75d30fde55485b965a1168a21d016dd07b50ed32
target/i386: Fix calculation of LOCK NEG eflags

After:

        lock negl -0x14(%rbp)
        pushf
        pop    %rax

%rax will contain the wrong value because the "lock neg" calculates the
wrong eflags.  Simple test:

        #include <assert.h>

        int main()
        {
          __volatile__ unsigned test = 0x2363a;
          __volatile__ char cond = 0;
          asm(
              "lock negl %0 \n\t"
              "sets %1"
              : "=m"(test), "=r"(cond));
          assert(cond & 1);
          return 0;
        }

Reported-by: Jinyang Shen <shenjinyang@loongson.cn>
Co-Developed-by: Xuehai Chen <chenxuehai@loongson.cn>
Signed-off-by: Xuehai Chen <chenxuehai@loongson.cn>
Signed-off-by: Qi Hu <huqi@loongson.cn>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/tcg/translate.c