1. 21 4月, 2020 2 次提交
    • S
      KVM: x86: Drop @invalidate_gpa param from kvm_x86_ops' tlb_flush() · f55ac304
      Sean Christopherson 提交于
      Drop @invalidate_gpa from ->tlb_flush() and kvm_vcpu_flush_tlb() now
      that all callers pass %true for said param, or ignore the param (SVM has
      an internal call to svm_flush_tlb() in svm_flush_tlb_guest that somewhat
      arbitrarily passes %false).
      
      Remove __vmx_flush_tlb() as it is no longer used.
      
      No functional change intended.
      Signed-off-by: NSean Christopherson <sean.j.christopherson@intel.com>
      Message-Id: <20200320212833.3507-17-sean.j.christopherson@intel.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f55ac304
    • S
      KVM: x86: Move "flush guest's TLB" logic to separate kvm_x86_ops hook · e64419d9
      Sean Christopherson 提交于
      Add a dedicated hook to handle flushing TLB entries on behalf of the
      guest, i.e. for a paravirtualized TLB flush, and use it directly instead
      of bouncing through kvm_vcpu_flush_tlb().
      
      For VMX, change the effective implementation implementation to never do
      INVEPT and flush only the current context, i.e. to always flush via
      INVVPID(SINGLE_CONTEXT).  The INVEPT performed by __vmx_flush_tlb() when
      @invalidate_gpa=false and enable_vpid=0 is unnecessary, as it will only
      flush guest-physical mappings; linear and combined mappings are flushed
      by VM-Enter when VPID is disabled, and changes in the guest pages tables
      do not affect guest-physical mappings.
      
      When EPT and VPID are enabled, doing INVVPID is not required (by Intel's
      architecture) to invalidate guest-physical mappings, i.e. TLB entries
      that cache guest-physical mappings can live across INVVPID as the
      mappings are associated with an EPTP, not a VPID.  The intent of
      @invalidate_gpa is to inform vmx_flush_tlb() that it must "invalidate
      gpa mappings", i.e. do INVEPT and not simply INVVPID.  Other than nested
      VPID handling, which now calls vpid_sync_context() directly, the only
      scenario where KVM can safely do INVVPID instead of INVEPT (when EPT is
      enabled) is if KVM is flushing TLB entries from the guest's perspective,
      i.e. is only required to invalidate linear mappings.
      
      For SVM, flushing TLB entries from the guest's perspective can be done
      by flushing the current ASID, as changes to the guest's page tables are
      associated only with the current ASID.
      
      Adding a dedicated ->tlb_flush_guest() paves the way toward removing
      @invalidate_gpa, which is a potentially dangerous control flag as its
      meaning is not exactly crystal clear, even for those who are familiar
      with the subtleties of what mappings Intel CPUs are/aren't allowed to
      keep across various invalidation scenarios.
      Signed-off-by: NSean Christopherson <sean.j.christopherson@intel.com>
      Message-Id: <20200320212833.3507-15-sean.j.christopherson@intel.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      e64419d9
  2. 16 4月, 2020 2 次提交
  3. 14 4月, 2020 1 次提交
  4. 03 4月, 2020 5 次提交
  5. 31 3月, 2020 3 次提交
  6. 25 3月, 2020 2 次提交
  7. 23 3月, 2020 1 次提交
    • T
      KVM: SVM: Issue WBINVD after deactivating an SEV guest · 2e2409af
      Tom Lendacky 提交于
      Currently, CLFLUSH is used to flush SEV guest memory before the guest is
      terminated (or a memory hotplug region is removed). However, CLFLUSH is
      not enough to ensure that SEV guest tagged data is flushed from the cache.
      
      With 33af3a7e ("KVM: SVM: Reduce WBINVD/DF_FLUSH invocations"), the
      original WBINVD was removed. This then exposed crashes at random times
      because of a cache flush race with a page that had both a hypervisor and
      a guest tag in the cache.
      
      Restore the WBINVD when destroying an SEV guest and add a WBINVD to the
      svm_unregister_enc_region() function to ensure hotplug memory is flushed
      when removed. The DF_FLUSH can still be avoided at this point.
      
      Fixes: 33af3a7e ("KVM: SVM: Reduce WBINVD/DF_FLUSH invocations")
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      Message-Id: <c8bf9087ca3711c5770bdeaafa3e45b717dc5ef4.1584720426.git.thomas.lendacky@amd.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      2e2409af
  8. 21 3月, 2020 1 次提交
  9. 18 3月, 2020 1 次提交
  10. 17 3月, 2020 22 次提交