1. 28 11月, 2020 1 次提交
  2. 15 11月, 2020 1 次提交
  3. 22 10月, 2020 1 次提交
  4. 28 9月, 2020 11 次提交
  5. 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
  6. 08 9月, 2020 1 次提交
  7. 31 7月, 2020 1 次提交
  8. 11 7月, 2020 8 次提交
  9. 09 7月, 2020 4 次提交
  10. 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
  11. 01 6月, 2020 9 次提交
    • 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
    • P
      KVM: nSVM: split nested_vmcb_check_controls · ca46d739
      Paolo Bonzini 提交于
      The authoritative state does not come from the VMCB once in guest mode,
      but KVM_SET_NESTED_STATE can still perform checks on L1's provided SVM
      controls because we get them from userspace.
      
      Therefore, split out a function to do them.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      ca46d739
    • P
      KVM: nSVM: remove HF_HIF_MASK · 08245e6d
      Paolo Bonzini 提交于
      The L1 flags can be found in the save area of svm->nested.hsave, fish
      it from there so that there is one fewer thing to migrate.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      08245e6d
    • P
      KVM: nSVM: remove HF_VINTR_MASK · e9fd761a
      Paolo Bonzini 提交于
      Now that the int_ctl field is stored in svm->nested.ctl.int_ctl, we can
      use it instead of vcpu->arch.hflags to check whether L2 is running
      in V_INTR_MASKING mode.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      e9fd761a
    • P
      KVM: nSVM: synthesize correct EXITINTINFO on vmexit · 36e2e983
      Paolo Bonzini 提交于
      This bit was added to nested VMX right when nested_run_pending was
      introduced, but it is not yet there in nSVM.  Since we can have pending
      events that L0 injected directly into L2 on vmentry, we have to transfer
      them into L1's queue.
      
      For this to work, one important change is required: svm_complete_interrupts
      (which clears the "injected" fields from the previous VMRUN, and updates them
      from svm->vmcb's EXITINTINFO) must be placed before we inject the vmexit.
      This is not too scary though; VMX even does it in vmx_vcpu_run.
      
      While at it, the nested_vmexit_inject tracepoint is moved towards the
      end of nested_svm_vmexit.  This ensures that the synthesized EXITINTINFO
      is visible in the trace.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      36e2e983
    • P
      KVM: SVM: preserve VGIF across VMCB switch · 91b7130c
      Paolo Bonzini 提交于
      There is only one GIF flag for the whole processor, so make sure it is not clobbered
      when switching to L2 (in which case we also have to include the V_GIF_ENABLE_MASK,
      lest we confuse enable_gif/disable_gif/gif_set).  When going back, L1 could in
      theory have entered L2 without issuing a CLGI so make sure the svm_set_gif is
      done last, after svm->vmcb->control.int_ctl has been copied back from hsave.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      91b7130c