Skip to content
  1. Feb 13, 2020
  2. Feb 12, 2020
    • Oliver Upton's avatar
      KVM: x86: Deliver exception payload on KVM_GET_VCPU_EVENTS · a06230b6
      Oliver Upton authored
      
      
      KVM allows the deferral of exception payloads when a vCPU is in guest
      mode to allow the L1 hypervisor to intercept certain events (#PF, #DB)
      before register state has been modified. However, this behavior is
      incompatible with the KVM_{GET,SET}_VCPU_EVENTS ABI, as userspace
      expects register state to have been immediately modified. Userspace may
      opt-in for the payload deferral behavior with the
      KVM_CAP_EXCEPTION_PAYLOAD per-VM capability. As such,
      kvm_multiple_exception() will immediately manipulate guest registers if
      the capability hasn't been requested.
      
      Since the deferral is only necessary if a userspace ioctl were to be
      serviced at the same as a payload bearing exception is recognized, this
      behavior can be relaxed. Instead, opportunistically defer the payload
      from kvm_multiple_exception() and deliver the payload before completing
      a KVM_GET_VCPU_EVENTS ioctl.
      
      Signed-off-by: default avatarOliver Upton <oupton@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      a06230b6
    • Oliver Upton's avatar
      KVM: nVMX: Handle pending #DB when injecting INIT VM-exit · 684c0422
      Oliver Upton authored
      SDM 27.3.4 states that the 'pending debug exceptions' VMCS field will
      be populated if a VM-exit caused by an INIT signal takes priority over a
      debug-trap. Emulate this behavior when synthesizing an INIT signal
      VM-exit into L1.
      
      Fixes: 4b9852f4
      
       ("KVM: x86: Fix INIT signal handling in various CPU states")
      Signed-off-by: default avatarOliver Upton <oupton@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      684c0422
    • Oliver Upton's avatar
      KVM: x86: Mask off reserved bit from #DB exception payload · 307f1cfa
      Oliver Upton authored
      KVM defines the #DB payload as compatible with the 'pending debug
      exceptions' field under VMX, not DR6. Mask off bit 12 when applying the
      payload to DR6, as it is reserved on DR6 but not the 'pending debug
      exceptions' field.
      
      Fixes: f10c729f
      
       ("kvm: vmx: Defer setting of DR6 until #DB delivery")
      Signed-off-by: default avatarOliver Upton <oupton@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      307f1cfa
    • Marc Zyngier's avatar
      KVM: Disable preemption in kvm_get_running_vcpu() · 1f03b2bc
      Marc Zyngier authored
      Accessing a per-cpu variable only makes sense when preemption is
      disabled (and the kernel does check this when the right debug options
      are switched on).
      
      For kvm_get_running_vcpu(), it is fine to return the value after
      re-enabling preemption, as the preempt notifiers will make sure that
      this is kept consistent across task migration (the comment above the
      function hints at it, but lacks the crucial preemption management).
      
      While we're at it, move the comment from the ARM code, which explains
      why the whole thing works.
      
      Fixes: 7495e22b
      
       ("KVM: Move running VCPU from ARM to common code").
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Reported-by: default avatarZenghui Yu <yuzenghui@huawei.com>
      Tested-by: default avatarZenghui Yu <yuzenghui@huawei.com>
      Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/318984f6-bc36-33a3-abc6-bf2295974b06@huawei.com
      Message-id: <20200207163410.31276-1-maz@kernel.org>
      Signed-off-by: Paolo Bo...
      1f03b2bc