Skip to contentSkip to conversation

Added tests for ia32_tsc_adjust funtionality.

PATCH Applied Will Auld 3 participants 3 messages Nov 28, 2012 KVM

lore
Share & tools
lore

Will Auld

author
#0 lore raw

PATCH v2 1/1 Added tests for ia32_tsc_adjust funtionality.

Added x86/tsc_adjust.c and updated x86/vmexit.c to include timing tests for reading and writing the emulated IA32_TSC_ADJUST msr.

---
 config-x86-common.mak |  5 ++++-
 x86/tsc_adjust.c      | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++
 x86/vmexit.c          | 13 +++++++++++
 3 files changed, 77 insertions(+), 1 deletion(-)
 create mode 100644 x86/tsc_adjust.c
config-x86-common.mak +4 -1
index c76cd11..8f909f7 100644
@@ -34,7 +34,8 @@ tests-common = $(TEST_DIR)/vmexit.flat $(TEST_DIR)/tsc.flat \
                $(TEST_DIR)/realmode.flat $(TEST_DIR)/msr.flat \
                $(TEST_DIR)/hypercall.flat $(TEST_DIR)/sieve.flat \
                $(TEST_DIR)/kvmclock_test.flat  $(TEST_DIR)/eventinj.flat \
-               $(TEST_DIR)/s3.flat $(TEST_DIR)/pmu.flat $(TEST_DIR)/asyncpf.flat
+               $(TEST_DIR)/s3.flat $(TEST_DIR)/pmu.flat \
+               $(TEST_DIR)/tsc_adjust.flat $(TEST_DIR)/asyncpf.flat
 
 ifdef API
 tests-common += api/api-sample
@@ -64,6 +65,8 @@ $(TEST_DIR)/port80.elf: $(cstart.o) $(TEST_DIR)/port80.o
 
 $(TEST_DIR)/tsc.elf: $(cstart.o) $(TEST_DIR)/tsc.o
 
+$(TEST_DIR)/tsc_adjust.elf: $(cstart.o) $(TEST_DIR)/tsc_adjust.o
+
 $(TEST_DIR)/apic.elf: $(cstart.o) $(TEST_DIR)/apic.o
 
 $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o
x86/tsc_adjust.c new file +60 -0

60 lines not on this page · raw message

x86/vmexit.c +13 -0
index ad8ab55..99ff964 100644
@@ -34,6 +34,7 @@ static void vmcall(void)
 	asm volatile ("vmcall" : "+a"(a), "=b"(b), "=c"(c), "=d"(d));
 }
 
+#define MSR_TSC_ADJUST 0x3b
 #define MSR_EFER 0xc0000080
 #define EFER_NX_MASK            (1ull << 11)
 
@@ -103,6 +104,16 @@ static void ple_round_robin(void)
 	++counters[you].n1;
 }
 
+static void rd_tsc_adjust_msr(void)
+{
+	rdmsr(MSR_TSC_ADJUST);
+}
+
+static void wr_tsc_adjust_msr(void)
+{
+	wrmsr(MSR_TSC_ADJUST, 0x0);
+}
+
 static struct test {
 	void (*func)(void);
 	const char *name;
@@ -119,6 +130,8 @@ static struct test {
 	{ ipi, "ipi", is_smp, .parallel = 0, },
 	{ ipi_halt, "ipi+halt", is_smp, .parallel = 0, },
 	{ ple_round_robin, "ple-round-robin", .parallel = 1 },
+	{ wr_tsc_adjust_msr, "wr_tsc_adjust_msr", .parallel = 1 },
+	{ rd_tsc_adjust_msr, "rd_tsc_adjust_msr", .parallel = 1 },
 };
 
 unsigned iterations;
Signature · 1 line
1.8.0.rc0
#1 lore raw
Quoted 10 lines · Will Auld

Added x86/tsc_adjust.c and updated x86/vmexit.c to include timing tests for reading and writing the emulated IA32_TSC_ADJUST msr.

---
 config-x86-common.mak |  5 ++++-
 x86/tsc_adjust.c      | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++
 x86/vmexit.c          | 13 +++++++++++
 3 files changed, 77 insertions(+), 1 deletion(-)
 create mode 100644 x86/tsc_adjust.c

Applied, thanks.

#2 lore raw

RE: [PATCH V2] Added tests for ia32_tsc_adjust functionality.

Thanks Marcelo!

Quoted 22 lines

-----Original Message-----
From: Marcelo Tosatti [mailto:[email protected]]
Sent: Wednesday, November 28, 2012 2:14 PM
To: Auld, Will
Cc: [email protected]; Dugger, Donald D; Liu, Jinsong; Zhang, Xiantao; [email protected]; Gleb
Subject: Re: [PATCH V2] Added tests for ia32_tsc_adjust funtionality.

Quoted 7 lines · Will Auld

Added x86/tsc_adjust.c and updated x86/vmexit.c to include timing tests for reading and writing the emulated IA32_TSC_ADJUST msr.

---
 config-x86-common.mak |  5 ++++-
 x86/tsc_adjust.c      | 60

+++++++++++++++++++++++++++++++++++++++++++++++++++

Quoted 3 lines
 x86/vmexit.c          | 13 +++++++++++
 3 files changed, 77 insertions(+), 1 deletion(-)  create mode 100644

x86/tsc_adjust.c

Applied, thanks.