From: "George Dunlap " Subject: Re: Emulating RDTSC Date: Fri, 27 Oct 2006 13:23:27 -0400 Message-ID: References: <891be9410610261341t6b024ea6i9fe5c37d2ab62f2c@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <891be9410610261341t6b024ea6i9fe5c37d2ab62f2c@mail.gmail.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Diwaker Gupta Cc: xen-devel List-Id: xen-devel@lists.xenproject.org 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 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@lists.xensource.com > http://lists.xensource.com/xen-devel >