Skip to content

Commit 5eb6083

Browse files
npitregregkh
authored andcommitted
vt: save/restore unicode screen buffer for alternate screen
The alternate screen support added by commit 23743ba ("vt: add support for smput/rmput escape codes") only saves and restores the regular screen buffer (vc_origin), but completely ignores the corresponding unicode screen buffer (vc_uni_lines) creating a messed-up display. Add vc_saved_uni_lines to save the unicode screen buffer when entering the alternate screen, and restore it when leaving. Also ensure proper cleanup in reset_terminal() and vc_deallocate(). Fixes: 23743ba ("vt: add support for smput/rmput escape codes") Cc: stable <[email protected]> Signed-off-by: Nicolas Pitre <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a7b9ce3 commit 5eb6083

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

drivers/tty/vt/vt.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,8 @@ struct vc_data *vc_deallocate(unsigned int currcons)
13391339
kfree(vc->vc_saved_screen);
13401340
vc->vc_saved_screen = NULL;
13411341
}
1342+
vc_uniscr_free(vc->vc_saved_uni_lines);
1343+
vc->vc_saved_uni_lines = NULL;
13421344
}
13431345
return vc;
13441346
}
@@ -1884,6 +1886,8 @@ static void enter_alt_screen(struct vc_data *vc)
18841886
vc->vc_saved_screen = kmemdup((u16 *)vc->vc_origin, size, GFP_KERNEL);
18851887
if (vc->vc_saved_screen == NULL)
18861888
return;
1889+
vc->vc_saved_uni_lines = vc->vc_uni_lines;
1890+
vc->vc_uni_lines = NULL;
18871891
vc->vc_saved_rows = vc->vc_rows;
18881892
vc->vc_saved_cols = vc->vc_cols;
18891893
save_cur(vc);
@@ -1905,6 +1909,8 @@ static void leave_alt_screen(struct vc_data *vc)
19051909
dest = ((u16 *)vc->vc_origin) + r * vc->vc_cols;
19061910
memcpy(dest, src, 2 * cols);
19071911
}
1912+
vc_uniscr_set(vc, vc->vc_saved_uni_lines);
1913+
vc->vc_saved_uni_lines = NULL;
19081914
restore_cur(vc);
19091915
/* Update the entire screen */
19101916
if (con_should_update(vc))
@@ -2227,6 +2233,8 @@ static void reset_terminal(struct vc_data *vc, int do_clear)
22272233
if (vc->vc_saved_screen != NULL) {
22282234
kfree(vc->vc_saved_screen);
22292235
vc->vc_saved_screen = NULL;
2236+
vc_uniscr_free(vc->vc_saved_uni_lines);
2237+
vc->vc_saved_uni_lines = NULL;
22302238
vc->vc_saved_rows = 0;
22312239
vc->vc_saved_cols = 0;
22322240
}

include/linux/console_struct.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ struct vc_data {
160160
struct uni_pagedict **uni_pagedict_loc; /* [!] Location of uni_pagedict variable for this console */
161161
u32 **vc_uni_lines; /* unicode screen content */
162162
u16 *vc_saved_screen;
163+
u32 **vc_saved_uni_lines;
163164
unsigned int vc_saved_cols;
164165
unsigned int vc_saved_rows;
165166
/* additional information is in vt_kern.h */

0 commit comments

Comments
 (0)