Skip to content
  1. Feb 09, 2022
    • Peter Zijlstra's avatar
      x86/perf: Default set FREEZE_ON_SMI for all · dd274cf8
      Peter Zijlstra authored
      commit a01994f5
      
       upstream.
      
      Kyle reported that rr[0] has started to malfunction on Comet Lake and
      later CPUs due to EFI starting to make use of CPL3 [1] and the PMU
      event filtering not distinguishing between regular CPL3 and SMM CPL3.
      
      Since this is a privilege violation, default disable SMM visibility
      where possible.
      
      Administrators wanting to observe SMM cycles can easily change this
      using the sysfs attribute while regular users don't have access to
      this file.
      
      [0] https://rr-project.org/
      
      [1] See the Intel white paper "Trustworthy SMM on the Intel vPro Platform"
      at https://bugzilla.kernel.org/attachment.cgi?id=300300, particularly the
      end of page 5.
      
      Reported-by: default avatarKyle Huey <me@kylehuey.com>
      Suggested-by: default avatarAndrew Cooper <Andrew.Cooper3@citrix.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: stable@kernel.org
      Link: https://lkml.kernel.org/r/YfKChjX61OW4CkYm@hirez.programming.kicks-ass.net
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dd274cf8
    • Tristan Hume's avatar
      perf/x86/intel/pt: Fix crash with stop filters in single-range mode · 456f041e
      Tristan Hume authored
      commit 1d909345 upstream.
      
      Add a check for !buf->single before calling pt_buffer_region_size in a
      place where a missing check can cause a kernel crash.
      
      Fixes a bug introduced by commit 67063847 ("perf/x86/intel/pt:
      Opportunistically use single range output mode"), which added a
      support for PT single-range output mode. Since that commit if a PT
      stop filter range is hit while tracing, the kernel will crash because
      of a null pointer dereference in pt_handle_status due to calling
      pt_buffer_region_size without a ToPA configured.
      
      The commit which introduced single-range mode guarded almost all uses of
      the ToPA buffer variables with checks of the buf->single variable, but
      missed the case where tracing was stopped by the PT hardware, which
      happens when execution hits a configured stop filter.
      
      Tested that hitting a stop filter while PT recording successfully
      records a trace with this patch but crashes without this patch.
      
      Fixes: 67063847
      
       ("perf/x86/intel/pt: Opportunistically use single range output mode")
      Signed-off-by: default avatarTristan Hume <tristan@thume.ca>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@kernel.org
      Link: https://lkml.kernel.org/r/20220127220806.73664-1-tristan@thume.ca
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      456f041e
    • Ian Rogers's avatar
      perf stat: Fix display of grouped aliased events · 8c0e6a8a
      Ian Rogers authored
      [ Upstream commit b2b1aa73 ]
      
      An event may have a number of uncore aliases that when added to the
      evlist are consecutive.
      
      If there are multiple uncore events in a group then
      parse_events__set_leader_for_uncore_aliase will reorder the evlist so
      that events on the same PMU are adjacent.
      
      The collect_all_aliases function assumes that aliases are in blocks so
      that only the first counter is printed and all others are marked merged.
      
      The reordering for groups breaks the assumption and so all counts are
      printed.
      
      This change removes the assumption from collect_all_aliases
      that the events are in blocks and instead processes the entire evlist.
      
      Before:
      
        ```
        $ perf stat -e '{UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE,UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE},duration_time' -a -A -- sleep 1
      
         Performance counter stats for 'system wide':
      
        CPU0                  256,866      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 494,413      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      967      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,738      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  285,161      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 429,920      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      955      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,443      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  310,753      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 416,657      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,231      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,573      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  416,067      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 405,966      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,481      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,447      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  312,911      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 408,154      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,086      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,380      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  333,994      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 370,349      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,287      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,335      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  188,107      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 302,423      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      701      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,070      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  307,221      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 383,642      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,036      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,158      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  318,479      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 821,545      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,028      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,550      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  227,618      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 372,272      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      903      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,456      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  376,783      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 419,827      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,406      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,453      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  286,583      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 429,956      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      999      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,436      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  313,867      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 370,159      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,114      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,291      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  342,083      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 409,111      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,399      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,684      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  365,828      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 376,037      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,378      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,411      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  382,456      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 621,743      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,232      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,955      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  342,316      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 385,067      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,176      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,268      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  373,588      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 386,163      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,394      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,464      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  381,206      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 546,891      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,266      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,712      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  221,176      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 392,069      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      831      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,456      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  355,401      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 705,595      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,235      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,216      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  371,436      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 428,103      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,306      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,442      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  384,352      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 504,200      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,468      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,860      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  228,856      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 287,976      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      832      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,060      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  215,121      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 334,162      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      681      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,026      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  296,179      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 436,083      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,084      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,525      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  262,296      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 416,573      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      986      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,533      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  285,852      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 359,842      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,073      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,326      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  303,379      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 367,222      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,008      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,156      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  273,487      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 425,449      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      932      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,367      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  297,596      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 414,793      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,140      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,601      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  342,365      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 360,422      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,291      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,342      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  327,196      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 580,858      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,122      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,014      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  296,564      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 452,817      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,087      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,694      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  375,002      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 389,393      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,478      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,540      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  365,213      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 594,685      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,401      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,222      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0            1,000,749,060 ns   duration_time
      
               1.000749060 seconds time elapsed
        ```
      
      After:
      
        ```
         Performance counter stats for 'system wide':
      
        CPU0               20,547,434      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36              45,202,862      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                   82,001      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                 159,688      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0            1,000,464,828 ns   duration_time
      
               1.000464828 seconds time elapsed
        ```
      
      Fixes: 3cdc5c2c
      
       ("perf parse-events: Handle uncore event aliases in small groups properly")
      Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
      Cc: Asaf Yaffe <asaf.yaffe@intel.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vineet Singh <vineet.singh@intel.com>
      Cc: Zhengjun Xing <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20220205010941.1065469-1-irogers@google.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8c0e6a8a
    • Helge Deller's avatar
      fbcon: Add option to enable legacy hardware acceleration · 57e8859a
      Helge Deller authored
      commit a3f781a9
      
       upstream.
      
      Add a config option CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION to
      enable bitblt and fillrect hardware acceleration in the framebuffer
      console. If disabled, such acceleration will not be used, even if it is
      supported by the graphics hardware driver.
      
      If you plan to use DRM as your main graphics output system, you should
      disable this option since it will prevent compiling in code which isn't
      used later on when DRM takes over.
      
      For all other configurations, e.g. if none of your graphic cards support
      DRM (yet), DRM isn't available for your architecture, or you can't be
      sure that the graphic card in the target system will support DRM, you
      most likely want to enable this option.
      
      In the non-accelerated case (e.g. when DRM is used), the inlined
      fb_scrollmode() function is hardcoded to return SCROLL_REDRAW and as such the
      compiler is able to optimize much unneccesary code away.
      
      In this v3 patch version I additionally changed the GETVYRES() and GETVXRES()
      macros to take a pointer to the fbcon_display struct. This fixes the build when
      console rotation is enabled and helps the compiler again to optimize out code.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Cc: stable@vger.kernel.org # v5.10+
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-4-deller@gmx.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      57e8859a
    • Helge Deller's avatar
      Revert "fbcon: Disable accelerated scrolling" · 460f6b1a
      Helge Deller authored
      commit 87ab9f6b upstream.
      
      This reverts commit 39aead83.
      
      Revert the first (of 2) commits which disabled scrolling acceleration in
      fbcon/fbdev.  It introduced a regression for fbdev-supported graphic cards
      because of the performance penalty by doing screen scrolling by software
      instead of using the existing graphic card 2D hardware acceleration.
      
      Console scrolling acceleration was disabled by dropping code which
      checked at runtime the driver hardware capabilities for the
      BINFO_HWACCEL_COPYAREA or FBINFO_HWACCEL_FILLRECT flags and if set, it
      enabled scrollmode SCROLL_MOVE which uses hardware acceleration to move
      screen contents.  After dropping those checks scrollmode was hard-wired
      to SCROLL_REDRAW instead, which forces all graphic cards to redraw every
      character at the new screen position when scrolling.
      
      This change effectively disabled all hardware-based scrolling acceleration for
      ALL drivers, because now all kind of 2D hardware acceleration (bitblt,
      fillrect) in the drivers isn't used any longer.
      
      The original commit message mentions that only 3 DRM drivers (nouveau, omapdrm
      and gma500) used hardware acceleration in the past and thus code for checking
      and using scrolling acceleration is obsolete.
      
      This statement is NOT TRUE, because beside the DRM drivers there are around 35
      other fbdev drivers which depend on fbdev/fbcon and still provide hardware
      acceleration for fbdev/fbcon.
      
      The original commit message also states that syzbot found lots of bugs in fbcon
      and thus it's "often the solution to just delete code and remove features".
      This is true, and the bugs - which actually affected all users of fbcon,
      including DRM - were fixed, or code was dropped like e.g. the support for
      software scrollback in vgacon (commit 973c096f
      
      ).
      
      So to further analyze which bugs were found by syzbot, I've looked through all
      patches in drivers/video which were tagged with syzbot or syzkaller back to
      year 2005. The vast majority fixed the reported issues on a higher level, e.g.
      when screen is to be resized, or when font size is to be changed. The few ones
      which touched driver code fixed a real driver bug, e.g. by adding a check.
      
      But NONE of those patches touched code of either the SCROLL_MOVE or the
      SCROLL_REDRAW case.
      
      That means, there was no real reason why SCROLL_MOVE had to be ripped-out and
      just SCROLL_REDRAW had to be used instead. The only reason I can imagine so far
      was that SCROLL_MOVE wasn't used by DRM and as such it was assumed that it
      could go away. That argument completely missed the fact that SCROLL_MOVE is
      still heavily used by fbdev (non-DRM) drivers.
      
      Some people mention that using memcpy() instead of the hardware acceleration is
      pretty much the same speed. But that's not true, at least not for older graphic
      cards and machines where we see speed decreases by factor 10 and more and thus
      this change leads to console responsiveness way worse than before.
      
      That's why the original commit is to be reverted. By reverting we
      reintroduce hardware-based scrolling acceleration and fix the
      performance regression for fbdev drivers.
      
      There isn't any impact on DRM when reverting those patches.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Acked-by: default avatarSven Schnelle <svens@stackframe.org>
      Cc: stable@vger.kernel.org # v5.10+
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-3-deller@gmx.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      460f6b1a
    • Riwen Lu's avatar
      rtc: cmos: Evaluate century appropriate · 460aa9d8
      Riwen Lu authored
      commit ff164ae3 upstream.
      
      There's limiting the year to 2069. When setting the rtc year to 2070,
      reading it returns 1970. Evaluate century starting from 19 to count the
      correct year.
      
      $ sudo date -s 20700106
      Mon 06 Jan 2070 12:00:00 AM CST
      $ sudo hwclock -w
      $ sudo hwclock -r
      1970-01-06 12:00:49.604968+08:00
      
      Fixes: 2a4daadd
      
       ("rtc: cmos: ignore bogus century byte")
      
      Signed-off-by: default avatarRiwen Lu <luriwen@kylinos.cn>
      Acked-by: default avatarEric Wong <e@80x24.org>
      Reviewed-by: default avatarMateusz Jończyk <mat.jonczyk@o2.pl>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Link: https://lore.kernel.org/r/20220106084609.1223688-1-luriwen@kylinos.cn
      Signed-off-by: Mateusz Jończyk <mat.jonczyk@o2.pl> # preparation for stable
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      460aa9d8
    • Nathan Chancellor's avatar
      tools/resolve_btfids: Do not print any commands when building silently · 2324f5fc
      Nathan Chancellor authored
      commit 7f3bdbc3 upstream.
      
      When building with 'make -s', there is some output from resolve_btfids:
      
      $ make -sj"$(nproc)" oldconfig prepare
        MKDIR     .../tools/bpf/resolve_btfids/libbpf/
        MKDIR     .../tools/bpf/resolve_btfids//libsubcmd
        LINK     resolve_btfids
      
      Silent mode means that no information should be emitted about what is
      currently being done. Use the $(silent) variable from Makefile.include
      to avoid defining the msg macro so that there is no information printed.
      
      Fixes: fbbb68de
      
       ("bpf: Add resolve_btfids tool to resolve BTF IDs in ELF object")
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20220201212503.731732-1-nathan@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2324f5fc
    • Muhammad Usama Anjum's avatar
      selftests: futex: Use variable MAKE instead of make · 1536fafa
      Muhammad Usama Anjum authored
      commit b9199181 upstream.
      
      Recursive make commands should always use the variable MAKE, not the
      explicit command name ‘make’. This has benefits and removes the
      following warning when multiple jobs are used for the build:
      
      make[2]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
      
      Fixes: a8ba798b
      
       ("selftests: enable O and KBUILD_OUTPUT")
      Signed-off-by: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
      Reviewed-by: default avatarAndré Almeida <andrealmeid@collabora.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1536fafa
    • Muhammad Usama Anjum's avatar
      selftests/exec: Remove pipe from TEST_GEN_FILES · 8f0fff8b
      Muhammad Usama Anjum authored
      commit 908a26e1 upstream.
      
      pipe named FIFO special file is being created in execveat.c to perform
      some tests. Makefile doesn't need to do anything with the pipe. When it
      isn't found, Makefile generates the following build error:
      
      make: *** No rule to make target
      '../tools/testing/selftests/exec/pipe', needed by 'all'.  Stop.
      
      pipe is created and removed during test run-time.
      
      Amended change log to add pipe remove info:
      Shuah Khan <skhan@linuxfoundation.org>
      
      Fixes: 61016db1
      
       ("selftests/exec: Verify execve of non-regular files fail")
      Signed-off-by: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
      Reviewed-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8f0fff8b
    • Hou Tao's avatar
      bpf: Use VM_MAP instead of VM_ALLOC for ringbuf · 6304a613
      Hou Tao authored
      commit b293dcc4 upstream.
      
      After commit 2fd3fb0be1d1 ("kasan, vmalloc: unpoison VM_ALLOC pages
      after mapping"), non-VM_ALLOC mappings will be marked as accessible
      in __get_vm_area_node() when KASAN is enabled. But now the flag for
      ringbuf area is VM_ALLOC, so KASAN will complain out-of-bound access
      after vmap() returns. Because the ringbuf area is created by mapping
      allocated pages, so use VM_MAP instead.
      
      After the change, info in /proc/vmallocinfo also changes from
        [start]-[end]   24576 ringbuf_map_alloc+0x171/0x290 vmalloc user
      to
        [start]-[end]   24576 ringbuf_map_alloc+0x171/0x290 vmap user
      
      Fixes: 457f4436
      
       ("bpf: Implement BPF ring buffer and verifier support for it")
      Reported-by: default avatar <syzbot+5ad567a418794b9b5983@syzkaller.appspotmail.com>
      Signed-off-by: default avatarHou Tao <houtao1@huawei.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20220202060158.6260-1-houtao1@huawei.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6304a613
    • Haiyue Wang's avatar
      gve: fix the wrong AdminQ buffer queue index check · f744a064
      Haiyue Wang authored
      commit 1f84a945 upstream.
      
      The 'tail' and 'head' are 'unsigned int' type free-running count, when
      'head' is overflow, the 'int i (= tail) < u32 head' will be false:
      
      Only '- loop 0: idx = 63' result is shown, so it needs to use 'int' type
      to compare, it can handle the overflow correctly.
      
      typedef uint32_t u32;
      
      int main()
      {
              u32 tail, head;
              int stail, shead;
              int i, loop;
      
              tail = 0xffffffff;
              head = 0x00000000;
      
              for (i = tail, loop = 0; i < head; i++) {
                      unsigned int idx = i & 63;
      
                      printf("+ loop %d: idx = %u\n", loop++, idx);
              }
      
              stail = tail;
              shead = head;
              for (i = stail, loop = 0; i < shead; i++) {
                      unsigned int idx = i & 63;
      
                      printf("- loop %d: idx = %u\n", loop++, idx);
              }
      
              return 0;
      }
      
      Fixes: 5cdad90d
      
       ("gve: Batch AQ commands for creating and destroying queues.")
      Signed-off-by: default avatarHaiyue Wang <haiyue.wang@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f744a064
    • Dai Ngo's avatar
      nfsd: nfsd4_setclientid_confirm mistakenly expires confirmed client. · 51e88e89
      Dai Ngo authored
      commit ab451ea9 upstream.
      
      From RFC 7530 Section 16.34.5:
      
      o  The server has not recorded an unconfirmed { v, x, c, *, * } and
         has recorded a confirmed { v, x, c, *, s }.  If the principals of
         the record and of SETCLIENTID_CONFIRM do not match, the server
         returns NFS4ERR_CLID_INUSE without removing any relevant leased
         client state, and without changing recorded callback and
         callback_ident values for client { x }.
      
      The current code intends to do what the spec describes above but
      it forgot to set 'old' to NULL resulting to the confirmed client
      to be expired.
      
      Fixes: 2b634821
      
       ("nfsd: fix clid_inuse on mount with security change")
      Signed-off-by: default avatarDai Ngo <dai.ngo@oracle.com>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Reviewed-by: default avatarBruce Fields <bfields@fieldses.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      51e88e89
    • John Meneghini's avatar
      scsi: bnx2fc: Make bnx2fc_recv_frame() mp safe · ec433415
      John Meneghini authored
      commit 936bd034 upstream.
      
      Running tests with a debug kernel shows that bnx2fc_recv_frame() is
      modifying the per_cpu lport stats counters in a non-mpsafe way.  Just boot
      a debug kernel and run the bnx2fc driver with the hardware enabled.
      
      [ 1391.699147] BUG: using smp_processor_id() in preemptible [00000000] code: bnx2fc_
      [ 1391.699160] caller is bnx2fc_recv_frame+0xbf9/0x1760 [bnx2fc]
      [ 1391.699174] CPU: 2 PID: 4355 Comm: bnx2fc_l2_threa Kdump: loaded Tainted: G    B
      [ 1391.699180] Hardware name: HP ProLiant DL120 G7, BIOS J01 07/01/2013
      [ 1391.699183] Call Trace:
      [ 1391.699188]  dump_stack_lvl+0x57/0x7d
      [ 1391.699198]  check_preemption_disabled+0xc8/0xd0
      [ 1391.699205]  bnx2fc_recv_frame+0xbf9/0x1760 [bnx2fc]
      [ 1391.699215]  ? do_raw_spin_trylock+0xb5/0x180
      [ 1391.699221]  ? bnx2fc_npiv_create_vports.isra.0+0x4e0/0x4e0 [bnx2fc]
      [ 1391.699229]  ? bnx2fc_l2_rcv_thread+0xb7/0x3a0 [bnx2fc]
      [ 1391.699240]  bnx2fc_l2_rcv_thread+0x1af/0x3a0 [bnx2fc]
      [ 1391.699250]  ? bnx2fc_ulp_init+0xc0/0xc0 [bnx2fc]
      [ 1391.699258]  kthread+0x364/0x420
      [ 1391.699263]  ? _raw_spin_unlock_irq+0x24/0x50
      [ 1391.699268]  ? set_kthread_struct+0x100/0x100
      [ 1391.699273]  ret_from_fork+0x22/0x30
      
      Restore the old get_cpu/put_cpu code with some modifications to reduce the
      size of the critical section.
      
      Link: https://lore.kernel.org/r/20220124145110.442335-1-jmeneghi@redhat.com
      Fixes: d576a5e8
      
       ("bnx2fc: Improve stats update mechanism")
      Tested-by: default avatarGuangwu Zhang <guazhang@redhat.com>
      Acked-by: default avatarSaurav Kashyap <skashyap@marvell.com>
      Signed-off-by: default avatarJohn Meneghini <jmeneghi@redhat.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec433415
    • Florian Fainelli's avatar
      pinctrl: bcm2835: Fix a few error paths · fd482f2d
      Florian Fainelli authored
      commit 5297c693 upstream.
      
      After commit 266423e6 ("pinctrl: bcm2835: Change init order for gpio
      hogs") a few error paths would not unwind properly the registration of
      gpio ranges. Correct that by assigning a single error label and goto it
      whenever we encounter a fatal error.
      
      Fixes: 266423e6
      
       ("pinctrl: bcm2835: Change init order for gpio hogs")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20220127215033.267227-1-f.fainelli@gmail.com
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fd482f2d
    • Łukasz Bartosik's avatar
      pinctrl: intel: fix unexpected interrupt · 752d9eaf
      Łukasz Bartosik authored
      commit e986f0e6 upstream.
      
      ASUS Chromebook C223 with Celeron N3350 crashes sometimes during
      cold booot. Inspection of the kernel log showed that it gets into
      an inifite loop logging the following message:
      
      ->handle_irq():  000000009cdb51e8, handle_bad_irq+0x0/0x251
      ->irq_data.chip(): 000000005ec212a7, 0xffffa043009d8e7
      ->action(): 00000
         IRQ_NOPROBE set
      unexpected IRQ trap at vector 7c
      
      The issue happens during cold boot but only if cold boot happens
      at most several dozen seconds after Chromebook is powered off. For
      longer intervals between power off and power on (cold boot) the issue
      does not reproduce. The unexpected interrupt is sourced from INT3452
      GPIO pin which is used for SD card detect. Investigation relevealed
      that when the interval between power off and power on (cold boot)
      is less than several dozen seconds then values of INT3452 GPIO interrupt
      enable and interrupt pending registers survive power off and power
      on sequence and interrupt for SD card detect pin is enabled and pending
      during probe of SD controller which causes the unexpected IRQ message.
      "Intel Pentium and Celeron Processor N- and J- Series" volume 3 doc
      mentions that GPIO interrupt enable and status registers default
      value is 0x0.
      The fix clears INT3452 GPIO interrupt enabled and interrupt pending
      registers in its probe function.
      
      Fixes: 7981c001
      
       ("pinctrl: intel: Add Intel Sunrisepoint pin controller and GPIO support")
      Signed-off-by: default avatarŁukasz Bartosik <lb@semihalf.com>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      752d9eaf
    • Andy Shevchenko's avatar
      pinctrl: intel: Fix a glitch when updating IRQ flags on a preconfigured line · 14bc9978
      Andy Shevchenko authored
      commit e12963c4 upstream.
      
      The commit af7e3eeb ("pinctrl: intel: Disable input and output buffer
      when switching to GPIO") hadn't taken into account an update of the IRQ
      flags scenario.
      
      When updating the IRQ flags on the preconfigured line the ->irq_set_type()
      is called again. In such case the sequential Rx buffer configuration
      changes may trigger a falling or rising edge interrupt that may lead,
      on some platforms, to an undesired event.
      
      This may happen because each of intel_gpio_set_gpio_mode() and
      __intel_gpio_set_direction() updates the pad configuration with a different
      value of the GPIORXDIS bit. Notable, that the intel_gpio_set_gpio_mode() is
      called only for the pads that are configured as an input. Due to this fact,
      integrate the logic of __intel_gpio_set_direction() call into the
      intel_gpio_set_gpio_mode() so that the Rx buffer won't be disabled and
      immediately re-enabled.
      
      Fixes: af7e3eeb
      
       ("pinctrl: intel: Disable input and output buffer when switching to GPIO")
      Reported-by: default avatarKane Chen <kane.chen@intel.com>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Tested-by: default avatarGrace Kao <grace.kao@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      14bc9978
    • Dan Carpenter's avatar
      ASoC: max9759: fix underflow in speaker_gain_control_put() · 5a45448a
      Dan Carpenter authored
      commit 4c907bcd upstream.
      
      Check for negative values of "priv->gain" to prevent an out of bounds
      access.  The concern is that these might come from the user via:
        -> snd_ctl_elem_write_user()
          -> snd_ctl_elem_write()
            -> kctl->put()
      
      Fixes: fa8d9151
      
       ("ASoC: max9759: Add Amplifier Driver")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Link: https://lore.kernel.org/r/20220119123101.GA9509@kili
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5a45448a
    • 蒋家盛's avatar
      ASoC: cpcap: Check for NULL pointer after calling of_get_child_by_name · 02f45971
      蒋家盛 authored
      commit f7a6021a upstream.
      
      If the device does not exist, of_get_child_by_name() will return NULL
      pointer.
      And devm_snd_soc_register_component() does not check it.
      Also, I have noticed that cpcap_codec_driver has not been used yet.
      Therefore, it should be better to check it in order to avoid the future
      dereference of the NULL pointer.
      
      Fixes: f6cdf2d3
      
       ("ASoC: cpcap: new codec")
      Signed-off-by: default avatarJiasheng Jiang <jiasheng@iscas.ac.cn>
      Link: https://lore.kernel.org/r/20220111025048.524134-1-jiasheng@iscas.ac.cn
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      02f45971
    • Robert Hancock's avatar
      ASoC: xilinx: xlnx_formatter_pcm: Make buffer bytes multiple of period bytes · cb5f1fbd
      Robert Hancock authored
      commit e958b588 upstream.
      
      This patch is based on one in the Xilinx kernel tree, "ASoc: xlnx: Make
      buffer bytes multiple of period bytes" by Devarsh Thakkar. The same
      issue exists in the mainline version of the driver. The original
      patch description is as follows:
      
      "The Xilinx Audio Formatter IP has a constraint on period
      bytes to be multiple of 64. This leads to driver changing
      the period size to suitable frames such that period bytes
      are multiple of 64.
      
      Now since period bytes and period size are updated but not
      the buffer bytes, this may make the buffer bytes unaligned
      and not multiple of period bytes.
      
      When this happens we hear popping noise as while DMA is being
      done the buffer bytes are not enough to complete DMA access
      for last period of frame within the application buffer boundary.
      
      To avoid this, align buffer bytes too as multiple of 64, and
      set another constraint to always enforce number of periods as
      integer. Now since, there is already a rule in alsa core
      to enforce Buffer size = Number of Periods * Period Size
      this automatically aligns buffer bytes as multiple of period
      bytes."
      
      Fixes: 6f6c3c36
      
       ("ASoC: xlnx: add pcm formatter platform driver")
      Cc: Devarsh Thakkar <devarsh.thakkar@xilinx.com>
      Signed-off-by: default avatarRobert Hancock <robert.hancock@calian.com>
      Link: https://lore.kernel.org/r/20220107214711.1100162-2-robert.hancock@calian.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb5f1fbd
    • Miaoqian Lin's avatar
      ASoC: fsl: Add missing error handling in pcm030_fabric_probe · 56e0747d
      Miaoqian Lin authored
      commit fb25621d upstream.
      
      Add the missing platform_device_put() and platform_device_del()
      before return from pcm030_fabric_probe in the error handling case.
      
      Fixes: c912fa91
      
       ("ASoC: fsl: register the wm9712-codec")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Link: https://lore.kernel.org/r/20220127131336.30214-1-linmq006@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      56e0747d
    • Dan Carpenter's avatar
      drm/i915/overlay: Prevent divide by zero bugs in scaling · 3e698375
      Dan Carpenter authored
      commit 90a3d22f upstream.
      
      Smatch detected a divide by zero bug in check_overlay_scaling().
      
          drivers/gpu/drm/i915/display/intel_overlay.c:976 check_overlay_scaling()
          error: potential divide by zero bug '/ rec->dst_height'.
          drivers/gpu/drm/i915/display/intel_overlay.c:980 check_overlay_scaling()
          error: potential divide by zero bug '/ rec->dst_width'.
      
      Prevent this by ensuring that the dst height and width are non-zero.
      
      Fixes: 02e792fb
      
       ("drm/i915: implement drmmode overlay support v4")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220124122409.GA31673@kili
      (cherry picked from commit cf5b64f7
      
      )
      Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e698375
    • Yannick Vignon's avatar
      net: stmmac: ensure PTP time register reads are consistent · 9ea01853
      Yannick Vignon authored
      commit 80d46090 upstream.
      
      Even if protected from preemption and interrupts, a small time window
      remains when the 2 register reads could return inconsistent values,
      each time the "seconds" register changes. This could lead to an about
      1-second error in the reported time.
      
      Add logic to ensure the "seconds" and "nanoseconds" values are consistent.
      
      Fixes: 92ba6888
      
       ("stmmac: add the support for PTP hw clock driver")
      Signed-off-by: default avatarYannick Vignon <yannick.vignon@nxp.com>
      Reviewed-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Link: https://lore.kernel.org/r/20220203160025.750632-1-yannick.vignon@oss.nxp.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9ea01853
    • Camel Guo's avatar
      net: stmmac: dump gmac4 DMA registers correctly · 41df2da2
      Camel Guo authored
      commit 7af037c3 upstream.
      
      Unlike gmac100, gmac1000, gmac4 has 27 DMA registers and they are
      located at DMA_CHAN_BASE_ADDR (0x1100). In order for ethtool to dump
      gmac4 DMA registers correctly, this commit checks if a net_device has
      gmac4 and uses different logic to dump its DMA registers.
      
      This fixes the following KASAN warning, which can normally be triggered
      by a command similar like "ethtool -d eth0":
      
      BUG: KASAN: vmalloc-out-of-bounds in dwmac4_dump_dma_regs+0x6d4/0xb30
      Write of size 4 at addr ffffffc010177100 by task ethtool/1839
       kasan_report+0x200/0x21c
       __asan_report_store4_noabort+0x34/0x60
       dwmac4_dump_dma_regs+0x6d4/0xb30
       stmmac_ethtool_gregs+0x110/0x204
       ethtool_get_regs+0x200/0x4b0
       dev_ethtool+0x1dac/0x3800
       dev_ioctl+0x7c0/0xb50
       sock_ioctl+0x298/0x6c4
       ...
      
      Fixes: fbf68229
      
       ("net: stmmac: unify registers dumps methods")
      Signed-off-by: default avatarCamel Guo <camelg@axis.com>
      Link: https://lore.kernel.org/r/20220131083841.3346801-1-camel.guo@axis.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      41df2da2
    • Lior Nahmanson's avatar
      net: macsec: Verify that send_sci is on when setting Tx sci explicitly · 114bf935
      Lior Nahmanson authored
      commit d0cfa548 upstream.
      
      When setting Tx sci explicit, the Rx side is expected to use this
      sci and not recalculate it from the packet.However, in case of Tx sci
      is explicit and send_sci is off, the receiver is wrongly recalculate
      the sci from the source MAC address which most likely be different
      than the explicit sci.
      
      Fix by preventing such configuration when macsec newlink is established
      and return EINVAL error code on such cases.
      
      Fixes: c09440f7
      
       ("macsec: introduce IEEE 802.1AE driver")
      Signed-off-by: default avatarLior Nahmanson <liorna@nvidia.com>
      Reviewed-by: default avatarRaed Salem <raeds@nvidia.com>
      Signed-off-by: default avatarRaed Salem <raeds@nvidia.com>
      Link: https://lore.kernel.org/r/1643542672-29403-1-git-send-email-raeds@nvidia.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      114bf935
    • Lior Nahmanson's avatar
      net: macsec: Fix offload support for NETDEV_UNREGISTER event · 2e7f5b6e
      Lior Nahmanson authored
      commit 9cef24c8 upstream.
      
      Current macsec netdev notify handler handles NETDEV_UNREGISTER event by
      releasing relevant SW resources only, this causes resources leak in case
      of macsec HW offload, as the underlay driver was not notified to clean
      it's macsec offload resources.
      
      Fix by calling the underlay driver to clean it's relevant resources
      by moving offload handling from macsec_dellink() to macsec_common_dellink()
      when handling NETDEV_UNREGISTER event.
      
      Fixes: 3cf3227a
      
       ("net: macsec: hardware offloading infrastructure")
      Signed-off-by: default avatarLior Nahmanson <liorna@nvidia.com>
      Reviewed-by: default avatarRaed Salem <raeds@nvidia.com>
      Signed-off-by: default avatarRaed Salem <raeds@nvidia.com>
      Reviewed-by: default avatarAntoine Tenart <atenart@kernel.org>
      Link: https://lore.kernel.org/r/1643542141-28956-1-git-send-email-raeds@nvidia.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2e7f5b6e
    • Miquel Raynal's avatar
      net: ieee802154: Return meaningful error codes from the netlink helpers · 87b1c9fa
      Miquel Raynal authored
      commit 79c37ca7 upstream.
      
      Returning -1 does not indicate anything useful.
      
      Use a standard and meaningful error code instead.
      
      Fixes: a26c5fd7
      
       ("nl802154: add support for security layer")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Acked-by: default avatarAlexander Aring <aahringo@redhat.com>
      Link: https://lore.kernel.org/r/20220125121426.848337-6-miquel.raynal@bootlin.com
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      87b1c9fa
    • Miquel Raynal's avatar
      net: ieee802154: ca8210: Stop leaking skb's · 78b3f20c
      Miquel Raynal authored
      commit 621b24b0 upstream.
      
      Upon error the ieee802154_xmit_complete() helper is not called. Only
      ieee802154_wake_queue() is called manually. We then leak the skb
      structure.
      
      Free the skb structure upon error before returning.
      
      Fixes: ded845a7
      
       ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Acked-by: default avatarAlexander Aring <aahringo@redhat.com>
      Link: https://lore.kernel.org/r/20220125121426.848337-5-miquel.raynal@bootlin.com
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      78b3f20c
    • Miquel Raynal's avatar
      net: ieee802154: mcr20a: Fix lifs/sifs periods · 0bfe50dc
      Miquel Raynal authored
      commit d753c400 upstream.
      
      These periods are expressed in time units (microseconds) while 40 and 12
      are the number of symbol durations these periods will last. We need to
      multiply them both with phy->symbol_duration in order to get these
      values in microseconds.
      
      Fixes: 8c6ad9cc
      
       ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Acked-by: default avatarAlexander Aring <aahringo@redhat.com>
      Link: https://lore.kernel.org/r/20220125121426.848337-3-miquel.raynal@bootlin.com
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0bfe50dc
    • Miquel Raynal's avatar
      net: ieee802154: hwsim: Ensure proper channel selection at probe time · 75bbda31
      Miquel Raynal authored
      commit 1293fccc upstream.
      
      Drivers are expected to set the PHY current_channel and current_page
      according to their default state. The hwsim driver is advertising being
      configured on channel 13 by default but that is not reflected in its own
      internal pib structure. In order to ensure that this driver consider the
      current channel as being 13 internally, we at least need to set the
      pib->channel field to 13.
      
      Fixes: f25da51f
      
       ("ieee802154: hwsim: add replacement for fakelb")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      [stefan@datenfreihafen.org: fixed assigment from page to channel]
      Acked-by: default avatarAlexander Aring <aahringo@redhat.com>
      Link: https://lore.kernel.org/r/20220125121426.848337-2-miquel.raynal@bootlin.com
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      75bbda31
    • Xin Xiong's avatar
      spi: uniphier: fix reference count leak in uniphier_spi_probe() · e895e067
      Xin Xiong authored
      commit 37c2c83c
      
       upstream.
      
      The issue happens in several error paths in uniphier_spi_probe().
      When either dma_get_slave_caps() or devm_spi_register_master() returns
      an error code, the function forgets to decrease the refcount of both
      `dma_rx` and `dma_tx` objects, which may lead to refcount leaks.
      
      Fix it by decrementing the reference count of specific objects in
      those error paths.
      
      Signed-off-by: default avatarXin Xiong <xiongx18@fudan.edu.cn>
      Signed-off-by: default avatarXiyu Yang <xiyuyang19@fudan.edu.cn>
      Signed-off-by: default avatarXin Tan <tanxin.ctf@gmail.com>
      Reviewed-by: default avatarKunihiko Hayashi <hayashi.kunihiko@socionext.com>
      Fixes: 28d1dddc
      
       ("spi: uniphier: Add DMA transfer mode support")
      Link: https://lore.kernel.org/r/20220125101214.35677-1-xiongx18@fudan.edu.cn
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e895e067
    • Miaoqian Lin's avatar
      spi: meson-spicc: add IRQ check in meson_spicc_probe · ec942d08
      Miaoqian Lin authored
      commit e937440f upstream.
      
      This check misses checking for  platform_get_irq()'s call and may passes
      the negative error codes to devm_request_irq(), which takes unsigned IRQ #,
      causing it to fail with -EINVAL, overriding an original error code.
      Stop calling devm_request_irq() with invalid IRQ #s.
      
      Fixes: 454fa271
      
       ("spi: Add Meson SPICC driver")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Link: https://lore.kernel.org/r/20220126110447.24549-1-linmq006@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec942d08
    • Benjamin Gaignard's avatar
      spi: mediatek: Avoid NULL pointer crash in interrupt · c2cf65e1
      Benjamin Gaignard authored
      commit f83a96e5 upstream.
      
      In some case, like after a transfer timeout, master->cur_msg pointer
      is NULL which led to a kernel crash when trying to use master->cur_msg->spi.
      mtk_spi_can_dma(), pointed by master->can_dma, doesn't use this parameter
      avoid the problem by setting NULL as second parameter.
      
      Fixes: a568231f
      
       ("spi: mediatek: Add spi bus for Mediatek MT8173")
      Signed-off-by: default avatarBenjamin Gaignard <benjamin.gaignard@collabora.com>
      Link: https://lore.kernel.org/r/20220131141708.888710-1-benjamin.gaignard@collabora.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c2cf65e1
    • Kamal Dasu's avatar
      spi: bcm-qspi: check for valid cs before applying chip select · 30e05c98
      Kamal Dasu authored
      commit 2cbd2726 upstream.
      
      Apply only valid chip select value. This change fixes case where chip
      select is set to initial value of '-1' during probe and  PM supend and
      subsequent resume can try to use the value with undefined behaviour.
      Also in case where gpio based chip select, the check in
      bcm_qspi_chip_select() shall prevent undefined behaviour on resume.
      
      Fixes: fa236a7e
      
       ("spi: bcm-qspi: Add Broadcom MSPI driver")
      Signed-off-by: default avatarKamal Dasu <kdasu.kdev@gmail.com>
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20220127185359.27322-1-kdasu.kdev@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      30e05c98
    • Joerg Roedel's avatar
      iommu/amd: Fix loop timeout issue in iommu_ga_log_enable() · 6d226e8a
      Joerg Roedel authored
      commit 9b45a773 upstream.
      
      The polling loop for the register change in iommu_ga_log_enable() needs
      to have a udelay() in it.  Otherwise the CPU might be faster than the
      IOMMU hardware and wrongly trigger the WARN_ON() further down the code
      stream. Use a 10us for udelay(), has there is some hardware where
      activation of the GA log can take more than a 100ms.
      
      A future optimization should move the activation check of the GA log
      to the point where it gets used for the first time. But that is a
      bigger change and not suitable for a fix.
      
      Fixes: 8bda0cfb
      
       ("iommu/amd: Detect and initialize guest vAPIC log")
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Link: https://lore.kernel.org/r/20220204115537.3894-1-joro@8bytes.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6d226e8a
    • Guoqing Jiang's avatar
      iommu/vt-d: Fix potential memory leak in intel_setup_irq_remapping() · 9d9995b0
      Guoqing Jiang authored
      commit 99e675d4 upstream.
      
      After commit e3beca48 ("irqdomain/treewide: Keep firmware node
      unconditionally allocated"). For tear down scenario, fn is only freed
      after fail to allocate ir_domain, though it also should be freed in case
      dmar_enable_qi returns error.
      
      Besides free fn, irq_domain and ir_msi_domain need to be removed as well
      if intel_setup_irq_remapping fails to enable queued invalidation.
      
      Improve the rewinding path by add out_free_ir_domain and out_free_fwnode
      lables per Baolu's suggestion.
      
      Fixes: e3beca48
      
       ("irqdomain/treewide: Keep firmware node unconditionally allocated")
      Suggested-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: default avatarGuoqing Jiang <guoqing.jiang@linux.dev>
      Link: https://lore.kernel.org/r/20220119063640.16864-1-guoqing.jiang@linux.dev
      Signed-off-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
      Link: https://lore.kernel.org/r/20220128031002.2219155-3-baolu.lu@linux.intel.com
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9d9995b0
    • Leon Romanovsky's avatar
      RDMA/mlx4: Don't continue event handler after memory allocation failure · b3958d31
      Leon Romanovsky authored
      commit f3136c4c upstream.
      
      The failure to allocate memory during MLX4_DEV_EVENT_PORT_MGMT_CHANGE
      event handler will cause skip the assignment logic, but
      ib_dispatch_event() will be called anyway.
      
      Fix it by calling to return instead of break after memory allocation
      failure.
      
      Fixes: 00f5ce99
      
       ("mlx4: Use port management change event instead of smp_snoop")
      Link: https://lore.kernel.org/r/12a0e83f18cfad4b5f62654f141e240d04915e10.1643622264.git.leonro@nvidia.com
      Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Reviewed-by: default avatarHåkon Bugge <haakon.bugge@oracle.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b3958d31
    • Bernard Metzler's avatar
      RDMA/siw: Fix broken RDMA Read Fence/Resume logic. · d3f8b927
      Bernard Metzler authored
      commit b43a76f4 upstream.
      
      Code unconditionally resumed fenced SQ processing after next RDMA Read
      completion, even if other RDMA Read responses are still outstanding, or
      ORQ is full. Also adds comments for better readability of fence
      processing, and removes orq_get_tail() helper, which is not needed
      anymore.
      
      Fixes: 8b6a361b ("rdma/siw: receive path")
      Fixes: a5319752
      
       ("rdma/siw: main include file")
      Link: https://lore.kernel.org/r/20220130170815.1940-1-bmt@zurich.ibm.com
      Reported-by: default avatarJared Holzman <jared.holzman@excelero.com>
      Signed-off-by: default avatarBernard Metzler <bmt@zurich.ibm.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d3f8b927
    • Mike Marciniszyn's avatar
      IB/rdmavt: Validate remote_addr during loopback atomic tests · c7db20f5
      Mike Marciniszyn authored
      commit 4028bccb upstream.
      
      The rdma-core test suite sends an unaligned remote address and expects a
      failure.
      
      ERROR: test_atomic_non_aligned_addr (tests.test_atomic.AtomicTest)
      
      The qib/hfi1 rc handling validates properly, but the test has the client
      and server on the same system.
      
      The loopback of these operations is a distinct code path.
      
      Fix by syntaxing the proposed remote address in the loopback code path.
      
      Fixes: 15703461
      
       ("IB/{hfi1, qib, rdmavt}: Move ruc_loopback to rdmavt")
      Link: https://lore.kernel.org/r/1642584489-141005-1-git-send-email-mike.marciniszyn@cornelisnetworks.com
      Reviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
      Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c7db20f5
    • Leon Romanovsky's avatar
      RDMA/ucma: Protect mc during concurrent multicast leaves · 75c61021
      Leon Romanovsky authored
      commit 36e8169e upstream.
      
      Partially revert the commit mentioned in the Fixes line to make sure that
      allocation and erasing multicast struct are locked.
      
        BUG: KASAN: use-after-free in ucma_cleanup_multicast drivers/infiniband/core/ucma.c:491 [inline]
        BUG: KASAN: use-after-free in ucma_destroy_private_ctx+0x914/0xb70 drivers/infiniband/core/ucma.c:579
        Read of size 8 at addr ffff88801bb74b00 by task syz-executor.1/25529
        CPU: 0 PID: 25529 Comm: syz-executor.1 Not tainted 5.16.0-rc7-syzkaller #0
        Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
        Call Trace:
         __dump_stack lib/dump_stack.c:88 [inline]
         dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
         print_address_description.constprop.0.cold+0x8d/0x320 mm/kasan/report.c:247
         __kasan_report mm/kasan/report.c:433 [inline]
         kasan_report.cold+0x83/0xdf mm/kasan/report.c:450
         ucma_cleanup_multicast drivers/infiniband/core/ucma.c:491 [inline]
         ucma_destroy_private_ctx+0x914/0xb70 drivers/infiniband/core/ucma.c:579
         ucma_destroy_id+0x1e6/0x280 drivers/infiniband/core/ucma.c:614
         ucma_write+0x25c/0x350 drivers/infiniband/core/ucma.c:1732
         vfs_write+0x28e/0xae0 fs/read_write.c:588
         ksys_write+0x1ee/0x250 fs/read_write.c:643
         do_syscall_x64 arch/x86/entry/common.c:50 [inline]
         do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
         entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Currently the xarray search can touch a concurrently freeing mc as the
      xa_for_each() is not surrounded by any lock. Rather than hold the lock for
      a full scan hold it only for the effected items, which is usually an empty
      list.
      
      Fixes: 95fe5109
      
       ("RDMA/ucma: Remove mc_list and rely on xarray")
      Link: https://lore.kernel.org/r/1cda5fabb1081e8d16e39a48d3a4f8160cea88b8.1642491047.git.leonro@nvidia.com
      Reported-by: default avatar <syzbot+e3f96c43d19782dd14a7@syzkaller.appspotmail.com>
      Suggested-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Reviewed-by: default avatarMaor Gottlieb <maorg@nvidia.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      75c61021
    • Maor Gottlieb's avatar
      RDMA/cma: Use correct address when leaving multicast group · 37197906
      Maor Gottlieb authored
      commit d9e410eb upstream.
      
      In RoCE we should use cma_iboe_set_mgid() and not cma_set_mgid to generate
      the mgid, otherwise we will generate an IGMP for an incorrect address.
      
      Fixes: b5de0c60
      
       ("RDMA/cma: Fix use after free race in roce multicast join")
      Link: https://lore.kernel.org/r/913bc6783fd7a95fe71ad9454e01653ee6fb4a9a.1642491047.git.leonro@nvidia.com
      Signed-off-by: default avatarMaor Gottlieb <maorg@nvidia.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      37197906