From patchwork Wed Feb 10 01:56:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 78274 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1A1s4Mg028318 for ; Wed, 10 Feb 2010 01:54:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755311Ab0BJBxr (ORCPT ); Tue, 9 Feb 2010 20:53:47 -0500 Received: from serv2.oss.ntt.co.jp ([222.151.198.100]:39077 "EHLO serv2.oss.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753746Ab0BJBxr (ORCPT ); Tue, 9 Feb 2010 20:53:47 -0500 Received: from serv2.oss.ntt.co.jp (localhost [127.0.0.1]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id E96C7248214; Wed, 10 Feb 2010 10:53:45 +0900 (JST) Received: from serv1.oss.ntt.co.jp (serv1.oss.ntt.co.jp [172.19.0.2]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id D95542481C7; Wed, 10 Feb 2010 10:53:45 +0900 (JST) Received: from yshtky3.kern.oss.ntt.co.jp (unknown [172.17.1.159]) by serv1.oss.ntt.co.jp (Postfix) with SMTP id B12EA11C0A6; Wed, 10 Feb 2010 10:53:44 +0900 (JST) Date: Wed, 10 Feb 2010 10:56:32 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH v2 3/8] Fix x86_emulate_insn() to handle faults propagated from kvm_load_segment_descriptor() Message-Id: <20100210105632.8fa7205c.yoshikawa.takuya@oss.ntt.co.jp> In-Reply-To: <20100210104541.e0f1fdd1.yoshikawa.takuya@oss.ntt.co.jp> References: <20100210104541.e0f1fdd1.yoshikawa.takuya@oss.ntt.co.jp> X-Mailer: Sylpheed 2.6.0 (GTK+ 2.16.1; i486-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 10 Feb 2010 01:54:04 +0000 (UTC) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 645b245..4527940 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -1980,7 +1980,6 @@ special_insn: case 0x8e: { /* mov seg, r/m16 */ uint16_t sel; int type_bits; - int err; sel = c->src.val; if (c->modrm_reg == VCPU_SREG_SS) @@ -1988,16 +1987,16 @@ special_insn: if (c->modrm_reg <= 5) { type_bits = (c->modrm_reg == 1) ? 9 : 1; - err = kvm_load_segment_descriptor(ctxt->vcpu, sel, - type_bits, c->modrm_reg); + rc = kvm_load_segment_descriptor(ctxt->vcpu, sel, + type_bits, c->modrm_reg); } else { printk(KERN_INFO "Invalid segreg in modrm byte 0x%02x\n", c->modrm); goto cannot_emulate; } - if (err < 0) - goto cannot_emulate; + if (rc != X86EMUL_CONTINUE) + goto done; c->dst.type = OP_NONE; /* Disable writeback. */ break; @@ -2168,11 +2167,10 @@ special_insn: case 0xe9: /* jmp rel */ goto jmp; case 0xea: /* jmp far */ - if (kvm_load_segment_descriptor(ctxt->vcpu, c->src2.val, 9, - VCPU_SREG_CS) < 0) { - DPRINTF("jmp far: Failed to load CS descriptor\n"); - goto cannot_emulate; - } + rc = kvm_load_segment_descriptor(ctxt->vcpu, c->src2.val, 9, + VCPU_SREG_CS); + if (rc != X86EMUL_CONTINUE) + goto done; c->eip = c->src.val; break;