NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/61047: lack of support of console cursor on/off on genfb/rasops display (patch included)



>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
>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@localhost:/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. 






Home | Main Index | Thread Index | Old Index