From nobody Mon Feb 9 19:11:05 2026 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 518B71E2858 for ; Tue, 27 Jan 2026 22:56:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769554567; cv=none; b=U0Xwi6Z53RxppcFgBK0BgxJBmNWLKBb67ogfvE/q+JdPHo0r7DqK6jg6c0navPuIg0kt/UFVcR1HZsW2Yjoq3P6y6GYWtyVGNgxkHhVgPxtNng1tgp/uom6XqONORB9WGv6ELADRm+hT9vrWVfg/4qR+UB3sbA2IBLPYb1A4zzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769554567; c=relaxed/simple; bh=BIqtV71O4b2nNBJ39pBWJei81bi2HK91qUvVgENdbQ0=; h=Date:From:To:cc:Subject:Message-ID:MIME-Version:Content-Type; b=sfgxHVCLbOTXEMr+WBvyPGcjvtIIBV2OZ1NqZkHaapImkznpREZ634llPOiCeGuR/ZsmDcnYBYDpYIC5zGMiEaPifmyOINjTca8tXECNXeMpBucnjPEITrQhXCkKMoYbr80YYokJUYLf/MPfE1HEBtZcR76aYnUoqjmIEn72Riw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=3f/m2CtP; arc=none smtp.client-ip=209.85.222.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="3f/m2CtP" Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-8c52f15c5b3so618278685a.3 for ; Tue, 27 Jan 2026 14:56:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1769554563; x=1770159363; darn=vger.kernel.org; h=mime-version:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=be7rCfgGfMyw8VXlN7Q+qrUYUoCH9F4cDfmNDHeRxCI=; b=3f/m2CtPUNVolk2N69gEc7bviJ1m+nKBFeRmpYkkWYlWhrv8k/yqXOHeV6BvnPkSok aTl8yRpeifm4BgFvLWm91Bmax9M3zxi1xTKRUQkrNEgxCUo4rxv5XbPh8I9zS4lnQdY4 U7m6EGV5wnHVLON91mq+kSA8KV3GWErvZu9cxnQyejMtrkB6BR2HsFpP/ufMBqhKSvvQ qfew+HXummM77l3xqfGaicL/sNE2NQ57b4wV4jxkxhYob7tviZJvDkgsHxNpUm5g3FrB IU3mYARufjGqRNLw7XHlP0G6keHF9HYMF7ZYoW+IG3Aj6Lrall/dsefb8CUafgsoN8wV qZuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769554563; x=1770159363; h=mime-version:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=be7rCfgGfMyw8VXlN7Q+qrUYUoCH9F4cDfmNDHeRxCI=; b=qym7d1eJZzlqLhrcuX/I2n1dzaHtDQauH1DTSQwS1AgFjv5m1R2kmV7xhPrVWGle5R fK2yXXtK8mfM+u1D3FLBN0mtO91XiiGJCDO48ES1oH3oTs/PiMPYFfm079nXbkXuuI5e eoMEz8xCAJLEui2jlINTbWdOODVWSQhYhE5q/esGFAx5lGnkEH1kWy6SXagtPUkXEFfV FUnO72Rm8eKCGSqjbOj64b+cB6xo0r+XQGpk8DXP/uoXnkipL7KqOQLhu6MiRmJ83cxB mRARnWRqR3VBVlK47bLDzjkJ9JIZE/vF2LFilYv4f6LZ0qJHRqYEdEjDFhmaXNymb3DT MpRw== X-Gm-Message-State: AOJu0Yz0rnPYTvZPLmj/h6jXgDdl9UQSwFWl8fr2UXVAEh26ztaO2fKs 8FDrgQAWvKmPlagqVFxyNf8wwZ111F6Tlt+saghKDWtK0gl2ZKo0uLgR/InXxREkhnU= X-Gm-Gg: AZuq6aJ0d+rbw9G7sxAi+qBlvkLlCh89EUZ2DqQ2sM4MGX2OklalDRqtNEfVcfAXg9p lT8twkKg5X8sIDXl2gyHm7OSjOsbP3BCbRhMviCTw2kuGdAAeQjOCbpCHG/Fyr+73kPSTf6VYYl V+PaHC79FdOPmaMfpaXBL9PSjBQRjf9ZCviEHxHS6OpihYgULU/MVtd3MV7e4djqkgGeRA8G30K yLTDJaF+QMFJSP8SaQwJazz4xAM9FZ9yomDudlIgRAU1yEf7eKjxHskw2HTSOSd7tcuPPmKunAn 78JFZJFoFQcNefzbu9C7PZa5XKL1na/THkwnddp7AQY/8/ne9bBhXIonrjLwI/NDltweoDibdKE ew2hjZIEhIg0E8Z+NN8UwpzH0q5rQhXkK7xOGcSldZSUKuXGlIpICwouf9pWsmp7OiHebTIikCe VPz6g9bR9xgvSFHC09jaQVrhvJAIcmoFrClgNeQTH0iiPvADCam5U= X-Received: by 2002:a05:620a:4624:b0:8b2:dcde:b670 with SMTP id af79cd13be357-8c70b918e63mr420739285a.70.1769554563190; Tue, 27 Jan 2026 14:56:03 -0800 (PST) Received: from xanadu (modemcable048.4-80-70.mc.videotron.ca. [70.80.4.48]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8c711d2a2d4sm64282485a.32.2026.01.27.14.56.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jan 2026 14:56:02 -0800 (PST) Date: Tue, 27 Jan 2026 17:56:01 -0500 (EST) From: Nicolas Pitre To: Greg Kroah-Hartman , Jiri Slaby , Calixte Pernot cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH] vt: save/restore unicode screen buffer for alternate screen Message-ID: <5o2p6qp3-91pq-0p17-or02-1oors4417ns7@onlyvoer.pbz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The alternate screen support added by commit 23743ba64709 ("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: 23743ba64709 ("vt: add support for smput/rmput escape codes") Signed-off-by: Nicolas Pitre --- drivers/tty/vt/vt.c | 8 ++++++++ include/linux/console_struct.h | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 59b4b5e126ba..83a285577708 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1345,6 +1345,8 @@ struct vc_data *vc_deallocate(unsigned int currcons) kfree(vc->vc_saved_screen); vc->vc_saved_screen =3D NULL; } + vc_uniscr_free(vc->vc_saved_uni_lines); + vc->vc_saved_uni_lines =3D NULL; } return vc; } @@ -1890,6 +1892,8 @@ static void enter_alt_screen(struct vc_data *vc) vc->vc_saved_screen =3D kmemdup((u16 *)vc->vc_origin, size, GFP_KERNEL); if (vc->vc_saved_screen =3D=3D NULL) return; + vc->vc_saved_uni_lines =3D vc->vc_uni_lines; + vc->vc_uni_lines =3D NULL; vc->vc_saved_rows =3D vc->vc_rows; vc->vc_saved_cols =3D vc->vc_cols; save_cur(vc); @@ -1911,6 +1915,8 @@ static void leave_alt_screen(struct vc_data *vc) dest =3D ((u16 *)vc->vc_origin) + r * vc->vc_cols; memcpy(dest, src, 2 * cols); } + vc_uniscr_set(vc, vc->vc_saved_uni_lines); + vc->vc_saved_uni_lines =3D NULL; restore_cur(vc); /* Update the entire screen */ if (con_should_update(vc)) @@ -2233,6 +2239,8 @@ static void reset_terminal(struct vc_data *vc, int do= _clear) if (vc->vc_saved_screen !=3D NULL) { kfree(vc->vc_saved_screen); vc->vc_saved_screen =3D NULL; + vc_uniscr_free(vc->vc_saved_uni_lines); + vc->vc_saved_uni_lines =3D NULL; vc->vc_saved_rows =3D 0; vc->vc_saved_cols =3D 0; } diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h index 13b35637bd5a..d5ca855116df 100644 --- a/include/linux/console_struct.h +++ b/include/linux/console_struct.h @@ -160,6 +160,7 @@ struct vc_data { struct uni_pagedict **uni_pagedict_loc; /* [!] Location of uni_pagedict v= ariable for this console */ u32 **vc_uni_lines; /* unicode screen content */ u16 *vc_saved_screen; + u32 **vc_saved_uni_lines; unsigned int vc_saved_cols; unsigned int vc_saved_rows; /* additional information is in vt_kern.h */ --=20 2.52.0