Re: [PATCH v3 09/12] KVM: VMX: Remove vmx->current_tsc_ratio and decache_tsc_multiplier()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 25, 2021, Paolo Bonzini wrote:
> On 25/05/21 17:58, Sean Christopherson wrote:
> > > The right place for the hw multiplier
> > > field to be updated is inside set_tsc_khz() in common code when the ratio
> > > changes.
> 
> Sort of, the problem is that you have two VMCS's to update.  If properly
> fixed, the cache is useful to fix the issue with KVM_SET_TSC_KHZ needing to
> update both of them.  For that to work, you'd have to move the cache to
> struct loaded_vmcs.

vmcs01 and vmcs02 will get updated at enter/exit, if there's no caching then
it all Just Works.

> So you can:
> 
> 1) move the cached tsc_ratio to struct loaded_vmcs
> 
> 2) add a function in common code (update_tsc_parameters or something like
> that) to update both the offset and the ratio depending on is_guest_mode()
> 
> 3) call that function from nested vmentry/vmexit
> 
> And at that point the cache will do its job and figure out whether a vmwrite
> is needed, on both vmentry and vmexit.
> 
> I actually like the idea of storing the expected value in kvm_vcpu and the
> current value in loaded_vmcs.  We might use it for other things such as
> reload_vmcs01_apic_access_page perhaps.

I'm not necessarily opposed to aggressively shadowing the VMCS, but if we go
that route then it should be a standalone series that implements a framework
that can be easily extended to arbitrary fields.  Adding fields to loaded_vmcs
one at a time will be tedious and error prone.  E.g. what makes TSC_MULTIPLIER
more special than TSC_OFFSET, GUEST_IA32_PAT, GUEST_IA32_DEBUGCTL, GUEST_BNDCFGS,
and other number of fields that are likely to persist for a given vmcs02?

The current caching logic is just plain ugly and should not exist.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux