1. 03 2月, 2021 1 次提交
    • P
      KVM: x86: cleanup CR3 reserved bits checks · c1c35cf7
      Paolo Bonzini 提交于
      If not in long mode, the low bits of CR3 are reserved but not enforced to
      be zero, so remove those checks.  If in long mode, however, the MBZ bits
      extend down to the highest physical address bit of the guest, excluding
      the encryption bit.
      
      Make the checks consistent with the above, and match them between
      nested_vmcb_checks and KVM_SET_SREGS.
      
      Cc: stable@vger.kernel.org
      Fixes: 761e4169 ("KVM: nSVM: Check that MBZ bits in CR3 and CR4 are not set on vmrun of nested guests")
      Fixes: a780a3ea ("KVM: X86: Fix reserved bits check for MOV to CR3")
      Reviewed-by: NSean Christopherson <seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c1c35cf7
  2. 26 1月, 2021 1 次提交
    • P
      KVM: x86: allow KVM_REQ_GET_NESTED_STATE_PAGES outside guest mode for VMX · 9a78e158
      Paolo Bonzini 提交于
      VMX also uses KVM_REQ_GET_NESTED_STATE_PAGES for the Hyper-V eVMCS,
      which may need to be loaded outside guest mode.  Therefore we cannot
      WARN in that case.
      
      However, that part of nested_get_vmcs12_pages is _not_ needed at
      vmentry time.  Split it out of KVM_REQ_GET_NESTED_STATE_PAGES handling,
      so that both vmentry and migration (and in the latter case, independent
      of is_guest_mode) do the parts that are needed.
      
      Cc: <stable@vger.kernel.org> # 5.10.x: f2c7ef3b: KVM: nSVM: cancel KVM_REQ_GET_NESTED_STATE_PAGES
      Cc: <stable@vger.kernel.org> # 5.10.x
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      9a78e158
  3. 08 1月, 2021 3 次提交
  4. 28 11月, 2020 1 次提交
  5. 15 11月, 2020 1 次提交
  6. 22 10月, 2020 1 次提交
  7. 28 9月, 2020 11 次提交
  8. 13 9月, 2020 2 次提交
    • M
      SVM: nSVM: setup nested msr permission bitmap on nested state load · 772b81bb
      Maxim Levitsky 提交于
      This code was missing and was forcing the L2 run with L1's msr
      permission bitmap
      Signed-off-by: NMaxim Levitsky <mlevitsk@redhat.com>
      Message-Id: <20200827162720.278690-3-mlevitsk@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      772b81bb
    • M
      SVM: nSVM: correctly restore GIF on vmexit from nesting after migration · 9883764a
      Maxim Levitsky 提交于
      Currently code in svm_set_nested_state copies the current vmcb control
      area to L1 control area (hsave->control), under assumption that
      it mostly reflects the defaults that kvm choose, and later qemu
      overrides  these defaults with L2 state using standard KVM interfaces,
      like KVM_SET_REGS.
      
      However nested GIF (which is AMD specific thing) is by default is true,
      and it is copied to hsave area as such.
      
      This alone is not a big deal since on VMexit, GIF is always set to false,
      regardless of what it was on VM entry.  However in nested_svm_vmexit we
      were first were setting GIF to false, but then we overwrite the control
      fields with value from the hsave area.  (including the nested GIF field
      itself if GIF virtualization is enabled).
      
      Now on normal vm entry this is not a problem, since GIF is usually false
      prior to normal vm entry, and this is the value that copied to hsave,
      and then restored, but this is not always the case when the nested state
      is loaded as explained above.
      
      To fix this issue, move svm_set_gif after we restore the L1 control
      state in nested_svm_vmexit, so that even with wrong GIF in the
      saved L1 control area, we still clear GIF as the spec says.
      Signed-off-by: NMaxim Levitsky <mlevitsk@redhat.com>
      Message-Id: <20200827162720.278690-2-mlevitsk@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      9883764a
  9. 08 9月, 2020 1 次提交
  10. 31 7月, 2020 1 次提交
  11. 11 7月, 2020 8 次提交
  12. 09 7月, 2020 4 次提交
  13. 08 6月, 2020 1 次提交
    • P
      KVM: SVM: fix calls to is_intercept · fb7333df
      Paolo Bonzini 提交于
      is_intercept takes an INTERCEPT_* constant, not SVM_EXIT_*; because
      of this, the compiler was removing the body of the conditionals,
      as if is_intercept returned 0.
      
      This unveils a latent bug: when clearing the VINTR intercept,
      int_ctl must also be changed in the L1 VMCB (svm->nested.hsave),
      just like the intercept itself is also changed in the L1 VMCB.
      Otherwise V_IRQ remains set and, due to the VINTR intercept being clear,
      we get a spurious injection of a vector 0 interrupt on the next
      L2->L1 vmexit.
      Reported-by: NQian Cai <cai@lca.pw>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      fb7333df
  14. 01 6月, 2020 4 次提交
    • V
      KVM: x86: extend struct kvm_vcpu_pv_apf_data with token info · 68fd66f1
      Vitaly Kuznetsov 提交于
      Currently, APF mechanism relies on the #PF abuse where the token is being
      passed through CR2. If we switch to using interrupts to deliver page-ready
      notifications we need a different way to pass the data. Extent the existing
      'struct kvm_vcpu_pv_apf_data' with token information for page-ready
      notifications.
      
      While on it, rename 'reason' to 'flags'. This doesn't change the semantics
      as we only have reasons '1' and '2' and these can be treated as bit flags
      but KVM_PV_REASON_PAGE_READY is going away with interrupt based delivery
      making 'reason' name misleading.
      
      The newly introduced apf_put_user_ready() temporary puts both flags and
      token information, this will be changed to put token only when we switch
      to interrupt based notifications.
      Signed-off-by: NVitaly Kuznetsov <vkuznets@redhat.com>
      Message-Id: <20200525144125.143875-3-vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      68fd66f1
    • P
      KVM: nSVM: implement KVM_GET_NESTED_STATE and KVM_SET_NESTED_STATE · cc440cda
      Paolo Bonzini 提交于
      Similar to VMX, the state that is captured through the currently available
      IOCTLs is a mix of L1 and L2 state, dependent on whether the L2 guest was
      running at the moment when the process was interrupted to save its state.
      
      In particular, the SVM-specific state for nested virtualization includes
      the L1 saved state (including the interrupt flag), the cached L2 controls,
      and the GIF.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      cc440cda
    • P
      KVM: MMU: pass arbitrary CR0/CR4/EFER to kvm_init_shadow_mmu · 929d1cfa
      Paolo Bonzini 提交于
      This allows fetching the registers from the hsave area when setting
      up the NPT shadow MMU, and is needed for KVM_SET_NESTED_STATE (which
      runs long after the CR0, CR4 and EFER values in vcpu have been switched
      to hold L2 guest state).
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      929d1cfa
    • P
      KVM: nSVM: leave guest mode when clearing EFER.SVME · c513f484
      Paolo Bonzini 提交于
      According to the AMD manual, the effect of turning off EFER.SVME while a
      guest is running is undefined.  We make it leave guest mode immediately,
      similar to the effect of clearing the VMX bit in MSR_IA32_FEAT_CTL.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c513f484