1. 26 11月, 2021 2 次提交
    • S
      KVM: nVMX: Abide to KVM_REQ_TLB_FLUSH_GUEST request on nested vmentry/vmexit · 40e5f908
      Sean Christopherson 提交于
      Like KVM_REQ_TLB_FLUSH_CURRENT, the GUEST variant needs to be serviced at
      nested transitions, as KVM doesn't track requests for L1 vs L2.  E.g. if
      there's a pending flush when a nested VM-Exit occurs, then the flush was
      requested in the context of L2 and needs to be handled before switching
      to L1, otherwise the flush for L2 would effectiely be lost.
      
      Opportunistically add a helper to handle CURRENT and GUEST as a pair, the
      logic for when they need to be serviced is identical as both requests are
      tied to L1 vs. L2, the only difference is the scope of the flush.
      Reported-by: NLai Jiangshan <jiangshanlai+lkml@gmail.com>
      Fixes: 07ffaf34 ("KVM: nVMX: Sync all PGDs on nested transition with shadow paging")
      Cc: stable@vger.kernel.org
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20211125014944.536398-2-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      40e5f908
    • P
      KVM: VMX: do not use uninitialized gfn_to_hva_cache · 8503fea6
      Paolo Bonzini 提交于
      An uninitialized gfn_to_hva_cache has ghc->len == 0, which causes
      the accessors to croak very loudly.  While a BUG_ON is definitely
      _too_ loud and a bug on its own, there is indeed an issue of using
      the caches in such a way that they could not have been initialized,
      because ghc->gpa == 0 might match and thus kvm_gfn_to_hva_cache_init
      would not be called.
      
      For the vmcs12_cache, the solution is simply to invoke
      kvm_gfn_to_hva_cache_init unconditionally: we already know
      that the cache does not match the current VMCS pointer.
      For the shadow_vmcs12_cache, there is no similar condition
      that checks the VMCS link pointer, so invalidate the cache
      on VMXON.
      
      Fixes: cee66664 ("KVM: nVMX: Use a gfn_to_hva_cache for vmptrld")
      Acked-by: NDavid Woodhouse <dwmw@amazon.co.uk>
      Reported-by: syzbot+7b7db8bb4db6fd5e157b@syzkaller.appspotmail.com
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      8503fea6
  2. 18 11月, 2021 4 次提交
  3. 11 11月, 2021 3 次提交
    • V
      KVM: VMX: Add a helper function to retrieve the GPR index for INVPCID, INVVPID, and INVEPT · 329bd56c
      Vipin Sharma 提交于
      handle_invept(), handle_invvpid(), handle_invpcid() read the same reg2
      field in vmcs.VMX_INSTRUCTION_INFO to get the index of the GPR that
      holds the invalidation type. Add a helper to retrieve reg2 from VMX
      instruction info to consolidate and document the shift+mask magic.
      Signed-off-by: NVipin Sharma <vipinsh@google.com>
      Reviewed-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20211109174426.2350547-2-vipinsh@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      329bd56c
    • S
      KVM: nVMX: Clean up x2APIC MSR handling for L2 · a5e0c252
      Sean Christopherson 提交于
      Clean up the x2APIC MSR bitmap intereption code for L2, which is the last
      holdout of open coded bitmap manipulations.  Freshen up the SDM/PRM
      comment, rename the function to make it abundantly clear the funky
      behavior is x2APIC specific, and explain _why_ vmcs01's bitmap is ignored
      (the previous comment was flat out wrong for x2APIC behavior).
      
      No functional change intended.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20211109013047.2041518-5-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      a5e0c252
    • S
      KVM: nVMX: Handle dynamic MSR intercept toggling · 67f4b996
      Sean Christopherson 提交于
      Always check vmcs01's MSR bitmap when merging L0 and L1 bitmaps for L2,
      and always update the relevant bits in vmcs02.  This fixes two distinct,
      but intertwined bugs related to dynamic MSR bitmap modifications.
      
      The first issue is that KVM fails to enable MSR interception in vmcs02
      for the FS/GS base MSRs if L1 first runs L2 with interception disabled,
      and later enables interception.
      
      The second issue is that KVM fails to honor userspace MSR filtering when
      preparing vmcs02.
      
      Fix both issues simultaneous as fixing only one of the issues (doesn't
      matter which) would create a mess that no one should have to bisect.
      Fixing only the first bug would exacerbate the MSR filtering issue as
      userspace would see inconsistent behavior depending on the whims of L1.
      Fixing only the second bug (MSR filtering) effectively requires fixing
      the first, as the nVMX code only knows how to transition vmcs02's
      bitmap from 1->0.
      
      Move the various accessor/mutators that are currently buried in vmx.c
      into vmx.h so that they can be shared by the nested code.
      
      Fixes: 1a155254 ("KVM: x86: Introduce MSR filtering")
      Fixes: d69129b4 ("KVM: nVMX: Disable intercept for FS/GS base MSRs in vmcs02 when possible")
      Cc: stable@vger.kernel.org
      Cc: Alexander Graf <graf@amazon.com>
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20211109013047.2041518-3-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      67f4b996
  4. 25 10月, 2021 1 次提交
  5. 30 9月, 2021 2 次提交
  6. 22 9月, 2021 4 次提交
  7. 13 8月, 2021 4 次提交
    • S
      KVM: nVMX: Unconditionally clear nested.pi_pending on nested VM-Enter · f7782bb8
      Sean Christopherson 提交于
      Clear nested.pi_pending on nested VM-Enter even if L2 will run without
      posted interrupts enabled.  If nested.pi_pending is left set from a
      previous L2, vmx_complete_nested_posted_interrupt() will pick up the
      stale flag and exit to userspace with an "internal emulation error" due
      the new L2 not having a valid nested.pi_desc.
      
      Arguably, vmx_complete_nested_posted_interrupt() should first check for
      posted interrupts being enabled, but it's also completely reasonable that
      KVM wouldn't screw up a fundamental flag.  Not to mention that the mere
      existence of nested.pi_pending is a long-standing bug as KVM shouldn't
      move the posted interrupt out of the IRR until it's actually processed,
      e.g. KVM effectively drops an interrupt when it performs a nested VM-Exit
      with a "pending" posted interrupt.  Fixing the mess is a future problem.
      
      Prior to vmx_complete_nested_posted_interrupt() interpreting a null PI
      descriptor as an error, this was a benign bug as the null PI descriptor
      effectively served as a check on PI not being enabled.  Even then, the
      new flow did not become problematic until KVM started checking the result
      of kvm_check_nested_events().
      
      Fixes: 705699a1 ("KVM: nVMX: Enable nested posted interrupt processing")
      Fixes: 966eefb8 ("KVM: nVMX: Disable vmcs02 posted interrupts if vmcs12 PID isn't mappable")
      Fixes: 47d3530f86c0 ("KVM: x86: Exit to userspace when kvm_check_nested_events fails")
      Cc: stable@vger.kernel.org
      Cc: Jim Mattson <jmattson@google.com>
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210810144526.2662272-1-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f7782bb8
    • S
      KVM: nVMX: Pull KVM L0's desired controls directly from vmcs01 · 389ab252
      Sean Christopherson 提交于
      When preparing controls for vmcs02, grab KVM's desired controls from
      vmcs01's shadow state instead of recalculating the controls from scratch,
      or in the secondary execution controls, instead of using the dedicated
      cache.  Calculating secondary exec controls is eye-poppingly expensive
      due to the guest CPUID checks, hence the dedicated cache, but the other
      calculations aren't exactly free either.
      
      Explicitly clear several bits (x2APIC, DESC exiting, and load EFER on
      exit) as appropriate as they may be set in vmcs01, whereas the previous
      implementation relied on dynamic bits being cleared in the calculator.
      
      Intentionally propagate VM_{ENTRY,EXIT}_LOAD_IA32_PERF_GLOBAL_CTRL from
      vmcs01 to vmcs02.  Whether or not PERF_GLOBAL_CTRL is loaded depends on
      whether or not perf itself is active, so unless perf stops between the
      exit from L1 and entry to L2, vmcs01 will hold the desired value.  This
      is purely an optimization as atomic_switch_perf_msrs() will set/clear
      the control as needed at VM-Enter, i.e. it avoids two extra VMWRITEs in
      the case where perf is active (versus starting with the bits clear in
      vmcs02, which was the previous behavior).
      
      Cc: Zeng Guang <guang.zeng@intel.com>
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210810171952.2758100-3-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      389ab252
    • S
      KVM: nVMX: Use vmx_need_pf_intercept() when deciding if L0 wants a #PF · 18712c13
      Sean Christopherson 提交于
      Use vmx_need_pf_intercept() when determining if L0 wants to handle a #PF
      in L2 or if the VM-Exit should be forwarded to L1.  The current logic fails
      to account for the case where #PF is intercepted to handle
      guest.MAXPHYADDR < host.MAXPHYADDR and ends up reflecting all #PFs into
      L1.  At best, L1 will complain and inject the #PF back into L2.  At
      worst, L1 will eat the unexpected fault and cause L2 to hang on infinite
      page faults.
      
      Note, while the bug was technically introduced by the commit that added
      support for the MAXPHYADDR madness, the shame is all on commit
      a0c13434 ("KVM: VMX: introduce vmx_need_pf_intercept").
      
      Fixes: 1dbf5d68 ("KVM: VMX: Add guest physical address check in EPT violation and misconfig")
      Cc: stable@vger.kernel.org
      Cc: Peter Shier <pshier@google.com>
      Cc: Oliver Upton <oupton@google.com>
      Cc: Jim Mattson <jmattson@google.com>
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210812045615.3167686-1-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      18712c13
    • J
      kvm: vmx: Sync all matching EPTPs when injecting nested EPT fault · 85aa8889
      Junaid Shahid 提交于
      When a nested EPT violation/misconfig is injected into the guest,
      the shadow EPT PTEs associated with that address need to be synced.
      This is done by kvm_inject_emulated_page_fault() before it calls
      nested_ept_inject_page_fault(). However, that will only sync the
      shadow EPT PTE associated with the current L1 EPTP. Since the ASID
      is based on EP4TA rather than the full EPTP, so syncing the current
      EPTP is not enough. The SPTEs associated with any other L1 EPTPs
      in the prev_roots cache with the same EP4TA also need to be synced.
      Signed-off-by: NJunaid Shahid <junaids@google.com>
      Message-Id: <20210806222229.1645356-1-junaids@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      85aa8889
  8. 02 8月, 2021 3 次提交
  9. 25 6月, 2021 1 次提交
  10. 24 6月, 2021 1 次提交
  11. 22 6月, 2021 1 次提交
  12. 18 6月, 2021 14 次提交
    • S
      KVM: nVMX: Drop redundant checks on vmcs12 in EPTP switching emulation · c5ffd408
      Sean Christopherson 提交于
      Drop the explicit check on EPTP switching being enabled.  The EPTP
      switching check is handled in the generic VMFUNC function check, while
      the underlying VMFUNC enablement check is done by hardware and redone
      by generic VMFUNC emulation.
      
      The vmcs12 EPT check is handled by KVM at VM-Enter in the form of a
      consistency check, keep it but add a WARN.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210609234235.1244004-16-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c5ffd408
    • S
      KVM: nVMX: WARN if subtly-impossible VMFUNC conditions occur · 546e8398
      Sean Christopherson 提交于
      WARN and inject #UD when emulating VMFUNC for L2 if the function is
      out-of-bounds or if VMFUNC is not enabled in vmcs12.  Neither condition
      should occur in practice, as the CPU is supposed to prioritize the #UD
      over VM-Exit for out-of-bounds input and KVM is supposed to enable
      VMFUNC in vmcs02 if and only if it's enabled in vmcs12, but neither of
      those dependencies is obvious.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210609234235.1244004-15-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      546e8398
    • S
      KVM: x86: Drop pointless @reset_roots from kvm_init_mmu() · c9060662
      Sean Christopherson 提交于
      Remove the @reset_roots param from kvm_init_mmu(), the one user,
      kvm_mmu_reset_context() has already unloaded the MMU and thus freed and
      invalidated all roots.  This also happens to be why the reset_roots=true
      paths doesn't leak roots; they're already invalid.
      
      No functional change intended.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210609234235.1244004-14-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c9060662
    • S
      KVM: nVMX: Use fast PGD switch when emulating VMFUNC[EPTP_SWITCH] · 39353ab5
      Sean Christopherson 提交于
      Use __kvm_mmu_new_pgd() via kvm_init_shadow_ept_mmu() to emulate
      VMFUNC[EPTP_SWITCH] instead of nuking all MMUs.  EPTP_SWITCH is the EPT
      equivalent of MOV to CR3, i.e. is a perfect fit for the common PGD flow,
      the only hiccup being that A/D enabling is buried in the EPTP.  But, that
      is easily handled by bouncing through kvm_init_shadow_ept_mmu().
      
      Explicitly request a guest TLB flush if VPID is disabled.  Per Intel's
      SDM, if VPID is disabled, "an EPTP-switching VMFUNC invalidates combined
      mappings associated with VPID 0000H (for all PCIDs and for all EP4TA
      values, where EP4TA is the value of bits 51:12 of EPTP)".
      
      Note, this technically is a very bizarre bug fix of sorts if L2 is using
      PAE paging, as avoiding the full MMU reload also avoids incorrectly
      reloading the PDPTEs, which the SDM explicitly states are not touched:
      
        If PAE paging is in use, an EPTP-switching VMFUNC does not load the
        four page-directory-pointer-table entries (PDPTEs) from the
        guest-physical address in CR3. The logical processor continues to use
        the four guest-physical addresses already present in the PDPTEs. The
        guest-physical address in CR3 is not translated through the new EPT
        paging structures (until some operation that would load the PDPTEs).
      
      In addition to optimizing L2's MMU shenanigans, avoiding the full reload
      also optimizes L1's MMU as KVM_REQ_MMU_RELOAD wipes out all roots in both
      root_mmu and guest_mmu.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210609234235.1244004-12-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      39353ab5
    • S
      KVM: nVMX: Free only guest_mode (L2) roots on INVVPID w/o EPT · 25b62c62
      Sean Christopherson 提交于
      When emulating INVVPID for L1, free only L2+ roots, using the guest_mode
      tag in the MMU role to identify L2+ roots.  From L1's perspective, its
      own TLB entries use VPID=0, and INVVPID is not requied to invalidate such
      entries.  Per Intel's SDM, INVVPID _may_ invalidate entries with VPID=0,
      but it is not required to do so.
      
      Cc: Lai Jiangshan <laijs@linux.alibaba.com>
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210609234235.1244004-10-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      25b62c62
    • S
      KVM: nVMX: Consolidate VM-Enter/VM-Exit TLB flush and MMU sync logic · 50a41796
      Sean Christopherson 提交于
      Drop the dedicated nested_vmx_transition_mmu_sync() now that the MMU sync
      is handled via KVM_REQ_TLB_FLUSH_GUEST, and fold that flush into the
      all-encompassing nested_vmx_transition_tlb_flush().
      
      Opportunistically add a comment explaning why nested EPT never needs to
      sync the MMU on VM-Enter.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210609234235.1244004-9-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      50a41796
    • S
      KVM: x86: Drop skip MMU sync and TLB flush params from "new PGD" helpers · b5129100
      Sean Christopherson 提交于
      Drop skip_mmu_sync and skip_tlb_flush from __kvm_mmu_new_pgd() now that
      all call sites unconditionally skip both the sync and flush.
      
      No functional change intended.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210609234235.1244004-8-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b5129100
    • S
      KVM: nVMX: Don't clobber nested MMU's A/D status on EPTP switch · 272b0a99
      Sean Christopherson 提交于
      Drop bogus logic that incorrectly clobbers the accessed/dirty enabling
      status of the nested MMU on an EPTP switch.  When nested EPT is enabled,
      walk_mmu points at L2's _legacy_ page tables, not L1's EPT for L2.
      
      This is likely a benign bug, as mmu->ept_ad is never consumed (since the
      MMU is not a nested EPT MMU), and stuffing mmu_role.base.ad_disabled will
      never propagate into future shadow pages since the nested MMU isn't used
      to map anything, just to walk L2's page tables.
      
      Note, KVM also does a full MMU reload, i.e. the guest_mmu will be
      recreated using the new EPTP, and thus any change in A/D enabling will be
      properly recognized in the relevant MMU.
      
      Fixes: 41ab9372 ("KVM: nVMX: Emulate EPTP switching for the L1 hypervisor")
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210609234235.1244004-4-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      272b0a99
    • S
      KVM: nVMX: Ensure 64-bit shift when checking VMFUNC bitmap · 0e75225d
      Sean Christopherson 提交于
      Use BIT_ULL() instead of an open-coded shift to check whether or not a
      function is enabled in L1's VMFUNC bitmap.  This is a benign bug as KVM
      supports only bit 0, and will fail VM-Enter if any other bits are set,
      i.e. bits 63:32 are guaranteed to be zero.
      
      Note, "function" is bounded by hardware as VMFUNC will #UD before taking
      a VM-Exit if the function is greater than 63.
      
      Before:
        if ((vmcs12->vm_function_control & (1 << function)) == 0)
         0x000000000001a916 <+118>:	mov    $0x1,%eax
         0x000000000001a91b <+123>:	shl    %cl,%eax
         0x000000000001a91d <+125>:	cltq
         0x000000000001a91f <+127>:	and    0x128(%rbx),%rax
      
      After:
        if (!(vmcs12->vm_function_control & BIT_ULL(function & 63)))
         0x000000000001a955 <+117>:	mov    0x128(%rbx),%rdx
         0x000000000001a95c <+124>:	bt     %rax,%rdx
      
      Fixes: 27c42a1b ("KVM: nVMX: Enable VMFUNC for the L1 hypervisor")
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210609234235.1244004-3-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      0e75225d
    • S
      KVM: nVMX: Sync all PGDs on nested transition with shadow paging · 07ffaf34
      Sean Christopherson 提交于
      Trigger a full TLB flush on behalf of the guest on nested VM-Enter and
      VM-Exit when VPID is disabled for L2.  kvm_mmu_new_pgd() syncs only the
      current PGD, which can theoretically leave stale, unsync'd entries in a
      previous guest PGD, which could be consumed if L2 is allowed to load CR3
      with PCID_NOFLUSH=1.
      
      Rename KVM_REQ_HV_TLB_FLUSH to KVM_REQ_TLB_FLUSH_GUEST so that it can
      be utilized for its obvious purpose of emulating a guest TLB flush.
      
      Note, there is no change the actual TLB flush executed by KVM, even
      though the fast PGD switch uses KVM_REQ_TLB_FLUSH_CURRENT.  When VPID is
      disabled for L2, vpid02 is guaranteed to be '0', and thus
      nested_get_vpid02() will return the VPID that is shared by L1 and L2.
      
      Generate the request outside of kvm_mmu_new_pgd(), as getting the common
      helper to correctly identify which requested is needed is quite painful.
      E.g. using KVM_REQ_TLB_FLUSH_GUEST when nested EPT is in play is wrong as
      a TLB flush from the L1 kernel's perspective does not invalidate EPT
      mappings.  And, by using KVM_REQ_TLB_FLUSH_GUEST, nVMX can do future
      simplification by moving the logic into nested_vmx_transition_tlb_flush().
      
      Fixes: 41fab65e ("KVM: nVMX: Skip MMU sync on nested VMX transition when possible")
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20210609234235.1244004-2-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      07ffaf34
    • V
      KVM: nVMX: Request to sync eVMCS from VMCS12 after migration · 8629b625
      Vitaly Kuznetsov 提交于
      VMCS12 is used to keep the authoritative state during nested state
      migration. In case 'need_vmcs12_to_shadow_sync' flag is set, we're
      in between L2->L1 vmexit and L1 guest run when actual sync to
      enlightened (or shadow) VMCS happens. Nested state, however, has
      no flag for 'need_vmcs12_to_shadow_sync' so vmx_set_nested_state()->
      set_current_vmptr() always sets it. Enlightened vmptrld path, however,
      doesn't have the quirk so some VMCS12 changes may not get properly
      reflected to eVMCS and L1 will see an incorrect state.
      
      Note, during L2 execution or when need_vmcs12_to_shadow_sync is not
      set the change is effectively a nop: in the former case all changes
      will get reflected during the first L2->L1 vmexit and in the later
      case VMCS12 and eVMCS are already in sync (thanks to
      copy_enlightened_to_vmcs12() in vmx_get_nested_state()).
      Reviewed-by: NMaxim Levitsky <mlevitsk@redhat.com>
      Signed-off-by: NVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20210526132026.270394-11-vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      8629b625
    • V
      KVM: nVMX: Reset eVMCS clean fields data from prepare_vmcs02() · dc313385
      Vitaly Kuznetsov 提交于
      When nested state migration happens during L1's execution, it
      is incorrect to modify eVMCS as it is L1 who 'owns' it at the moment.
      At least genuine Hyper-V seems to not be very happy when 'clean fields'
      data changes underneath it.
      
      'Clean fields' data is used in KVM twice: by copy_enlightened_to_vmcs12()
      and prepare_vmcs02_rare() so we can reset it from prepare_vmcs02() instead.
      
      While at it, update a comment stating why exactly we need to reset
      'hv_clean_fields' data from L0.
      Signed-off-by: NVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20210526132026.270394-10-vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      dc313385
    • V
      KVM: nVMX: Force enlightened VMCS sync from nested_vmx_failValid() · b7685cfd
      Vitaly Kuznetsov 提交于
      'need_vmcs12_to_shadow_sync' is used for both shadow and enlightened
      VMCS sync when we exit to L1. The comment in nested_vmx_failValid()
      validly states why shadow vmcs sync can be omitted but this doesn't
      apply to enlightened VMCS as it 'shadows' all VMCS12 fields.
      Reviewed-by: NMaxim Levitsky <mlevitsk@redhat.com>
      Signed-off-by: NVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20210526132026.270394-9-vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b7685cfd
    • V
      KVM: nVMX: Ignore 'hv_clean_fields' data when eVMCS data is copied in vmx_get_nested_state() · d6bf71a1
      Vitaly Kuznetsov 提交于
      'Clean fields' data from enlightened VMCS is only valid upon vmentry: L1
      hypervisor is not obliged to keep it up-to-date while it is mangling L2's
      state, KVM_GET_NESTED_STATE request may come at a wrong moment when actual
      eVMCS changes are unsynchronized with 'hv_clean_fields'. As upon migration
      VMCS12 is used as a source of ultimate truth, we must make sure we pick all
      the changes to eVMCS and thus 'clean fields' data must be ignored.
      Signed-off-by: NVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20210526132026.270394-8-vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      d6bf71a1