NetBSD Problem Report #61047

From www@netbsd.org  Mon Nov 23 00:07:56 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.netbsd.org", Issuer "YR1" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id C7B361A923B
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 23 Nov 2026 00:07:56 +0000 (UTC)
Message-Id: <20261123000755.022F61A923D@mollari.NetBSD.org>
Date: Mon, 23 Nov 2026 00:07:54 +0000 (UTC)
From: aniou+gnats@smutek.pl
Reply-To: aniou+gnats@smutek.pl
To: gnats-bugs@NetBSD.org
Subject: lack of support of console cursor on/off on genfb/rasops display (patch included)
X-Send-Pr-Version: www-1.0
X-From4GNATS: "aniou+gnats@smutek.pl via gnats" <gnats-admin@NetBSD.org>

>Number:         61047
>Category:       kern
>Synopsis:       lack of support of console cursor on/off on genfb/rasops display (patch included)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 23 00:10:00 +0000 2026
>Last-Modified:  Mon Nov 23 00:35:01 +0000 2026
>Originator:     Piotr Meyer
>Release:        11.0
>Organization:
>Environment:
NetBSD net11.xc 11.0_STABLE NetBSD 11.0_STABLE (GENERIC) #0: Fri Oct 30 19:02:53 UTC 2026  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
Combination of wsdisplay (vcons) on genfb lacks support for disabling/enabling console cursor. An ANSI command or tput civis move cursor to next row and first column but remain them enabled.

That behavior looks like consistent between different platforms that uses wsdisplay and genfb, I tried amd64/evbarm ones.

amd64:
[     1.026675] genfb0 at pci0 dev 1 function 0: vendor 1234 product 1111 (rev. 0x02)
[     1.026675] genfb0: framebuffer at 0xfd000000, size 1920x1080, depth 32, stride 7680
[     1.026675] wsdisplay0 at genfb0 kbdmux 1

evbarm:
[     1.000004] genfb0 at simplebus1: switching to framebuffer console
[     1.000004] genfb0: framebuffer at 0xfe99a000, size 1024x600, depth 32, stride 4096
[     1.000004] wsdisplay0 at genfb0 kbdmux 1: console (default, vt100 emulation)

After fiddling with wsdisplay_vscons.c code I realize that there is no permanent state for cursor visibility at vscons nor genfb level and requests like that one from vcons_redraw_screen(...) unconditionally draws cursor, even if it was already disabled at wsemul_vt100* level:

...
scr->scr_vd->private->cursor(ri, 1, ri->ri_crow, ri->ri_ccol);
>How-To-Repeat:
Run netbsd in qemu with following parameters and try commands like 'tput civis' on console/virtual terminal:

menu=Boot genfb:rndseed /etc/entropy-file;vesa 1920x1080x32; boot

White cursor should be moved to lower line and placed into first column and remain here to 'tput cnorm' because updating cursor position depends from cursor visibility marked at vd-flags and obey at higher level than wsdisplay_vcons...
>Fix:
I tried following patch that uses unused bits on scr->scr_status to keep cursor state per virtual console and make calls to scr->scr_vd->private->cursor(ri, 1, ... depended from that state. I tried it succesfully on kernel compiled with- and without VCONS_DRAW_INTR flag.

--- wsdisplay_vconsvar.h.orig   2026-11-23 00:49:18.255745466 +0100
+++ wsdisplay_vconsvar.h        2026-11-23 00:48:38.900408023 +0100
@@ -81,6 +81,7 @@
        /* status flags used by vcons */
        uint32_t scr_status;
 #define VCONS_IS_VISIBLE       1       /* this screen is currently visible */
+#define VCONS_CURSOR_ON     2   /* this screen has cursor enabled   */
        /* non zero when some rasops operation is in progress */
        int scr_busy;
 #ifdef WSDISPLAY_SCROLLSUPPORT
@@ -104,6 +105,7 @@
 #define SCREEN_INVISIBLE(scr) ((scr)->scr_status &= ~VCONS_IS_VISIBLE)
 #define SCREEN_DISABLE_DRAWING(scr) ((scr)->scr_flags |= VCONS_DONT_DRAW)
 #define SCREEN_ENABLE_DRAWING(scr) ((scr)->scr_flags &= ~VCONS_DONT_DRAW)
+#define SCREEN_CURSOR_IS_ON(scr) (((scr)->scr_status & VCONS_CURSOR_ON) != 0)

 #define DEFATTR ((WS_DEFAULT_FG << 24) || (WS_DEFAULT_BG << 16))


--- wsdisplay_vcons.c   2026-11-23 00:48:44.134032357 +0100
+++ wsdisplay_vcons.c.orig      2026-11-23 00:49:18.648046369 +0100
@@ -753,15 +753,8 @@
                                vdp->erasecols(ri, i, start, j - start, last_a);
                        }
                }
-#ifdef WSDISPLAY_SCROLLSUPPORT
-        if ((scr->scr_line_wanted == 0) && (SCREEN_CURSOR_IS_ON(scr))) {
-#else
-        if SCREEN_CURSOR_IS_ON(scr) {
-#endif
-                   ri->ri_flg &= ~RI_CURSOR;
-                   scr->scr_vd->private->cursor(ri, 1, ri->ri_crow, ri->ri_ccol);
-        }
-
+               ri->ri_flg &= ~RI_CURSOR;
+               scr->scr_vd->private->cursor(ri, 1, ri->ri_crow, ri->ri_ccol);
 #ifdef VCONS_DRAW_INTR
                vdp->cursor_offset = ri->ri_crow * ri->ri_cols + ri->ri_ccol;
 #endif
@@ -817,10 +810,8 @@
                                boffset++;
                        }
                }
-               if SCREEN_CURSOR_IS_ON(scr) {
-                       ri->ri_flg &= ~RI_CURSOR;
-                       scr->scr_vd->private->cursor(ri, 1, ri->ri_crow, ri->ri_ccol);
-               }
+               ri->ri_flg &= ~RI_CURSOR;
+               scr->scr_vd->private->cursor(ri, 1, ri->ri_crow, ri->ri_ccol);
                vdp->cursor_offset = ri->ri_crow * ri->ri_cols + ri->ri_ccol;
        }
        vcons_unlock(scr);
@@ -902,7 +893,7 @@
                return ENOMEM;

        scr->scr_flags = 0;
-       scr->scr_status = VCONS_CURSOR_ON;
+       scr->scr_status = 0;
        scr->scr_busy = 0;
        scr->scr_type = __UNCONST(type);

@@ -1359,20 +1350,10 @@
 {
        struct rasops_info *ri = cookie;
        struct vcons_screen *scr = ri->ri_hw;
-       bool cursor_state_flip;
-
-    vcons_lock(scr);
-       cursor_state_flip = (on != 0) != SCREEN_CURSOR_IS_ON(scr);
-       if (cursor_state_flip) {
-               scr->scr_status &= ~VCONS_CURSOR_ON;
-               scr->scr_status |= (on != 0) ? VCONS_CURSOR_ON : 0;
-       }
-    vcons_unlock(scr);

        if (vcons_use_intr(scr)) {
                vcons_lock(scr);
-
-               if ((scr->scr_ri.ri_crow != row || scr->scr_ri.ri_ccol != col) || cursor_state_flip) {
+               if (scr->scr_ri.ri_crow != row || scr->scr_ri.ri_ccol != col) {
                        scr->scr_ri.ri_crow = row;
                        scr->scr_ri.ri_ccol = col;
                        vcons_dirty(scr);
@@ -1618,7 +1599,7 @@
                }
        }

-       if ((scr->scr_line_wanted == 0) && (SCREEN_CURSOR_IS_ON(scr))) {
+       if (scr->scr_line_wanted == 0) {
                /* this was a reset - need to draw the cursor */
                scr->scr_ri.ri_flg &= ~RI_CURSOR;
                scr->scr_vd->private->cursor(scr, 1, scr->scr_ri.ri_crow,


Warning: there is one corner case when cursor is not hidden during scroll-up (WSDISPLAY_SCROLLSUPPORT) when there is empty space in column in rows above cursor but this behavior is specific for vanilla version too, it has no connection with my diff. 



>Audit-Trail:
From: Piotr Meyer <aniou+gnats@smutek.pl>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/61047: lack of support of console cursor on/off on
 genfb/rasops display (patch included)
Date: Mon, 23 Nov 2026 01:24:04 +0100

 Poor me, I messed-up files order in diff. There is an valid patch, 
 sorry.

 Best regards,
 Piotr Meyer


 --- wsdisplay_vconsvar.h.orig   2026-11-23 00:49:18.255745466 +0100
 +++ wsdisplay_vconsvar.h        2026-11-23 00:48:38.900408023 +0100
 @@ -81,6 +81,7 @@
         /* status flags used by vcons */
         uint32_t scr_status;
  #define VCONS_IS_VISIBLE       1       /* this screen is currently visible */
 +#define VCONS_CURSOR_ON     2   /* this screen has cursor enabled   */
         /* non zero when some rasops operation is in progress */
         int scr_busy;
  #ifdef WSDISPLAY_SCROLLSUPPORT
 @@ -104,6 +105,7 @@
  #define SCREEN_INVISIBLE(scr) ((scr)->scr_status &= ~VCONS_IS_VISIBLE)
  #define SCREEN_DISABLE_DRAWING(scr) ((scr)->scr_flags |= VCONS_DONT_DRAW)
  #define SCREEN_ENABLE_DRAWING(scr) ((scr)->scr_flags &= ~VCONS_DONT_DRAW)
 +#define SCREEN_CURSOR_IS_ON(scr) (((scr)->scr_status & VCONS_CURSOR_ON) != 0)

  #define DEFATTR ((WS_DEFAULT_FG << 24) || (WS_DEFAULT_BG << 16))


 --- wsdisplay_vcons.c.orig      2026-11-23 00:49:18.648046369 +0100
 +++ wsdisplay_vcons.c   2026-11-23 00:48:44.134032357 +0100
 @@ -753,8 +753,15 @@
                                 vdp->erasecols(ri, i, start, j - start, last_a);
                         }
                 }
 -               ri->ri_flg &= ~RI_CURSOR;
 -               scr->scr_vd->private->cursor(ri, 1, ri->ri_crow, ri->ri_ccol);
 +#ifdef WSDISPLAY_SCROLLSUPPORT
 +        if ((scr->scr_line_wanted == 0) && (SCREEN_CURSOR_IS_ON(scr))) {
 +#else
 +        if SCREEN_CURSOR_IS_ON(scr) {
 +#endif
 +                   ri->ri_flg &= ~RI_CURSOR;
 +                   scr->scr_vd->private->cursor(ri, 1, ri->ri_crow, ri->ri_ccol);
 +        }
 +
  #ifdef VCONS_DRAW_INTR
                 vdp->cursor_offset = ri->ri_crow * ri->ri_cols + ri->ri_ccol;
  #endif

 @@ -810,8 +817,10 @@
                                 boffset++;
                         }
                 }
 -               ri->ri_flg &= ~RI_CURSOR;
 -               scr->scr_vd->private->cursor(ri, 1, ri->ri_crow, ri->ri_ccol);
 +               if SCREEN_CURSOR_IS_ON(scr) {
 +                       ri->ri_flg &= ~RI_CURSOR;
 +                       scr->scr_vd->private->cursor(ri, 1, ri->ri_crow, ri->ri_ccol);
 +               }
                 vdp->cursor_offset = ri->ri_crow * ri->ri_cols + ri->ri_ccol;
         }
         vcons_unlock(scr);
 @@ -893,7 +902,7 @@
                 return ENOMEM;

         scr->scr_flags = 0;
 -       scr->scr_status = 0;
 +       scr->scr_status = VCONS_CURSOR_ON;
         scr->scr_busy = 0;
         scr->scr_type = __UNCONST(type);

 @@ -1350,10 +1359,20 @@
  {
         struct rasops_info *ri = cookie;
         struct vcons_screen *scr = ri->ri_hw;
 +       bool cursor_state_flip;
 +
 +    vcons_lock(scr);
 +       cursor_state_flip = (on != 0) != SCREEN_CURSOR_IS_ON(scr);
 +       if (cursor_state_flip) {
 +               scr->scr_status &= ~VCONS_CURSOR_ON;
 +               scr->scr_status |= (on != 0) ? VCONS_CURSOR_ON : 0;
 +       }
 +    vcons_unlock(scr);

         if (vcons_use_intr(scr)) {
                 vcons_lock(scr);
 -               if (scr->scr_ri.ri_crow != row || scr->scr_ri.ri_ccol != col) {
 +
 +               if ((scr->scr_ri.ri_crow != row || scr->scr_ri.ri_ccol != col) || cursor_state_flip) {
                         scr->scr_ri.ri_crow = row;
                         scr->scr_ri.ri_ccol = col;
                         vcons_dirty(scr);
 @ -1599,7 +1618,7 @@
                 }
         }

 -       if (scr->scr_line_wanted == 0) {
 +       if ((scr->scr_line_wanted == 0) && (SCREEN_CURSOR_IS_ON(scr))) {
                 /* this was a reset - need to draw the cursor */
                 scr->scr_ri.ri_flg &= ~RI_CURSOR;
                 scr->scr_vd->private->cursor(scr, 1, scr->scr_ri.ri_crow,


 -- 
 Piotr 'aniou' Meyer

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.