From patchwork Thu Aug 26 09:21:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 134071 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 o7Q9LUN3030243 for ; Thu, 26 Aug 2010 09:22:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751822Ab0HZJWD (ORCPT ); Thu, 26 Aug 2010 05:22:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46550 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751643Ab0HZJWC (ORCPT ); Thu, 26 Aug 2010 05:22:02 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7Q9M1mX025651 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 26 Aug 2010 05:22:01 -0400 Received: from [127.0.1.1] (dhcp-65-37.nay.redhat.com [10.66.65.37]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7Q9LxWg014131; Thu, 26 Aug 2010 05:22:00 -0400 Subject: [PATCH kvm-unit-tests v2 06/10] Remove the duplicated rdmsr/wrmsr To: mtosatti@redhat.com, avi@redhat.com, kvm@vger.kernel.org From: Jason Wang Date: Thu, 26 Aug 2010 17:21:59 +0800 Message-ID: <20100826092159.1690.58517.stgit@FreeLancer> In-Reply-To: <20100826091520.1690.44200.stgit@FreeLancer> References: <20100826091520.1690.44200.stgit@FreeLancer> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 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.3 (demeter1.kernel.org [140.211.167.41]); Thu, 26 Aug 2010 09:22:05 +0000 (UTC) diff --git a/x86/msr.c b/x86/msr.c index 1e7987d..9c85369 100644 --- a/x86/msr.c +++ b/x86/msr.c @@ -1,6 +1,7 @@ /* msr tests */ #include "libcflat.h" +#include "processor.h" struct msr_info { int index; @@ -87,21 +88,6 @@ static void report(const char *name, int passed) printf("%s: %s\n", name, passed ? "PASS" : "FAIL"); } -static void wrmsr(unsigned index, unsigned long long value) -{ - unsigned a = value, d = value >> 32; - - asm volatile("wrmsr" : : "a"(a), "d"(d), "c"(index)); -} - -static unsigned long long rdmsr(unsigned index) -{ - unsigned a, d; - - asm volatile("rdmsr" : "=a"(a), "=d"(d) : "c"(index)); - return ((unsigned long long)d << 32) | a; -} - static void test_msr_rw(int msr_index, unsigned long long input, unsigned long long expected) { unsigned long long r = 0; diff --git a/x86/vmexit.c b/x86/vmexit.c index 707d5c6..819c24b 100644 --- a/x86/vmexit.c +++ b/x86/vmexit.c @@ -1,6 +1,7 @@ #include "libcflat.h" #include "smp.h" +#include "processor.h" static inline unsigned long long rdtsc() { @@ -32,7 +33,7 @@ static unsigned int inl(unsigned short port) # define R "e" #endif -static void cpuid(void) +static void cpuid_test(void) { asm volatile ("push %%"R "bx; cpuid; pop %%"R "bx" : : : "eax", "ecx", "edx"); @@ -48,21 +49,6 @@ static void vmcall(void) #define MSR_EFER 0xc0000080 #define EFER_NX_MASK (1ull << 11) -unsigned long long rdmsr(unsigned index) -{ - unsigned a, d; - - asm volatile("rdmsr" : "=a"(a), "=d"(d) : "c"(index)); - return ((unsigned long long)d << 32) | a; -} - -void wrmsr(unsigned index, unsigned long long val) -{ - unsigned a = val, d = val >> 32; - - asm volatile("wrmsr" : : "a"(a), "d"(d), "c"(index)); -} - static void mov_from_cr8(void) { unsigned long cr8; @@ -112,7 +98,7 @@ static struct test { int (*valid)(void); int parallel; } tests[] = { - { cpuid, "cpuid", .parallel = 1, }, + { cpuid_test, "cpuid", .parallel = 1, }, { vmcall, "vmcall", .parallel = 1, }, { mov_from_cr8, "mov_from_cr8", .parallel = 1, }, { mov_to_cr8, "mov_to_cr8" , .parallel = 1, },