Casey Jeffery wrote:
> I've tried out the last few versions of KVM and think it's great. It's
> much easier to use and understand than Xen and performance is
> surprisingly good.
>
> One of the things I'd like to do is modify it to allow PMI generation
> based on the Intel performance counter facilities. Specifically, I'd
> like to be able to pin a guest to a CPU, program one of the IA32_PMCx
> MSR's to a count, configure the LVT to deliver an NMI on overflow,
> enable the PERF_EVT_SELx, and use the hardware-based MSR save/restore
> area to disable counting in root mode and re-enable when entering
> non-root.
>   

Ok.  Note that there are two possible mutually exclusive uses for the 
performance counters:

1.  Allow the guest to program the performance counters as it sees fit, 
for example to run oprofile internally.
2.  Let the host control the performance counters, for stuff like 
deterministic record/replay.

We should by default allow (1), with the option for (2).  This is 
somewhat similar to the hardware breakpoints, so you'd need some control 
like KVM_DEBUG_GUEST to switch modes.

> The questions I have now are the following:
>
> 1. It looks like the MSR save/restore area is set up already for EFER
> MSR and I assume that adding IA32_PMCx and IA32_PERFEVTSEL to the
> vmx_msr_index[] array would be enough to save/restore them.  Is that
> correct?
>   

Yes.

> 2. I don't completely follow the code from vmx.c
>
>        save_msrs(vcpu->host_msrs, vcpu->nmsrs);
>   

This saves the host msrs to the host save area.

>        load_msrs(vcpu->guest_msrs, NR_BAD_MSRS);
>   

vmx has a bug where it corrupts a couple of msrs, so we load the first 
NR_BAD_MSRS explicitly.


>        ...VMLAUNCH/RESUME etc. ...
>   

This loads vcpu->nmsrs - NR_BAD_MSRS from the guest area.

>        ....
>        ...VMEXIT...
>
>   

This saves vcpu->nmsrs - NR_BAD_MSRS into the guest area, and then loads 
vcpu->nmsrs - NR_BAD_MSRS from the host area.


>        save_msrs(vcpu->guest_msrs, NR_BAD_MSRS);
>        load_msrs(vcpu->host_msrs, NR_BAD_MSRS);
>   

These two lines do the same for the vmx-incompatible msrs.

> Does this mean the MSR values to be loaded on VM exit are initialized
> before leaving root mode while the VM_entry_load / VM_exit_store area
> is not touched?
>   

I'm not sure I understand the question, but host msrs are never saved 
automatically, and there are a couple of msrs we load and save manually 
for both host and guest.

> 3.  Is it possible to attribute counter ticks solely to a given KVM
> guest process and avoid counting ticks from other processes? I assume
> this isn't a problem since a VM exit should occur if the KVM process
> were to be pulled off the CPU by the kernel to do a context switch.
>   

Yes.

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to