From patchwork Thu Jun 5 23:56:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nadav Amit X-Patchwork-Id: 4309241 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6C950BEEAA for ; Thu, 5 Jun 2014 23:57:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AF112201D5 for ; Thu, 5 Jun 2014 23:57:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CA8AE20265 for ; Thu, 5 Jun 2014 23:57:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752446AbaFEX5j (ORCPT ); Thu, 5 Jun 2014 19:57:39 -0400 Received: from mailgw12.technion.ac.il ([132.68.225.12]:49228 "EHLO mailgw12.technion.ac.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751834AbaFEX5H (ORCPT ); Thu, 5 Jun 2014 19:57:07 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ag8CAPECkVOERCABjGdsb2JhbABZx0cBgQgWDgEBASc8giYBBXkQQBFXGYhCzWGFMReOUgcWhCoEiiWmYg X-IPAS-Result: Ag8CAPECkVOERCABjGdsb2JhbABZx0cBgQgWDgEBASc8giYBBXkQQBFXGYhCzWGFMReOUgcWhCoEiiWmYg X-IronPort-AV: E=Sophos;i="4.98,984,1392156000"; d="scan'208";a="110197070" Received: from csa.cs.technion.ac.il ([132.68.32.1]) by mailgw12.technion.ac.il with ESMTP; 06 Jun 2014 02:57: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 45FDB14003C; Fri, 6 Jun 2014 02:57:00 +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 3AD3E598005; Fri, 6 Jun 2014 02:57:00 +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, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Nadav Amit Subject: [PATCH kvm-unit-tests1/2] x86: emulator: additional smsw test-case Date: Fri, 6 Jun 2014 02:56:52 +0300 Message-Id: <1402012613-29891-2-git-send-email-namit@cs.technion.ac.il> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1402012613-29891-1-git-send-email-namit@cs.technion.ac.il> References: <53908C66.20600@redhat.com> <1402012613-29891-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=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 An additional test case for the emulator was added to test smsw which is trapped by the emulator. The other existing test-cases occur in the guest (at least on VMX), since the values are read directly from the CR0 read shadow. Signed-off-by: Nadav Amit --- x86/emulator.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/x86/emulator.c b/x86/emulator.c index 20e3a45..033f246 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -336,7 +336,7 @@ void test_incdecnotneg(void *mem) report("lock notb", *mb == vb); } -void test_smsw(void) +void test_smsw(uint64_t *h_mem) { char mem[16]; unsigned short msw, msw_orig, *pmsw; @@ -355,6 +355,12 @@ void test_smsw(void) if (i != 4 && pmsw[i]) zero = 0; report("smsw (2)", msw == pmsw[4] && zero); + + /* Trigger exit on smsw */ + *h_mem = 0x12345678abcdeful; + asm volatile("smsw %0" : "=m"(*h_mem)); + report("smsw (3)", msw == (unsigned short)*h_mem && + (*h_mem & ~0xfffful) == 0x12345678ab0000ul); } void test_lmsw(void) @@ -998,7 +1004,7 @@ int main() test_cr8(); - test_smsw(); + test_smsw(mem); test_lmsw(); test_ljmp(mem); test_stringio();