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

Re: [Xen-devel] Emulating RDTSC


  • To: "Diwaker Gupta" <diwaker.lists@xxxxxxxxx>
  • From: "George Dunlap " <dunlapg@xxxxxxxxx>
  • Date: Fri, 27 Oct 2006 13:23:27 -0400
  • Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 27 Oct 2006 10:23:55 -0700
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=AxeMIkz1XT4BBWS35gPZ/vkLYS5Qk0haHMRzW+YLKOukmkoLJmoLt16XhicMmf5/hARSmj04CU2N5H7M4lD3bIXf84Ki+59e2Wu6FsOeqgZwYba5WWmzThsXHmKD6tE/yZQA/VEPYoNGvKSl7txzLX/Yss/AWvz+yYTajKZFySg=
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

First, add emulation for rdtsc in
xen/arch/x86/traps.c:emulate_privileged_op().  (Probably right next to
the implementation of RDMSR makes the most sense.)

Then, set CR4.TSD in this manner:
set_in_cr4(X86_CR4_TSD);

Of course simply enabling TSD will cause all RDTSCs in all domains to
be emulated, which may not be exactly what you want.  You might
consider adding a flag or something to the domain / vcpu struct and
modifying the context switch code to set the TSD flag is set only for
domains that you're interested in, and clear it otherwise.

Let me know if you have any trouble, and I'll see if I can extract a
patch from some old code that I have that did this exact thing.

-George

On 10/26/06, Diwaker Gupta <diwaker.lists@xxxxxxxxx> wrote:
Hi all,

Is it possible to modify Xen such that guests incur a fault when they
try to execute RDTSC and control is then passed to the hypervisor
which can then return whatever it wants to?

I'm starting with x86 PV guests, but using HVM guests is certainly an
option if that hardware makes it easier to achieve this. I'm thinking
that setting CR4.TSD in the guest control registers should be the
first step? Any comments or suggestions much appreciated.

Thanks,
Diwaker
--
Web/Blog/Gallery: http://floatingsun.net/blog

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.