From patchwork Wed Oct 5 13:19:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Razvan Cojocaru X-Patchwork-Id: 9362917 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B65536075E for ; Wed, 5 Oct 2016 13:22:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5F79287FD for ; Wed, 5 Oct 2016 13:22:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98DF82893D; Wed, 5 Oct 2016 13:22:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 85840287FD for ; Wed, 5 Oct 2016 13:22:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brm76-0004l9-Q2; Wed, 05 Oct 2016 13:20:00 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brm75-0004l1-Jk for xen-devel@lists.xen.org; Wed, 05 Oct 2016 13:19:59 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 48/B9-15788-EFDF4F75; Wed, 05 Oct 2016 13:19:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMIsWRWlGSWpSXmKPExsUSfTxjoe6/v1/ CDfYe5bdY8nExiwOjx9Hdv5kCGKNYM/OS8isSWDMmz9rLUrCVs+JfdzNjA+Nu9i5GTg4hAXeJ fUuus3UxcgHZaxglju54DOVcY5S4df8oG0SVm8SCuYeZIBL7GCVmfLgJ1s4mYCixemMLWJGIg LTEtc+XGUFsZoFKic4vl8BsYYEgiRffdzOB2CwCqhLffu0DinNw8Ap4SvTf1AEJSwjISZw8Np kVws6RuLy+gQ2kREJASuJ/qxLIWgmBbhaJ85++sEPUyEg8mniTbQKjwAJGhlWMGsWpRWWpRbp GBnpJRZnpGSW5iZk5uoYGxnq5qcXFiempOYlJxXrJ+bmbGIGBVc/AwLiDsfmE3yFGSQ4mJVHe 9ye/hAvxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4L34BygnWJSanlqRlpkDDHGYtAQHj5II73aQN G9xQWJucWY6ROoUo6KUOO87kIQASCKjNA+uDRZXlxhlpYR5GRkYGIR4ClKLcjNLUOVfMYpzMC oJ88oAo1SIJzOvBG76K6DFTECL85eCLS5JREhJNTAmfmhfuaU2nyVy7V37lGc+Losll1zes06 yRjf2Zl9GVixDwfHrC7USJ7G42j/ievGV/f7TZfMcyq28dWUSOs9t1diY8XzLduOTs19kMx+X ttEzP2mdK7pbetFc4ffv6g2nKa5tiDW5L/rt/qws53Lmbzxnzl3xvhpiaMIf9Kf68tYFczb6P F6pxFKckWioxVxUnAgAlvm5iqYCAAA= X-Env-Sender: rcojocaru@bitdefender.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1475673597!56976582!1 X-Originating-IP: [91.199.104.161] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 56397 invoked from network); 5 Oct 2016 13:19:58 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-16.tower-31.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 5 Oct 2016 13:19:58 -0000 Received: (qmail 16103 invoked from network); 5 Oct 2016 16:19:56 +0300 Received: from unknown (HELO mx-sr.buh.bitdefender.com) (10.17.80.103) by mx01.bbu.dsd.mx.bitdefender.com with AES256-GCM-SHA384 encrypted SMTP; 5 Oct 2016 16:19:56 +0300 Received: from smtp02.buh.bitdefender.net (smtp.bitdefender.biz [10.17.80.76]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 9D3037FC21 for ; Wed, 5 Oct 2016 16:19:56 +0300 (EEST) Received: (qmail 2672 invoked from network); 5 Oct 2016 16:19:56 +0300 Received: from xen.dsd.ro (HELO xen.dsd.bitdefender.biz) (rcojocaru@bitdefender.com@10.10.14.109) by smtp02.buh.bitdefender.net with AES128-SHA256 encrypted SMTP; 5 Oct 2016 16:19:56 +0300 From: Razvan Cojocaru To: xen-devel@lists.xen.org Date: Wed, 5 Oct 2016 16:19:18 +0300 Message-Id: <1475673558-30720-1-git-send-email-rcojocaru@bitdefender.com> X-Mailer: git-send-email 1.9.1 X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.6 on smtp02.buh.bitdefender.net, sigver: 7.67485 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.911, Dats: 433577, Stamp: 3], Multi: [Enabled, t: (0.000009, 0.001521)], BW: [Enabled, t: (0.000007,0.000002)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.002283), Flags: 85D2ED72; NN_NO_CONTENT_TYPE; NN_NO_LINK_NMD; NN_LEGIT_BITDEFENDER; NN_LEGIT_S_SQARE_BRACKETS; NN_LEGIT_MAILING_LIST_TO], SGN: [Enabled, t: (0.006530)], URL: [Enabled, t: (0.000006)], RTDA: [Enabled, t: (0.056279), Hit: No, Details: v2.3.11; Id: 2m1ghjn.1au7vrueq.fm30], total: 0(775) X-BitDefender-CF-Stamp: none Cc: andrew.cooper3@citrix.com, paul.durrant@citrix.com, Razvan Cojocaru , jbeulich@suse.com Subject: [Xen-devel] [PATCH] x86/hvm: Set the emulation context correctly in hvmemul_cmpxchg() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP hvmemul_cmpxchg() sets the read emulation context in p_new instead of p_old, which is inconsistent (and wrong). We are now setting p_old (even though it's unused) and adding a comment explaining the change. Suggested-by: Jan Beulich Signed-off-by: Razvan Cojocaru --- xen/arch/x86/hvm/emulate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index d759d3f..0cbb16e 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -1031,13 +1031,17 @@ static int hvmemul_cmpxchg( if ( unlikely(hvmemul_ctxt->set_context) ) { - int rc = set_context_data(p_new, bytes); + int rc = set_context_data(p_old, bytes); if ( rc != X86EMUL_OKAY ) return rc; } - /* Fix this in case the guest is really relying on r-m-w atomicity. */ + /* + * Fix this in case the guest is really relying on r-m-w atomicity. + * Please note that while the set_context code is provided here for + * consistency, p_old is unused. + */ return hvmemul_write(seg, offset, p_new, bytes, ctxt); }