1. 04 2月, 2021 17 次提交
    • J
      KVM: x86/xen: register vcpu info · 73e69a86
      Joao Martins 提交于
      The vcpu info supersedes the per vcpu area of the shared info page and
      the guest vcpus will use this instead.
      Signed-off-by: NJoao Martins <joao.m.martins@oracle.com>
      Signed-off-by: NAnkur Arora <ankur.a.arora@oracle.com>
      Signed-off-by: NDavid Woodhouse <dwmw@amazon.co.uk>
      73e69a86
    • D
      xen: add wc_sec_hi to struct shared_info · 42387042
      David Woodhouse 提交于
      Xen added this in 2015 (Xen 4.6). On x86_64 and Arm it fills what was
      previously a 32-bit hole in the generic shared_info structure; on
      i386 it had to go at the end of struct arch_shared_info.
      Signed-off-by: NDavid Woodhouse <dwmw@amazon.co.uk>
      42387042
    • J
      KVM: x86/xen: register shared_info page · 13ffb97a
      Joao Martins 提交于
      Add KVM_XEN_ATTR_TYPE_SHARED_INFO to allow hypervisor to know where the
      guest's shared info page is.
      Signed-off-by: NJoao Martins <joao.m.martins@oracle.com>
      Signed-off-by: NDavid Woodhouse <dwmw@amazon.co.uk>
      13ffb97a
    • D
      a3833b81
    • J
      KVM: x86/xen: intercept xen hypercalls if enabled · 23200b7a
      Joao Martins 提交于
      Add a new exit reason for emulator to handle Xen hypercalls.
      
      Since this means KVM owns the ABI, dispense with the facility for the
      VMM to provide its own copy of the hypercall pages; just fill them in
      directly using VMCALL/VMMCALL as we do for the Hyper-V hypercall page.
      
      This behaviour is enabled by a new INTERCEPT_HCALL flag in the
      KVM_XEN_HVM_CONFIG ioctl structure, and advertised by the same flag
      being returned from the KVM_CAP_XEN_HVM check.
      
      Rename xen_hvm_config() to kvm_xen_write_hypercall_page() and move it
      to the nascent xen.c while we're at it, and add a test case.
      Signed-off-by: NJoao Martins <joao.m.martins@oracle.com>
      Signed-off-by: NDavid Woodhouse <dwmw@amazon.co.uk>
      23200b7a
    • B
      KVM: x86/mmu: Use atomic ops to set SPTEs in TDP MMU map · 9a77daac
      Ben Gardon 提交于
      To prepare for handling page faults in parallel, change the TDP MMU
      page fault handler to use atomic operations to set SPTEs so that changes
      are not lost if multiple threads attempt to modify the same SPTE.
      Reviewed-by: NPeter Feiner <pfeiner@google.com>
      Signed-off-by: NBen Gardon <bgardon@google.com>
      
      Message-Id: <20210202185734.1680553-21-bgardon@google.com>
      [Document new locking rules. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      9a77daac
    • B
      KVM: x86/mmu: Use an rwlock for the x86 MMU · 531810ca
      Ben Gardon 提交于
      Add a read / write lock to be used in place of the MMU spinlock on x86.
      The rwlock will enable the TDP MMU to handle page faults, and other
      operations in parallel in future commits.
      Reviewed-by: NPeter Feiner <pfeiner@google.com>
      Signed-off-by: NBen Gardon <bgardon@google.com>
      
      Message-Id: <20210202185734.1680553-19-bgardon@google.com>
      [Introduce virt/kvm/mmu_lock.h - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      531810ca
    • S
      KVM: VMX: Use the kernel's version of VMXOFF · 6a289139
      Sean Christopherson 提交于
      Drop kvm_cpu_vmxoff() in favor of the kernel's cpu_vmxoff().  Modify the
      latter to return -EIO on fault so that KVM can invoke
      kvm_spurious_fault() when appropriate.  In addition to the obvious code
      reuse, dropping kvm_cpu_vmxoff() also eliminates VMX's last usage of the
      __ex()/__kvm_handle_fault_on_reboot() macros, thus helping pave the way
      toward dropping them entirely.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20201231002702.22237077-7-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      6a289139
    • D
      x86/virt: Mark flags and memory as clobbered by VMXOFF · 53666664
      David P. Reed 提交于
      Explicitly tell the compiler that VMXOFF modifies flags (like all VMX
      instructions), and mark memory as clobbered since VMXOFF must not be
      reordered and also may have memory side effects (though the kernel
      really shouldn't be accessing the root VMCS anyways).
      
      Practically speaking, adding the clobbers is most likely a nop; the
      primary motivation is to properly document VMXOFF's behavior.
      
      For the flags clobber, both Clang and GCC automatically mark flags as
      clobbered; this is noted in commit 4b1e5478 ("KVM/x86: Use assembly
      instruction mnemonics instead of .byte streams"), which intentionally
      removed the previous clobber.  But, neither Clang nor GCC documents
      this behavior, and there's no downside to including the clobber.
      
      For the memory clobber, the RFLAGS.IF and CR4.VMXE manipulations that
      immediately follow VMXOFF have compiler barriers of their own, i.e.
      VMXOFF can't get reordered after clearing CR4.VMXE, which is really
      what's of interest.
      
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Signed-off-by: NDavid P. Reed <dpreed@deepplum.com>
      [sean: rewrote changelog, dropped comment adjustments]
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20201231002702.22237077-4-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      53666664
    • S
      x86/virt: Eat faults on VMXOFF in reboot flows · aec511ad
      Sean Christopherson 提交于
      Silently ignore all faults on VMXOFF in the reboot flows as such faults
      are all but guaranteed to be due to the CPU not being in VMX root.
      Because (a) VMXOFF may be executed in NMI context, e.g. after VMXOFF but
      before CR4.VMXE is cleared, (b) there's no way to query the CPU's VMX
      state without faulting, and (c) the whole point is to get out of VMX
      root, eating faults is the simplest way to achieve the desired behaior.
      
      Technically, VMXOFF can fault (or fail) for other reasons, but all other
      fault and failure scenarios are mode related, i.e. the kernel would have
      to magically end up in RM, V86, compat mode, at CPL>0, or running with
      the SMI Transfer Monitor active.  The kernel is beyond hosed if any of
      those scenarios are encountered; trying to do something fancy in the
      error path to handle them cleanly is pointless.
      
      Fixes: 1e993114 ("x86: asm/virtext.h: add cpu_vmxoff() inline function")
      Reported-by: NDavid P. Reed <dpreed@deepplum.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20201231002702.22237077-2-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      aec511ad
    • J
      KVM: x86: use static calls to reduce kvm_x86_ops overhead · b3646477
      Jason Baron 提交于
      Convert kvm_x86_ops to use static calls. Note that all kvm_x86_ops are
      covered here except for 'pmu_ops and 'nested ops'.
      
      Here are some numbers running cpuid in a loop of 1 million calls averaged
      over 5 runs, measured in the vm (lower is better).
      
      Intel Xeon 3000MHz:
      
                 |default    |mitigations=off
      -------------------------------------
      vanilla    |.671s      |.486s
      static call|.573s(-15%)|.458s(-6%)
      
      AMD EPYC 2500MHz:
      
                 |default    |mitigations=off
      -------------------------------------
      vanilla    |.710s      |.609s
      static call|.664s(-6%) |.609s(0%)
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Signed-off-by: NJason Baron <jbaron@akamai.com>
      Message-Id: <e057bf1b8a7ad15652df6eeba3f907ae758d3399.1610680941.git.jbaron@akamai.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b3646477
    • J
      KVM: x86: introduce definitions to support static calls for kvm_x86_ops · 9af5471b
      Jason Baron 提交于
      Use static calls to improve kvm_x86_ops performance. Introduce the
      definitions that will be used by a subsequent patch to actualize the
      savings. Add a new kvm-x86-ops.h header that can be used for the
      definition of static calls. This header is also intended to be
      used to simplify the defition of svm_kvm_ops and vmx_x86_ops.
      
      Note that all functions in kvm_x86_ops are covered here except for
      'pmu_ops' and 'nested ops'. I think they can be covered by static
      calls in a simlilar manner, but were omitted from this series to
      reduce scope and because I don't think they have as large of a
      performance impact.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Signed-off-by: NJason Baron <jbaron@akamai.com>
      Message-Id: <e5cc82ead7ab37b2dceb0837a514f3f8bea4f8d1.1610680941.git.jbaron@akamai.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      9af5471b
    • W
      KVM: SVM: Add support for SVM instruction address check change · 3b9c723e
      Wei Huang 提交于
      New AMD CPUs have a change that checks #VMEXIT intercept on special SVM
      instructions before checking their EAX against reserved memory region.
      This change is indicated by CPUID_0x8000000A_EDX[28]. If it is 1, #VMEXIT
      is triggered before #GP. KVM doesn't need to intercept and emulate #GP
      faults as #GP is supposed to be triggered.
      Co-developed-by: NBandan Das <bsd@redhat.com>
      Signed-off-by: NBandan Das <bsd@redhat.com>
      Signed-off-by: NWei Huang <wei.huang2@amd.com>
      Reviewed-by: NMaxim Levitsky <mlevitsk@redhat.com>
      Message-Id: <20210126081831.570253-4-wei.huang2@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      3b9c723e
    • C
      KVM: X86: Rename DR6_INIT to DR6_ACTIVE_LOW · 9a3ecd5e
      Chenyi Qiang 提交于
      DR6_INIT contains the 1-reserved bits as well as the bit that is cleared
      to 0 when the condition (e.g. RTM) happens. The value can be used to
      initialize dr6 and also be the XOR mask between the #DB exit
      qualification (or payload) and DR6.
      
      Concerning that DR6_INIT is used as initial value only once, rename it
      to DR6_ACTIVE_LOW and apply it in other places, which would make the
      incoming changes for bus lock debug exception more simple.
      Signed-off-by: NChenyi Qiang <chenyi.qiang@intel.com>
      Message-Id: <20210202090433.13441-2-chenyi.qiang@intel.com>
      [Define DR6_FIXED_1 from DR6_ACTIVE_LOW and DR6_VOLATILE. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      9a3ecd5e
    • C
      KVM: VMX: Enable bus lock VM exit · fe6b6bc8
      Chenyi Qiang 提交于
      Virtual Machine can exploit bus locks to degrade the performance of
      system. Bus lock can be caused by split locked access to writeback(WB)
      memory or by using locks on uncacheable(UC) memory. The bus lock is
      typically >1000 cycles slower than an atomic operation within a cache
      line. It also disrupts performance on other cores (which must wait for
      the bus lock to be released before their memory operations can
      complete).
      
      To address the threat, bus lock VM exit is introduced to notify the VMM
      when a bus lock was acquired, allowing it to enforce throttling or other
      policy based mitigations.
      
      A VMM can enable VM exit due to bus locks by setting a new "Bus Lock
      Detection" VM-execution control(bit 30 of Secondary Processor-based VM
      execution controls). If delivery of this VM exit was preempted by a
      higher priority VM exit (e.g. EPT misconfiguration, EPT violation, APIC
      access VM exit, APIC write VM exit, exception bitmap exiting), bit 26 of
      exit reason in vmcs field is set to 1.
      
      In current implementation, the KVM exposes this capability through
      KVM_CAP_X86_BUS_LOCK_EXIT. The user can get the supported mode bitmap
      (i.e. off and exit) and enable it explicitly (disabled by default). If
      bus locks in guest are detected by KVM, exit to user space even when
      current exit reason is handled by KVM internally. Set a new field
      KVM_RUN_BUS_LOCK in vcpu->run->flags to inform the user space that there
      is a bus lock detected in guest.
      
      Document for Bus Lock VM exit is now available at the latest "Intel
      Architecture Instruction Set Extensions Programming Reference".
      
      Document Link:
      https://software.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.htmlCo-developed-by: NXiaoyao Li <xiaoyao.li@intel.com>
      Signed-off-by: NXiaoyao Li <xiaoyao.li@intel.com>
      Signed-off-by: NChenyi Qiang <chenyi.qiang@intel.com>
      Message-Id: <20201106090315.18606-4-chenyi.qiang@intel.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      fe6b6bc8
    • S
      KVM: x86/mmu: Remove the defunct update_pte() paging hook · c5e2184d
      Sean Christopherson 提交于
      Remove the update_pte() shadow paging logic, which was obsoleted by
      commit 4731d4c7 ("KVM: MMU: out of sync shadow core"), but never
      removed.  As pointed out by Yu, KVM never write protects leaf page
      tables for the purposes of shadow paging, and instead marks their
      associated shadow page as unsync so that the guest can write PTEs at
      will.
      
      The update_pte() path, which predates the unsync logic, optimizes COW
      scenarios by refreshing leaf SPTEs when they are written, as opposed to
      zapping the SPTE, restarting the guest, and installing the new SPTE on
      the subsequent fault.  Since KVM no longer write-protects leaf page
      tables, update_pte() is unreachable and can be dropped.
      Reported-by: NYu Zhang <yu.c.zhang@intel.com>
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210115004051.4099250-1-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c5e2184d
    • K
      Enumerate AVX Vector Neural Network instructions · b85a0425
      Kyung Min Park 提交于
      Add AVX version of the Vector Neural Network (VNNI) Instructions.
      
      A processor supports AVX VNNI instructions if CPUID.0x07.0x1:EAX[4] is
      present. The following instructions are available when this feature is
      present.
        1. VPDPBUS: Multiply and Add Unsigned and Signed Bytes
        2. VPDPBUSDS: Multiply and Add Unsigned and Signed Bytes with Saturation
        3. VPDPWSSD: Multiply and Add Signed Word Integers
        4. VPDPWSSDS: Multiply and Add Signed Integers with Saturation
      
      The only in-kernel usage of this is kvm passthrough. The CPU feature
      flag is shown as "avx_vnni" in /proc/cpuinfo.
      
      This instruction is currently documented in the latest "extensions"
      manual (ISE). It will appear in the "main" manual (SDM) in the future.
      Signed-off-by: NKyung Min Park <kyung.min.park@intel.com>
      Signed-off-by: NYang Zhong <yang.zhong@intel.com>
      Reviewed-by: NTony Luck <tony.luck@intel.com>
      Message-Id: <20210105004909.42000-2-yang.zhong@intel.com>
      Acked-by: NBorislav Petkov <bp@suse.de>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b85a0425
  2. 08 1月, 2021 2 次提交
    • T
      KVM: SVM: Add support for booting APs in an SEV-ES guest · 647daca2
      Tom Lendacky 提交于
      Typically under KVM, an AP is booted using the INIT-SIPI-SIPI sequence,
      where the guest vCPU register state is updated and then the vCPU is VMRUN
      to begin execution of the AP. For an SEV-ES guest, this won't work because
      the guest register state is encrypted.
      
      Following the GHCB specification, the hypervisor must not alter the guest
      register state, so KVM must track an AP/vCPU boot. Should the guest want
      to park the AP, it must use the AP Reset Hold exit event in place of, for
      example, a HLT loop.
      
      First AP boot (first INIT-SIPI-SIPI sequence):
        Execute the AP (vCPU) as it was initialized and measured by the SEV-ES
        support. It is up to the guest to transfer control of the AP to the
        proper location.
      
      Subsequent AP boot:
        KVM will expect to receive an AP Reset Hold exit event indicating that
        the vCPU is being parked and will require an INIT-SIPI-SIPI sequence to
        awaken it. When the AP Reset Hold exit event is received, KVM will place
        the vCPU into a simulated HLT mode. Upon receiving the INIT-SIPI-SIPI
        sequence, KVM will make the vCPU runnable. It is again up to the guest
        to then transfer control of the AP to the proper location.
      
        To differentiate between an actual HLT and an AP Reset Hold, a new MP
        state is introduced, KVM_MP_STATE_AP_RESET_HOLD, which the vCPU is
        placed in upon receiving the AP Reset Hold exit event. Additionally, to
        communicate the AP Reset Hold exit event up to userspace (if needed), a
        new exit reason is introduced, KVM_EXIT_AP_RESET_HOLD.
      
      A new x86 ops function is introduced, vcpu_deliver_sipi_vector, in order
      to accomplish AP booting. For VMX, vcpu_deliver_sipi_vector is set to the
      original SIPI delivery function, kvm_vcpu_deliver_sipi_vector(). SVM adds
      a new function that, for non SEV-ES guests, invokes the original SIPI
      delivery function, kvm_vcpu_deliver_sipi_vector(), but for SEV-ES guests,
      implements the logic above.
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      Message-Id: <e8fbebe8eb161ceaabdad7c01a5859a78b424d5e.1609791600.git.thomas.lendacky@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      647daca2
    • B
      KVM: x86/mmu: Clarify TDP MMU page list invariants · c0dba6e4
      Ben Gardon 提交于
      The tdp_mmu_roots and tdp_mmu_pages in struct kvm_arch should only contain
      pages with tdp_mmu_page set to true. tdp_mmu_pages should not contain any
      pages with a non-zero root_count and tdp_mmu_roots should only contain
      pages with a positive root_count, unless a thread holds the MMU lock and
      is in the process of modifying the list. Various functions expect these
      invariants to be maintained, but they are not explictily documented. Add
      to the comments on both fields to document the above invariants.
      Signed-off-by: NBen Gardon <bgardon@google.com>
      Message-Id: <20210107001935.3732070-2-bgardon@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c0dba6e4
  3. 30 12月, 2020 1 次提交
  4. 16 12月, 2020 2 次提交
  5. 15 12月, 2020 13 次提交
    • T
      KVM: SVM: Provide support for SEV-ES vCPU loading · 86137773
      Tom Lendacky 提交于
      An SEV-ES vCPU requires additional VMCB vCPU load/put requirements. SEV-ES
      hardware will restore certain registers on VMEXIT, but not save them on
      VMRUN (see Table B-3 and Table B-4 of the AMD64 APM Volume 2), so make the
      following changes:
      
      General vCPU load changes:
        - During vCPU loading, perform a VMSAVE to the per-CPU SVM save area and
          save the current values of XCR0, XSS and PKRU to the per-CPU SVM save
          area as these registers will be restored on VMEXIT.
      
      General vCPU put changes:
        - Do not attempt to restore registers that SEV-ES hardware has already
          restored on VMEXIT.
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      Message-Id: <019390e9cb5e93cd73014fa5a040c17d42588733.1607620209.git.thomas.lendacky@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      86137773
    • T
      KVM: SVM: Provide support for SEV-ES vCPU creation/loading · 376c6d28
      Tom Lendacky 提交于
      An SEV-ES vCPU requires additional VMCB initialization requirements for
      vCPU creation and vCPU load/put requirements. This includes:
      
      General VMCB initialization changes:
        - Set a VMCB control bit to enable SEV-ES support on the vCPU.
        - Set the VMCB encrypted VM save area address.
        - CRx registers are part of the encrypted register state and cannot be
          updated. Remove the CRx register read and write intercepts and replace
          them with CRx register write traps to track the CRx register values.
        - Certain MSR values are part of the encrypted register state and cannot
          be updated. Remove certain MSR intercepts (EFER, CR_PAT, etc.).
        - Remove the #GP intercept (no support for "enable_vmware_backdoor").
        - Remove the XSETBV intercept since the hypervisor cannot modify XCR0.
      
      General vCPU creation changes:
        - Set the initial GHCB gpa value as per the GHCB specification.
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      Message-Id: <3a8aef366416eddd5556dfa3fdc212aafa1ad0a2.1607620209.git.thomas.lendacky@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      376c6d28
    • T
      KVM: SVM: Guest FPU state save/restore not needed for SEV-ES guest · ed02b213
      Tom Lendacky 提交于
      The guest FPU state is automatically restored on VMRUN and saved on VMEXIT
      by the hardware, so there is no reason to do this in KVM. Eliminate the
      allocation of the guest_fpu save area and key off that to skip operations
      related to the guest FPU state.
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      Message-Id: <173e429b4d0d962c6a443c4553ffdaf31b7665a4.1607620209.git.thomas.lendacky@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      ed02b213
    • T
      KVM: SVM: Do not report support for SMM for an SEV-ES guest · 5719455f
      Tom Lendacky 提交于
      SEV-ES guests do not currently support SMM. Update the has_emulated_msr()
      kvm_x86_ops function to take a struct kvm parameter so that the capability
      can be reported at a VM level.
      
      Since this op is also called during KVM initialization and before a struct
      kvm instance is available, comments will be added to each implementation
      of has_emulated_msr() to indicate the kvm parameter can be null.
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      Message-Id: <75de5138e33b945d2fb17f81ae507bda381808e3.1607620209.git.thomas.lendacky@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      5719455f
    • T
      KVM: SVM: Add support for CR4 write traps for an SEV-ES guest · 5b51cb13
      Tom Lendacky 提交于
      For SEV-ES guests, the interception of control register write access
      is not recommended. Control register interception occurs prior to the
      control register being modified and the hypervisor is unable to modify
      the control register itself because the register is located in the
      encrypted register state.
      
      SEV-ES guests introduce new control register write traps. These traps
      provide intercept support of a control register write after the control
      register has been modified. The new control register value is provided in
      the VMCB EXITINFO1 field, allowing the hypervisor to track the setting
      of the guest control registers.
      
      Add support to track the value of the guest CR4 register using the control
      register write trap so that the hypervisor understands the guest operating
      mode.
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      Message-Id: <c3880bf2db8693aa26f648528fbc6e967ab46e25.1607620209.git.thomas.lendacky@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      5b51cb13
    • T
      KVM: SVM: Add support for CR0 write traps for an SEV-ES guest · f27ad38a
      Tom Lendacky 提交于
      For SEV-ES guests, the interception of control register write access
      is not recommended. Control register interception occurs prior to the
      control register being modified and the hypervisor is unable to modify
      the control register itself because the register is located in the
      encrypted register state.
      
      SEV-ES support introduces new control register write traps. These traps
      provide intercept support of a control register write after the control
      register has been modified. The new control register value is provided in
      the VMCB EXITINFO1 field, allowing the hypervisor to track the setting
      of the guest control registers.
      
      Add support to track the value of the guest CR0 register using the control
      register write trap so that the hypervisor understands the guest operating
      mode.
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      Message-Id: <182c9baf99df7e40ad9617ff90b84542705ef0d7.1607620209.git.thomas.lendacky@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f27ad38a
    • T
      KVM: SVM: Support string IO operations for an SEV-ES guest · 7ed9abfe
      Tom Lendacky 提交于
      For an SEV-ES guest, string-based port IO is performed to a shared
      (un-encrypted) page so that both the hypervisor and guest can read or
      write to it and each see the contents.
      
      For string-based port IO operations, invoke SEV-ES specific routines that
      can complete the operation using common KVM port IO support.
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      Message-Id: <9d61daf0ffda496703717218f415cdc8fd487100.1607620209.git.thomas.lendacky@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      7ed9abfe
    • T
      KVM: SVM: Add initial support for a VMGEXIT VMEXIT · 291bd20d
      Tom Lendacky 提交于
      SEV-ES adds a new VMEXIT reason code, VMGEXIT. Initial support for a
      VMGEXIT includes mapping the GHCB based on the guest GPA, which is
      obtained from a new VMCB field, and then validating the required inputs
      for the VMGEXIT exit reason.
      
      Since many of the VMGEXIT exit reasons correspond to existing VMEXIT
      reasons, the information from the GHCB is copied into the VMCB control
      exit code areas and KVM register areas. The standard exit handlers are
      invoked, similar to standard VMEXIT processing. Before restarting the
      vCPU, the GHCB is updated with any registers that have been updated by
      the hypervisor.
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      Message-Id: <c6a4ed4294a369bd75c44d03bd7ce0f0c3840e50.1607620209.git.thomas.lendacky@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      291bd20d
    • T
      KVM: SVM: Add required changes to support intercepts under SEV-ES · f1c6366e
      Tom Lendacky 提交于
      When a guest is running under SEV-ES, the hypervisor cannot access the
      guest register state. There are numerous places in the KVM code where
      certain registers are accessed that are not allowed to be accessed (e.g.
      RIP, CR0, etc). Add checks to prevent register accesses and add intercept
      update support at various points within the KVM code.
      
      Also, when handling a VMGEXIT, exceptions are passed back through the
      GHCB. Since the RDMSR/WRMSR intercepts (may) inject a #GP on error,
      update the SVM intercepts to handle this for SEV-ES guests.
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      [Redo MSR part using the .complete_emulated_msr callback. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f1c6366e
    • P
      KVM: x86: introduce complete_emulated_msr callback · f9a4d621
      Paolo Bonzini 提交于
      This will be used by SEV-ES to inject MSR failure via the GHCB.
      Reviewed-by: NTom Lendacky <thomas.lendacky@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f9a4d621
    • T
      KVM: SVM: Add support for the SEV-ES VMSA · add5e2f0
      Tom Lendacky 提交于
      Allocate a page during vCPU creation to be used as the encrypted VM save
      area (VMSA) for the SEV-ES guest. Provide a flag in the kvm_vcpu_arch
      structure that indicates whether the guest state is protected.
      
      When freeing a VMSA page that has been encrypted, the cache contents must
      be flushed using the MSR_AMD64_VM_PAGE_FLUSH before freeing the page.
      
      [ i386 build warnings ]
      Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      Message-Id: <fde272b17eec804f3b9db18c131262fe074015c5.1607620209.git.thomas.lendacky@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      add5e2f0
    • T
      KVM: SVM: Add GHCB accessor functions for retrieving fields · 0f60bde1
      Tom Lendacky 提交于
      Update the GHCB accessor functions to add functions for retrieve GHCB
      fields by name. Update existing code to use the new accessor functions.
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      Message-Id: <664172c53a5fb4959914e1a45d88e805649af0ad.1607620209.git.thomas.lendacky@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      0f60bde1
    • T
      x86/cpu: Add VM page flush MSR availablility as a CPUID feature · 69372cf0
      Tom Lendacky 提交于
      On systems that do not have hardware enforced cache coherency between
      encrypted and unencrypted mappings of the same physical page, the
      hypervisor can use the VM page flush MSR (0xc001011e) to flush the cache
      contents of an SEV guest page. When a small number of pages are being
      flushed, this can be used in place of issuing a WBINVD across all CPUs.
      
      CPUID 0x8000001f_eax[2] is used to determine if the VM page flush MSR is
      available. Add a CPUID feature to indicate it is supported and define the
      MSR.
      Signed-off-by: NTom Lendacky <thomas.lendacky@amd.com>
      Message-Id: <f1966379e31f9b208db5257509c4a089a87d33d0.1607620209.git.thomas.lendacky@amd.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      69372cf0
  6. 12 12月, 2020 2 次提交
  7. 11 12月, 2020 1 次提交
  8. 10 12月, 2020 1 次提交
  9. 09 12月, 2020 1 次提交