1. 08 12月, 2021 4 次提交
    • L
      KVM: x86/svm: Add module param to control PMU virtualization · b1d66dad
      Like Xu 提交于
      For Intel, the guest PMU can be disabled via clearing the PMU CPUID.
      For AMD, all hw implementations support the base set of four
      performance counters, with current mainstream hardware indicating
      the presence of two additional counters via X86_FEATURE_PERFCTR_CORE.
      
      In the virtualized world, the AMD guest driver may detect
      the presence of at least one counter MSR. Most hypervisor
      vendors would introduce a module param (like lbrv for svm)
      to disable PMU for all guests.
      
      Another control proposal per-VM is to pass PMU disable information
      via MSR_IA32_PERF_CAPABILITIES or one bit in CPUID Fn4000_00[FF:00].
      Both of methods require some guest-side changes, so a module
      parameter may not be sufficiently granular, but practical enough.
      Signed-off-by: NLike Xu <likexu@tencent.com>
      Message-Id: <20211117080304.38989-1-likexu@tencent.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b1d66dad
    • E
      KVM: nSVM: introduce struct vmcb_ctrl_area_cached · 8fc78909
      Emanuele Giuseppe Esposito 提交于
      This structure will replace vmcb_control_area in
      svm_nested_state, providing only the fields that are actually
      used by the nested state. This avoids having and copying around
      uninitialized fields. The cost of this, however, is that all
      functions (in this case vmcb_is_intercept) expect the old
      structure, so they need to be duplicated.
      
      In addition, in svm_get_nested_state() user space expects a
      vmcb_control_area struct, so we need to copy back all fields
      in a temporary structure before copying it to userspace.
      Signed-off-by: NEmanuele Giuseppe Esposito <eesposit@redhat.com>
      Reviewed-by: NMaxim Levitsky <mlevitsk@redhat.com>
      Message-Id: <20211103140527.752797-7-eesposit@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      8fc78909
    • E
      KVM: nSVM: rename nested_load_control_from_vmcb12 in nested_copy_vmcb_control_to_cache · 7907160d
      Emanuele Giuseppe Esposito 提交于
      Following the same naming convention of the previous patch,
      rename nested_load_control_from_vmcb12.
      In addition, inline copy_vmcb_control_area as it is only called
      by this function.
      
      __nested_copy_vmcb_control_to_cache() works with vmcb_control_area
      parameters and it will be useful in next patches, when we use
      local variables instead of svm cached state.
      Signed-off-by: NEmanuele Giuseppe Esposito <eesposit@redhat.com>
      Message-Id: <20211103140527.752797-4-eesposit@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      7907160d
    • E
      KVM: nSVM: introduce svm->nested.save to cache save area before checks · f2740a8d
      Emanuele Giuseppe Esposito 提交于
      This is useful in the next patch, to keep a saved copy
      of vmcb12 registers and pass it around more easily.
      
      Instead of blindly copying everything, we just copy EFER, CR0, CR3, CR4,
      DR6 and DR7 which are needed by the VMRUN checks.  If more fields will
      need to be checked, it will be quite obvious to see that they must be added
      in struct vmcb_save_area_cached and in nested_copy_vmcb_save_to_cache().
      
      __nested_copy_vmcb_save_to_cache() takes a vmcb_save_area_cached
      parameter, which is useful in order to save the state to a local
      variable.
      Signed-off-by: NEmanuele Giuseppe Esposito <eesposit@redhat.com>
      Message-Id: <20211103140527.752797-3-eesposit@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f2740a8d
  2. 30 11月, 2021 1 次提交
    • P
      KVM: x86: check PIR even for vCPUs with disabled APICv · 37c4dbf3
      Paolo Bonzini 提交于
      The IRTE for an assigned device can trigger a POSTED_INTR_VECTOR even
      if APICv is disabled on the vCPU that receives it.  In that case, the
      interrupt will just cause a vmexit and leave the ON bit set together
      with the PIR bit corresponding to the interrupt.
      
      Right now, the interrupt would not be delivered until APICv is re-enabled.
      However, fixing this is just a matter of always doing the PIR->IRR
      synchronization, even if the vCPU has temporarily disabled APICv.
      
      This is not a problem for performance, or if anything it is an
      improvement.  First, in the common case where vcpu->arch.apicv_active is
      true, one fewer check has to be performed.  Second, static_call_cond will
      elide the function call if APICv is not present or disabled.  Finally,
      in the case for AMD hardware we can remove the sync_pir_to_irr callback:
      it is only needed for apic_has_interrupt_for_ppr, and that function
      already has a fallback for !APICv.
      
      Cc: stable@vger.kernel.org
      Co-developed-by: NSean Christopherson <seanjc@google.com>
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Reviewed-by: NMaxim Levitsky <mlevitsk@redhat.com>
      Reviewed-by: NDavid Matlack <dmatlack@google.com>
      Message-Id: <20211123004311.2954158-4-pbonzini@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      37c4dbf3
  3. 11 11月, 2021 3 次提交
    • V
      KVM: Move INVPCID type check from vmx and svm to the common kvm_handle_invpcid() · 796c83c5
      Vipin Sharma 提交于
      Handle #GP on INVPCID due to an invalid type in the common switch
      statement instead of relying on the callers (VMX and SVM) to manually
      validate the type.
      
      Unlike INVVPID and INVEPT, INVPCID is not explicitly documented to check
      the type before reading the operand from memory, so deferring the
      type validity check until after that point is architecturally allowed.
      Signed-off-by: NVipin Sharma <vipinsh@google.com>
      Reviewed-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20211109174426.2350547-3-vipinsh@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      796c83c5
    • P
      KVM: SEV: Add support for SEV intra host migration · b5663931
      Peter Gonda 提交于
      For SEV to work with intra host migration, contents of the SEV info struct
      such as the ASID (used to index the encryption key in the AMD SP) and
      the list of memory regions need to be transferred to the target VM.
      This change adds a commands for a target VMM to get a source SEV VM's sev
      info.
      Signed-off-by: NPeter Gonda <pgonda@google.com>
      Suggested-by: NSean Christopherson <seanjc@google.com>
      Reviewed-by: NMarc Orr <marcorr@google.com>
      Cc: Marc Orr <marcorr@google.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
      Cc: Brijesh Singh <brijesh.singh@amd.com>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
      Cc: Wanpeng Li <wanpengli@tencent.com>
      Cc: Jim Mattson <jmattson@google.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: kvm@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Message-Id: <20211021174303.385706-3-pgonda@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b5663931
    • P
      KVM: SEV: Refactor out sev_es_state struct · b67a4cc3
      Peter Gonda 提交于
      Move SEV-ES vCPU metadata into new sev_es_state struct from vcpu_svm.
      Signed-off-by: NPeter Gonda <pgonda@google.com>
      Suggested-by: NTom Lendacky <thomas.lendacky@amd.com>
      Acked-by: NTom Lendacky <thomas.lendacky@amd.com>
      Reviewed-by: NSean Christopherson <seanjc@google.com>
      Cc: Marc Orr <marcorr@google.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
      Cc: Brijesh Singh <brijesh.singh@amd.com>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
      Cc: Wanpeng Li <wanpengli@tencent.com>
      Cc: Jim Mattson <jmattson@google.com>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: kvm@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Message-Id: <20211021174303.385706-2-pgonda@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b67a4cc3
  4. 25 10月, 2021 1 次提交
  5. 23 10月, 2021 1 次提交
  6. 22 10月, 2021 2 次提交
    • S
      KVM: x86: Move SVM's APICv sanity check to common x86 · ee49a893
      Sean Christopherson 提交于
      Move SVM's assertion that vCPU's APICv state is consistent with its VM's
      state out of svm_vcpu_run() and into x86's common inner run loop.  The
      assertion and underlying logic is not unique to SVM, it's just that SVM
      has more inhibiting conditions and thus is more likely to run headfirst
      into any KVM bugs.
      
      Add relevant comments to document exactly why the update path has unusual
      ordering between the update the kick, why said ordering is safe, and also
      the basic rules behind the assertion in the run loop.
      
      Cc: Maxim Levitsky <mlevitsk@redhat.com>
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20211022004927.1448382-3-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      ee49a893
    • S
      KVM: x86: Add vendor name to kvm_x86_ops, use it for error messages · 9dadfc4a
      Sean Christopherson 提交于
      Paul pointed out the error messages when KVM fails to load are unhelpful
      in understanding exactly what went wrong if userspace probes the "wrong"
      module.
      
      Add a mandatory kvm_x86_ops field to track vendor module names, kvm_intel
      and kvm_amd, and use the name for relevant error message when KVM fails
      to load so that the user knows which module failed to load.
      
      Opportunistically tweak the "disabled by bios" error message to clarify
      that _support_ was disabled, not that the module itself was magically
      disabled by BIOS.
      Suggested-by: NPaul Menzel <pmenzel@molgen.mpg.de>
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20211018183929.897461-2-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      9dadfc4a
  7. 04 10月, 2021 1 次提交
  8. 01 10月, 2021 3 次提交
  9. 30 9月, 2021 2 次提交
  10. 23 9月, 2021 2 次提交
  11. 22 9月, 2021 3 次提交
  12. 21 8月, 2021 8 次提交
  13. 16 8月, 2021 1 次提交
  14. 13 8月, 2021 1 次提交
  15. 02 8月, 2021 7 次提交