Re: [PATCH v3] target/i386: Fix calculation of LOCK NEG eflags

2022-11-03 Thread Qi Hu
ping On 2022/10/24 16:41, Qi Hu wrote: In sequence: --- lock negl -0x14(%rbp) pushf pop%rax --- %rax will obtain the wrong value becasue the "lock neg" calculates the wrong eflags. The "s->T0" is updated by the wrong value. You can use this to do some test:

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

2022-10-24 Thread Qi Hu
On 2022/10/24 05:02, Philippe Mathieu-Daudé wrote: Typo "calculation" in subject. Thanks for the reminder. It's my fault. I will send V3 to fix this typo. Qi On 22/10/22 08:12, Qi Hu wrote: In sequence: --- lock negl -0x14(%rbp) pushf pop    %rax --- %rax will obtain

[PATCH v3] target/i386: Fix calculation of LOCK NEG eflags

2022-10-24 Thread Qi Hu
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 Co-Developed-by: Xuehai Chen Signe

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

2022-10-21 Thread Qi Hu
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 Co-Developed-by: Xuehai Chen Signed

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

2022-10-21 Thread Qi Hu
unsigned test = 0x2363a; __volatile__ char cond = 0; asm( "lock negl %0 \n\t" "sets %1" : "=m"(test), "=r"(cond) : :); assert(cond & 1); } --- Reported-by: Jinyang Shen Co-Developed-by: Xuehai Chen Signed-off-by: Xuehai Chen Si

[PATCH] tcg/aarch64: Remove unused code in tcg_out_op

2022-10-16 Thread Qi Hu
AArch64 defines the TCG_TARGET_HAS_direct_jump. So the "else" block is useless in the case of "INDEX_op_goto_tb" in function "tcg_out_op". Add an assertion and delete these codes for clarity. Suggested-by: WANG Xuerui Signed-off-by: Qi Hu --- tcg

[PATCH v4] tcg/loongarch64: Add direct jump support

2022-10-15 Thread Qi Hu
nop will be used by "tb_target_set_jump_target". Cc: Richard Henderson Signed-off-by: Qi Hu --- Changes since v3: - Fix the offset check error which is pointed by WANG Xuerui. - Use TMP0 instead of T0. - Remove useless block due to direct jump support. - Add some assertions. --- tcg/loo

[PATCH v3] tcg/loongarch64: Add direct jump support

2022-10-13 Thread Qi Hu
nop will be used by "tb_target_set_jump_target". Signed-off-by: Qi Hu --- tcg/loongarch64/tcg-target.c.inc | 56 +--- tcg/loongarch64/tcg-target.h | 5 ++- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/tcg/loongarch64/tcg-targ

Re: [PATCH v2] tcg/loongarch64: Add direct jump support

2022-10-13 Thread Qi Hu
On 2022/10/14 02:52, Richard Henderson wrote: On 10/13/22 20:01, Qi Hu wrote: Similar to the ARM64, LoongArch has PC-relative instructions such as PCADDU18I. These instructions can be used to support direct jump for LoongArch. Additionally, if instruction "B offset" can cover

[PATCH v2] tcg/loongarch64: Add direct jump support

2022-10-12 Thread Qi Hu
nop will be used by "tb_target_set_jump_target". Signed-off-by: Qi Hu --- tcg/loongarch64/tcg-target.c.inc | 53 +--- tcg/loongarch64/tcg-target.h | 3 +- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/tcg/loongarch64/tcg-targ

Re: [PATCH 2/2] tcg/loongarch64: Add direct jump support

2022-10-12 Thread Qi Hu
On 2022/10/12 19:34, WANG Xuerui wrote: Hi, Thanks for the improvement! Some room for improvement though... On 2022/10/12 17:13, Qi Hu wrote: Similar to the ARM64, LoongArch has PC-relative instructions such as PCADDU18I. These instructions can be used to support direct jump for LoongArch

Re: [PATCH 1/2] tcg/loongarch64: Implement INDEX_op_neg_i{32,64}

2022-10-12 Thread Qi Hu
On 2022/10/12 17:41, WANG Xuerui wrote: Hi, On 2022/10/12 17:13, Qi Hu wrote: Signed-off-by: Qi Hu ---   tcg/loongarch64/tcg-target.c.inc | 9 +   tcg/loongarch64/tcg-target.h | 4 ++--   2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tcg/loongarch64/tcg

[PATCH 1/2] tcg/loongarch64: Implement INDEX_op_neg_i{32,64}

2022-10-12 Thread Qi Hu
Signed-off-by: Qi Hu --- tcg/loongarch64/tcg-target.c.inc | 9 + tcg/loongarch64/tcg-target.h | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index a3debf6da7..f5a214a17f 100644 --- a/tcg

[PATCH 2/2] tcg/loongarch64: Add direct jump support

2022-10-12 Thread Qi Hu
Similar to the ARM64, LoongArch has PC-relative instructions such as PCADDU18I. These instructions can be used to support direct jump for LoongArch. Additionally, if instruction "B offset" can cover the target address, "tb_target_set_jmp_target" will only patch the "B of

[PATCH 0/2] tcg/loongarch64: add neg tcg_op and direct jump support

2022-10-12 Thread Qi Hu
Hi, This patch series add neg tcg_op and direct jump support into loongarch tcg backend. Qi Hu (2): tcg/loongarch64: Implement INDEX_op_neg_i{32,64} tcg/loongarch64: Add direct jump support tcg/loongarch64/tcg-insn-defs.c.inc | 3 ++ tcg/loongarch64/tcg-target.c.inc| 58

Re: [PATCH 5/5] target/loongarch: div if x/0 set dividend to 0

2022-09-19 Thread Qi Hu
On 2022/9/19 19:45, gaosong wrote: 在 2022/9/17 下午6:12, Richard Henderson 写道: On 9/17/22 11:12, gaosong wrote: 在 2022/9/17 下午4:59, Qi Hu 写道: On 2022/9/17 15:59, Song Gao wrote: div.d, div.du, div,w, div.wu, the LoongArch host if x/0  the result is 0. The message has a typo: "

Re: [PATCH 2/5] target/loongarch: bstrins.w need set dest register EXT_SIGN

2022-09-17 Thread Qi Hu
On 2022/9/17 17:16, gaosong wrote: 在 2022/9/17 下午4:41, Qi Hu 写道: On 2022/9/17 15:59, Song Gao wrote: Signed-off-by: Song Gao ---   target/loongarch/insn_trans/trans_bit.c.inc | 4 ++--   1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/loongarch/insn_trans

Re: [PATCH 5/5] target/loongarch: div if x/0 set dividend to 0

2022-09-17 Thread Qi Hu
On 2022/9/17 15:59, Song Gao wrote: div.d, div.du, div,w, div.wu, the LoongArch host if x/0 the result is 0. The message has a typo: "div,w" => "div.w" Also I don't know why we need to do this, since the manual say: "When the divisor is 0, the result can be any value". So we set the div

Re: [PATCH 2/5] target/loongarch: bstrins.w need set dest register EXT_SIGN

2022-09-17 Thread Qi Hu
On 2022/9/17 15:59, Song Gao wrote: Signed-off-by: Song Gao --- target/loongarch/insn_trans/trans_bit.c.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/loongarch/insn_trans/trans_bit.c.inc b/target/loongarch/insn_trans/trans_bit.c.inc index 9337714ec4..33

[PATCH] target/loongarch: Fix "movfcsr2gr" gets wrong value

2022-08-06 Thread Qi Hu
write the globle "fcsr"). This causes the "fdiv" helper updates the "fcsr" into mem, but "movfcsr2gr" does not load it from mem. Reported-by: Feiyang Chen Signed-off-by: Qi Hu --- target/loongarch/helper.h | 64 +++

Re: [PATCH] disas: Add LoongArch support

2022-08-06 Thread Qi Hu
On 2022/8/5 02:23, Richard Henderson wrote: On 8/4/22 10:29, Qi Hu wrote: Signed-off-by: Qi Hu ---   disas.c | 2 ++   1 file changed, 2 insertions(+) diff --git a/disas.c b/disas.c index e31438f349..d44f46 100644 --- a/disas.c +++ b/disas.c @@ -176,6 +176,8 @@ static void

[PATCH] disas: Add LoongArch support

2022-08-04 Thread Qi Hu
Signed-off-by: Qi Hu --- disas.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/disas.c b/disas.c index e31438f349..d44f46 100644 --- a/disas.c +++ b/disas.c @@ -176,6 +176,8 @@ static void initialize_debug_host(CPUDebug *s) #else #error unsupported RISC-V ABI #endif +#elif defined

[PATCH] target/loongarch: Fix macros SET_FPU_* in cpu.h

2022-08-04 Thread Qi Hu
The macros SET_FPU_* are used to set corresponding bits of fcsr. Unfortunately it forgets to set the result and it causes fcsr's "CAUSE" never being updated. This patch is to fix this bug. Signed-off-by: Qi Hu --- target/loongarch/cpu.h | 18 +++--- 1 file changed