Skip to content
Snippets Groups Projects
  1. Sep 14, 2022
    • Paolo Bonzini's avatar
      KVM: x86: do not report a vCPU as preempted outside instruction boundaries · adb2f636
      Paolo Bonzini authored
      mainline inclusion
      from mainline-v5.19-rc2
      commit 6cd88243c7e03845a450795e134b488fc2afb736
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I5PJ7H
      
      
      CVE: CVE-2022-39189
      
      ----------------------------------------
      
      If a vCPU is outside guest mode and is scheduled out, it might be in the
      process of making a memory access.  A problem occurs if another vCPU uses
      the PV TLB flush feature during the period when the vCPU is scheduled
      out, and a virtual address has already been translated but has not yet
      been accessed, because this is equivalent to using a stale TLB entry.
      
      To avoid this, only report a vCPU as preempted if sure that the guest
      is at an instruction boundary.  A rescheduling request will be delivered
      to the host physical CPU as an external interrupt, so for simplicity
      consider any vmexit *not* instruction boundary except for external
      interrupts.
      
      It would in principle be okay to report the vCPU as preempted also
      if it is sleeping in kvm_vcpu_block(): a TLB flush IPI will incur the
      vmentry/vmexit overhead unnecessarily, and optimistic spinning is
      also unlikely to succeed.  However, leave it for later because right
      now kvm_vcpu_check_block() is doing memory accesses.  Even
      though the TLB flush issue only applies to virtual memory address,
      it's very much preferrable to be conservative.
      
      Reported-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      
      conflict:
      	arch/x86/include/asm/kvm_host.h
      	arch/x86/kvm/svm.c
      	arch/x86/kvm/vmx.c
      	arch/x86/kvm/x86.c
      
      Signed-off-by: default avatarGuo Mengqi <guomengqi3@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Reviewed-by: default avatarWeilong Chen <chenweilong@huawei.com>
      Signed-off-by: default avatarYongqiang Liu <liuyongqiang13@huawei.com>
    • Andrew Murray's avatar
      KVM: arm64: Write arch.mdcr_el2 changes since last vcpu_load on VHE · 0ff1abf0
      Andrew Murray authored
      mainline inclusion
      from mainline-v5.6
      commit 4942dc66
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I5QR6C
      CVE: NA
      
      -------------
      
      On VHE systems arch.mdcr_el2 is written to mdcr_el2 at vcpu_load time to
      set options for self-hosted debug and the performance monitors
      extension.
      
      Unfortunately the value of arch.mdcr_el2 is not calculated until
      kvm_arm_setup_debug() in the run loop after the vcpu has been loaded.
      This means that the initial brief iterations of the run loop use a zero
      value of mdcr_el2 - until the vcpu is preempted. This also results in a
      delay between changes to vcpu->guest_debug taking effect.
      
      Fix this by writing to mdcr_el2 in kvm_arm_setup_debug() on VHE systems
      when a change to arch.mdcr_el2 has been detected.
      
      Fixes: d5a21bcc ("KVM: arm64: Move common VHE/non-VHE trap config in separate functions")
      Cc: <stable@vger.kernel.org> # 4.17.x-
      Suggested-by: James Mors...
      0ff1abf0
  2. Sep 13, 2022
  3. Sep 07, 2022