1. 13 Dec, 2020 31 commits
    • Johannes Berg's avatar
      um: time-travel: Correct time event IRQ delivery · 11385539
      Johannes Berg authored
      Lockdep (on 5.10-rc) points out that we're delivering IRQs while IRQs
      are not even enabled, which clearly shouldn't happen. Defer the time
      event IRQ delivery until they actually are enabled.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      11385539
    • Johannes Berg's avatar
      um: irq/sigio: Support suspend/resume handling of workaround IRQs · cae20ba0
      Johannes Berg authored
      If the sigio workaround needed to be applied to a file descriptor,
      set_irq_wake() wouldn't work for it since it would get polled by
      the thread instead of causing SIGIO, and thus could never really
      cause a wakeup, since the thread notification FD wasn't marked as
      being able to wake up the system.
      
      Fix this by marking the thread's notification FD explicitly as a
      wake source FD, i.e. not suppressing SIGIO for it in suspend. In
      order to not cause spurious wakeups, we then need to remove all
      FDs that shouldn't wake up the system from the polling thread. In
      order to do this, add unlocked versions of ignore_sigio_fd() and
      add_sigio_fd() (nothing else is happening in suspend, so this is
      fine), and also modify ignore_sigio_fd() to return -ENOENT if the
      FD wasn't originally in there. This doesn't matter because nothing
      else currently checks the return value, but the irq code needs to
      know which ones to restore the workaround for.
      
      All told, this lets us use a timerfd for the RTC clock in the next
      patch, which doesn't send SIGIO.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      cae20ba0
    • Johannes Berg's avatar
      um: time-travel: Actually apply "free-until" optimisation · 452f94ce
      Johannes Berg authored
      Due a bug - we never checked the time_travel_ext_free_until value - we
      were always requesting time for every single scheduling. This adds up
      since we make reading time cost 256ns, and it's a fairly common call.
      Fix this.
      
      While at it, also make reading time only cost something when we're not
      currently waiting for our scheduling turn - otherwise things get mixed
      up in a very confusing way. We should never get here, since we're not
      actually running, but it's possible if you stick printk() or such into
      the virtio code that must handle the external interrupts.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      452f94ce
    • Anton Ivanov's avatar
      um: chan_xterm: Fix fd leak · 9431f7c1
      Anton Ivanov authored
      xterm serial channel was leaking a fd used in setting up the
      port helper
      
      This bug is prehistoric - it predates switching to git. The "fixes"
      header here is really just to mark all the versions we would like this to
      apply to which is "Anything from the Cretaceous period onwards".
      
      No dinosaurs were harmed in fixing this bug.
      
      Fixes: b40997b8 ("um: drivers/xterm.c: fix a file descriptor leak")
      Signed-off-by: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      9431f7c1
    • Anton Ivanov's avatar
      um: tty: Fix handling of close in tty lines · 9b1c0c0e
      Anton Ivanov authored
      Fix a logical error in tty reading. We get 0 and errno == EAGAIN
      on the first attempt to read from a closed file descriptor.
      
      Compared to that a true EAGAIN is EAGAIN and -1.
      
      If we check errno for EAGAIN first, before checking the return
      value we miss the fact that the descriptor is closed.
      
      This bug is as old as the driver. It was not showing up with
      the original POLL based IRQ controller, because it was
      producing multiple events. Switching to EPOLL unmasked it.
      
      Fixes: ff6a1798 ("Epoll based IRQ controller")
      Signed-off-by: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      9b1c0c0e
    • Anton Ivanov's avatar
      um: Monitor error events in IRQ controller · e3a01cbe
      Anton Ivanov authored
      Ensure that file closes, connection closes, etc are propagated
      as interrupts in the interrupt controller.
      
      Fixes: ff6a1798 ("Epoll based IRQ controller")
      Signed-off-by: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      e3a01cbe
    • Johannes Berg's avatar
      um: allocate a guard page to helper threads · ef4459a6
      Johannes Berg authored
      We've been running into stack overflows in helper threads
      corrupting memory (e.g. because somebody put printf() or
      os_info() there), so to avoid those causing hard-to-debug
      issues later on, allocate a guard page for helper thread
      stacks and mark it read-only.
      
      Unfortunately, the crash dump at that point is useless as
      the stack tracer will try to backtrace the *kernel* thread,
      not the helper thread, but at least we don't survive to a
      random issue caused by corruption.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      ef4459a6
    • Johannes Berg's avatar
      um: support some of ARCH_HAS_SET_MEMORY · 963285b0
      Johannes Berg authored
      For now, only support set_memory_ro()/rw() which we need for
      the stack protection in the next patch.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      963285b0
    • Johannes Berg's avatar
      um: time-travel: avoid multiple identical propagations · 58b09f68
      Johannes Berg authored
      If there is some kind of interrupt negotation or such then
      it may happen that we send an update message multiple times,
      avoid that in the interest of efficiency by storing the last
      transmitted value and only sending a new update if it's not
      the same as the last update.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      58b09f68
    • Anton Ivanov's avatar
      um: Fetch registers only for signals which need them · 3c6ac61b
      Anton Ivanov authored
      UML userspace fetches siginfo and passes it to signal handlers
      in UML. This is needed only for some of the signals, because
      key handlers like SIGIO make no use of this variable.
      Signed-off-by: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      3c6ac61b
    • Johannes Berg's avatar
      um: Support suspend to RAM · a374b7cb
      Johannes Berg authored
      With all the previous bits in place, we can now also support
      suspend to RAM, in the sense that everything is suspended,
      not just most, including userspace, processes like in s2idle.
      
      Since um_idle_sleep() now waits forever, we can simply call
      that to "suspend" the system.
      
      As before, you can wake it up using SIGUSR1 since we're just
      in a pause() call that only needs to return.
      
      In order to implement selective resume from certain devices,
      and not have any arbitrary device interrupt wake up, suspend
      interrupts by removing SIGIO notification (O_ASYNC) from all
      the FDs that are not supposed to wake up the system. However,
      swap out the handler so we don't actually handle the SIGIO as
      an interrupt.
      
      Since we're in pause(), the mere act of receiving SIGIO wakes
      us up, and then after things have been restored enough, re-set
      O_ASYNC for all previously suspended FDs, reinstall the proper
      SIGIO handler, and send SIGIO to self to process anything that
      might now be pending.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      a374b7cb
    • Johannes Berg's avatar
      um: Allow PM with suspend-to-idle · 92dcd3d3
      Johannes Berg authored
      In order to be able to experiment with suspend in UML, add the
      minimal work to be able to suspend (s2idle) an instance of UML,
      and be able to wake it back up from that state with the USR1
      signal sent to the main UML process.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      92dcd3d3
    • Johannes Berg's avatar
      um: time: Fix read_persistent_clock64() in time-travel · 2701c1bd
      Johannes Berg authored
      In time-travel mode, we've relied on read_persistent_clock64()
      being called only once at system startup, but this is both the
      right thing to call from the pseudo-RTC, and also gets called
      by the timekeeping core during suspend/resume.
      
      Thus, fix this to always fall make use of the time_travel_time
      in any time-travel mode, initializing time_travel_start at boot
      to the right value depending on the time-travel mode.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      2701c1bd
    • Johannes Berg's avatar
      um: Simplify os_idle_sleep() and sleep longer · 49da38a3
      Johannes Berg authored
      There really is no reason to pass the amount of time we should
      sleep, especially since it's just hard-coded to one second.
      
      Additionally, one second isn't really all that long, and as we
      are expecting to be woken up by a signal, we can sleep longer
      and avoid doing some work every second, so replace the current
      clock_nanosleep() with just an empty select() that can _only_
      be woken up by a signal.
      
      We can also remove the deliver_alarm() since we don't need to
      do that when we got e.g. SIGIO that woke us up, and if we got
      SIGALRM the signal handler will actually (have) run, so it's
      just unnecessary extra work.
      
      Similarly, in time-travel mode, just program the wakeup event
      from idle to be S64_MAX, which is basically the most you could
      ever simulate to. Of course, you should already have an event
      in the list that's earlier and will cause a wakeup, normally
      that's the regular timer interrupt, though in suspend it may
      (later) also be an RTC event. Since actually getting to this
      point would be a bug and you can't ever get out again, panic()
      on it in the time control code.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      49da38a3
    • Johannes Berg's avatar
      um: Simplify IRQ handling code · 3032b945
      Johannes Berg authored
      Reduce dynamic allocations (and thereby cache misses) by simply
      embedding the registration data for IRQs in the irq_entry, we
      never supported these being really dynamic anyway as only one
      was ever allowed ("Trying to reregister ...").
      
      Lockless behaviour is preserved by removing the FD from the poll
      set appropriately, but we use reg->events to indicate whether or
      not this entry is used, rather than dynamically allocating them.
      
      Also port the list of IRQ entries to list_head instead of the
      current open-coded singly-linked list implementation, just for
      sanity.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      3032b945
    • Johannes Berg's avatar
      um: Remove IRQ_NONE type · 2fccfcc0
      Johannes Berg authored
      We don't actually use this in um_request_irq(), so it can
      never be assigned. It's also not clear what that would be
      useful for, so just remove it.
      
      This results in quite a number of cleanups, all the way to
      removing the "SIGIO on close" startup check, since the data
      it assigns (pty_close_sigio) is not used anymore.
      
      While at it, also make this an enum so we get a minimum of
      type checking, and remove the IRQ_NONE hack in virtio since
      we now no longer have the name twice.
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      2fccfcc0
    • Johannes Berg's avatar
      um: irq: Reduce irq_reg allocation · 0737402f
      Johannes Berg authored
      We don't need an array of 4 entries to capture three and the
      name 'MAX_IRQ_TYPE' really gets confusing as well. Remove it
      and add a correct NUM_IRQ_TYPES, and use that correctly.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      0737402f
    • Johannes Berg's avatar
      um: irq: Clean up and rename struct irq_fd · 458e1f7d
      Johannes Berg authored
      This really shouldn't be called "irq_fd" since it doesn't
      carry an fd. Well, it used to, apparently, but that struct
      member is unused.
      
      Rename it to "irq_reg" since it more accurately reflects a
      registered interrupt, and remove the unused 'next' and 'fd'
      members from the struct as well.
      
      While at it, also move it to the implementation, it's not
      used anywhere else, and the header file is shared with the
      userspace components.
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      458e1f7d
    • Johannes Berg's avatar
      um: Clean up alarm IRQ chip name · 0ede3c05
      Johannes Berg authored
      We don't use "SIGVTALRM", it's just SIGALRM. Clean up the naming.
      While at it, fix the comment's grammar.
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      0ede3c05
    • Johannes Berg's avatar
      um: virtio: Use dynamic IRQ allocation · aaf5800e
      Johannes Berg authored
      This separates the devices, which is better for debug and for
      later suspend/resume and wakeup support, since there we'll
      have to separate which IRQs can wake up the system and which
      cannot.
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      aaf5800e
    • Johannes Berg's avatar
      um: Support dynamic IRQ allocation · 36d46a59
      Johannes Berg authored
      It's cumbersome and error-prone to keep adding fixed IRQ numbers,
      and for proper device wakeup support for the virtio/vhost-user
      support we need to have different IRQs for each device. Even if
      in theory two IRQs (with and without wake) might be sufficient,
      it's much easier to reason about it when we have dynamic number
      assignment. It also makes it easier to add new devices that may
      dynamically exist or depending on the configuration, etc.
      
      Add support for this, up to 64 IRQs (the same limit as epoll FDs
      we have right now). Since it's not easy to port all the existing
      places to dynamic allocation (some data is statically initialized)
      keep the low numbers are reserved for the existing hard-coded IRQ
      numbers.
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      36d46a59
    • Johannes Berg's avatar
      um: sigio: Return error from add_sigio_fd() · d66c9183
      Johannes Berg authored
      If we run out of space, return an error instead of 0.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      d66c9183
    • Christopher Obbard's avatar
      um: ubd: Set device serial attribute from cmdline · ef3ba87c
      Christopher Obbard authored
      Adds the ability to set the UBD device serial number from the
      commandline, disabling the serial number functionality by default.
      
      In some cases it may be useful to set a serial to the UBD device, such
      that downstream users (i.e. udev) can use this information to better
      describe the hardware to the user from the UML cmdline. In our case we
      use this parameter to create some entries under /dev/disk/by-ubd-id/
      for each of the UBD devices passed through the UML cmdline.
      Signed-off-by: default avatarChristopher Obbard <chris.obbard@collabora.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      ef3ba87c
    • Andy Shevchenko's avatar
      um: Increase stack frame size threshold for signal.c · 517f6020
      Andy Shevchenko authored
      The signal.c can't use heap for bit data located on stack. However,
      by default a compiler warns us about overstepping stack frame size
      threshold:
      
      arch/um/os-Linux/signal.c: In function ‘sig_handler_common’:
      arch/um/os-Linux/signal.c:51:1: warning: the frame size of 2960 bytes is larger than 2048 bytes [-Wframe-larger-than=]
         51 | }
            | ^
      arch/um/os-Linux/signal.c: In function ‘timer_real_alarm_handler’:
      arch/um/os-Linux/signal.c:95:1: warning: the frame size of 2960 bytes is larger than 2048 bytes [-Wframe-larger-than=]
          95 | }
             | ^
      
      Due to above increase stack frame size threshold explicitly for signal.c
      to avoid unnecessary warning.
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Tested-by: default avatarDavid Gow <davidgow@google.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      517f6020
    • Johannes Berg's avatar
      um: line: Don't free winch (with IRQ) under spinlock · f4ab7818
      Johannes Berg authored
      Lockdep correctly complains that one shouldn't call um_free_irq()
      with free_irq() inside under a spinlock since that will attempt
      to acquire a mutex.
      
      Rearrange the code to keep the list manipulations under the lock
      while moving the actual freeing outside of it, to avoid this.
      
      In particular, this removes the lockdep complaint at shutdown that
      I was seeing with lockdep enabled.
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Acked-By: anton.ivanov@cambridgegreys.com
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      f4ab7818
    • Gabriel Krisman Bertazi's avatar
      um: ubd: Submit all data segments atomically · fc6b6a87
      Gabriel Krisman Bertazi authored
      Internally, UBD treats each physical IO segment as a separate command to
      be submitted in the execution pipe.  If the pipe returns a transient
      error after a few segments have already been written, UBD will tell the
      block layer to requeue the request, but there is no way to reclaim the
      segments already submitted.  When a new attempt to dispatch the request
      is done, those segments already submitted will get duplicated, causing
      the WARN_ON below in the best case, and potentially data corruption.
      
      In my system, running a UML instance with 2GB of RAM and a 50M UBD disk,
      I can reproduce the WARN_ON by simply running mkfs.fvat against the
      disk on a freshly booted system.
      
      There are a few ways to around this, like reducing the pressure on
      the pipe by reducing the queue depth, which almost eliminates the
      occurrence of the problem, increasing the pipe buffer size on the host
      system, or by limiting the request to one physical segment, which causes
      the block layer to submit way more requests to resolve a single
      operation.
      
      Instead, this patch modifies the format of a UBD command, such that all
      segments are sent through a single element in the communication pipe,
      turning the command submission atomic from the point of view of the
      block layer.  The new format has a variable size, depending on the
      number of elements, and looks like this:
      
      +------------+-----------+-----------+------------
      | cmd_header | segment 0 | segment 1 | segment ...
      +------------+-----------+-----------+------------
      
      With this format, we push a pointer to cmd_header in the submission
      pipe.
      
      This has the advantage of reducing the memory footprint of executing a
      single request, since it allow us to merge some fields in the header.
      It is possible to reduce even further each segment memory footprint, by
      merging bitmap_words and cow_offset, for instance, but this is not the
      focus of this patch and is left as future work.  One issue with the
      patch is that for a big number of segments, we now perform one big
      memory allocation instead of multiple small ones, but I wasn't able to
      trigger any real issues or -ENOMEM because of this change, that wouldn't
      be reproduced otherwise.
      
      This was tested using fio with the verify-crc32 option, and by running
      an ext4 filesystem over this UBD device.
      
      The original WARN_ON was:
      
      ------------[ cut here ]------------
      WARNING: CPU: 0 PID: 0 at lib/refcount.c:28 refcount_warn_saturate+0x13f/0x141
      refcount_t: underflow; use-after-free.
      Modules linked in:
      CPU: 0 PID: 0 Comm: swapper Not tainted 5.5.0-rc6-00002-g2a5bb2cf75c8 #346
      Stack:
       6084eed0 6063dc77 00000009 6084ef60
       00000000 604b8d9f 6084eee0 6063dcbc
       6084ef40 6006ab8d e013d780 1c00000000
      Call Trace:
       [<600a0c1c>] ? printk+0x0/0x94
       [<6004a888>] show_stack+0x13b/0x155
       [<6063dc77>] ? dump_stack_print_info+0xdf/0xe8
       [<604b8d9f>] ? refcount_warn_saturate+0x13f/0x141
       [<6063dcbc>] dump_stack+0x2a/0x2c
       [<6006ab8d>] __warn+0x107/0x134
       [<6008da6c>] ? wake_up_process+0x17/0x19
       [<60487628>] ? blk_queue_max_discard_sectors+0x0/0xd
       [<6006b05f>] warn_slowpath_fmt+0xd1/0xdf
       [<6006af8e>] ? warn_slowpath_fmt+0x0/0xdf
       [<600acc14>] ? raw_read_seqcount_begin.constprop.0+0x0/0x15
       [<600619ae>] ? os_nsecs+0x1d/0x2b
       [<604b8d9f>] refcount_warn_saturate+0x13f/0x141
       [<6048bc8f>] refcount_sub_and_test.constprop.0+0x2f/0x37
       [<6048c8de>] blk_mq_free_request+0xf1/0x10d
       [<6048ca06>] __blk_mq_end_request+0x10c/0x114
       [<6005ac0f>] ubd_intr+0xb5/0x169
       [<600a1a37>] __handle_irq_event_percpu+0x6b/0x17e
       [<600a1b70>] handle_irq_event_percpu+0x26/0x69
       [<600a1bd9>] handle_irq_event+0x26/0x34
       [<600a1bb3>] ? handle_irq_event+0x0/0x34
       [<600a5186>] ? unmask_irq+0x0/0x37
       [<600a57e6>] handle_edge_irq+0xbc/0xd6
       [<600a131a>] generic_handle_irq+0x21/0x29
       [<60048f6e>] do_IRQ+0x39/0x54
       [...]
      ---[ end trace c6e7444e55386c0f ]---
      
      Cc: Christopher Obbard <chris.obbard@collabora.com>
      Reported-by: default avatarMartyn Welch <martyn@collabora.com>
      Signed-off-by: default avatarGabriel Krisman Bertazi <krisman@collabora.com>
      Tested-by: default avatarChristopher Obbard <chris.obbard@collabora.com>
      Acked-by: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      fc6b6a87
    • Johannes Berg's avatar
      um: Fix time-travel mode · ff9632d2
      Johannes Berg authored
      Since the time-travel rework, basic time-travel mode hasn't worked
      properly, but there's no longer a need for this WARN_ON() so just
      remove it and thereby fix things.
      
      Cc: stable@vger.kernel.org
      Fixes: 4b786e24 ("um: time-travel: Rewrite as an event scheduler")
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      ff9632d2
    • Anton Ivanov's avatar
      um: Remove use of asprinf in umid.c · 97be7cea
      Anton Ivanov authored
      asprintf is not compatible with the existing uml memory allocation
      mechanism. Its use on the "user" side of UML results in a corrupt slab
      state.
      
      Fixes: 0d4e5ac7 ("um: remove uses of variable length arrays")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      97be7cea
    • Jens Axboe's avatar
      um: Add support for TIF_NOTIFY_SIGNAL · 09041c92
      Jens Axboe authored
      Wire up TIF_NOTIFY_SIGNAL handling for um.
      
      Cc: linux-um@lists.infradead.org
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      09041c92
    • Christopher Obbard's avatar
      um: random: Register random as hwrng-core device · 72d3e093
      Christopher Obbard authored
      The UML random driver creates a dummy device under the guest,
      /dev/hw_random. When this file is read from the guest, the driver
      reads from the host machine's /dev/random, in-turn reading from
      the host kernel's entropy pool. This entropy pool could have been
      filled by a hardware random number generator or just the host
      kernel's internal software entropy generator.
      
      Currently the driver does not fill the guests kernel entropy pool,
      this requires a userspace tool running inside the guest (like
      rng-tools) to read from the dummy device provided by this driver,
      which then would fill the guest's internal entropy pool.
      
      This all seems quite pointless when we are already reading from an
      entropy pool, so this patch aims to register the device as a hwrng
      device using the hwrng-core framework. This not only improves and
      cleans up the driver, but also fills the guest's entropy pool
      without having to resort to using extra userspace tools in the guest.
      
      This is typically a nuisance when booting a guest: the random pool
      takes a long time (~200s) to build up enough entropy since the dummy
      hwrng is not used to fill the guest's pool.
      
      This port was originally attempted by Alexander Neville "dark" (in CC,
      discussion in Link), but the conversation there stalled since the
      handling of -EAGAIN errors were no removed and longer handled by the
      driver. This patch attempts to use the existing method of error
      handling but utilises the new hwrng core.
      
      The issue can be noticed when booting a UML guest:
      
          [    2.560000] random: fast init done
          [  214.000000] random: crng init done
      
      With the patch applied, filling the pool becomes a lot quicker:
      
          [    2.560000] random: fast init done
          [   12.000000] random: crng init done
      
      Cc: Alexander Neville <dark@volatile.bz>
      Link: https://lore.kernel.org/lkml/20190828204609.02a7ff70@TheDarkness/
      Link: https://lore.kernel.org/lkml/20190829135001.6a5ff940@TheDarkness.local/
      Cc: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
      Signed-off-by: default avatarChristopher Obbard <chris.obbard@collabora.com>
      Acked-by: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      72d3e093
    • Allen Pais's avatar
      um: Convert tasklets to use new tasklet_setup() API · db03b428
      Allen Pais authored
      In preparation for unconditionally passing the
      struct tasklet_struct pointer to all tasklet
      callbacks, switch to using the new tasklet_setup()
      and from_tasklet() to pass the tasklet pointer explicitly.
      Signed-off-by: default avatarRomain Perier <romain.perier@gmail.com>
      Signed-off-by: default avatarAllen Pais <allen.lkml@gmail.com>
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      db03b428
  2. 29 Nov, 2020 5 commits
  3. 28 Nov, 2020 4 commits
    • Linus Torvalds's avatar
      Merge tag 'riscv-for-linus-5.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux · aae5ab85
      Linus Torvalds authored
      Pull RISC-V fixes from Palmer Dabbelt:
       "I've collected a handful of fixes over the past few weeks:
      
         - A fix to un-break the build-id argument to the vDSO build, which is
           necessary for the LLVM linker.
      
         - A fix to initialize the jump label subsystem, without which it (and
           all the stuff that uses it) doesn't actually function.
      
         - A fix to include <asm/barrier.h> from <vdso/processor.h>, without
           which some drivers won't compile"
      
      * tag 'riscv-for-linus-5.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
        RISC-V: fix barrier() use in <vdso/processor.h>
        RISC-V: Add missing jump label initialization
        riscv: Explicitly specify the build id style in vDSO Makefile again
      aae5ab85
    • Linus Torvalds's avatar
      Merge tag 'kbuild-fixes-v5.10' of... · 45e885c4
      Linus Torvalds authored
      Merge tag 'kbuild-fixes-v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
      
      Pull Kbuild fixes from Masahiro Yamada:
      
       - Remove unused OBJSIZE variable.
      
       - Fix rootless deb-pkg build in a setgid directory.
      
      * tag 'kbuild-fixes-v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
        builddeb: Fix rootless build in setuid/setgid directory
        kbuild: remove unused OBJSIZE
      45e885c4
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-fixes-for-v5.10-2020-11-28' of... · ca579827
      Linus Torvalds authored
      Merge tag 'perf-tools-fixes-for-v5.10-2020-11-28' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull perf tool fixes from Arnaldo Carvalho de Melo:
      
       - Fix die_entrypc() when DW_AT_ranges DWARF attribute not available
      
       - Cope with broken DWARF (missing DW_AT_declaration) generated by some
         recent gcc versions
      
       - Do not generate CGROUP metadata events when not asked to in 'perf
         record'
      
       - Use proper CPU for shadow stats in 'perf stat'
      
       - Update copy of libbpf's hashmap.c, silencing tools/perf build warning
      
       - Fix return value in 'perf diff'
      
      * tag 'perf-tools-fixes-for-v5.10-2020-11-28' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
        perf probe: Change function definition check due to broken DWARF
        perf probe: Fix to die_entrypc() returns error correctly
        perf stat: Use proper cpu for shadow stats
        perf record: Synthesize cgroup events only if needed
        perf diff: Fix error return value in __cmd_diff()
        perf tools: Update copy of libbpf's hashmap.c
      ca579827
    • Linus Torvalds's avatar
      Merge tag 'usb-5.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · 67f34fa8
      Linus Torvalds authored
      Pull USB / PHY driver fixes from Greg KH:
       "Here are a few small USB and PHY driver fixes for 5.10-rc6. They
        include:
      
         - small PHY driver fixes to resolve reported issues
      
         - USB quirks added for "broken" devices
      
         - typec fixes for reported problems
      
         - USB gadget fixes for small issues
      
        Full details are in the shortlog, nothing major in here and all have
        been in linux-next with no reported issues"
      
      * tag 'usb-5.10-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
        usb: typec: stusb160x: fix power-opmode property with typec-power-opmode
        USB: core: Change %pK for __user pointers to %px
        USB: core: Fix regression in Hercules audio card
        usb: gadget: Fix memleak in gadgetfs_fill_super
        usb: gadget: f_midi: Fix memleak in f_midi_alloc
        USB: quirks: Add USB_QUIRK_DISCONNECT_SUSPEND quirk for Lenovo A630Z TIO built-in usb-audio card
        usb: typec: qcom-pmic-typec: fix builtin build errors
        phy: mediatek: fix spelling mistake in Kconfig "veriosn" -> "version"
        phy: qualcomm: Fix 28 nm Hi-Speed USB PHY OF dependency
        phy: qualcomm: usb: Fix SuperSpeed PHY OF dependency
        phy: intel: PHY_INTEL_KEEMBAY_EMMC should depend on ARCH_KEEMBAY
        usb: cdns3: gadget: calculate TD_SIZE based on TD
        usb: cdns3: gadget: initialize link_trb as NULL
        phy: cpcap-usb: Use IRQF_ONESHOT
        phy: qcom-qmp: Initialize another pointer to NULL
        phy: tegra: xusb: Fix dangling pointer on probe failure
        phy: usb: Fix incorrect clearing of tca_drv_sel bit in SETUP reg for 7211
      67f34fa8