qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] target/i386: Fix caculation of LOCK NEG eflags


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2] target/i386: Fix caculation of LOCK NEG eflags
Date: Sun, 23 Oct 2022 23:02:17 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.2

Typo "calculation" in subject.

On 22/10/22 08:12, Qi Hu wrote:
In sequence:
---
lock negl -0x14(%rbp)
pushf
pop    %rax
---

%rax will obtain the wrong value becasue the "lock neg" caculates the
wrong eflags. The "s->T0" is updated by the wrong value.

You can use this to do some 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>
---
V1 -> V2:
Following Richard's suggestion, just change mov to neg instead of using
local_tmp.
---
  target/i386/tcg/translate.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]