From patchwork Thu Apr 11 10:16:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 2427131 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id DEA463FD40 for ; Thu, 11 Apr 2013 10:17:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762632Ab3DKKRJ (ORCPT ); Thu, 11 Apr 2013 06:17:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12806 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755066Ab3DKKRI (ORCPT ); Thu, 11 Apr 2013 06:17:08 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3BAH7o7002967 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 11 Apr 2013 06:17:07 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-4-26.tlv.redhat.com [10.35.4.26]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3BAH7eX015753; Thu, 11 Apr 2013 06:17:07 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id C283B18D3C0; Thu, 11 Apr 2013 13:17:06 +0300 (IDT) From: Gleb Natapov To: kvm@vger.kernel.org Cc: mtosatti@redhat.com, pbonzini@redhat.com Subject: [PATCH 3/4] KVM: emulator: Do not fail on emulation of undefined opcode Date: Thu, 11 Apr 2013 13:16:54 +0300 Message-Id: <1365675415-18925-3-git-send-email-gleb@redhat.com> In-Reply-To: <1365675415-18925-1-git-send-email-gleb@redhat.com> References: <1365675415-18925-1-git-send-email-gleb@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Emulation of undefined opcode should inject #UD instead of causing emulation failure. Do that by moving Undefined flag check to emulation stage and injection #UD there. Signed-off-by: Gleb Natapov --- arch/x86/kvm/emulate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index c2b7f33..2f66e98 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -4374,7 +4374,7 @@ done_prefixes: ctxt->intercept = opcode.intercept; /* Unrecognised? */ - if ((ctxt->d & NotImpl) || (ctxt->d & Undefined)) + if ((ctxt->d & NotImpl)) return EMULATION_FAILED; if (!(ctxt->d & VendorSpecific) && ctxt->only_vendor_specific_insn) @@ -4512,7 +4512,8 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) ctxt->mem_read.pos = 0; - if (ctxt->mode == X86EMUL_MODE_PROT64 && (ctxt->d & No64)) { + if ((ctxt->mode == X86EMUL_MODE_PROT64 && (ctxt->d & No64)) || + (ctxt->d & Undefined)) { rc = emulate_ud(ctxt); goto done; }