Patchwork target-i386: fix decoding of negative 4-byte displacements

login
register
mail settings
Submitter Paolo Bonzini
Date June 4, 2010, 2:27 p.m.
Message ID <1275661653-16726-1-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/54612/
State New
Headers show

Comments

Paolo Bonzini - June 4, 2010, 2:27 p.m.
Negative four byte displacements need to be sign-extended after
c086b783eb7a578993d6d2ab62c4c2666800b63d.  Do so.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
        There are quite a few other ldl's to audit after the patch
        (about 70 in target-*).  Any volunteers? :-)

 target-i386/translate.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Richard Henderson - June 4, 2010, 4:23 p.m.
On 06/04/2010 07:27 AM, Paolo Bonzini wrote:
> Negative four byte displacements need to be sign-extended after
> c086b783eb7a578993d6d2ab62c4c2666800b63d.  Do so.

Acked-by: Richard Henderson  <rth@twiddle.net>


>         There are quite a few other ldl's to audit after the patch
>         (about 70 in target-*).  Any volunteers? :-)

I've looked over all the uses of ldl_code.  Thankfully 95% of them
are immediately stored into an explicit 32-bit variable.  I do not
see any other problematic uses of that particular identifier.


r~
Blue Swirl - June 4, 2010, 8:03 p.m.
Thanks, applied.

On Fri, Jun 4, 2010 at 4:23 PM, Richard Henderson <rth@twiddle.net> wrote:
> On 06/04/2010 07:27 AM, Paolo Bonzini wrote:
>> Negative four byte displacements need to be sign-extended after
>> c086b783eb7a578993d6d2ab62c4c2666800b63d.  Do so.
>
> Acked-by: Richard Henderson  <rth@twiddle.net>
>
>
>>         There are quite a few other ldl's to audit after the patch
>>         (about 70 in target-*).  Any volunteers? :-)
>
> I've looked over all the uses of ldl_code.  Thankfully 95% of them
> are immediately stored into an explicit 32-bit variable.  I do not
> see any other problematic uses of that particular identifier.
>
>
> r~
>

Patch

diff --git a/target-i386/translate.c b/target-i386/translate.c
index 38c6016..708b0a1 100644
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -2016,7 +2016,7 @@  static void gen_lea_modrm(DisasContext *s, int modrm, int *reg_ptr, int *offset_
             break;
         default:
         case 2:
-            disp = ldl_code(s->pc);
+            disp = (int32_t)ldl_code(s->pc);
             s->pc += 4;
             break;
         }