|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] Branch Trace Storage for guestsandVPMUinitialization
On 02/26/2015 08:44 AM, Kevin.Mayer@xxxxxxxx wrote: -----Ursprüngliche Nachricht----- Von: Boris Ostrovsky [mailto:boris.ostrovsky@xxxxxxxxxx] Gesendet: Mittwoch, 25. Februar 2015 23:20 An: Mayer, Kevin Betreff: Re: AW: AW: [Xen-devel] Branch Trace Storage for guests andVPMUinitialization On 02/25/2015 01:23 PM, Kevin.Mayer@xxxxxxxx wrote:-----Ursprüngliche Nachricht----- Von: Boris Ostrovsky [mailto:boris.ostrovsky@xxxxxxxxxx] Gesendet: Mittwoch, 25. Februar 2015 17:32 An: Mayer, Kevin Cc: xen-devel@xxxxxxxxxxxxx Betreff: Re: AW: [Xen-devel] Branch Trace Storage for guests and VPMUinitialization On 02/25/2015 10:12 AM, Kevin.Mayer@xxxxxxxx wrote:-----Ursprüngliche Nachricht----- Von: Boris Ostrovsky [mailto:boris.ostrovsky@xxxxxxxxxx] Gesendet: Dienstag, 24. Februar 2015 18:13 An: Mayer, Kevin; xen-devel@xxxxxxxxxxxxx Betreff: Re: [Xen-devel] Branch Trace Storage for guests and VPMU initialization On 02/24/2015 10:27 AM, Kevin.Mayer@xxxxxxxx wrote:Hi guys I`m trying to set up the BTS so that I can log the branches taken in the guest using Xen 4.4.1 with a WinXP SP3 guest on a Core i7 Sandy Bridge. I added the vpmu=bts boot parameter to my grub2 configuration and extended the libxl,libxc,domctl,… with an own command so that I can trigger the activation of the BTS whenever I want.I am not sure why you are doing all these changes to Xen code. BTS is supposed to be managed from the guest. For example, a FedoraHVM I was hoping that you might then keep the buffer in hypervisor space. But I don't think it's possible to make HW not virtualize those two registers (DS_AREA in particular). The idea was to access/setup the guest IA32_DEBUGCTLMSR and MSR_IA32_DS_AREA when in dom0. So when there is a VMENTER the guest registers get loaded and the BTS starts to log. And stops of course when there is an VMEXIT. Regarding 1. I`m not sure how I know at which address the BTS is located in this case. Let´s say I setup the BTS in the guest at address x. To get this address x I need to read the guest MSR_IA32_DS_AREA, right? If the guest wrote this address to MSR_IA32_DS_AREA then yes. For this I would need to access the vcpu->arch_vcpu-> hvm_vcpu->vpmu used by the guest since the MSR_IA32_DS_AREA isn`t part of the vmcs (and therefore cannot be accessed by the handy __vmread()). Is there a good way to get this information during a vpmu_interrupt() (since I believe The BTINT will have to be handled there), or maybe a VMEXIT? I believe the interrupt can only happen when the guest is running on the physical processor so you should be able to get to guest's VPMU as vcpu_vpmu(v)->context->ds_area. Same for VMEXIT. 2. I already use the vmx_vmcs_enter/exit but didn’t think about pausing the vpcu. I will add that. 3. I didn’t look at the BTINT yet, but this sounds reasonable.This would be "the guest is logging the branch traces", but it is setup andcontrolled from the dom0. So more or less a hybrid I think.Of course the guest must not be able to use this memory in its normaloperations but just for BTS.Is this even possible? I am rather confused at the moment. :-DThen I write the pointer to the BTS Buffer into the DS Buffer Management Area at +0x0 and +0x8 (BTS Buffer Base and BTS Index) When I use vmx_msr_write_intercept to store the value in MSR_IA32_DS_AREA the host reboots (my idea is he tries to access a vpmu-struct that isn´t there in the current vcpu and panics).Who is trying to write to MSR_IA32_DS_AREA? The guest or dom0? I thought you said that you want dom0 to do sampling. Or are you trying to setup DS area from your guest and control it from dom0? I amsomewhat confused.The dom0 writes to MSR_IA32_DS_AREA. I want to do all the setup and controlling from dom0 in a way that enables the guest to store branch traces in the BTS (that was setup by the dom0)I think I understand why you crash hypervisor now. I mentioned above that writing into vmcs requires bracketing by vmx_vmcs_enter/exit. So, in addition to having new vcpu parameter to vmx_msr_write_intercept(), you need to add those two. See vmx_vlapic_msr_changed(), right above vmx_msr_write_intercept(). And don't forget to pause guest's vcpu (I am pretty sure you need that since your guest may be running somewhere else at this time).Sorry if my explanations are a bit confusing. I myself am confused aboutthis part of the Xen-code.Can you post hypervisor log? (hard to say how helpful it will be without seeing your code changes though)Right after enabling the BTS I get a triple fault. hvm.c:1357:d2 Triple fault on VCPU0 - invoking HVM shutdown action 1.That's not host reboot, this is your guest dying.Yes When I use my own vmx_msr_write_intercept (which explicitly uses thevcpu of my guest domain instead of the "current") and my own core2_vpmu_do_wrmsr , core2_vpmu_msr_common_check I don’t get a host reboot, but a dying guest when I try to enable BTS. As you said most likely because the MSR_IA32_DS_AREA points to dom0-memory and the hypervisor is not amused when a guest tries to write stuff there.When I use the build in ones (which all use struct vcpu *v = current;) I get ahost reboot.Maybe because of a missing vpmu-structs as I notice that only one vcpu_idgets initialized in vpmu_initialise during boot. Yes, it should. BTW, why are you explicitly calling vpmu_initialise()? It should be called during guest VCPU initialization. I'd need to see 'xl dmesg' output at time of reboot, possibly with disassembly of code at RIP that presumably will be reported as causing the reboot. -boris Kevin-borisWhen I use a modified version of vmx_msr_write_intercept I don’tgetany crashes as long as I don’t enable BTS and TR in the GUEST_IA32_DEBUGCTL (BTR works). When I enable the BTS (and TR)theguest crashes. I suppose he gets killed by the hypervisor for accessing forbidden memory.Possibly because DS area point to hypervisor memory. Having said all this, I am not sure how well BTS works. You did notice this in the hypervisor log: (XEN)******************************************************(XEN) ** WARNING: Emulation of BTS Feature is switched on ** (XEN) ** Using this processor feature in a virtualized ** (XEN) ** environment is not 100% safe. ** (XEN) ** Setting the DS buffer address with wrong values ** (XEN) ** may lead to hypervisor hangs or crashes. ** (XEN) ** It is NOT recommended for production use! ** (XEN)******************************************************Yes, I saw that. It doesn’t state that BTS is not working at all, just that it isnot that safe to use.As I understand it as long as I set the DS buffer address correctly I shouldbefine, right? Right. Except that I am not convinced you did set this buffer correctly, which is possibly why your hypervisor crashed (I am not sure I understood under what circumstances though). -borisWe are thinking very much alike. I also am not convinced I set the buffercorrectly. ^^But since I get a reboot as soon as return vpmu->arch_vpmu_ops->do_wrmsr(msr, msr_content); gets calledI don’t think that the setup of the buffer is the problem (when using the original vmx_msr_write_intercept), but rather something with the setup of the vpmu.When I use my own vmx_msr_write_intercept with the d->vcpu[0] insteadof current the writing succeeds but the guest crashes/gets killed when the BTS is enabled.So in this second case the setup of the buffer seems to be the problem. KevinSince I don’t want to use for production that is fine with me. At least fornow.Kevin-borisThe modified version of vmx_msr_write_intercept takes a vcpu-structasa parameter and uses this instead of the current vcpu. Instead of staticint vmx_msr_write_intercept(unsigned int msr, uint64_tmsr_content) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |