* [PATCH] vt: Skip hardware scrolling while blanked and fix VESA blanking
@ 2026-11-23 10:11 Yu Peng
2026-11-23 10:30 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Yu Peng @ 2026-11-23 10:11 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Helge Deller
Cc: Thomas Zimmermann, Nicolas Pitre, Ronan Pigott, linux-serial,
linux-fbdev, dri-devel, linux-kernel, Yu Peng
When vgacon is blanked without palette blanking (!vga_palette_blanked),
vgacon_set_origin() rejects VRAM so vc->vc_origin points to the heap
buffer vc->vc_screenbuf. Calling hardware scroll callbacks while blanked
then treats vc->vc_screenbuf as VRAM and causes out-of-bounds accesses.
Use con_should_update() to skip hardware scrolling and scrollback while
blanked, allowing con_scroll() to fall back to software scrolling.
In vgacon_blank(), return !vga_palette_blanked for VESA blanking so
direct VESA blanking switches vc->vc_origin to vc->vc_screenbuf
immediately instead of losing output on unblank.
Assisted-by: LLM
Signed-off-by: Yu Peng <pengyu@kylinos.cn>
---
drivers/tty/vt/vt.c | 7 ++++---
drivers/video/console/vgacon.c | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 6a6eb8b2a6dec..39be682645097 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -726,8 +726,8 @@ static void con_scroll(struct vc_data *vc, unsigned int top,
return;
vc_uniscr_scroll(vc, top, bottom, dir, nr);
- if (con_is_visible(vc) &&
- vc->vc_sw->con_scroll(vc, top, bottom, dir, nr))
+ if (con_should_update(vc) &&
+ vc->vc_sw->con_scroll(vc, top, bottom, dir, nr))
return;
src = clear = (u16 *)(vc->vc_origin + vc->vc_size_row * top);
@@ -3488,7 +3488,8 @@ static void console_callback(struct work_struct *ignored)
if (scrollback_delta) {
struct vc_data *vc = vc_cons[fg_console].d;
clear_selection();
- if (vc->vc_mode == KD_TEXT && vc->vc_sw->con_scrolldelta)
+ if (con_should_update(vc) && vc->vc_mode == KD_TEXT &&
+ vc->vc_sw->con_scrolldelta)
vc->vc_sw->con_scrolldelta(vc, scrollback_delta);
scrollback_delta = 0;
}
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 09f7c376b4689..3a706c1f1cb28 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -796,7 +796,7 @@ static bool vgacon_blank(struct vc_data *c, enum vesa_blank_mode blank,
vga_vesa_blank(&vgastate, blank);
vga_vesa_blanked = blank;
}
- return false;
+ return !vga_palette_blanked;
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] vt: Skip hardware scrolling while blanked and fix VESA blanking
2026-11-23 10:11 [PATCH] vt: Skip hardware scrolling while blanked and fix VESA blanking Yu Peng
@ 2026-11-23 10:30 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-23 10:30 UTC (permalink / raw)
To: Yu Peng; +Cc: linux-serial, dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] vt: con_scroll() skips vgacon_scroll() while palette-blanked
in VRAM
--
commit fd87e862e45bd2b98326c37c1251a1bf748045f6
Author: Yu Peng <pengyu@kylinos.cn>
vt: Skip hardware scrolling while blanked and fix VESA blanking
This commit uses con_should_update() in con_scroll() and
console_callback() to skip hardware scrolling and scrollback while the
console is blanked, and returns !vga_palette_blanked from vgacon_blank()
for VESA blanking.
> diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
> index 7dbc0072a40a9..0e24e4ea99bf1 100644
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
> @@ -726,8 +726,8 @@ static void con_scroll(struct vc_data *vc, unsigned int top,
> return;
>
> vc_uniscr_scroll(vc, top, bottom, dir, nr);
> - if (con_is_visible(vc) &&
> - vc->vc_sw->con_scroll(vc, top, bottom, dir, nr))
> + if (con_should_update(vc) &&
> + vc->vc_sw->con_scroll(vc, top, bottom, dir, nr))
> return;
>
> src = clear = (u16 *)(vc->vc_origin + vc->vc_size_row * top);
[Severity: Medium]
Does checking con_should_update(vc) here break vgacon_scroll() while
vgacon is palette-blanked?
On color VGA text consoles (vga_video_type == VIDEO_TYPE_VGAC), normal
blanking in vgacon_blank() sets vga_palette_blanked = true and returns
false, leaving vc->vc_origin pointing to uncached VGA MMIO VRAM rather
than vc->vc_screenbuf.
Because con_should_update(vc) is false whenever console_blanked is
non-zero, con_scroll() skips vgacon_scroll() even when
vga_palette_blanked is true. Every scroll while palette-blanked then
falls back to software scr_memmovew() directly over uncached VGA MMIO
VRAM and overwrites vc->vc_origin in place instead of advancing through
the 32KB VRAM scrollback buffer.
In addition, if the console was scrolled back when do_blank_screen() ran,
hide_cursor() -> vgacon_cursor() -> vgacon_restore_screen() ->
vgacon_scrolldelta(c, 0) resets c->vc_visible_origin = c->vc_origin and
returns early without calling vga_set_mem_top(c). Skipping
vgacon_scroll() (which calls vga_set_mem_top(c)) and then unblanking via
vgacon_unblank() (which only restores the palette when
vga_palette_blanked is true) leaves the VGA CRTC start address register
stuck at the old scrolled-back VRAM offset.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123101151.414436-1-pengyu@kylinos.cn?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-23 10:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 10:11 [PATCH] vt: Skip hardware scrolling while blanked and fix VESA blanking Yu Peng
2026-11-23 10:30 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox