From patchwork Sun Apr 26 15:10:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nadav Amit X-Patchwork-Id: 6276931 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B9B4ABF4A6 for ; Sun, 26 Apr 2015 15:11:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E677A202B4 for ; Sun, 26 Apr 2015 15:11:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6C5C32028D for ; Sun, 26 Apr 2015 15:11:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751803AbbDZPLK (ORCPT ); Sun, 26 Apr 2015 11:11:10 -0400 Received: from mailgw10.technion.ac.il ([132.68.225.10]:9536 "EHLO mailgw10.technion.ac.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751335AbbDZPLI (ORCPT ); Sun, 26 Apr 2015 11:11:08 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2ANBADa/zxVjAEgRIRchDu2AwOCQI1aCYFDhhOBHTgUAQEBAQEBAREBAQEnT4ROUoFRiCvALIUnkD0dhBcFi1mcNYlhgQNmgjFsgkQBAQE X-IPAS-Result: A2ANBADa/zxVjAEgRIRchDu2AwOCQI1aCYFDhhOBHTgUAQEBAQEBAREBAQEnT4ROUoFRiCvALIUnkD0dhBcFi1mcNYlhgQNmgjFsgkQBAQE X-IronPort-AV: E=Sophos;i="5.11,651,1422914400"; d="scan'208";a="20636236" Received: from csa.cs.technion.ac.il ([132.68.32.1]) by mailgw10.technion.ac.il with ESMTP; 26 Apr 2015 18:10:55 +0300 Received: from csn.cs.technion.ac.il (csn.cs.technion.ac.il [132.68.32.15]) by csa.cs.technion.ac.il (Postfix) with ESMTP id 62F83140036; Sun, 26 Apr 2015 18:10:53 +0300 (IDT) Received: from csl-tapuz20.cs.technion.ac.il (csl-tapuz20.cs.technion.ac.il [132.68.206.58]) by csn.cs.technion.ac.il (Postfix) with ESMTPSA id 40E90A03FE; Sun, 26 Apr 2015 18:10:53 +0300 (IDT) From: Nadav Amit To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, Nadav Amit Subject: [PATCH] KVM: x86: Fix cmpxchg with two 32-bit registers Date: Sun, 26 Apr 2015 18:10:48 +0300 Message-Id: <1430061048-14958-1-git-send-email-namit@cs.technion.ac.il> X-Mailer: git-send-email 2.1.4 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The emulation of CMPXCHG with two register operands in 64-bit mistakenly masks the high 32-bits as it performs assignment. Fix it. Fixes: 2fcf5c8ae244b4c298d2111a288d410a719ac626 Signed-off-by: Nadav Amit --- arch/x86/kvm/emulate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 630bcb0..84c132b 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -2242,6 +2242,8 @@ static int em_cmpxchg(struct x86_emulate_ctxt *ctxt) ctxt->src.val = ctxt->dst.orig_val; /* Create write-cycle to dest by writing the same value */ ctxt->dst.val = ctxt->dst.orig_val; + if (ctxt->dst.type != OP_MEM) + ctxt->dst.type = OP_NONE; } return X86EMUL_CONTINUE; }