1. 04 2月, 2023 1 次提交
  2. 15 12月, 2022 1 次提交
  3. 22 11月, 2022 1 次提交
    • T
      fbcon: Use kzalloc() in fbcon_prepare_logo() · a6a00d7e
      Tetsuo Handa 提交于
      A kernel built with syzbot's config file reported that
      
        scr_memcpyw(q, save, array3_size(logo_lines, new_cols, 2))
      
      causes uninitialized "save" to be copied.
      
        ----------
        [drm] Initialized vgem 1.0.0 20120112 for vgem on minor 0
        [drm] Initialized vkms 1.0.0 20180514 for vkms on minor 1
        Console: switching to colour frame buffer device 128x48
        =====================================================
        BUG: KMSAN: uninit-value in do_update_region+0x4b8/0xba0
         do_update_region+0x4b8/0xba0
         update_region+0x40d/0x840
         fbcon_switch+0x3364/0x35e0
         redraw_screen+0xae3/0x18a0
         do_bind_con_driver+0x1cb3/0x1df0
         do_take_over_console+0x11cb/0x13f0
         fbcon_fb_registered+0xacc/0xfd0
         register_framebuffer+0x1179/0x1320
         __drm_fb_helper_initial_config_and_unlock+0x23ad/0x2b40
         drm_fbdev_client_hotplug+0xbea/0xda0
         drm_fbdev_generic_setup+0x65e/0x9d0
         vkms_init+0x9f3/0xc76
         (...snipped...)
      
        Uninit was stored to memory at:
         fbcon_prepare_logo+0x143b/0x1940
         fbcon_init+0x2c1b/0x31c0
         visual_init+0x3e7/0x820
         do_bind_con_driver+0x14a4/0x1df0
         do_take_over_console+0x11cb/0x13f0
         fbcon_fb_registered+0xacc/0xfd0
         register_framebuffer+0x1179/0x1320
         __drm_fb_helper_initial_config_and_unlock+0x23ad/0x2b40
         drm_fbdev_client_hotplug+0xbea/0xda0
         drm_fbdev_generic_setup+0x65e/0x9d0
         vkms_init+0x9f3/0xc76
         (...snipped...)
      
        Uninit was created at:
         __kmem_cache_alloc_node+0xb69/0x1020
         __kmalloc+0x379/0x680
         fbcon_prepare_logo+0x704/0x1940
         fbcon_init+0x2c1b/0x31c0
         visual_init+0x3e7/0x820
         do_bind_con_driver+0x14a4/0x1df0
         do_take_over_console+0x11cb/0x13f0
         fbcon_fb_registered+0xacc/0xfd0
         register_framebuffer+0x1179/0x1320
         __drm_fb_helper_initial_config_and_unlock+0x23ad/0x2b40
         drm_fbdev_client_hotplug+0xbea/0xda0
         drm_fbdev_generic_setup+0x65e/0x9d0
         vkms_init+0x9f3/0xc76
         (...snipped...)
      
        CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.1.0-rc4-00356-g8f2975c2 #924
        Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
        ----------
      Signed-off-by: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/cad03d25-0ea0-32c4-8173-fd1895314bce@I-love.SAKURA.ne.jp
      a6a00d7e
  4. 27 8月, 2022 1 次提交
  5. 25 8月, 2022 1 次提交
  6. 07 7月, 2022 3 次提交
  7. 27 6月, 2022 1 次提交
  8. 20 6月, 2022 2 次提交
  9. 09 6月, 2022 1 次提交
  10. 15 4月, 2022 1 次提交
  11. 14 4月, 2022 1 次提交
    • D
      fbcon: Fix delayed takeover locking · 9d797991
      Daniel Vetter 提交于
      I messed up the delayed takover path in the locking conversion in
      6e7da3af ("fbcon: Move console_lock for register/unlink/unregister").
      
      If CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER is enabled, fbcon take-over
      doesn't take place when calling fbcon_fb_registered(). Instead, is deferred
      using a workqueue and its fbcon_register_existing_fbs() function calls to
      fbcon_fb_registered() again for each registered fbcon fb.
      
      This leads to the console_lock tried to be held twice, causing a deadlock.
      
      Fix it by re-extracting the lockless function and using it in the
      delayed takeover path, where we need to hold the lock already to
      iterate over the list of already registered fb. Well the current code
      still is broken in there (since the list is protected by a
      registration_lock, which we can't take here because it nests the other
      way round with console_lock), but in the future this will be a list
      protected by console_lock when this is all sorted out.
      
      While reviewing the broken commit I realized that I've left some
      outdated comments about the locking behind. Fix those too.
      
      v2: Improve commit message (Javier)
      Reported-by: NNathan Chancellor <nathan@kernel.org>
      Tested-by: NNathan Chancellor <nathan@kernel.org>
      Reviewed-by: NJavier Martinez Canillas <javierm@redhat.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Fixes: 6e7da3af ("fbcon: Move console_lock for register/unlink/unregister")
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: Du Cheng <ducheng2@gmail.com>
      Cc: Claudio Suarez <cssk@net-c.es>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Zheyu Ma <zheyuma97@gmail.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Javier Martinez Canillas <javierm@redhat.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220413082128.348186-1-daniel.vetter@ffwll.ch
      9d797991
  12. 13 4月, 2022 1 次提交
  13. 07 4月, 2022 15 次提交
  14. 08 2月, 2022 1 次提交
  15. 02 2月, 2022 3 次提交
    • H
      fbcon: Add option to enable legacy hardware acceleration · a3f781a9
      Helge Deller 提交于
      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: NHelge Deller <deller@gmx.de>
      Cc: stable@vger.kernel.org # v5.10+
      Signed-off-by: NHelge Deller <deller@gmx.de>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-4-deller@gmx.de
      a3f781a9
    • H
      Revert "fbcon: Disable accelerated scrolling" · 87ab9f6b
      Helge Deller 提交于
      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: NHelge Deller <deller@gmx.de>
      Acked-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Acked-by: NSven Schnelle <svens@stackframe.org>
      Cc: stable@vger.kernel.org # v5.10+
      Signed-off-by: NHelge Deller <deller@gmx.de>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-3-deller@gmx.de
      87ab9f6b
    • H
      Revert "fbdev: Garbage collect fbdev scrolling acceleration, part 1 (from TODO list)" · 1148836f
      Helge Deller 提交于
      This reverts commit b3ec8cdf.
      
      Revert the second (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: NHelge Deller <deller@gmx.de>
      Acked-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Acked-by: NSven Schnelle <svens@stackframe.org>
      Cc: stable@vger.kernel.org # v5.16+
      Signed-off-by: NHelge Deller <deller@gmx.de>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-2-deller@gmx.de
      1148836f
  16. 13 10月, 2021 1 次提交
  17. 15 5月, 2021 1 次提交
  18. 23 3月, 2021 1 次提交
  19. 30 11月, 2020 1 次提交
  20. 17 11月, 2020 1 次提交
    • D
      fbcon: Disable accelerated scrolling · 39aead83
      Daniel Vetter 提交于
      So ever since syzbot discovered fbcon, we have solid proof that it's
      full of bugs. And often the solution is to just delete code and remove
      features, e.g.  50145474 ("fbcon: remove soft scrollback code").
      
      Now the problem is that most modern-ish drivers really only treat
      fbcon as an dumb kernel console until userspace takes over, and Oops
      printer for some emergencies. Looking at drm drivers and the basic
      vesa/efi fbdev drivers shows that only 3 drivers support any kind of
      acceleration:
      
      - nouveau, seems to be enabled by default
      - omapdrm, when a DMM remapper exists using remapper rewriting for
        y/xpanning
      - gma500, but that is getting deleted now for the GTT remapper trick,
        and the accelerated copyarea never set the FBINFO_HWACCEL_COPYAREA
        flag, so unused (and could be deleted already I think).
      
      No other driver supportes accelerated fbcon. And fbcon is the only
      user of this accel code (it's not exposed as uapi through ioctls),
      which means we could garbage collect fairly enormous amounts of code
      if we kill this.
      
      Plus because syzbot only runs on virtual hardware, and none of the
      drivers for that have acceleration, we'd remove a huge gap in testing.
      And there's no other even remotely comprehensive testing aside from
      syzbot.
      
      This patch here just disables the acceleration code by always
      redrawing when scrolling. The plan is that once this has been merged
      for well over a year in released kernels, we can start to go around
      and delete a lot of code.
      
      v2:
      - Drop a few more unused local variables, somehow I missed the
      compiler warnings (Sam)
      - Fix typo in comment (Jiri)
      - add a todo entry for the cleanup (Thomas)
      
      v3: Remove more unused variables (0day)
      Reviewed-by: NTomi Valkeinen <tomi.valkeinen@ti.com>
      Reviewed-by: NThomas Zimmermann <tzimmermann@suse.de>
      Reviewed-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: NSam Ravnborg <sam@ravnborg.org>
      Cc: Jiri Slaby <jirislaby@kernel.org>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: nouveau@lists.freedesktop.org
      Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Jiri Slaby <jirislaby@kernel.org>
      Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Peilin Ye <yepeilin.cs@gmail.com>
      Cc: George Kennedy <george.kennedy@oracle.com>
      Cc: Nathan Chancellor <natechancellor@gmail.com>
      Cc: Peter Rosin <peda@axentia.se>
      Signed-off-by: NDaniel Vetter <daniel.vetter@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20201029132229.4068359-1-daniel.vetter@ffwll.ch
      39aead83
  21. 16 11月, 2020 1 次提交
    • P
      fbcon: Avoid using FNTCHARCNT() and hard-coded built-in font charcount · a1ac250a
      Peilin Ye 提交于
      For user-provided fonts, the framebuffer layer is using a magic
      negative-indexing macro, FNTCHARCNT(), to keep track of their number of
      characters:
      
      	#define FNTCHARCNT(fd)	(((int *)(fd))[-3])
      
      For built-in fonts, it is using hard-coded values (256). This results in
      something like the following:
      
      		map.length = (ops->p->userfont) ?
      			FNTCHARCNT(ops->p->fontdata) : 256;
      
      This is unsatisfactory. In fact, there is already a `charcount` field in
      our virtual console descriptor (see `struct console_font` inside `struct
      vc_data`), let us use it:
      
      		map.length = vc->vc_font.charcount;
      
      Recently we added a `charcount` field to `struct font_desc`. Use it to set
      `vc->vc_font.charcount` properly. The idea is:
      
        - We only use FNTCHARCNT() on `vc->vc_font.data` and `p->fontdata`.
          Assume FNTCHARCNT() is working as intended;
        - Whenever `vc->vc_font.data` is set, also set `vc->vc_font.charcount`
          properly;
        - We can now replace `FNTCHARCNT(vc->vc_font.data)` with
          `vc->vc_font.charcount`;
        - Since `p->fontdata` always point to the same font data buffer with
          `vc->vc_font.data`, we can also replace `FNTCHARCNT(p->fontdata)` with
          `vc->vc_font.charcount`.
      
      In conclusion, set `vc->vc_font.charcount` properly in fbcon_startup(),
      fbcon_init(), fbcon_set_disp() and fbcon_do_set_font(), then replace
      FNTCHARCNT() with `vc->vc_font.charcount`. No more if-else between
      negative-indexing macros and hard-coded values.
      
      Do not include <linux/font.h> in fbcon_rotate.c and tileblit.c, since they
      no longer need it.
      
      Depends on patch "Fonts: Add charcount field to font_desc".
      Suggested-by: NDaniel Vetter <daniel@ffwll.ch>
      Signed-off-by: NPeilin Ye <yepeilin.cs@gmail.com>
      Reviewed-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/e460a5780e54e3022661d5f09555144583b4cc59.1605169912.git.yepeilin.cs@gmail.com
      a1ac250a