From patchwork Tue Apr 12 15:24:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 701151 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3CFPGsI024380 for ; Tue, 12 Apr 2011 15:25:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757571Ab1DLPZF (ORCPT ); Tue, 12 Apr 2011 11:25:05 -0400 Received: from mail-vw0-f46.google.com ([209.85.212.46]:53852 "EHLO mail-vw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757477Ab1DLPZC (ORCPT ); Tue, 12 Apr 2011 11:25:02 -0400 Received: by vws1 with SMTP id 1so5130087vws.19 for ; Tue, 12 Apr 2011 08:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:x-mailer :mime-version:content-type:content-transfer-encoding; bh=r9rihZqdbqiBR2ieSH945GsfiLc4/FbXV2L48AcQJ+k=; b=Z18jYRSsB2xHTJ9MPHpMTM8nJRBq91Ni13ZJJMxmH7Bp878iLzuY1S918ZHiiVZ+D/ bkaUGbZlKJE94qmXuOSbF2kVnrFv5xppfsEBimemsTFKHc2ghL/PteWwOYWCiE5V8F3v yBrFrXOWOJ7y+PjwVDmJuW0UsppM6AaN436bU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:x-mailer:mime-version :content-type:content-transfer-encoding; b=l6iLsE6TlsAZSQoGRVtDM2ORE2Gzm02gLht/qMQzGH54RrwcNZUCpOtrIpfTEj1tgH Jmraxl57o+6Q7eBatir7W2p+oqLiGgDnc5aj5pjnnebZokE0hgE32mguXMZwy2Tmh1ax HJgf2vafYG8Sy6LbwXUgX4tiykn6pWcehhKJ4= Received: by 10.52.93.103 with SMTP id ct7mr9492869vdb.119.1302621901886; Tue, 12 Apr 2011 08:25:01 -0700 (PDT) Received: from amd (s198099.dynamic.ppp.asahi-net.or.jp [220.157.198.99]) by mx.google.com with ESMTPS id f32sm1474758vcm.14.2011.04.12.08.24.57 (version=SSLv3 cipher=OTHER); Tue, 12 Apr 2011 08:24:59 -0700 (PDT) Date: Wed, 13 Apr 2011 00:24:55 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp, gleb@redhat.com Subject: [PATCH 1/3 v2] KVM: x86 emulator: Disable writeback for CMP emulation Message-Id: <20110413002455.f2160cd3.takuya.yoshikawa@gmail.com> X-Mailer: Sylpheed 3.1.0beta2 (GTK+ 2.22.0; x86_64-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.6 (demeter1.kernel.org [140.211.167.41]); Tue, 12 Apr 2011 15:25:16 +0000 (UTC) From: Takuya Yoshikawa This stops "CMP r/m, reg" to write back the data into memory. Pointed out by Avi. The writeback suppression now covers CMP, CMPS, SCAS. Signed-off-by: Takuya Yoshikawa --- Changelog v1->v2: moved the line just after the cmp label. arch/x86/kvm/emulate.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 3e8b4ab..db48e91 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -3671,6 +3671,7 @@ special_insn: break; case 0x38 ... 0x3d: cmp: /* cmp */ + c->dst.type = OP_NONE; /* Disable writeback. */ emulate_2op_SrcV("cmp", c->src, c->dst, ctxt->eflags); break; case 0x40 ... 0x47: /* inc r16/r32 */ @@ -3797,7 +3798,6 @@ special_insn: rc = emulate_popf(ctxt, ops, &c->dst.val, c->op_bytes); break; case 0xa6 ... 0xa7: /* cmps */ - c->dst.type = OP_NONE; /* Disable writeback. */ goto cmp; case 0xa8 ... 0xa9: /* test ax, imm */ goto test;