From patchwork Wed Jun 18 14:19:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nadav Amit X-Patchwork-Id: 4376441 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A64D39F1C4 for ; Wed, 18 Jun 2014 14:23:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CEA502035D for ; Wed, 18 Jun 2014 14:23:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F26E020357 for ; Wed, 18 Jun 2014 14:23:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966944AbaFROVh (ORCPT ); Wed, 18 Jun 2014 10:21:37 -0400 Received: from mailgw12.technion.ac.il ([132.68.225.12]:30903 "EHLO mailgw12.technion.ac.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756896AbaFROUG (ORCPT ); Wed, 18 Jun 2014 10:20:06 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtcBACOfoVOERCABjGdsb2JhbABarlABAQaZKAGBCRYPAQEBJzyEBAEFeRBRVxmIQscbhV4XhWKJEwcWhC0EijmnJw X-IPAS-Result: AtcBACOfoVOERCABjGdsb2JhbABarlABAQaZKAGBCRYPAQEBJzyEBAEFeRBRVxmIQscbhV4XhWKJEwcWhC0EijmnJw X-IronPort-AV: E=Sophos;i="5.01,501,1400014800"; d="scan'208";a="112034678" Received: from csa.cs.technion.ac.il ([132.68.32.1]) by mailgw12.technion.ac.il with ESMTP; 18 Jun 2014 17:20:02 +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 5163514003E; Wed, 18 Jun 2014 17:20:01 +0300 (IDT) Received: from ds-had5.cs.technion.ac.il (ds-had5.cs.technion.ac.il [132.68.206.94]) by csn.cs.technion.ac.il (Postfix) with ESMTP id 4A7A1598002; Wed, 18 Jun 2014 17:20:01 +0300 (IDT) From: Nadav Amit To: pbonzini@redhat.com Cc: gleb@kernel.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Nadav Amit Subject: [PATCH kvm-unit-tests 2/5] x86: test xadd with two identical operands Date: Wed, 18 Jun 2014 17:19:51 +0300 Message-Id: <1403101194-23707-3-git-send-email-namit@cs.technion.ac.il> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1403101194-23707-1-git-send-email-namit@cs.technion.ac.il> References: <1403101194-23707-1-git-send-email-namit@cs.technion.ac.il> 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 Previously, KVM emulated xadd incorrectly when the source and destination operands were identical. The expected result is that the register would hold the sum (2x) and not the previous value (x). This test checks this behavior. It should be executed with a disabled unrestricted mode. Signed-off-by: Nadav Amit --- x86/realmode.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x86/realmode.c b/x86/realmode.c index dc4a1d3..10c3e03 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -1663,6 +1663,14 @@ void test_smsw(void) report("smsw", R_AX | R_BX | R_CX, outregs.eax == outregs.ebx); } +void test_xadd(void) +{ + MK_INSN(xadd, "xaddl %eax, %eax\n\t"); + inregs.eax = 0x12345678; + exec_in_big_real_mode(&insn_xadd); + report("xadd", R_AX, outregs.eax == inregs.eax * 2); +} + void realmode_start(void) { @@ -1712,6 +1720,7 @@ void realmode_start(void) test_dr_mod(); test_smsw(); test_nopl(); + test_xadd(); test_perf_loop(); test_perf_mov(); test_perf_arith();