diff mbox series

target/i386: Eip error in x86_64-softmmu

Message ID 20240115020804.30272-1-guoguangyao18@mails.ucas.ac.cn (mailing list archive)
State New, archived
Headers show
Series target/i386: Eip error in x86_64-softmmu | expand

Commit Message

guoguangyao Jan. 15, 2024, 2:08 a.m. UTC
When closing PCREL, qemu-system-x86_64 run into error.
Eip modification here leads to the result. Using s->pc
in func gen_update_eip_next() solves the problem.

Fixes: b5e0d5d22fbf("target/i386: Fix 32-bit wrapping of pc/eip computation")

Signed-off-by: guoguangyao <guoguangyao18@mails.ucas.ac.cn>

	modified:   target/i386/tcg/translate.c
---
 target/i386/tcg/translate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Richard Henderson Jan. 15, 2024, 2:52 a.m. UTC | #1
On 1/15/24 13:08, guoguangyao wrote:
> When closing PCREL, qemu-system-x86_64 run into error.
> Eip modification here leads to the result. Using s->pc
> in func gen_update_eip_next() solves the problem.
> 
> Fixes: b5e0d5d22fbf("target/i386: Fix 32-bit wrapping of pc/eip computation")
> 
> Signed-off-by: guoguangyao <guoguangyao18@mails.ucas.ac.cn>
> 
> 	modified:   target/i386/tcg/translate.c
> ---
>   target/i386/tcg/translate.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

> 
> diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
> index e1eb82a5c6..6f57d5a8a5 100644
> --- a/target/i386/tcg/translate.c
> +++ b/target/i386/tcg/translate.c
> @@ -567,9 +567,9 @@ static void gen_update_eip_next(DisasContext *s)
>       if (tb_cflags(s->base.tb) & CF_PCREL) {
>           tcg_gen_addi_tl(cpu_eip, cpu_eip, s->pc - s->pc_save);
>       } else if (CODE64(s)) {
> -        tcg_gen_movi_tl(cpu_eip, s->base.pc_next);
> +        tcg_gen_movi_tl(cpu_eip, s->pc);
>       } else {
> -        tcg_gen_movi_tl(cpu_eip, (uint32_t)(s->base.pc_next - s->cs_base));
> +        tcg_gen_movi_tl(cpu_eip, (uint32_t)(s->pc - s->cs_base));
>       }
>       s->pc_save = s->pc;
>   }
Michael Tokarev Jan. 15, 2024, 6:31 a.m. UTC | #2
15.01.2024 05:08, guoguangyao :
> When closing PCREL, qemu-system-x86_64 run into error.
> Eip modification here leads to the result. Using s->pc
> in func gen_update_eip_next() solves the problem.
> 
> Fixes: b5e0d5d22fbf("target/i386: Fix 32-bit wrapping of pc/eip computation")
> 
> Signed-off-by: guoguangyao <guoguangyao18@mails.ucas.ac.cn>

It looks like a -stable material. Marked as "to-apply", please let me know
if I shouldn't.

/mjt
Michael Tokarev Feb. 17, 2024, 9:21 a.m. UTC | #3
15.01.2024 05:08, guoguangyao wrote:
> When closing PCREL, qemu-system-x86_64 run into error.
> Eip modification here leads to the result. Using s->pc
> in func gen_update_eip_next() solves the problem.
> 
> Fixes: b5e0d5d22fbf("target/i386: Fix 32-bit wrapping of pc/eip computation")

It looks like the situation with PCREL is a bit more complex,
see https://gitlab.com/qemu-project/qemu/-/issues/2092
I'm assuming this particular change does not actually fix the problem
(which is still unfixed on master).

Thanks,

/mjt

> Signed-off-by: guoguangyao <guoguangyao18@mails.ucas.ac.cn>
> 
> 	modified:   target/i386/tcg/translate.c
> ---
>   target/i386/tcg/translate.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
> index e1eb82a5c6..6f57d5a8a5 100644
> --- a/target/i386/tcg/translate.c
> +++ b/target/i386/tcg/translate.c
> @@ -567,9 +567,9 @@ static void gen_update_eip_next(DisasContext *s)
>       if (tb_cflags(s->base.tb) & CF_PCREL) {
>           tcg_gen_addi_tl(cpu_eip, cpu_eip, s->pc - s->pc_save);
>       } else if (CODE64(s)) {
> -        tcg_gen_movi_tl(cpu_eip, s->base.pc_next);
> +        tcg_gen_movi_tl(cpu_eip, s->pc);
>       } else {
> -        tcg_gen_movi_tl(cpu_eip, (uint32_t)(s->base.pc_next - s->cs_base));
> +        tcg_gen_movi_tl(cpu_eip, (uint32_t)(s->pc - s->cs_base));
>       }
>       s->pc_save = s->pc;
>   }
diff mbox series

Patch

diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index e1eb82a5c6..6f57d5a8a5 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -567,9 +567,9 @@  static void gen_update_eip_next(DisasContext *s)
     if (tb_cflags(s->base.tb) & CF_PCREL) {
         tcg_gen_addi_tl(cpu_eip, cpu_eip, s->pc - s->pc_save);
     } else if (CODE64(s)) {
-        tcg_gen_movi_tl(cpu_eip, s->base.pc_next);
+        tcg_gen_movi_tl(cpu_eip, s->pc);
     } else {
-        tcg_gen_movi_tl(cpu_eip, (uint32_t)(s->base.pc_next - s->cs_base));
+        tcg_gen_movi_tl(cpu_eip, (uint32_t)(s->pc - s->cs_base));
     }
     s->pc_save = s->pc;
 }