From: Marcelo Tosatti <mtosatti@redhat.com>
To: will.auld@intel.com
Cc: "jinsong.liu@intel.com" <jinsong.liu@intel.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
Gleb <gleb@redhat.com>, qemu-devel <qemu-devel@nongnu.org>,
"donald.d.dugger@intel.com" <donald.d.dugger@intel.com>,
"avi@redhat.com" <avi@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] Resend - Added x86/tsc_adjust.c to test the ia32_tsc_adjust funtionality.
Date: Tue, 27 Nov 2012 22:49:19 -0200 [thread overview]
Message-ID: <20121128004919.GF8295@amt.cnet> (raw)
In-Reply-To: <1353955454.6006.0.camel@WillAuldHomeLinux>
Will,
1. Please check CPUID before using ADJUST_TSC MSR, exit test successfully
if CPUID bit disabled.
2. Please test the implementation of ADJUST_TSC MSR (functional test).
vmexit.flat test can be used for performance of MSR emulation.
Example
tsc1 = rdtsc();
wrmsr(IA32_TSC_ADJUST, 100000000000ull);
tsc2 = rdtsc();
if (tsc2 - tsc1 < 100000000000ull) {
printf("failure ... should be ...");
failure++;
}
...
write to tsc
check if IA32_TSC_ADJUST is adjusted accordingly
return !failure ? 0 : 1;
Thanks
On Mon, Nov 26, 2012 at 10:44:14AM -0800, Will Auld wrote:
> Signed-off-by: Will Auld <will.auld@intel.com>
> ---
> config-x86-common.mak | 5 ++++-
> x86/tsc_adjust.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 47 insertions(+), 1 deletion(-)
> create mode 100644 x86/tsc_adjust.c
>
> diff --git a/config-x86-common.mak b/config-x86-common.mak
> index c76cd11..47a9056 100644
> --- a/config-x86-common.mak
> +++ b/config-x86-common.mak
> @@ -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
> diff --git a/x86/tsc_adjust.c b/x86/tsc_adjust.c
> new file mode 100644
> index 0000000..bcb8982
> --- /dev/null
> +++ b/x86/tsc_adjust.c
> @@ -0,0 +1,43 @@
> +#include "libcflat.h"
> +#include "processor.h"
> +
> +#define IA32_TSC_ADJUST 0x3b
> +
> +int main()
> +{
> + u64 t1, t2, t3, t4, t5;
> + u64 lat;
> +
> + t3 = 0x0;
> +
> + t1 = rdtsc();
> + wrmsr(IA32_TSC_ADJUST, t3);
> + t2 = rdtsc();
> + lat = t2 - t1;
> + printf("rdtsc/wrmsr/rdtsc latency %lld\n", lat);
> + printf("Initial rdtsc: %lld\n", t2);
> +
> + t1 = rdmsr(IA32_TSC_ADJUST);
> + printf("Initial rdmsr IA32_TSC_ADJUST: %lld\n", t1);
> +
> + t5 = 100000000000ull;
> + wrtsc(t5);
> + t1 = rdmsr(IA32_TSC_ADJUST);
> + printf("wrtsc %lld, rdmsr IA32_TSC_ADJUST: %lld\n", t5, t1);
> +
> + wrmsr(IA32_TSC_ADJUST, t3);
> + t2 = rdtsc();
> + t1 = rdmsr(IA32_TSC_ADJUST);
> + printf( "wrmsr IA32_TSC_ADJUST %lld, rdmsr IA32_TSC_ADJUST: %lld, rdtsc: %lld\n", t3, t1, t2);
> +
> + t3 = 0xffff;
> + t4 = rdtsc();
> + wrmsr(IA32_TSC_ADJUST, t3);
> + t2 = rdtsc();
> + t1 = rdmsr(IA32_TSC_ADJUST);
> + printf( "wrmsr IA32_TSC_ADJUST %lld, rdmsr IA32_TSC_ADJUST: %lld, rdtsc: %lld\n", t3, t1, t2);
> + lat = t2 - t4;
> + printf("rdtsc/wrmsr/rdtsc latency %lld\n", lat);
> +
> + return 0;
> +}
> --
> 1.8.0.rc0
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2012-11-28 0:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-26 18:44 [Qemu-devel] [PATCH] Resend - Added x86/tsc_adjust.c to test the ia32_tsc_adjust funtionality Will Auld
2012-11-28 0:49 ` Marcelo Tosatti [this message]
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=20121128004919.GF8295@amt.cnet \
--to=mtosatti@redhat.com \
--cc=avi@redhat.com \
--cc=donald.d.dugger@intel.com \
--cc=gleb@redhat.com \
--cc=jinsong.liu@intel.com \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=will.auld@intel.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;
as well as URLs for NNTP newsgroup(s).