I am trying to allow rdpmc access from Dom0 for some performance measurement related work I am doing. The platform is x86_64 and I am running the latest xen-unstable distribution. I''ve traveresed around the xen code and as per my understanding, here''s a short snippet of what I''ve done to get rdpmc working through DOM0. I have only recently begun to go through Xen source-code, please feel free to offer comments: 1) Added a relevant section for RDPMC in /xen/arch/x86/traps.c (case 0x33; right under RDMSR (0x32)). 2) Wrote a rdpmc_safe assembly code in xen/include/asm-x86/msr.h (based on rdmsr_safe in the same file). 3) Added code in xen/arch/x86/x86_emulate.c to interpret the opcode for RDPMC and call read_pmc (based off of read_msr in the same file). 4) Added relevant sections in xen/include/asm/x86_emulate.h for read_pmc (based off of read_msr). I boot into the new kernel but am still unable to trap rdpmc instructions from DOM0. Is there any step I am missing in my attempt to trap+emulate rdpmc? Thanks, Hemant _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 6/9/07 14:44, "Mohapatra, Hemant" <Hemant.Mohapatra@amd.com> wrote:> I boot into the new kernel but am still unable to trap rdpmc > instructions from DOM0. Is there any step I am missing in my attempt to > trap+emulate rdpmc?RDPMC is not much use unless you can also set up the performance-counting MSRs in advance to count appropriate things. Since we do not virtualise these MSRs, providing access to RDPMC is pointless. You should look at xenoprof for example usage of performance counter infrastructure in Xen. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
> From: Keir Fraser [mailto:Keir.Fraser@cl.cam.ac.uk] > Subject: Re: [Xen-devel] [Q] Allow rdpmc access from DOM-0 > > RDPMC is not much use unless you can also set up theperformance-counting> MSRs in advance to count appropriate things. Since we do notvirtualise> these MSRs, providing access to RDPMC is pointless. You should lookat> xenoprof for example usage of performance counter infrastructure inXen. My bad; I should''ve mentioned this before: I already have allowed access to the appropriate MSRs and can read/write to them using rdmsr/wrmsr on DOM-0. It was easy to add them to the white-list since the opcode was already being trapped and virtualized and it was only a matter of adding access to the MSRs I needed specifically. I have worked with Xenoprof but I am essentially trying to port a few applications to Xen here and trying to re-write them in conjunction with Xenoprof seems like the round-about way of doing it. I am trying to follow the route of how rdmsr/wrmsr were virtualized so that I can do the same with rdpmc. I see no harm in this since RDMSR is already allowed from Dom0. Thanks, Hemant _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 6/9/07 16:23, "Mohapatra, Hemant" <Hemant.Mohapatra@amd.com> wrote:> My bad; I should''ve mentioned this before: I already have allowed access > to the appropriate MSRs and can read/write to them using rdmsr/wrmsr on > DOM-0. It was easy to add them to the white-list since the opcode was > already being trapped and virtualized and it was only a matter of adding > access to the MSRs I needed specifically. > > I have worked with Xenoprof but I am essentially trying to port a few > applications to Xen here and trying to re-write them in conjunction with > Xenoprof seems like the round-about way of doing it. I am trying to > follow the route of how rdmsr/wrmsr were virtualized so that I can do > the same with rdpmc. I see no harm in this since RDMSR is already > allowed from Dom0.Your problem might then be that your RDPMC emulation path is only executed if the instruction was trapped in guest kernel mode. I guess you are trying to execute it in guest user mode, and you may find that this mode is tested for before you reach the RDPMC case that you''ve added. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
> From: Keir Fraser [mailto:Keir.Fraser@cl.cam.ac.uk] > Subject: Re: [Xen-devel] [Q] Allow rdpmc access from DOM-0 > > Your problem might then be that your RDPMC emulation path is only > executed > if the instruction was trapped in guest kernel mode. I guess you are > trying > to execute it in guest user mode, and you may find that this mode is > tested > for before you reach the RDPMC case that you''ve added.Yes, that could be it. Could you please direct me to the appropriate place for user-mode emulation path(s)? Thanks. Hemant _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 6/9/07 16:43, "Mohapatra, Hemant" <Hemant.Mohapatra@amd.com> wrote:> Yes, that could be it. Could you please direct me to the appropriate > place for user-mode emulation path(s)?There isn''t one right now. All emulations in traps.c either depend on IOPL or on running in guest kernel mode. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
> -----Original Message----- > From: Keir Fraser [mailto:Keir.Fraser@cl.cam.ac.uk] > Subject: Re: [Xen-devel] [Q] Allow rdpmc access from DOM-0 > > On 6/9/07 16:43, "Mohapatra, Hemant" <Hemant.Mohapatra@amd.com>wrote:> > > Yes, that could be it. Could you please direct me to theappropriate> > place for user-mode emulation path(s)? > > There isn''t one right now. All emulations in traps.c either depend on > IOPL > or on running in guest kernel mode.I see. I''ll find some alternative. Thanks, Hemant _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel