1. 17 Oct, 2018 6 commits
    • Uros Bizjak's avatar
      KVM/x86: Use 32bit xor to clear registers in svm.c · 43ce76ce
      Uros Bizjak authored
      x86_64 zero-extends 32bit xor operation to a full 64bit register.
      
      Also add a comment and remove unnecessary instruction suffix in vmx.c
      Signed-off-by: default avatarUros Bizjak <ubizjak@gmail.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      43ce76ce
    • Jim Mattson's avatar
      kvm: x86: Introduce KVM_CAP_EXCEPTION_PAYLOAD · c4f55198
      Jim Mattson authored
      This is a per-VM capability which can be enabled by userspace so that
      the faulting linear address will be included with the information
      about a pending #PF in L2, and the "new DR6 bits" will be included
      with the information about a pending #DB in L2. With this capability
      enabled, the L1 hypervisor can now intercept #PF before CR2 is
      modified. Under VMX, the L1 hypervisor can now intercept #DB before
      DR6 and DR7 are modified.
      
      When userspace has enabled KVM_CAP_EXCEPTION_PAYLOAD, it should
      generally provide an appropriate payload when injecting a #PF or #DB
      exception via KVM_SET_VCPU_EVENTS. However, to support restoring old
      checkpoints, this payload is not required.
      
      Note that bit 16 of the "new DR6 bits" is set to indicate that a debug
      exception (#DB) or a breakpoint exception (#BP) occurred inside an RTM
      region while advanced debugging of RTM transactional regions was
      enabled. This is the reverse of DR6.RTM, which is cleared in this
      scenario.
      
      This capability also enables exception.pending in struct
      kvm_vcpu_events, which allows userspace to distinguish between pending
      and injected exceptions.
      Reported-by: default avatarJim Mattson <jmattson@google.com>
      Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarJim Mattson <jmattson@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      c4f55198
    • Jim Mattson's avatar
      kvm: vmx: Defer setting of DR6 until #DB delivery · f10c729f
      Jim Mattson authored
      When exception payloads are enabled by userspace (which is not yet
      possible) and a #DB is raised in L2, defer the setting of DR6 until
      later. Under VMX, this allows the L1 hypervisor to intercept the fault
      before DR6 is modified. Under SVM, DR6 is modified before L1 can
      intercept the fault (as has always been the case with DR7).
      
      Note that the payload associated with a #DB exception includes only
      the "new DR6 bits." When the payload is delievered, DR6.B0-B3 will be
      cleared and DR6.RTM will be set prior to merging in the new DR6 bits.
      
      Also note that bit 16 in the "new DR6 bits" is set to indicate that a
      debug exception (#DB) or a breakpoint exception (#BP) occurred inside
      an RTM region while advanced debugging of RTM transactional regions
      was enabled. Though the reverse of DR6.RTM, this makes the #DB payload
      field compatible with both the pending debug exceptions field under
      VMX and the exit qualification for #DB exceptions under VMX.
      Reported-by: default avatarJim Mattson <jmattson@google.com>
      Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarJim Mattson <jmattson@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      f10c729f
    • Jim Mattson's avatar
      kvm: x86: Defer setting of CR2 until #PF delivery · da998b46
      Jim Mattson authored
      When exception payloads are enabled by userspace (which is not yet
      possible) and a #PF is raised in L2, defer the setting of CR2 until
      the #PF is delivered. This allows the L1 hypervisor to intercept the
      fault before CR2 is modified.
      
      For backwards compatibility, when exception payloads are not enabled
      by userspace, kvm_multiple_exception modifies CR2 when the #PF
      exception is raised.
      Reported-by: default avatarJim Mattson <jmattson@google.com>
      Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarJim Mattson <jmattson@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      da998b46
    • Jim Mattson's avatar
      kvm: x86: Add payload operands to kvm_multiple_exception · 91e86d22
      Jim Mattson authored
      kvm_multiple_exception now takes two additional operands: has_payload
      and payload, so that updates to CR2 (and DR6 under VMX) can be delayed
      until the exception is delivered. This is necessary to properly
      emulate VMX or SVM hardware behavior for nested virtualization.
      
      The new behavior is triggered by
      vcpu->kvm->arch.exception_payload_enabled, which will (later) be set
      by a new per-VM capability, KVM_CAP_EXCEPTION_PAYLOAD.
      Reported-by: default avatarJim Mattson <jmattson@google.com>
      Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarJim Mattson <jmattson@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      91e86d22
    • Jim Mattson's avatar
      kvm: x86: Add exception payload fields to kvm_vcpu_events · 59073aaf
      Jim Mattson authored
      The per-VM capability KVM_CAP_EXCEPTION_PAYLOAD (to be introduced in a
      later commit) adds the following fields to struct kvm_vcpu_events:
      exception_has_payload, exception_payload, and exception.pending.
      
      With this capability set, all of the details of vcpu->arch.exception,
      including the payload for a pending exception, are reported to
      userspace in response to KVM_GET_VCPU_EVENTS.
      
      With this capability clear, the original ABI is preserved, and the
      exception.injected field is set for either pending or injected
      exceptions.
      
      When userspace calls KVM_SET_VCPU_EVENTS with
      KVM_CAP_EXCEPTION_PAYLOAD clear, exception.injected is no longer
      translated to exception.pending. KVM_SET_VCPU_EVENTS can now only
      establish a pending exception when KVM_CAP_EXCEPTION_PAYLOAD is set.
      Reported-by: default avatarJim Mattson <jmattson@google.com>
      Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarJim Mattson <jmattson@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      59073aaf
  2. 16 Oct, 2018 34 commits