This patch just replaces integer values used inside
x86_emulate_insn() and its helper functions to X86EMUL_*.

The purpose of this is to make it clear what will happen
when rc variable is compared to X86EMUL_* at the end of
x86_emulate_insn().


Signed-off-by: Takuya Yoshikawa <yoshikawa.tak...@oss.ntt.co.jp>
---
 arch/x86/kvm/emulate.c |   62 ++++++++++++++++++++++-------------------------
 1 files changed, 29 insertions(+), 33 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 3bcd75e..91c0eb7 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -662,7 +662,7 @@ static int read_descriptor(struct x86_emulate_ctxt *ctxt,
        *address = 0;
        rc = ops->read_std((unsigned long)ptr, (unsigned long *)size, 2,
                           ctxt->vcpu);
-       if (rc)
+       if (rc != X86EMUL_CONTINUE)
                return rc;
        rc = ops->read_std((unsigned long)ptr + 2, address, op_bytes,
                           ctxt->vcpu);
@@ -1222,7 +1222,7 @@ static int emulate_pop_sreg(struct x86_emulate_ctxt *ctxt,
        int rc;
 
        rc = emulate_pop(ctxt, ops, &selector, c->op_bytes);
-       if (rc != 0)
+       if (rc != X86EMUL_CONTINUE)
                return rc;
 
        rc = kvm_load_segment_descriptor(ctxt->vcpu, (u16)selector, 1, seg);
@@ -1248,7 +1248,7 @@ static int emulate_popa(struct x86_emulate_ctxt *ctxt,
                        struct x86_emulate_ops *ops)
 {
        struct decode_cache *c = &ctxt->decode;
-       int rc = 0;
+       int rc = X86EMUL_CONTINUE;
        int reg = VCPU_REGS_RDI;
 
        while (reg >= VCPU_REGS_RAX) {
@@ -1259,7 +1259,7 @@ static int emulate_popa(struct x86_emulate_ctxt *ctxt,
                }
 
                rc = emulate_pop(ctxt, ops, &c->regs[reg], c->op_bytes);
-               if (rc != 0)
+               if (rc != X86EMUL_CONTINUE)
                        break;
                --reg;
        }
@@ -1270,12 +1270,8 @@ static inline int emulate_grp1a(struct x86_emulate_ctxt 
*ctxt,
                                struct x86_emulate_ops *ops)
 {
        struct decode_cache *c = &ctxt->decode;
-       int rc;
 
-       rc = emulate_pop(ctxt, ops, &c->dst.val, c->dst.bytes);
-       if (rc != 0)
-               return rc;
-       return 0;
+       return emulate_pop(ctxt, ops, &c->dst.val, c->dst.bytes);
 }
 
 static inline void emulate_grp2(struct x86_emulate_ctxt *ctxt)
@@ -1311,7 +1307,7 @@ static inline int emulate_grp3(struct x86_emulate_ctxt 
*ctxt,
                               struct x86_emulate_ops *ops)
 {
        struct decode_cache *c = &ctxt->decode;
-       int rc = 0;
+       int rc = X86EMUL_CONTINUE;
 
        switch (c->modrm_reg) {
        case 0 ... 1:   /* test */
@@ -1358,7 +1354,7 @@ static inline int emulate_grp45(struct x86_emulate_ctxt 
*ctxt,
                emulate_push(ctxt);
                break;
        }
-       return 0;
+       return X86EMUL_CONTINUE;
 }
 
 static inline int emulate_grp9(struct x86_emulate_ctxt *ctxt,
@@ -1389,7 +1385,7 @@ static inline int emulate_grp9(struct x86_emulate_ctxt 
*ctxt,
                        return rc;
                ctxt->eflags |= EFLG_ZF;
        }
-       return 0;
+       return X86EMUL_CONTINUE;
 }
 
 static int emulate_ret_far(struct x86_emulate_ctxt *ctxt,
@@ -1400,12 +1396,12 @@ static int emulate_ret_far(struct x86_emulate_ctxt 
*ctxt,
        unsigned long cs;
 
        rc = emulate_pop(ctxt, ops, &c->eip, c->op_bytes);
-       if (rc)
+       if (rc != X86EMUL_CONTINUE)
                return rc;
        if (c->op_bytes == 4)
                c->eip = (u32)c->eip;
        rc = emulate_pop(ctxt, ops, &cs, c->op_bytes);
-       if (rc)
+       if (rc != X86EMUL_CONTINUE)
                return rc;
        rc = kvm_load_segment_descriptor(ctxt->vcpu, (u16)cs, 1, VCPU_SREG_CS);
        return rc;
@@ -1460,7 +1456,7 @@ static inline int writeback(struct x86_emulate_ctxt *ctxt,
        default:
                break;
        }
-       return 0;
+       return X86EMUL_CONTINUE;
 }
 
 static void toggle_interruptibility(struct x86_emulate_ctxt *ctxt, u32 mask)
@@ -1695,7 +1691,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct 
x86_emulate_ops *ops)
        struct decode_cache *c = &ctxt->decode;
        unsigned int port;
        int io_dir_in;
-       int rc = 0;
+       int rc = X86EMUL_CONTINUE;
 
        ctxt->interruptibility = 0;
 
@@ -1793,7 +1789,7 @@ special_insn:
                break;
        case 0x07:              /* pop es */
                rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_ES);
-               if (rc != 0)
+               if (rc != X86EMUL_CONTINUE)
                        goto done;
                break;
        case 0x08 ... 0x0d:
@@ -1812,7 +1808,7 @@ special_insn:
                break;
        case 0x17:              /* pop ss */
                rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_SS);
-               if (rc != 0)
+               if (rc != X86EMUL_CONTINUE)
                        goto done;
                break;
        case 0x18 ... 0x1d:
@@ -1824,7 +1820,7 @@ special_insn:
                break;
        case 0x1f:              /* pop ds */
                rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_DS);
-               if (rc != 0)
+               if (rc != X86EMUL_CONTINUE)
                        goto done;
                break;
        case 0x20 ... 0x25:
@@ -1855,7 +1851,7 @@ special_insn:
        case 0x58 ... 0x5f: /* pop reg */
        pop_instruction:
                rc = emulate_pop(ctxt, ops, &c->dst.val, c->op_bytes);
-               if (rc != 0)
+               if (rc != X86EMUL_CONTINUE)
                        goto done;
                break;
        case 0x60:      /* pusha */
@@ -1863,7 +1859,7 @@ special_insn:
                break;
        case 0x61:      /* popa */
                rc = emulate_popa(ctxt, ops);
-               if (rc != 0)
+               if (rc != X86EMUL_CONTINUE)
                        goto done;
                break;
        case 0x63:              /* movsxd */
@@ -2003,7 +1999,7 @@ special_insn:
        }
        case 0x8f:              /* pop (sole member of Grp1a) */
                rc = emulate_grp1a(ctxt, ops);
-               if (rc != 0)
+               if (rc != X86EMUL_CONTINUE)
                        goto done;
                break;
        case 0x90: /* nop / xchg r8,rax */
@@ -2136,7 +2132,7 @@ special_insn:
                break;
        case 0xcb:              /* ret far */
                rc = emulate_ret_far(ctxt, ops);
-               if (rc)
+               if (rc != X86EMUL_CONTINUE)
                        goto done;
                break;
        case 0xd0 ... 0xd1:     /* Grp2 */
@@ -2205,7 +2201,7 @@ special_insn:
                break;
        case 0xf6 ... 0xf7:     /* Grp3 */
                rc = emulate_grp3(ctxt, ops);
-               if (rc != 0)
+               if (rc != X86EMUL_CONTINUE)
                        goto done;
                break;
        case 0xf8: /* clc */
@@ -2231,14 +2227,14 @@ special_insn:
                break;
        case 0xfe ... 0xff:     /* Grp4/Grp5 */
                rc = emulate_grp45(ctxt, ops);
-               if (rc != 0)
+               if (rc != X86EMUL_CONTINUE)
                        goto done;
                break;
        }
 
 writeback:
        rc = writeback(ctxt, ops);
-       if (rc != 0)
+       if (rc != X86EMUL_CONTINUE)
                goto done;
 
        /* Commit shadow register state. */
@@ -2264,7 +2260,7 @@ twobyte_insn:
                                goto cannot_emulate;
 
                        rc = kvm_fix_hypercall(ctxt->vcpu);
-                       if (rc)
+                       if (rc != X86EMUL_CONTINUE)
                                goto done;
 
                        /* Let the processor re-execute the fixed hypercall */
@@ -2275,7 +2271,7 @@ twobyte_insn:
                case 2: /* lgdt */
                        rc = read_descriptor(ctxt, ops, c->src.ptr,
                                             &size, &address, c->op_bytes);
-                       if (rc)
+                       if (rc != X86EMUL_CONTINUE)
                                goto done;
                        realmode_lgdt(ctxt->vcpu, size, address);
                        /* Disable writeback. */
@@ -2286,7 +2282,7 @@ twobyte_insn:
                                switch (c->modrm_rm) {
                                case 1:
                                        rc = kvm_fix_hypercall(ctxt->vcpu);
-                                       if (rc)
+                                       if (rc != X86EMUL_CONTINUE)
                                                goto done;
                                        break;
                                default:
@@ -2296,7 +2292,7 @@ twobyte_insn:
                                rc = read_descriptor(ctxt, ops, c->src.ptr,
                                                     &size, &address,
                                                     c->op_bytes);
-                               if (rc)
+                               if (rc != X86EMUL_CONTINUE)
                                        goto done;
                                realmode_lidt(ctxt->vcpu, size, address);
                        }
@@ -2420,7 +2416,7 @@ twobyte_insn:
                break;
        case 0xa1:       /* pop fs */
                rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_FS);
-               if (rc != 0)
+               if (rc != X86EMUL_CONTINUE)
                        goto done;
                break;
        case 0xa3:
@@ -2439,7 +2435,7 @@ twobyte_insn:
                break;
        case 0xa9:      /* pop gs */
                rc = emulate_pop_sreg(ctxt, ops, VCPU_SREG_GS);
-               if (rc != 0)
+               if (rc != X86EMUL_CONTINUE)
                        goto done;
                break;
        case 0xab:
@@ -2512,7 +2508,7 @@ twobyte_insn:
                break;
        case 0xc7:              /* Grp9 (cmpxchg8b) */
                rc = emulate_grp9(ctxt, ops, memop);
-               if (rc != 0)
+               if (rc != X86EMUL_CONTINUE)
                        goto done;
                c->dst.type = OP_NONE;
                break;
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to