From patchwork Sun Apr 18 06:33:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Regmi X-Patchwork-Id: 93336 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 o3I6XQss014302 for ; Sun, 18 Apr 2010 06:33:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752625Ab0DRGdQ (ORCPT ); Sun, 18 Apr 2010 02:33:16 -0400 Received: from mail-iw0-f197.google.com ([209.85.223.197]:41613 "EHLO mail-iw0-f197.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752539Ab0DRGdP (ORCPT ); Sun, 18 Apr 2010 02:33:15 -0400 Received: by iwn35 with SMTP id 35so1351561iwn.21 for ; Sat, 17 Apr 2010 23:33:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:received:message-id :subject:from:to:cc:content-type; bh=Z2niFRQHt/LKu0fMe3OgfMTG4lO5S8HvzEwKDoGp9/A=; b=OBOi54ots7gAPKpLLgklD4E+cMB+7oRxxhc98tes74IWLrYi/c0lkqUYQbb1D5/UHm 1ASUIjfevTelri2M6FjPVXhQypeIaBsj4qtsluTUHuJD1PYgjDW3Whhu7nbECzc+fwao pNcolCGtxOme8RrzzmFC2SifDksF3K26kP7Xk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=cak6RKrS7DoKKbyZQ48CcwpWwmSLtK2VaTz14SlCPgLgZHY76UdMW/YOypENlTJ+wP yNIC6njl+Y3yNdJFY2WtsXD1eChuHMc3ie9xmTaZjUp8bumca9uxcbBFNPyj1zbmIvHz /P75T8QCAz5hZr7OZawahZRMvG95L+EdKffts= MIME-Version: 1.0 Received: by 10.231.59.72 with HTTP; Sat, 17 Apr 2010 23:33:14 -0700 (PDT) Date: Sun, 18 Apr 2010 01:33:14 -0500 Received: by 10.231.152.79 with SMTP id f15mr614882ibw.19.1271572394864; Sat, 17 Apr 2010 23:33:14 -0700 (PDT) Message-ID: Subject: [PATCH 0/1] trace all instructions whose emulation failed From: Manish Regmi To: kvm@vger.kernel.org Cc: avi@redhat.com 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]); Sun, 18 Apr 2010 06:33:27 +0000 (UTC) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index b6e7535..fd1e875 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3784,36 +3784,35 @@ int emulate_instruction(struct kvm_vcpu *vcpu, c = &vcpu->arch.emulate_ctxt.decode; if (emulation_type & EMULTYPE_TRAP_UD) { if (!c->twobyte) - return EMULATE_FAIL; + goto emulate_failed; switch (c->b) { case 0x01: /* VMMCALL */ if (c->modrm_mod != 3 || c->modrm_rm != 1) - return EMULATE_FAIL; + goto emulate_failed; break; case 0x34: /* sysenter */ case 0x35: /* sysexit */ if (c->modrm_mod != 0 || c->modrm_rm != 0) - return EMULATE_FAIL; + goto emulate_failed; break; case 0x05: /* syscall */ if (c->modrm_mod != 0 || c->modrm_rm != 0) - return EMULATE_FAIL; + goto emulate_failed;; break; default: - return EMULATE_FAIL; + goto emulate_failed; } if (!(c->modrm_reg == 0 || c->modrm_reg == 3)) - return EMULATE_FAIL; + goto emulate_failed; } ++vcpu->stat.insn_emulation; if (r) { ++vcpu->stat.insn_emulation_fail; - trace_kvm_emulate_insn_failed(vcpu); if (kvm_mmu_unprotect_page_virt(vcpu, cr2)) return EMULATE_DONE; - return EMULATE_FAIL; + goto emulate_failed; } } @@ -3848,9 +3847,8 @@ restart: goto done; if (!vcpu->mmio_needed) { ++vcpu->stat.insn_emulation_fail; - trace_kvm_emulate_insn_failed(vcpu); kvm_report_emulation_failure(vcpu, "mmio"); - return EMULATE_FAIL; + goto emulate_failed; } return EMULATE_DO_MMIO; } @@ -3868,6 +3866,10 @@ done: goto restart; return EMULATE_DONE; + +emulate_failed: + trace_kvm_emulate_insn_failed(vcpu); + return EMULATE_FAIL; } EXPORT_SYMBOL_GPL(emulate_instruction);