[PATCH 5/8] test: make use of new processor.h header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Avi Kivity <avi@xxxxxxxxxx>
---
 kvm/test/x86/apic.c     |    8 --------
 kvm/test/x86/emulator.c |   10 +++++-----
 kvm/test/x86/vm.c       |   20 +++++++-------------
 kvm/test/x86/vm.h       |   43 ++-----------------------------------------
 4 files changed, 14 insertions(+), 67 deletions(-)

diff --git a/kvm/test/x86/apic.c b/kvm/test/x86/apic.c
index b6718ec..48fa0f7 100644
--- a/kvm/test/x86/apic.c
+++ b/kvm/test/x86/apic.c
@@ -127,14 +127,6 @@ void test_enable_x2apic(void)
     }
 }
 
-static u16 read_cs(void)
-{
-    u16 v;
-
-    asm("mov %%cs, %0" : "=rm"(v));
-    return v;
-}
-
 static void init_idt(void)
 {
     struct {
diff --git a/kvm/test/x86/emulator.c b/kvm/test/x86/emulator.c
index db6a134..1483e3b 100644
--- a/kvm/test/x86/emulator.c
+++ b/kvm/test/x86/emulator.c
@@ -18,7 +18,7 @@ void report(const char *name, int result)
 	}
 }
 
-static char str[] = "abcdefghijklmnop";
+static char st1[] = "abcdefghijklmnop";
 
 void test_stringio()
 {
@@ -27,18 +27,18 @@ void test_stringio()
 		     "movw %0, %%dx \n\t"
 		     "rep outsb \n\t"
 		     : : "i"((short)TESTDEV_IO_PORT),
-		       "S"(str), "c"(sizeof(str) - 1));
+		       "S"(st1), "c"(sizeof(st1) - 1));
 	asm volatile("inb %1, %0\n\t" : "=a"(r) : "i"((short)TESTDEV_IO_PORT));
-	report("outsb up", r == str[sizeof(str) - 2]); /* last char */
+	report("outsb up", r == st1[sizeof(st1) - 2]); /* last char */
 
 	asm volatile("std \n\t"
 		     "movw %0, %%dx \n\t"
 		     "rep outsb \n\t"
 		     : : "i"((short)TESTDEV_IO_PORT),
-		       "S"(str + sizeof(str) - 2), "c"(sizeof(str) - 1));
+		       "S"(st1 + sizeof(st1) - 2), "c"(sizeof(st1) - 1));
 	asm volatile("cld \n\t" : : );
 	asm volatile("in %1, %0\n\t" : "=a"(r) : "i"((short)TESTDEV_IO_PORT));
-	report("outsb down", r == str[0]);
+	report("outsb down", r == st1[0]);
 }
 
 void test_cmps_one(unsigned char *m1, unsigned char *m3)
diff --git a/kvm/test/x86/vm.c b/kvm/test/x86/vm.c
index c8f1553..62b3ba8 100644
--- a/kvm/test/x86/vm.c
+++ b/kvm/test/x86/vm.c
@@ -118,19 +118,13 @@ void install_page(unsigned long *cr3,
 }
 
 
-struct gdt_table_descr
-{
-    unsigned short len;
-    unsigned long *table;
-} __attribute__((packed));
-
 static inline void load_gdt(unsigned long *table, int nent)
 {
-    struct gdt_table_descr descr;
+    struct descriptor_table_ptr descr;
 
-    descr.len = nent * 8 - 1;
-    descr.table = table;
-    asm volatile ( "lgdt %0" : : "m"(descr) );
+    descr.limit = nent * 8 - 1;
+    descr.base = (ulong)table;
+    lgdt(&descr);
 }
 
 #define SEG_CS_32 8
@@ -158,11 +152,11 @@ static void setup_mmu(unsigned long len)
 	install_page(cr3, phys, (void *)phys);
 	phys += PAGE_SIZE;
     }
-    load_cr3(virt_to_phys(cr3));
+    write_cr3(virt_to_phys(cr3));
 #ifndef __x86_64__
-    load_cr4(X86_CR4_PSE);
+    write_cr4(X86_CR4_PSE);
 #endif
-    load_cr0(X86_CR0_PG |X86_CR0_PE);
+    write_cr0(X86_CR0_PG |X86_CR0_PE);
 
     printf("paging enabled\n");
     printf("cr0 = %x\n", read_cr0());
diff --git a/kvm/test/x86/vm.h b/kvm/test/x86/vm.h
index 80dab8b..a3d2676 100644
--- a/kvm/test/x86/vm.h
+++ b/kvm/test/x86/vm.h
@@ -1,6 +1,8 @@
 #ifndef VM_H
 #define VM_H
 
+#include "processor.h"
+
 #define PAGE_SIZE 4096ul
 #ifdef __x86_64__
 #define LARGE_PAGE_SIZE (512 * PAGE_SIZE)
@@ -41,45 +43,4 @@ static inline void *phys_to_virt(unsigned long phys)
     return (void *)phys;
 }
 
-
-static inline void load_cr3(unsigned long cr3)
-{
-    asm ( "mov %0, %%cr3" : : "r"(cr3) );
-}
-
-static inline unsigned long read_cr3()
-{
-    unsigned long cr3;
-
-    asm volatile ( "mov %%cr3, %0" : "=r"(cr3) );
-    return cr3;
-}
-
-static inline void load_cr0(unsigned long cr0)
-{
-    asm volatile ( "mov %0, %%cr0" : : "r"(cr0) );
-}
-
-static inline unsigned long read_cr0()
-{
-    unsigned long cr0;
-
-    asm volatile ( "mov %%cr0, %0" : "=r"(cr0) );
-    return cr0;
-}
-
-
-static inline void load_cr4(unsigned long cr4)
-{
-    asm volatile ( "mov %0, %%cr4" : : "r"(cr4) );
-}
-
-static inline unsigned long read_cr4()
-{
-    unsigned long cr4;
-
-    asm volatile ( "mov %%cr4, %0" : "=r"(cr4) );
-    return cr4;
-}
-
 #endif
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux