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@gmail.com>
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
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel