mbox series

[v2,0/7] Split kvm_update_cpuid_runtime()

Message ID 1603271410-71343-1-git-send-email-robert.hu@linux.intel.com (mailing list archive)
Headers show
Series Split kvm_update_cpuid_runtime() | expand

Message

Robert Hoo Oct. 21, 2020, 9:10 a.m. UTC
kvm_update_cpuid_runtime() is currently called by various functions for the
purpose of updating vCPU's cpuid entries, due to specific runtime changes, e.g.
CR4 bits changes, XCR0 bits changes, etc. Each of them actually just needs to
update 1 ~ 2 CPUID entries. But current kvm_update_cpuid_runtime() packages all.
Given finding a target CPUID entry need to go through all CPUID entries, calling
kvm_update_cpuid_runtime() is a waste for each cause.

This patch set splits kvm_update_cpuid_runtime() into pieces according to
different updating causes.
Then let various callers call their specific necessary kvm_xxx_update_cpuid().
This patch set also refactors kvm_vcpu_after_set_cpuid().

This not only significantly saves each caller's time, but also eliminates
unnecessary couplings.

---
Change Log
v2:
Reorders patch set, let each extracted function with its caller in a patch.
Also, added a helper function guest_cpuid_change(), which is the extraction
of the common code.

Robert Hoo (7):
  kvm: x86: Extract kvm_apic_base_update_cpuid() from
    kvm_update_cpuid_runtime()
  kvm: x86: Extract kvm_xcr0_update_cpuid() from
    kvm_update_cpuid_runtime()
  kvm: x86: Extract kvm_osxsave_update_cpuid() and    
    kvm_pke_update_cpuid() from kvm_update_cpuid_runtime()
  kvm: x86: Extract kvm_mwait_update_cpuid() from
    kvm_update_cpuid_runtime()
  [Trivial] kvm: x86: cpuid_query_maxphyaddr(): Use a simple 'e' instead
    of     misleading 'best', as the variable name
  kvm: x86: Refactor kvm_vcpu_after_set_cpuid()
  kvm: x86: Remove kvm_update_cpuid_runtime()

 arch/x86/kvm/cpuid.c | 148 ++++++++++++++++++++++++++++++---------------------
 arch/x86/kvm/cpuid.h |   7 ++-
 arch/x86/kvm/lapic.c |   2 +-
 arch/x86/kvm/x86.c   |  29 ++++++----
 4 files changed, 113 insertions(+), 73 deletions(-)