diff mbox

[kvm-unit-tests,v2,06/10] Remove the duplicated rdmsr/wrmsr

Message ID 20100826092159.1690.58517.stgit@FreeLancer (mailing list archive)
State New, archived
Headers show

Commit Message

Jason Wang Aug. 26, 2010, 9:21 a.m. UTC
None
diff mbox

Patch

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, },