Skip to contentSkip to conversation

i386 ROR r8/r16 instruction fix

PATCH Applied Pavel Dovgaluk 3 participants 4 messages Apr 15, 2013 – Apr 20, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i386 ROR r8/r16 instruction fix

Fixed EFLAGS corruption by ROR r8/r16 instruction located at the end of the TB.

---
 target-i386/translate.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
target-i386/translate.c +1 -0
index 233f24f..40f891d 100644
@@ -1775,6 +1775,7 @@ static void gen_rot_rm_T1(DisasContext *s, int ot, int op1, int is_right)
     if (is_right) {
         tcg_gen_shri_tl(cpu_cc_src2, cpu_T[0], mask - 1);
         tcg_gen_shri_tl(cpu_cc_dst, cpu_T[0], mask);
+        tcg_gen_andi_tl(cpu_cc_dst, cpu_cc_dst, 1);
     } else {
         tcg_gen_shri_tl(cpu_cc_src2, cpu_T[0], mask);
         tcg_gen_andi_tl(cpu_cc_dst, cpu_T[0], 1);

--

Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Pavel Dovgaluk

Fixed EFLAGS corruption by ROR r8/r16 instruction located at the end of the TB.

---
 target-i386/translate.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
target-i386/translate.c +0 -0
index 233f24f..40f891d 100644

target-i386/translate.c static void gen_rot_rm_T1(DisasContext *s, int ot, int op1, int is_right) · line 1781

Quoted 7 lines
target-i386/translate.c +1 -0
@@ -1775,6 +1775,7 @@ static void gen_rot_rm_T1(DisasContext *s, int ot, int op1, int is_right)
     if (is_right) {
         tcg_gen_shri_tl(cpu_cc_src2, cpu_T[0], mask - 1);
         tcg_gen_shri_tl(cpu_cc_dst, cpu_T[0], mask);
+        tcg_gen_andi_tl(cpu_cc_dst, cpu_cc_dst, 1);
     } else {
         tcg_gen_shri_tl(cpu_cc_src2, cpu_T[0], mask);
         tcg_gen_andi_tl(cpu_cc_dst, cpu_T[0], 1);

This looks correct to me, though I haven't tested.

The corresponding code seems to have been changed in commit 34d80a55ff8517fd37bcfea5063b9797e2bd9132. I therefore added Richard in Cc: for him to comment.

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
Reviewed-by
#2 lore raw
Quoted 23 lines · Aurelien Jarno
Quoted 12 lines · Pavel Dovgaluk

Fixed EFLAGS corruption by ROR r8/r16 instruction located at the end of the TB.

---
  target-i386/translate.c |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
target-i386/translate.c +0 -0
index 233f24f..40f891d 100644

target-i386/translate.c static void gen_rot_rm_T1(DisasContext *s, int ot, int op1, int is_right) · line 1781

Quoted 7 lines
target-i386/translate.c +1 -0
@@ -1775,6 +1775,7 @@ static void gen_rot_rm_T1(DisasContext *s, int ot, int op1, int is_right)
      if (is_right) {
          tcg_gen_shri_tl(cpu_cc_src2, cpu_T[0], mask - 1);
          tcg_gen_shri_tl(cpu_cc_dst, cpu_T[0], mask);
+        tcg_gen_andi_tl(cpu_cc_dst, cpu_cc_dst, 1);
      } else {
          tcg_gen_shri_tl(cpu_cc_src2, cpu_T[0], mask);
          tcg_gen_andi_tl(cpu_cc_dst, cpu_T[0], 1);

This looks correct to me, though I haven't tested.

Quoted 6 lines

The corresponding code seems to have been changed in commit 34d80a55ff8517fd37bcfea5063b9797e2bd9132. I therefore added Richard in Cc: for him to comment.

Ah, right. Presumably this was for x86_64 guest running in 32-bit mode?
Because then its 31 bit logical shift, and the only way there could be garbage at the top is if the _tl quantity is 64-bit.

One might hope that the known zero bits optimization that we already have will eliminate the extra AND when this is an i386 guest, or x86_64 guest with 64-bit rotate...

All that said,

r~

#3 lore raw
In reply to Pavel Dovgaluk
Quoted 12 lines · Pavel Dovgaluk

Fixed EFLAGS corruption by ROR r8/r16 instruction located at the end of the TB.

---
 target-i386/translate.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
target-i386/translate.c +0 -0
index 233f24f..40f891d 100644

target-i386/translate.c static void gen_rot_rm_T1(DisasContext *s, int ot, int op1, int is_right) · line 1781

Quoted 7 lines
target-i386/translate.c +1 -0
@@ -1775,6 +1775,7 @@ static void gen_rot_rm_T1(DisasContext *s, int ot, int op1, int is_right)
     if (is_right) {
         tcg_gen_shri_tl(cpu_cc_src2, cpu_T[0], mask - 1);
         tcg_gen_shri_tl(cpu_cc_dst, cpu_T[0], mask);
+        tcg_gen_andi_tl(cpu_cc_dst, cpu_cc_dst, 1);
     } else {
         tcg_gen_shri_tl(cpu_cc_src2, cpu_T[0], mask);
         tcg_gen_andi_tl(cpu_cc_dst, cpu_T[0], 1);

Thanks, applied.

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net