18 Mar, 2016

1 commit

  • Pull char/misc updates from Greg KH:
    "Here is the big char/misc driver update for 4.6-rc1.

    The majority of the patches here is hwtracing and some new mic
    drivers, but there's a lot of other driver updates as well. Full
    details in the shortlog.

    All have been in linux-next for a while with no reported issues"

    * tag 'char-misc-4.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (238 commits)
    goldfish: Fix build error of missing ioremap on UM
    nvmem: mediatek: Fix later provider initialization
    nvmem: imx-ocotp: Fix return value of imx_ocotp_read
    nvmem: Fix dependencies for !HAS_IOMEM archs
    char: genrtc: replace blacklist with whitelist
    drivers/hwtracing: make coresight-etm-perf.c explicitly non-modular
    drivers: char: mem: fix IS_ERROR_VALUE usage
    char: xillybus: Fix internal data structure initialization
    pch_phub: return -ENODATA if ROM can't be mapped
    Drivers: hv: vmbus: Support kexec on ws2012 r2 and above
    Drivers: hv: vmbus: Support handling messages on multiple CPUs
    Drivers: hv: utils: Remove util transport handler from list if registration fails
    Drivers: hv: util: Pass the channel information during the init call
    Drivers: hv: vmbus: avoid unneeded compiler optimizations in vmbus_wait_for_unload()
    Drivers: hv: vmbus: remove code duplication in message handling
    Drivers: hv: vmbus: avoid wait_for_completion() on crash
    Drivers: hv: vmbus: don't loose HVMSG_TIMER_EXPIRED messages
    misc: at24: replace memory_accessor with nvmem_device_read
    eeprom: 93xx46: extend driver to plug into the NVMEM framework
    eeprom: at25: extend driver to plug into the NVMEM framework
    ...

    Linus Torvalds
     

02 Mar, 2016

8 commits

  • WS2012 R2 and above hosts can support kexec in that thay can support
    reconnecting to the host (as would be needed in the kexec path)
    on any CPU. Enable this. Pre ws2012 r2 hosts don't have this ability
    and consequently cannot support kexec.

    Signed-off-by: Alex Ng
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Alex Ng
     
  • Starting with Windows 2012 R2, message inteerupts can be delivered
    on any VCPU in the guest. Support this functionality.

    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    K. Y. Srinivasan
     
  • If util transport fails to initialize for any reason, the list of transport
    handlers may become corrupted due to freeing the transport handler without
    removing it from the list. Fix this by cleaning it up from the list.

    Signed-off-by: Alex Ng
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Alex Ng
     
  • Pass the channel information to the util drivers that need to defer
    reading the channel while they are processing a request. This would address
    the following issue reported by Vitaly:

    Commit 3cace4a61610 ("Drivers: hv: utils: run polling callback always in
    interrupt context") removed direct *_transaction.state = HVUTIL_READY
    assignments from *_handle_handshake() functions introducing the following
    race: if a userspace daemon connects before we get first non-negotiation
    request from the server hv_poll_channel() won't set transaction state to
    HVUTIL_READY as (!channel) condition will fail, we set it to non-NULL on
    the first real request from the server.

    Signed-off-by: K. Y. Srinivasan
    Reported-by: Vitaly Kuznetsov
    Signed-off-by: Greg Kroah-Hartman

    K. Y. Srinivasan
     
  • Message header is modified by the hypervisor and we read it in a loop,
    we need to prevent compilers from optimizing accesses. There are no such
    optimizations at this moment, this is just a future proof.

    Suggested-by: Radim Krcmar
    Signed-off-by: Vitaly Kuznetsov
    Reviewed-by: Radim Kr.má
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     
  • We have 3 functions dealing with messages and they all implement
    the same logic to finalize reads, move it to vmbus_signal_eom().

    Suggested-by: Radim Krcmar
    Signed-off-by: Vitaly Kuznetsov
    Reviewed-by: Radim Kr.má
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     
  • wait_for_completion() may sleep, it enables interrupts and this
    is something we really want to avoid on crashes because interrupt
    handlers can cause other crashes. Switch to the recently introduced
    vmbus_wait_for_unload() doing busy wait instead.

    Reported-by: Radim Krcmar
    Signed-off-by: Vitaly Kuznetsov
    Reviewed-by: Radim Kr.má
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     
  • We must handle HVMSG_TIMER_EXPIRED messages in the interrupt context
    and we offload all the rest to vmbus_on_msg_dpc() tasklet. This functions
    loops to see if there are new messages pending. In case we'll ever see
    HVMSG_TIMER_EXPIRED message there we're going to lose it as we can't
    handle it from there. Avoid looping in vmbus_on_msg_dpc(), we're OK
    with handling one message per interrupt.

    Signed-off-by: Vitaly Kuznetsov
    Reviewed-by: Radim Kr.má
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     

17 Feb, 2016

1 commit

  • VMBus hypercall codes inside Hyper-V UAPI header will
    be used by QEMU to implement VMBus host devices support.

    Signed-off-by: Andrey Smetanin
    Acked-by: K. Y. Srinivasan
    Reviewed-by: Roman Kagan
    CC: Gleb Natapov
    CC: Paolo Bonzini
    CC: Joerg Roedel
    CC: "K. Y. Srinivasan"
    CC: Haiyang Zhang
    CC: Roman Kagan
    CC: Denis V. Lunev
    CC: qemu-devel@nongnu.org
    [Do not rename the constant at the same time as moving it, as that
    would cause semantic conflicts with the Hyper-V tree. - Paolo]
    Signed-off-by: Paolo Bonzini

    Andrey Smetanin
     

08 Feb, 2016

12 commits


14 Jan, 2016

1 commit

  • Pull char/misc updates from Greg KH:
    "Here's the big set of char/misc patches for 4.5-rc1.

    Nothing major, lots of different driver subsystem updates, full
    details in the shortlog. All of these have been in linux-next for a
    while"

    * tag 'char-misc-4.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (71 commits)
    mei: fix fasync return value on error
    parport: avoid assignment in if
    parport: remove unneeded space
    parport: change style of NULL comparison
    parport: remove unnecessary out of memory message
    parport: remove braces
    parport: quoted strings should not be split
    parport: code indent should use tabs
    parport: fix coding style
    parport: EXPORT_SYMBOL should follow function
    parport: remove trailing white space
    parport: fix a trivial typo
    coresight: Fix a typo in Kconfig
    coresight: checking for NULL string in coresight_name_match()
    Drivers: hv: vmbus: Treat Fibre Channel devices as performance critical
    Drivers: hv: utils: fix hvt_op_poll() return value on transport destroy
    Drivers: hv: vmbus: fix the building warning with hyperv-keyboard
    extcon: add Maxim MAX3355 driver
    Drivers: hv: ring_buffer: eliminate hv_ringbuffer_peek()
    Drivers: hv: remove code duplication between vmbus_recvpacket()/vmbus_recvpacket_raw()
    ...

    Linus Torvalds
     

22 Dec, 2015

2 commits


17 Dec, 2015

4 commits

  • 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: Andrey Smetanin
    CC: Gleb Natapov
    CC: Paolo Bonzini
    CC: "K. Y. Srinivasan"
    CC: Haiyang Zhang
    CC: Vitaly Kuznetsov
    CC: Roman Kagan
    CC: Denis V. Lunev
    CC: qemu-devel@nongnu.org
    Signed-off-by: Paolo Bonzini

    Andrey Smetanin
     
  • 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: Andrey Smetanin
    Acked-by: K. Y. Srinivasan
    Reviewed-by: Roman Kagan
    CC: Gleb Natapov
    CC: Paolo Bonzini
    CC: "K. Y. Srinivasan"
    CC: Haiyang Zhang
    CC: Vitaly Kuznetsov
    CC: Roman Kagan
    CC: Denis V. Lunev
    CC: qemu-devel@nongnu.org
    Signed-off-by: Paolo Bonzini

    Andrey Smetanin
     
  • This constant is required for Hyper-V SynIC timers MSR's
    support by userspace(QEMU).

    Signed-off-by: Andrey Smetanin
    Acked-by: K. Y. Srinivasan
    Reviewed-by: Roman Kagan
    CC: Gleb Natapov
    CC: Paolo Bonzini
    CC: "K. Y. Srinivasan"
    CC: Haiyang Zhang
    CC: Vitaly Kuznetsov
    CC: Roman Kagan
    CC: Denis V. Lunev
    CC: qemu-devel@nongnu.org
    Signed-off-by: Paolo Bonzini

    Andrey Smetanin
     
  • enum hv_message_type inside struct hv_message, hv_post_message
    is not size portable. Replace enum by u32.

    Signed-off-by: Andrey Smetanin
    CC: Gleb Natapov
    CC: Paolo Bonzini
    CC: "K. Y. Srinivasan"
    CC: Haiyang Zhang
    CC: Vitaly Kuznetsov
    CC: Roman Kagan
    CC: Denis V. Lunev
    CC: qemu-devel@nongnu.org
    Signed-off-by: Paolo Bonzini

    Andrey Smetanin
     

15 Dec, 2015

11 commits

  • Currently, there is only one user for hv_ringbuffer_read()/
    hv_ringbuffer_peak() functions and the usage of these functions is:
    - insecure as we drop ring_lock between them, someone else (in theory
    only) can acquire it in between;
    - non-optimal as we do a number of things (acquire/release the above
    mentioned lock, calculate available space on the ring, ...) twice and
    this path is performance-critical.

    Remove hv_ringbuffer_peek() moving the logic from __vmbus_recvpacket() to
    hv_ringbuffer_read().

    Signed-off-by: Vitaly Kuznetsov
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     
  • vmbus_recvpacket() and vmbus_recvpacket_raw() are almost identical but
    there are two discrepancies:
    1) vmbus_recvpacket() doesn't propagate errors from hv_ringbuffer_read()
    which looks like it is not desired.
    2) There is an error message printed in packetlen > bufferlen case in
    vmbus_recvpacket(). I'm removing it as it is usless for users to see
    such messages and /vmbus_recvpacket_raw() doesn't have it.

    Signed-off-by: Vitaly Kuznetsov
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     
  • hv_ringbuffer_peek() does the same as hv_ringbuffer_read() without
    advancing the read index. The only functional change this patch brings
    is moving hv_need_to_signal_on_read() call under the ring_lock but this
    function is just a couple of comparisons.

    Signed-off-by: Vitaly Kuznetsov
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     
  • Convert 6+-string comments repeating function names to normal kernel-style
    comments and fix a couple of other comment style issues. No textual or
    functional changes intended.

    Signed-off-by: Vitaly Kuznetsov
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     
  • The crash is observed when a service is being disabled host side while
    userspace daemon is connected to the device:

    [ 90.244859] general protection fault: 0000 [#1] SMP
    ...
    [ 90.800082] Call Trace:
    [ 90.800082] [] __fput+0xc8/0x1f0
    [ 90.800082] [] ____fput+0xe/0x10
    ...
    [ 90.800082] [] do_signal+0x28/0x580
    [ 90.800082] [] ? finish_task_switch+0xa6/0x180
    [ 90.800082] [] ? __schedule+0x28f/0x870
    [ 90.800082] [] ? hvt_op_read+0x12a/0x140 [hv_utils]
    ...

    The problem is that hvutil_transport_destroy() which does misc_deregister()
    freeing the appropriate device is reachable by two paths: module unload
    and from util_remove(). While module unload path is protected by .owner in
    struct file_operations util_remove() path is not. Freeing the device while
    someone holds an open fd for it is a show stopper.

    In general, it is not possible to revoke an fd from all users so the only
    way to solve the issue is to defer freeing the hvutil_transport structure.

    Signed-off-by: Vitaly Kuznetsov
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     
  • When Hyper-V host asks us to remove some util driver by closing the
    appropriate channel there is no easy way to force the current file
    descriptor holder to hang up but we can start to respond -EBADF to all
    operations asking it to exit gracefully.

    As we're setting hvt->mode from two separate contexts now we need to use
    a proper locking.

    Signed-off-by: Vitaly Kuznetsov
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     
  • As a preparation to reusing outmsg_lock to protect test-and-set openrations
    on 'mode' rename it the more general 'lock'.

    Signed-off-by: Vitaly Kuznetsov
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     
  • inmsg should be freed in case of on_msg() failure to avoid memory leak.
    Preserve the error code from on_msg().

    Signed-off-by: Vitaly Kuznetsov
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Vitaly Kuznetsov
     
  • When the handshake with daemon is complete, we should poll the channel since
    during the handshake, we will not be processing any messages. This is a
    potential bug if the host is waiting for a response from the guest.
    I would like to thank Dexuan for pointing this out.

    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    K. Y. Srinivasan
     
  • Force all channel messages to be delivered on CPU0. These messages are not
    performance critical and are used during the setup and teardown of the
    channel.

    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    K. Y. Srinivasan
     
  • Hypervisor Top Level Functional Specification v3/4 says
    that TSC page sequence value = -1(0xFFFFFFFF) is used to
    indicate that TSC page no longer reliable source of reference
    timer. Unfortunately, we found that Windows Hyper-V guest
    side implementation uses sequence value = 0 to indicate
    that Tsc page no longer valid. This is clearly visible
    inside Windows 2012R2 ntoskrnl.exe HvlGetReferenceTime()
    function dissassembly:

    HvlGetReferenceTime proc near
    xchg ax, ax
    loc_1401C3132:
    mov rax, cs:HvlpReferenceTscPage
    mov r9d, [rax]
    test r9d, r9d
    jz short loc_1401C3176
    rdtsc
    mov rcx, cs:HvlpReferenceTscPage
    shl rdx, 20h
    or rdx, rax
    mov rax, [rcx+8]
    mov rcx, cs:HvlpReferenceTscPage
    mov r8, [rcx+10h]
    mul rdx
    mov rax, cs:HvlpReferenceTscPage
    add rdx, r8
    mov ecx, [rax]
    cmp ecx, r9d
    jnz short loc_1401C3132
    jmp short loc_1401C3184
    loc_1401C3176:
    mov ecx, 40000020h
    rdmsr
    shl rdx, 20h
    or rdx, rax
    loc_1401C3184:
    mov rax, rdx
    retn
    HvlGetReferenceTime endp

    This patch aligns Tsc page invalid sequence value with
    Windows Hyper-V guest implementation which is more
    compatible with both Hyper-V hypervisor and KVM hypervisor.

    Signed-off-by: Andrey Smetanin
    Signed-off-by: Denis V. Lunev
    CC: "K. Y. Srinivasan"
    CC: Haiyang Zhang
    CC: Vitaly Kuznetsov

    Signed-off-by: Denis V. Lunev
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Andrey Smetanin