lkml.org 
[lkml]   [2009]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 06/48] KVM: x86 emulator: Implement zero-extended immediate decoding
    Date
    Absolute jumps use zero extended immediate operands.

    Signed-off-by: Avi Kivity <avi@redhat.com>
    ---
    arch/x86/kvm/x86_emulate.c | 15 +++++++++++++++
    1 files changed, 15 insertions(+), 0 deletions(-)

    diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
    index 616de46..a30d5fc 100644
    --- a/arch/x86/kvm/x86_emulate.c
    +++ b/arch/x86/kvm/x86_emulate.c
    @@ -60,6 +60,7 @@
    #define SrcImmByte (6<<4) /* 8-bit sign-extended immediate operand. */
    #define SrcOne (7<<4) /* Implied '1' */
    #define SrcImmUByte (8<<4) /* 8-bit unsigned immediate operand. */
    +#define SrcImmU (9<<4) /* Immediate operand, unsigned */
    #define SrcMask (0xf<<4)
    /* Generic ModRM decode. */
    #define ModRM (1<<8)
    @@ -1027,6 +1028,7 @@ done_prefixes:
    c->src.type = OP_MEM;
    break;
    case SrcImm:
    + case SrcImmU:
    c->src.type = OP_IMM;
    c->src.ptr = (unsigned long *)c->eip;
    c->src.bytes = (c->d & ByteOp) ? 1 : c->op_bytes;
    @@ -1044,6 +1046,19 @@ done_prefixes:
    c->src.val = insn_fetch(s32, 4, c->eip);
    break;
    }
    + if ((c->d & SrcMask) == SrcImmU) {
    + switch (c->src.bytes) {
    + case 1:
    + c->src.val &= 0xff;
    + break;
    + case 2:
    + c->src.val &= 0xffff;
    + break;
    + case 4:
    + c->src.val &= 0xffffffff;
    + break;
    + }
    + }
    break;
    case SrcImmByte:
    case SrcImmUByte:
    --
    1.6.3.3


    \
     
     \ /
      Last update: 2009-08-16 11:57    [W:0.031 / U:1.268 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site