Language Selection

English French German Italian Portuguese Spanish

Kernel: NVIDIA, Wayland and Intel

Filed under
Linux
  • NVIDIA Fixes Flaws in Linux4Tegra Driver for Jetson AI Supercomputers

    NVIDIA released a security update for the Jetson TX1 and TX2 to patch vulnerabilities discovered in the Linux for Tegra (L4T or Linux4Tegra) driver package that could enable local attackers with basic user privileges to elevate privileges and to perform privilege escalation, denial-of-service (DoS) or information disclosure attacks.

    As described by NVIDIA, Jetson TX1 and TX2 are high-performance and low-power embedded AI supercomputers on a module designed to be used for compute-intensive deep learning and computer vision projects.

  • RFC: Wayland high-resolution wheel scrolling
    I've been trying to sort out the new hi-res wheel scrolling that was added to
    linux 5.0 but it's been a bit of a struggle to say the least. For the
    impatient, skip forward to the protocol diff but the background info is
    important.
    
    Everything below applies equally to horizontal and vertical scrolling, both
    directions and wheels and wheel tilts.
    
    The APIs that are involved for low-resolution wheel scrolling:
    
    kernel:
    - REL_WHEEL for every wheel click
    
    libinput uses pointer axis events for wheels:
    - pointer axis value: the movement of the wheel in degrees
    - pointer axis discrete value: the number of wheel clicks
    - pointer axis source: set to 'wheel'
    
    Usally this means you get discrete 1, value 15 for the standard 15-degree mouse
    wheel, discrete 2 value 30 is two wheel clicks within one hw frame.
    
    There is one implicit assumption here: the discrete value must
    be 1 or more for every event. Otherwise it's impossible to use the value and
    calculate the angle. More on that later.
    
    This API is effectively the same in the wayland protocol except for the unit of
    the 'value' which is is in screen coordinates, not degrees.
    
    wayland protocol:
    - pointer axis value: the movement in screen coordinates
    - pointer axis discrete: the number of wheel clicks
    - pointer axis source: set to 'wheel'
    
    The big difference here though: libinput's API is per-device, wayland's API is
    per wl-seat pointer. There's no way to tell in the protocol that you're
    scrolling simultaneously with wheels on two different mice.
    
    Let's see how the common compositors implement this:
    
    weston:
    - for source wheel, only the discrete value is handled and:
    - pointer axis discrete is sent as-is from libinput
    - pointer axis source is sent as-is from libinput
    - pointer axis value is always (discrete * 10)
    - otherwise the libinput pointer value (degrees) from a source wheel is ignored
    
    The magic multiplier 10 is afaik for historical reasons, weston used to do 10
    so early libinput took that. When libinput switched to use physical dimensions
    instead of 10, that value was kept for backwards compatibility with existing
    wayland clients.
    
    mutter:
    - for source wheel, only the discrete value is handled and:
    - clutter-internal event for the discrete **direction** from libinput
      - i.e. discrete > 1 will still only generate one event,some events
        drop to the floor here for fast wheel movements
    - clutter-internal event with (value * 10) marked as 'emulated' but
      that event is ignored later when we're writing to the protocol
    - the discrete event is written as wl_pointer.axis_discrete and
      wl_pointer.axis with a value of 10
    
    So, the same multiplier of 10 but fast scroll events with more than one click
    per frame appear to get dropped.
    
    kwin (through qtwayland):
    - doesn't handle discrete at all afaict
    - pointer axis events are passed through but I got a bit confused over the
      actual value written on the wire here.
    
    wlroots:
    - pointer axis discrete is sent as-is from libinput
    - pointer axis source is sent as-is from libinput
    - pointer axis value is sent as-is from libinput
    
    Because the physical angle is passed on from libinput as screen coordinates,
    this means wlroots has different scroll behaviour to GNOME/sway and it does
    scroll a larger distance for wheels with higher click angles. This is the
    opposite of the intended behaviour, manufacturers advertise these wheels
    as slow-scrolling wheels. Realistically though the physical movements is the
    same-ish and if a client uses discrete it doesn't matter anyway.
    
    xf86-input-libinput:
    - X devices need to set up a scroll distance for scroll motion, the driver
      uses 120 (since Feb, before it was 15). This means any multiple of 120.0
      triggers legacy button emulation in the server, otherwise the number has no
      meaning.
    - for source wheel it uses the discrete value only, so effectively 120 *
      discrete.
    
    This driver had a division by 0 for discrete values of 0, fixed in the
    current release. More on this later.
    
    
    
    Let's look at how wheel events are processed in some of the clients:
    
    GTK:
    - for a discrete event, GDK_SCROLL_UP is passed on flagged as 'emulated'
    - the axis value is passed on as GDK_SCROLL_SMOOTH
    
    Qt:
    - doesn't handle discrete
    - multiplies the value by -12. This gives it a 120-based value which
      matches the Windows API provided the axis value is 10 of course.
      Qt on wlroots is probably off here.
    
    Xwayland:
    - X devices need to set up a scroll distance for scroll motion, Xwayland
      currently uses 1.0 for that. This means any multiple of 1.0 triggers legacy
      button emulation in the server.
    - wl_pointer.axis_discrete are used where available
    - wl_pointer.axis uses the value * 0.1. This effectively means Xwayland
      relies on the deltas to be 10 like in mutter/weston, X clients under
      wlroots will have off wheel click emulation.
    
    With me so far? Hooray, now let's introduce hi-res scrolling.
    
    All the examples below are for a quarter scroll wheel movement, i.e. you get
    4 hi-res events for every 1 lo-res event. The kernel uses a fraction/multiple
    of 120 for logical clicks, same as the Windows API. So one wheel click is 120,
    half a click is 60, etc. I'm calling this 120-based value the v120 because I'm
    very creative.
    
    kernel:
    - REL_WHEEL for every wheel click
    - REL_WHEEL_HI_RES for every fraction of a wheel click (as portion of 120),
      so a quarter-wheel stop gives you a value of 30.
      - there is no guarantee that REL_WHEEL is sent every full 120 because e.g.
        Logitech mice may reset halfway through a wheel motion. So the two axes
        must be considered completely independent.
    
    libinput:
    
    Basically: the current API is fairly useless in handling fractional scroll
    because libinput uses physical distances. libinput could send four events:
    - value 3.75, discrete 0
    - value 3.75, discrete 0
    - value 3.75, discrete 0
    - value 3.75, discrete 1
    
    Which is technically correct. But callers have no reliable way how much of a
    fraction of a wheel the 3.75 represents until the first discrete event comes
    in. Guessing is unreliable, if you scroll faster you may get 2+ fractional
    units in one event. And mice may reset halfway through a scroll motion so you
    don't always get the same number of events per discrete. So libinput needs some
    extra API that gives us some baseline to compare values against, i.e. same as
    the kernel's 120-based API does.
    
    There are other problems, specifically related to sending discrete 0 events:
    
    weston:
    - Current weston: a discrete value of 0 ends up as value of 0 which weston
      treats as axis_stop event. So our event sequence is axis_source,
      axis_stop, pointer_frame. this breaks scrolling.
    
    mutter:
    - Current mutter: a discrete value of 0 ends up in noops.
      mutter still generates internal clutter events but they are never pushed
      onto the wire. The normal values are ignored, so we basically
      get low-res scrolling just as before.
      Note: this is based on reading the code, not test runs
    
    wlroots:
    - will forward value/discrete as it comes in from libinput
    
    kwin:
    - doesn't use discrete so won't be affected by changes
    
    xf86-input-libinput:
    - anything pre 0.28.2 will get a division by 0
    - current state: discrete values of 0 end up as noops and we we get lo-res
      scrolling only
    
    So basically: if we change libinput to send discrete 0 events, we'll break
    weston and all but the most recent xf86-input-libinput. Code changes are needed
    just to cope with the different event sequence, let alone the actual hi-res bits.
    
    
    
    The solution to this is to add a new event, LIBINPUT_EVENT_POINTER_AXIS_WHEEL.
    That event provides libinput_event_pointer_axis_value_v120() which is basically
    a mirror of the kernel API. This event obsoletes POINTER_AXIS events for
    sources WHEEL and WHEEL_TILT, so callers should just ignore those if they
    support the new event. A branch for this is available here:
    https://gitlab.freedesktop.org/whot/libinput/commits/wip/hi-res-scrolling
    
    The event sequence would now be:
    
    - WHEEL: value 3.75, v120 30
    - WHEEL: value 3.75, v120 30
    - WHEEL: value 3.75, v120 30
    - WHEEL: value 3.75, v120 30
    - AXIS: value 3.75, discrete 1, v120 120
    
    Implementation-wise: AXIS and WHEEL are independent, so there's no guarantee
    that they add up to the same 120 values. This new event is easy to add to
    compositors.
    
    
    
    
    Let's look at the Wayland protocol with the current API given hi-res scroll
    events:
    - value 3.75, no discrete event
    - value 3.75, no discrete event
    - value 3.75, no discrete event
    - value 3.75, discrete 1
    
    This is assuming 15 degrees/4 == 3.75 but if the compositor force wheels
    to a scale of 10, the value would be 2.5.
    
    Qt:
    - doesn't use discrete so won't be affected by changes
    
    GTK:
    - generates 4 GDK_SCROLL_SMOOTH events, 
    - generates 1 GDK_SCROLL_DOWN event ('emulated')
    - GTK doesn't really care as such about whether the distance-to-wheel is 10 or
      something else, it'll just have different scroll distances (e.g. under
      wlroots).
    
    Afaict this works correctly (tested with stock F29 nautilus)
    
    Xwayland:
    - current Xwayland: values are handled as fraction as before, so we get 3
      smooth-scroll events at 25%. Event 4 has a discrete event which is handled
      as full event, so we scroll by a logical click. Total distance is 175%.
    
    This means: Xwayland cannot work at all without any extra wayland protocol
    unless it assumes factor 10 is the base unit.
    
    
    So we have at least one ubiquitous Wayland client that cannot handle it.
    And the issues are very similar to the ones libinput's API has, added to that
    is that you cannot guarantee that two events come from the same device.
    What we need is a new event, but I'm struggling to add this to the wayland
    protocol in a good way, mostly for backwards-compatibility reasons. 
    
    
    Much of the below would be easier to solve if we can say "if you claim to
    support wl_pointer version 8, you get different behaviour for axis events". I
    don't think we can trust clients to handle this correctly, I got burned by
    those assumptions before (in XI2). So I'm ruling out changing any of the
    existing protocol behaviour.
    
    
    My current idea is to add a wl_pointer.axis_v120 event:
    
       wl_pointer.axis_source    wheel
       wl_pointer.axis_v120      30
       wl_pointer.frame
       wl_pointer.axis_source    wheel
       wl_pointer.axis_v120      30
       wl_pointer.frame
       wl_pointer.axis_source    wheel
       wl_pointer.axis_v120      30
       wl_pointer.frame
       wl_pointer.axis_source    wheel
       wl_pointer.axis           10
       wl_pointer.axis_discrete  1
       wl_pointer.axis_v120      30
       wl_pointer.frame
    
    Main problems here: this puts a fair bit of implementation requirements on the
    compositor - skip source/v120/frame for clients < supported version.
    wl_pointer.source cannot currently occur on its own, it requires a
    wl_pointer.axis event in the current protocol. Same with axis_discrete. Empty
    frames are allowed, I think, but pointless.
    
    It also puts a bit of extra logic in the client, you need to remember if you've
    seen a v120 in this frame and discard the axis/axis_discrete events. If not,
    then axis events must be processed as normal.
    
    A possible workaround would be to add v120 to all axis frames (including
    touchpad scrolling) but that would then put the compositor in charge of
    deciding what distance is a wheel click and encodes that information in the
    protocol.
    
    The v120 event must also carry the equivalent to the wl_pointer.axis value so
    that can be passed on into existing code. So the above would have a v120 event
    with v120 value of 30 and an axis value of 2.5 (if enforcing 10 units per
    wheel click).
    
    Because the hi-res and lo-res sources are independent, we need to allow for a
    0-value v120 event, which basically just tags that frame as 
    
    The compositor also need to *always* send v120 events for wheel/tilt sources
    because otherwise the client code becomes even more of a nightmare.
    Where not backed by libinput the compositor needs to handle that itself.
    
    Anyway, the below is the best I've come up with so far though I haven't
    implemented it client-side yet. I'd really appreciate any feedback and/or
    epiphanies.
    
    Cheers,
      Peter
  • High Resolution Scroll Wheel Support Being Worked On For Wayland

    The high resolution scrolling support in Linux 5.0 has been a headache to say the least. After being ejected from Linux 4.20 following early fall-out, the support was merged for Linux 5.0 but the user-space support has yet to stabilize.

    Red Hat input expert Peter Hutterer who has been involved in this high-resolution scroll wheel support for the likes of Logitech and Microsoft mouse referred to the situation as "a bit of a struggle to say the least."

  • Intel Wi-Fi 6 AX200 Launches With Linux Support In Tow

    The product page does list Linux support that comes as little surprise these days. In fact, back in January we wrote about Linux support for these new Intel adapters within the "IWLWIFI" driver and that enablement is now present in the Linux 5.1 kernel.

More in Tux Machines

digiKam 7.7.0 is released

After three months of active maintenance and another bug triage, the digiKam team is proud to present version 7.7.0 of its open source digital photo manager. See below the list of most important features coming with this release. Read more

Dilution and Misuse of the "Linux" Brand

Samsung, Red Hat to Work on Linux Drivers for Future Tech

The metaverse is expected to uproot system design as we know it, and Samsung is one of many hardware vendors re-imagining data center infrastructure in preparation for a parallel 3D world. Samsung is working on new memory technologies that provide faster bandwidth inside hardware for data to travel between CPUs, storage and other computing resources. The company also announced it was partnering with Red Hat to ensure these technologies have Linux compatibility. Read more

today's howtos

  • How to install go1.19beta on Ubuntu 22.04 – NextGenTips

    In this tutorial, we are going to explore how to install go on Ubuntu 22.04 Golang is an open-source programming language that is easy to learn and use. It is built-in concurrency and has a robust standard library. It is reliable, builds fast, and efficient software that scales fast. Its concurrency mechanisms make it easy to write programs that get the most out of multicore and networked machines, while its novel-type systems enable flexible and modular program constructions. Go compiles quickly to machine code and has the convenience of garbage collection and the power of run-time reflection. In this guide, we are going to learn how to install golang 1.19beta on Ubuntu 22.04. Go 1.19beta1 is not yet released. There is so much work in progress with all the documentation.

  • molecule test: failed to connect to bus in systemd container - openQA bites

    Ansible Molecule is a project to help you test your ansible roles. I’m using molecule for automatically testing the ansible roles of geekoops.

  • How To Install MongoDB on AlmaLinux 9 - idroot

    In this tutorial, we will show you how to install MongoDB on AlmaLinux 9. For those of you who didn’t know, MongoDB is a high-performance, highly scalable document-oriented NoSQL database. Unlike in SQL databases where data is stored in rows and columns inside tables, in MongoDB, data is structured in JSON-like format inside records which are referred to as documents. The open-source attribute of MongoDB as a database software makes it an ideal candidate for almost any database-related project. This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the MongoDB NoSQL database on AlmaLinux 9. You can follow the same instructions for CentOS and Rocky Linux.

  • An introduction (and how-to) to Plugin Loader for the Steam Deck. - Invidious
  • Self-host a Ghost Blog With Traefik

    Ghost is a very popular open-source content management system. Started as an alternative to WordPress and it went on to become an alternative to Substack by focusing on membership and newsletter. The creators of Ghost offer managed Pro hosting but it may not fit everyone's budget. Alternatively, you can self-host it on your own cloud servers. On Linux handbook, we already have a guide on deploying Ghost with Docker in a reverse proxy setup. Instead of Ngnix reverse proxy, you can also use another software called Traefik with Docker. It is a popular open-source cloud-native application proxy, API Gateway, Edge-router, and more. I use Traefik to secure my websites using an SSL certificate obtained from Let's Encrypt. Once deployed, Traefik can automatically manage your certificates and their renewals. In this tutorial, I'll share the necessary steps for deploying a Ghost blog with Docker and Traefik.