1. 08 Jan, 2016 13 commits
  2. 07 Jan, 2016 5 commits
  3. 18 Dec, 2015 8 commits
  4. 16 Dec, 2015 14 commits
    • Andrey Smetanin's avatar
      kvm/x86: Remove Hyper-V SynIC timer stopping · 481d2bcc
      Andrey Smetanin authored
      It's possible that guest send us Hyper-V EOM at the middle
      of Hyper-V SynIC timer running, so we start processing of Hyper-V
      SynIC timers in vcpu context and stop the Hyper-V SynIC timer
      unconditionally:
      
          host                                       guest
          ------------------------------------------------------------------------------
                                                 start periodic stimer
          start periodic timer
          timer expires after 15ms
          send expiration message into guest
          restart periodic timer
          timer expires again after 15 ms
          msg slot is still not cleared so
          setup ->msg_pending
      (1) restart periodic timer
                                                 process timer msg and clear slot
                                                 ->msg_pending was set:
                                                     send EOM into host
          received EOM
            kvm_make_request(KVM_REQ_HV_STIMER)
      
          kvm_hv_process_stimers():
              ...
              stimer_stop()
              if (time_now >= stimer->exp_time)
                      stimer_expiration(stimer);
      
      Because the timer was rearmed at (1), time_now < stimer->exp_time
      and stimer_expiration is not called.  The timer then never fires.
      
      The patch fixes such situation by not stopping Hyper-V SynIC timer
      at all, because it's safe to restart it without stop in vcpu context
      and timer callback always returns HRTIMER_NORESTART.
      Signed-off-by: default avatarAndrey Smetanin <asmetanin@virtuozzo.com>
      CC: Gleb Natapov <gleb@kernel.org>
      CC: Paolo Bonzini <pbonzini@redhat.com>
      CC: Roman Kagan <rkagan@virtuozzo.com>
      CC: Denis V. Lunev <den@openvz.org>
      CC: qemu-devel@nongnu.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      481d2bcc
    • Borislav Petkov's avatar
      kvm: Dump guest rIP when the guest tried something unsupported · 671d9ab3
      Borislav Petkov authored
      It looks like this in action:
      
        kvm [5197]: vcpu0, guest rIP: 0xffffffff810187ba unhandled rdmsr: 0xc001102
      
      and helps to pinpoint quickly where in the guest we did the unsupported
      thing.
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      671d9ab3
    • Paolo Bonzini's avatar
      KVM: vmx: detect mismatched size in VMCS read/write · 8a86aea9
      Paolo Bonzini authored
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      ---
      	I am sending this as RFC because the error messages it produces are
      	very ugly.  Because of inlining, the original line is lost.  The
      	alternative is to change vmcs_read/write/checkXX into macros, but
      	then you need to have a single huge BUILD_BUG_ON or BUILD_BUG_ON_MSG
      	because multiple BUILD_BUG_ON* with the same __LINE__ are not
      	supported well.
      8a86aea9
    • Paolo Bonzini's avatar
      KVM: VMX: fix read/write sizes of VMCS fields in dump_vmcs · 845c5b40
      Paolo Bonzini authored
      This was not printing the high parts of several 64-bit fields on
      32-bit kernels.  Separate from the previous one to make the patches
      easier to review.
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      845c5b40
    • Paolo Bonzini's avatar
      KVM: VMX: fix read/write sizes of VMCS fields · f3531054
      Paolo Bonzini authored
      In theory this should have broken EPT on 32-bit kernels (due to
      reading the high part of natural-width field GUEST_CR3).  Not sure
      if no one noticed or the processor behaves differently from the
      documentation.
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      f3531054
    • Li RongQing's avatar
      KVM: VMX: fix the writing POSTED_INTR_NV · 0bcf261c
      Li RongQing authored
      POSTED_INTR_NV is 16bit, should not use 64bit write function
      
      [ 5311.676074] vmwrite error: reg 3 value 0 (err 12)
        [ 5311.680001] CPU: 49 PID: 4240 Comm: qemu-system-i38 Tainted: G I 4.1.13-WR8.0.0.0_standard #1
        [ 5311.689343] Hardware name: Intel Corporation S2600WT2/S2600WT2, BIOS SE5C610.86B.01.01.0008.021120151325 02/11/2015
        [ 5311.699550] 00000000 00000000 e69a7e1c c1950de1 00000000 e69a7e38 fafcff45 fafebd24
        [ 5311.706924] 00000003 00000000 0000000c b6a06dfa e69a7e40 fafcff79 e69a7eb0 fafd5f57
        [ 5311.714296] e69a7ec0 c1080600 00000000 00000001 c0e18018 000001be 00000000 00000b43
        [ 5311.721651] Call Trace:
        [ 5311.722942] [<c1950de1>] dump_stack+0x4b/0x75
        [ 5311.726467] [<fafcff45>] vmwrite_error+0x35/0x40 [kvm_intel]
        [ 5311.731444] [<fafcff79>] vmcs_writel+0x29/0x30 [kvm_intel]
        [ 5311.736228] [<fafd5f57>] vmx_create_vcpu+0x337/0xb90 [kvm_intel]
        [ 5311.741600] [<c1080600>] ? dequeue_task_fair+0x2e0/0xf60
        [ 5311.746197] [<faf3b9ca>] kvm_arch_vcpu_create+0x3a/0x70 [kvm]
        [ 5311.751278] [<faf29e9d>] kvm_vm_ioctl+0x14d/0x640 [kvm]
        [ 5311.755771] [<c1129d44>] ? free_pages_prepare+0x1a4/0x2d0
        [ 5311.760455] [<c13e2842>] ? debug_smp_processor_id+0x12/0x20
        [ 5311.765333] [<c10793be>] ? sched_move_task+0xbe/0x170
        [ 5311.769621] [<c11752b3>] ? kmem_cache_free+0x213/0x230
        [ 5311.774016] [<faf29d50>] ? kvm_set_memory_region+0x60/0x60 [kvm]
        [ 5311.779379] [<c1199fa2>] do_vfs_ioctl+0x2e2/0x500
        [ 5311.783285] [<c11752b3>] ? kmem_cache_free+0x213/0x230
        [ 5311.787677] [<c104dc73>] ? __mmdrop+0x63/0xd0
        [ 5311.791196] [<c104dc73>] ? __mmdrop+0x63/0xd0
        [ 5311.794712] [<c104dc73>] ? __mmdrop+0x63/0xd0
        [ 5311.798234] [<c11a2ed7>] ? __fget+0x57/0x90
        [ 5311.801559] [<c11a2f72>] ? __fget_light+0x22/0x50
        [ 5311.805464] [<c119a240>] SyS_ioctl+0x80/0x90
        [ 5311.808885] [<c1957d30>] sysenter_do_call+0x12/0x12
        [ 5312.059280] kvm: zapping shadow pages for mmio generation wraparound
        [ 5313.678415] kvm [4231]: vcpu0 disabled perfctr wrmsr: 0xc2 data 0xffff
        [ 5313.726518] kvm [4231]: vcpu0 unhandled rdmsr: 0x570
      Signed-off-by: default avatarLi RongQing <roy.qing.li@gmail.com>
      Cc: Yang Zhang <yang.z.zhang@Intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      0bcf261c
    • Andrey Smetanin's avatar
      kvm/x86: Hyper-V SynIC timers · 1f4b34f8
      Andrey Smetanin authored
      Per Hyper-V specification (and as required by Hyper-V-aware guests),
      SynIC provides 4 per-vCPU timers.  Each timer is programmed via a pair
      of MSRs, and signals expiration by delivering a special format message
      to the configured SynIC message slot and triggering the corresponding
      synthetic interrupt.
      
      Note: as implemented by this patch, all periodic timers are "lazy"
      (i.e. if the vCPU wasn't scheduled for more than the timer period the
      timer events are lost), regardless of the corresponding configuration
      MSR.  If deemed necessary, the "catch up" mode (the timer period is
      shortened until the timer catches up) will be implemented later.
      
      Changes v2:
      * Use remainder to calculate periodic timer expiration time
      Signed-off-by: default avatarAndrey Smetanin <asmetanin@virtuozzo.com>
      Reviewed-by: default avatarRoman Kagan <rkagan@virtuozzo.com>
      CC: Gleb Natapov <gleb@kernel.org>
      CC: Paolo Bonzini <pbonzini@redhat.com>
      CC: "K. Y. Srinivasan" <kys@microsoft.com>
      CC: Haiyang Zhang <haiyangz@microsoft.com>
      CC: Vitaly Kuznetsov <vkuznets@redhat.com>
      CC: Roman Kagan <rkagan@virtuozzo.com>
      CC: Denis V. Lunev <den@openvz.org>
      CC: qemu-devel@nongnu.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      1f4b34f8
    • Andrey Smetanin's avatar
      kvm/x86: Hyper-V SynIC message slot pending clearing at SINT ack · 765eaa0f
      Andrey Smetanin authored
      The SynIC message protocol mandates that the message slot is claimed
      by atomically setting message type to something other than HVMSG_NONE.
      If another message is to be delivered while the slot is still busy,
      message pending flag is asserted to indicate to the guest that the
      hypervisor wants to be notified when the slot is released.
      
      To make sure the protocol works regardless of where the message
      sources are (kernel or userspace), clear the pending flag on SINT ACK
      notification, and let the message sources compete for the slot again.
      Signed-off-by: default avatarAndrey Smetanin <asmetanin@virtuozzo.com>
      Reviewed-by: default avatarRoman Kagan <rkagan@virtuozzo.com>
      CC: Gleb Natapov <gleb@kernel.org>
      CC: Paolo Bonzini <pbonzini@redhat.com>
      CC: "K. Y. Srinivasan" <kys@microsoft.com>
      CC: Haiyang Zhang <haiyangz@microsoft.com>
      CC: Vitaly Kuznetsov <vkuznets@redhat.com>
      CC: Roman Kagan <rkagan@virtuozzo.com>
      CC: Denis V. Lunev <den@openvz.org>
      CC: qemu-devel@nongnu.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      765eaa0f
    • Andrey Smetanin's avatar
      kvm/x86: Hyper-V internal helper to read MSR HV_X64_MSR_TIME_REF_COUNT · 93bf4172
      Andrey Smetanin authored
      This helper will be used also in Hyper-V SynIC timers implementation.
      Signed-off-by: default avatarAndrey Smetanin <asmetanin@virtuozzo.com>
      Reviewed-by: default avatarRoman Kagan <rkagan@virtuozzo.com>
      CC: Gleb Natapov <gleb@kernel.org>
      CC: Paolo Bonzini <pbonzini@redhat.com>
      CC: "K. Y. Srinivasan" <kys@microsoft.com>
      CC: Haiyang Zhang <haiyangz@microsoft.com>
      CC: Vitaly Kuznetsov <vkuznets@redhat.com>
      CC: Roman Kagan <rkagan@virtuozzo.com>
      CC: Denis V. Lunev <den@openvz.org>
      CC: qemu-devel@nongnu.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      93bf4172
    • Andrey Smetanin's avatar
      kvm/x86: Added Hyper-V vcpu_to_hv_vcpu()/hv_vcpu_to_vcpu() helpers · 0ae80384
      Andrey Smetanin authored
      Signed-off-by: default avatarAndrey Smetanin <asmetanin@virtuozzo.com>
      Reviewed-by: default avatarRoman Kagan <rkagan@virtuozzo.com>
      CC: Gleb Natapov <gleb@kernel.org>
      CC: Paolo Bonzini <pbonzini@redhat.com>
      CC: "K. Y. Srinivasan" <kys@microsoft.com>
      CC: Haiyang Zhang <haiyangz@microsoft.com>
      CC: Vitaly Kuznetsov <vkuznets@redhat.com>
      CC: Roman Kagan <rkagan@virtuozzo.com>
      CC: Denis V. Lunev <den@openvz.org>
      CC: qemu-devel@nongnu.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      0ae80384
    • Andrey Smetanin's avatar
      kvm/x86: Rearrange func's declarations inside Hyper-V header · e18eaeed
      Andrey Smetanin authored
      This rearrangement places functions declarations together
      according to their functionality, so future additions
      will be simplier.
      Signed-off-by: default avatarAndrey Smetanin <asmetanin@virtuozzo.com>
      Reviewed-by: default avatarRoman Kagan <rkagan@virtuozzo.com>
      CC: Gleb Natapov <gleb@kernel.org>
      CC: Paolo Bonzini <pbonzini@redhat.com>
      CC: "K. Y. Srinivasan" <kys@microsoft.com>
      CC: Haiyang Zhang <haiyangz@microsoft.com>
      CC: Vitaly Kuznetsov <vkuznets@redhat.com>
      CC: Roman Kagan <rkagan@virtuozzo.com>
      CC: Denis V. Lunev <den@openvz.org>
      CC: qemu-devel@nongnu.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      e18eaeed
    • Andrey Smetanin's avatar
      drivers/hv: Move struct hv_timer_message_payload into UAPI Hyper-V x86 header · c71acc4c
      Andrey Smetanin authored
      This struct is required for Hyper-V SynIC timers implementation inside KVM
      and for upcoming Hyper-V VMBus support by userspace(QEMU). So place it into
      Hyper-V UAPI header.
      Signed-off-by: default avatarAndrey Smetanin <asmetanin@virtuozzo.com>
      CC: Gleb Natapov <gleb@kernel.org>
      CC: Paolo Bonzini <pbonzini@redhat.com>
      CC: "K. Y. Srinivasan" <kys@microsoft.com>
      CC: Haiyang Zhang <haiyangz@microsoft.com>
      CC: Vitaly Kuznetsov <vkuznets@redhat.com>
      CC: Roman Kagan <rkagan@virtuozzo.com>
      CC: Denis V. Lunev <den@openvz.org>
      CC: qemu-devel@nongnu.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      c71acc4c
    • Andrey Smetanin's avatar
      drivers/hv: Move struct hv_message into UAPI Hyper-V x86 header · 5b423efe
      Andrey Smetanin authored
      This struct is required for Hyper-V SynIC timers implementation inside KVM
      and for upcoming Hyper-V VMBus support by userspace(QEMU). So place it into
      Hyper-V UAPI header.
      Signed-off-by: default avatarAndrey Smetanin <asmetanin@virtuozzo.com>
      Acked-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
      Reviewed-by: default avatarRoman Kagan <rkagan@virtuozzo.com>
      CC: Gleb Natapov <gleb@kernel.org>
      CC: Paolo Bonzini <pbonzini@redhat.com>
      CC: "K. Y. Srinivasan" <kys@microsoft.com>
      CC: Haiyang Zhang <haiyangz@microsoft.com>
      CC: Vitaly Kuznetsov <vkuznets@redhat.com>
      CC: Roman Kagan <rkagan@virtuozzo.com>
      CC: Denis V. Lunev <den@openvz.org>
      CC: qemu-devel@nongnu.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      5b423efe
    • Andrey Smetanin's avatar
      drivers/hv: Move HV_SYNIC_STIMER_COUNT into Hyper-V UAPI x86 header · 4f39bcfd
      Andrey Smetanin authored
      This constant is required for Hyper-V SynIC timers MSR's
      support by userspace(QEMU).
      Signed-off-by: default avatarAndrey Smetanin <asmetanin@virtuozzo.com>
      Acked-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
      Reviewed-by: default avatarRoman Kagan <rkagan@virtuozzo.com>
      CC: Gleb Natapov <gleb@kernel.org>
      CC: Paolo Bonzini <pbonzini@redhat.com>
      CC: "K. Y. Srinivasan" <kys@microsoft.com>
      CC: Haiyang Zhang <haiyangz@microsoft.com>
      CC: Vitaly Kuznetsov <vkuznets@redhat.com>
      CC: Roman Kagan <rkagan@virtuozzo.com>
      CC: Denis V. Lunev <den@openvz.org>
      CC: qemu-devel@nongnu.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      4f39bcfd