1. 26 Mar, 2020 3 commits
  2. 23 Mar, 2020 8 commits
    • Sean Christopherson's avatar
      KVM: VMX: Gracefully handle faults on VMXON · 4f6ea0a8
      Sean Christopherson authored
      Gracefully handle faults on VMXON, e.g. #GP due to VMX being disabled by
      BIOS, instead of letting the fault crash the system.  Now that KVM uses
      cpufeatures to query support instead of reading MSR_IA32_FEAT_CTL
      directly, it's possible for a bug in a different subsystem to cause KVM
      to incorrectly attempt VMXON[*].  Crashing the system is especially
      annoying if the system is configured such that hardware_enable() will
      be triggered during boot.
      
      Oppurtunistically rename @addr to @vmxon_pointer and use a named param
      to reference it in the inline assembly.
      
      Print 0xdeadbeef in the ultra-"rare" case that reading MSR_IA32_FEAT_CTL
      also faults.
      
      [*] https://lkml.kernel.org/r/20200226231615.13664-1-sean.j.christopherson@intel.comSigned-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
      Message-Id: <20200321193751.24985-4-sean.j.christopherson@intel.com>
      Reviewed-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      4f6ea0a8
    • Sean Christopherson's avatar
      KVM: VMX: Fold loaded_vmcs_init() into alloc_loaded_vmcs() · d260f9ef
      Sean Christopherson authored
      Subsume loaded_vmcs_init() into alloc_loaded_vmcs(), its only remaining
      caller, and drop the VMCLEAR on the shadow VMCS, which is guaranteed to
      be NULL.  loaded_vmcs_init() was previously used by loaded_vmcs_clear(),
      but loaded_vmcs_clear() also subsumed loaded_vmcs_init() to properly
      handle smp_wmb() with respect to VMCLEAR.
      Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
      Message-Id: <20200321193751.24985-3-sean.j.christopherson@intel.com>
      Reviewed-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      d260f9ef
    • Sean Christopherson's avatar
      KVM: VMX: Always VMCLEAR in-use VMCSes during crash with kexec support · 31603d4f
      Sean Christopherson authored
      VMCLEAR all in-use VMCSes during a crash, even if kdump's NMI shootdown
      interrupted a KVM update of the percpu in-use VMCS list.
      
      Because NMIs are not blocked by disabling IRQs, it's possible that
      crash_vmclear_local_loaded_vmcss() could be called while the percpu list
      of VMCSes is being modified, e.g. in the middle of list_add() in
      vmx_vcpu_load_vmcs().  This potential corner case was called out in the
      original commit[*], but the analysis of its impact was wrong.
      
      Skipping the VMCLEARs is wrong because it all but guarantees that a
      loaded, and therefore cached, VMCS will live across kexec and corrupt
      memory in the new kernel.  Corruption will occur because the CPU's VMCS
      cache is non-coherent, i.e. not snooped, and so the writeback of VMCS
      memory on its eviction will overwrite random memory in the new kernel.
      The VMCS will live because the NMI shootdown also disables VMX, i.e. the
      in-progress VMCLEAR will #UD, and existing Intel CPUs do not flush the
      VMCS cache on VMXOFF.
      
      Furthermore, interrupting list_add() and list_del() is safe due to
      crash_vmclear_local_loaded_vmcss() using forward iteration.  list_add()
      ensures the new entry is not visible to forward iteration unless the
      entire add completes, via WRITE_ONCE(prev->next, new).  A bad "prev"
      pointer could be observed if the NMI shootdown interrupted list_del() or
      list_add(), but list_for_each_entry() does not consume ->prev.
      
      In addition to removing the temporary disabling of VMCLEAR, open code
      loaded_vmcs_init() in __loaded_vmcs_clear() and reorder VMCLEAR so that
      the VMCS is deleted from the list only after it's been VMCLEAR'd.
      Deleting the VMCS before VMCLEAR would allow a race where the NMI
      shootdown could arrive between list_del() and vmcs_clear() and thus
      neither flow would execute a successful VMCLEAR.  Alternatively, more
      code could be moved into loaded_vmcs_init(), but that gets rather silly
      as the only other user, alloc_loaded_vmcs(), doesn't need the smp_wmb()
      and would need to work around the list_del().
      
      Update the smp_*() comments related to the list manipulation, and
      opportunistically reword them to improve clarity.
      
      [*] https://patchwork.kernel.org/patch/1675731/#3720461
      
      Fixes: 8f536b76 ("KVM: VMX: provide the vmclear function and a bitmap to support VMCLEAR in kdump")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
      Message-Id: <20200321193751.24985-2-sean.j.christopherson@intel.com>
      Reviewed-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      31603d4f
    • Zhenyu Wang's avatar
      KVM: x86: Expose fast short REP MOV for supported cpuid · e3747407
      Zhenyu Wang authored
      For CPU supporting fast short REP MOV (XF86_FEATURE_FSRM) e.g Icelake,
      Tigerlake, expose it in KVM supported cpuid as well.
      Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
      Message-Id: <20200323092236.3703-1-zhenyuw@linux.intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      e3747407
    • Stefan Raspl's avatar
      tools/kvm_stat: add command line switch '-c' to log in csv format · 0c794dce
      Stefan Raspl authored
      Add an alternative format that can be more easily used for further
      processing later on.
      Note that we add a timestamp in the first column for both, the regular
      and the new csv format.
      Signed-off-by: default avatarStefan Raspl <raspl@linux.ibm.com>
      Message-Id: <20200306114250.57585-5-raspl@linux.ibm.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      0c794dce
    • Stefan Raspl's avatar
      tools/kvm_stat: add command line switch '-s' to set update interval · 3cbb394d
      Stefan Raspl authored
      This now controls both, the refresh rate of the interactive mode as well
      as the logging mode. Which, as a consequence, means that the default of
      logging mode is now 3s, too (use command line switch '-s' to adjust to
      your liking).
      Signed-off-by: default avatarStefan Raspl <raspl@linux.ibm.com>
      Message-Id: <20200306114250.57585-4-raspl@linux.ibm.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      3cbb394d
    • Stefan Raspl's avatar
      tools/kvm_stat: switch to argparse · 0e6618fb
      Stefan Raspl authored
      optparse is deprecated for a while, hence switching over to argparse
      (which also works with python2).
      As a consequence, help output has some subtle changes, the most
      significant one being that the options are all listed explicitly
      instead of a universal '[options]' indicator. Also, some of the error
      messages are phrased slightly different.
      While at it, squashed a number of minor PEP8 issues.
      Signed-off-by: default avatarStefan Raspl <raspl@linux.ibm.com>
      Message-Id: <20200306114250.57585-3-raspl@linux.ibm.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      0e6618fb
    • Stefan Raspl's avatar
      tools/kvm_stat: rework command line sequence and message texts · eecda7a9
      Stefan Raspl authored
      Make sure command line arguments are sorted alphabetically
      everywhere, and adjusted existing texts for interactive command 's' to
      become consistent with the long form --set-delay.
      Throwing in some PEP8 fixes (all cosmetics) for good measure.
      Signed-off-by: default avatarStefan Raspl <raspl@linux.ibm.com>
      Message-Id: <20200306114250.57585-2-raspl@linux.ibm.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      eecda7a9
  3. 18 Mar, 2020 7 commits
  4. 17 Mar, 2020 1 commit
  5. 16 Mar, 2020 21 commits