From patchwork Thu Jan 10 16:40:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 155214 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2101263jaa; Thu, 10 Jan 2019 08:40:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN6W48+sboj7U9iPWxUeGnGuoGWu1sjCd58tj82nUtEA/ujvpfzvFqF7nKLEhuZtvoza4cGP X-Received: by 2002:a63:ae01:: with SMTP id q1mr9762053pgf.402.1547138434829; Thu, 10 Jan 2019 08:40:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547138434; cv=none; d=google.com; s=arc-20160816; b=SOVMu4oqYG3SjPZZ1D8JAfVIDz/GlG35jG2lSpoJjAjM2pXPryjGpCs4Wsyz9VACYC KkpNSQ/QrTOqgRDj8IaQwZwmznGbpJUqQ3vjeEx6YjHjLUQPyd6TYbgpWW0FwFK73CFO MyzgcTt0cN6yNK3EH+JWQkbu0XMt723HIbcGVEPy82U6YhVUyl2hrzVA3hq+xekImLAT tcdoVlIsDUAaX8BKkQViIZKDyXn8EccUAxFj7ESzuaIcf2p8O2iAVsNCc+pjOfg8YN0t o21/ligEF0CH+MdIg0amV9Mh//SwIV5JmxTRx2tF2N8UsTcrIk2p8OXgSwkXjQJ2R8C+ Ky9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :subject:cc:to:from:date:dkim-signature; bh=mBcQZOKa9Newdq27djWne7nwXId0AwdhV+OFwusDdUk=; b=HpNpd25s3VSoUL9cVRSrRFxnszZ0nUA9H00kDamDPji0L7WZS+JiEV6PFOLg0hxrhq gpUxCTuDAFuAz6qjE7UNayX9MkhqBbchkZEK2PhXmv5oTU1xvokAgAYuQtgE7PuPjubM ctWes2Lxow6oh8TUjWS/E8R2ORngMsstW+ydkPgRh14mrGEeYEbvZnAYe+skZFSy5cV8 yYbZOXz6hqsaNOw01I4H28+hBfsYILxH49b5pgD/giQmEXaTo5cxx2J7yU+c/DkVEZK5 HJm9QqH6TCpEmj9wCKO5xkPiySmgGYHh2HHgDIHPoP+PhpzMHE9wa4OT2ON8vGGufnAv lqqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PVLSnkNV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f10si14700989pln.289.2019.01.10.08.40.34; Thu, 10 Jan 2019 08:40:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PVLSnkNV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728506AbfAJQkd (ORCPT + 31 others); Thu, 10 Jan 2019 11:40:33 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:36006 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727807AbfAJQkd (ORCPT ); Thu, 10 Jan 2019 11:40:33 -0500 Received: by mail-qt1-f195.google.com with SMTP id t13so13837540qtn.3 for ; Thu, 10 Jan 2019 08:40:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=mBcQZOKa9Newdq27djWne7nwXId0AwdhV+OFwusDdUk=; b=PVLSnkNVkz+k8XlAsQvBOYKuNdz/ihk/xPmhwj7IUnS28W1LA89pJz/8OECRk3/gp6 F0dpAJtHYko3q/6vREzw2YDtFbZjV83cSK5tYsqQhfm5C237jiiwZJGlgQdXuRTim9Ts K2EmKmCDwwMCpNM64HkzoNiFj4nHiuxsnnN1o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version; bh=mBcQZOKa9Newdq27djWne7nwXId0AwdhV+OFwusDdUk=; b=JaYxDTou4sMocx3CwCto1NfKwyP82qx4rFX6SfizEPq9OAAbnCZZK0Mc4raN/niw/S dkop09xwZXd8ghTgD5jX93zXY61wzlPgLJr8XgkLW37rCotXLuou8FSZlZaEqC2v9H+t NBM5H2mEzXkI3ZiGAqtMK0pVbjPff4/dIdZBahIsma4VLUeQieg7MgI5GGUIfYngmLJL gvUsNiYHsJnlwzs8kJwJTFoKYSmDiQdkaxCBHPzWQUsxHWkAZljsbLlIRnsCas3lygNf Pb9AKCyQS2q9JX02hhLZ2FUd2KAxzehAhVSOT6EE/R30ZlafrJjKivrTVOzwFKoY6/0b HvSw== X-Gm-Message-State: AJcUukcwmVNM6lpGZpcSfY5HpM0UrOC84LlnL6geS/usKEsnsyTqxh6u N3mIoZBnjhEdzmJ5xQ/Kz4yNAw== X-Received: by 2002:a37:7a06:: with SMTP id v6mr9609481qkc.10.1547138431918; Thu, 10 Jan 2019 08:40:31 -0800 (PST) Received: from xanadu.home (modemcable228.104-82-70.mc.videotron.ca. [70.82.104.228]) by smtp.gmail.com with ESMTPSA id c12sm47814698qka.42.2019.01.10.08.40.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Jan 2019 08:40:31 -0800 (PST) Date: Thu, 10 Jan 2019 11:40:29 -0500 (EST) From: Nicolas Pitre To: Greg KH cc: Dave Mielke , linux-kernel@vger.kernel.org Subject: [PATCH] vgacon: unconfuse vc_origin when using soft scrollback Message-ID: User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When CONFIG_VGACON_SOFT_SCROLLBACK is selected, the VGA display memory index and vc_visible_origin don't change when scrollback is activated. The actual screen content is saved away and the scrollbackdata is copied over it. However the vt code, and /dev/vcs devices in particular, still expect vc_origin to always point at the actual screen content not the displayed scrollback content. So adjust vc_origin to point at the saved screen content when scrollback is active and set it back to vc_visible_origin when restoring the screen. This fixes /dev/vcsa that return scrollback content when they shouldn't (onli /dev/vcsa without a number should), and also fixes /dev/vcsu that should return scrollback content when scrollback is active but currently doesn't. An unnecessary call to vga_set_mem_top() is also removed. Signed-off-by: Nicolas Pitre Cc: stable@vger.kernel.org # v4.19+ --- I tagged it for stable starting with v4.19 as this is the kernel that introduced /dev/vcsu* which is directly affected. Users of earlier kernels most likely won't care. Signed-off-by: Nicolas Pitre Signed-off-by: Nicolas Pitre diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 09731b2f68..a3353a9970 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -271,6 +271,7 @@ static void vgacon_scrollback_update(struct vc_data *c, int t, int count) static void vgacon_restore_screen(struct vc_data *c) { + c->vc_origin = c->vc_visible_origin; vgacon_scrollback_cur->save = 0; if (!vga_is_gfx && !vgacon_scrollback_cur->restore) { @@ -287,8 +288,7 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines) int start, end, count, soff; if (!lines) { - c->vc_visible_origin = c->vc_origin; - vga_set_mem_top(c); + vgacon_restore_screen(c); return; } @@ -298,6 +298,7 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines) if (!vgacon_scrollback_cur->save) { vgacon_cursor(c, CM_ERASE); vgacon_save_screen(c); + c->vc_origin = c->vc_screenbuf; vgacon_scrollback_cur->save = 1; } @@ -335,7 +336,7 @@ static void vgacon_scrolldelta(struct vc_data *c, int lines) int copysize; int diff = c->vc_rows - count; - void *d = (void *) c->vc_origin; + void *d = (void *) c->vc_visible_origin; void *s = (void *) c->vc_screenbuf; count *= c->vc_size_row;