From: Avi Kivity <avi@redhat.com>
To: Joerg Roedel <joerg.roedel@amd.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
kvm@vger.kernel.org
Subject: [PATCH 5/8] test: make use of new processor.h header
Date: Wed, 28 Jul 2010 13:18:24 +0300 [thread overview]
Message-ID: <1280312307-16686-6-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1280312307-16686-1-git-send-email-avi@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
---
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
next prev parent reply other threads:[~2010-07-28 10:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-28 10:18 [PATCH 0/8] Nested SVM unit tests Avi Kivity
2010-07-28 10:18 ` [PATCH 1/8] test: move ARRAY_SIZE() to libcflat.h Avi Kivity
2010-07-28 10:18 ` [PATCH 2/8] test: move memset() to libcflat Avi Kivity
2010-07-28 10:18 ` [PATCH 3/8] test: add type bool Avi Kivity
2010-07-28 10:18 ` [PATCH 4/8] test: add processor register access functions Avi Kivity
2010-07-28 10:18 ` Avi Kivity [this message]
2010-07-28 10:18 ` [PATCH 6/8] test: add svm definitions header Avi Kivity
2010-07-28 10:18 ` [PATCH 7/8] test: add msr " Avi Kivity
2010-07-28 10:18 ` [PATCH 8/8] test: add svm tests Avi Kivity
2010-07-28 11:40 ` [PATCH 0/8] Nested SVM unit tests Roedel, Joerg
2010-07-28 11:53 ` Avi Kivity
2010-07-28 12:39 ` Roedel, Joerg
2010-07-28 12:46 ` Avi Kivity
2010-07-29 16:55 ` Marcelo Tosatti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1280312307-16686-6-git-send-email-avi@redhat.com \
--to=avi@redhat.com \
--cc=joerg.roedel@amd.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox