From patchwork Tue Feb 12 00:36:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 158062 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3234210jaa; Mon, 11 Feb 2019 16:36:47 -0800 (PST) X-Google-Smtp-Source: AHgI3IZuQ8irWGV6mxUzOw9mpQkS6FACWb79auNCzespzA6qNuvHELYYaQeTTkhy38JvBMck9p2C X-Received: by 2002:a17:902:bf44:: with SMTP id u4mr1111968pls.5.1549931806944; Mon, 11 Feb 2019 16:36:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549931806; cv=none; d=google.com; s=arc-20160816; b=cGQ186gc7iupElTuCSxwb6JQk7zJoe414+6v73zTamTKTo2s7UBy6YppMa6b8nM1y4 g5jYXxTNTJTweVsCxry+uWqi03aHw0LUnLi10oCGKCaj5j4Na50NuV7MW+EPKFLwuVm3 JXknQE6zGSmJUB1YglL8UbVmnK5IHYm6ZefPTn8DJEFuQhpjfYBuknydv5adnwWxhhCo VVa40zSpjUomB2A4tVsrO4dbCmxljuGnJY0eGrp5OeYzzZTldJw2Cg+w/f/kVui9Brj6 6tYvkU88wiwANNng5msN0zm19GNn6cpD/idgd+hDsQP6HaxfFBXHxa34yVIcRzy2fA0J FamQ== 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=p6UZlmJNvW6qn9lMpKGAK6h+ZzY5nTSp1ppNfG3zito=; b=UQ68cKlHyIb298fw4NwYld597B1Ji/89G7iJnfVQG9ZJ+lncjyts05eKxdawvexD+h 3ET5X1D2PeE3/Jo81W0aQHamoSKOZUUq/La8uzy/CS/iys7y+pI4Ft4XlhR0vtGieO8A CkmY1V6YwEGlC6NzgVCvcreaTr6YJ51BXZ1Dn8t2mOr9KMF/BjwHBYmq9deRv0lCrjSc jtNfbERWUIfO1RIgPu+TK81Z9tD63XzrOYSxtBdtjcLBbSDb9qc8cTfVmZO4X/vJkVEP BoC1pDATqZOaaOSYsNx8+p6KByvS6DlGeRXhHiF1QwnaqhD6uq/KEF3fEVV24nLlacVI ltLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UWVKchDp; 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 j127si10835845pgc.444.2019.02.11.16.36.46; Mon, 11 Feb 2019 16:36:46 -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=UWVKchDp; 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 S1728024AbfBLAgo (ORCPT + 31 others); Mon, 11 Feb 2019 19:36:44 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:39535 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727926AbfBLAgo (ORCPT ); Mon, 11 Feb 2019 19:36:44 -0500 Received: by mail-qk1-f196.google.com with SMTP id x6so7673716qki.6 for ; Mon, 11 Feb 2019 16:36:43 -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=p6UZlmJNvW6qn9lMpKGAK6h+ZzY5nTSp1ppNfG3zito=; b=UWVKchDptb/mMvXJH9eaB8sONNav2zs3oXVVHA5crBHGZhtrPABF+Jmp/e6N34QkOh 8yzZN0l3BbHFjPaGNM5Y21GEgbheGKJX/rOWLWeijXS/oyVVFH5Bo8mXzRCw+Kj+3d+g jaE2E0AX1jfFbP2lO2Ot5uqndRvxFRSBUYb6kSdLNjvmM+ED0rN6MJxH6uUQPi7DJ9A8 Fnv+63IA3AQtyY26+pY2VjCEPnII2Yka/faT9thWhNixbqPOCmBjTq181g/njQUAMEFL tsfmA95a4Dp9O9gUcXlKXnOe2I9ndbypXH6q6Ic6dM+Koez8aELRa8LYecQS87VhQBi8 nK3g== 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=p6UZlmJNvW6qn9lMpKGAK6h+ZzY5nTSp1ppNfG3zito=; b=Tn3YFhFr5g8GOVH0ZfBhmg/6zjERwzNEwPGOLRJqZcFFcfTiILSNBceb+7BB3yks7S 5ixOBgaDuo5fKvZ7Uc+OCmQ+xBK0g3pz/ljqTp1QLpd7gC1WcDW+wA69nzBS3dmPJyUc sTfvd6Z0dNo2hUE2OMrmKPBklloONh4xVsKZxmtpDO57EoOY8PBK4IJEPqicto3K2UnV Rui1AiD7CFjUBhh73MCpue0xQFOdvA2PE1rW88NfCEShh6dZNrp+9BD3ODoybNz07ZkH 3g0trLqR6p25lX+KTrN34iNDSAXGeGbrTy6f61j+Rfyg6wmk/7HK/iuy7M39ugSGr8N2 jOfA== X-Gm-Message-State: AHQUAuZKCgazz44jyLEIwN9mUQp1hv07ViU8cdIrGwPZURLoYKHMlsoF Mr85bv352mjWasd+MkKHT0FAcR56yVk= X-Received: by 2002:ae9:ea0f:: with SMTP id f15mr700826qkg.113.1549931802995; Mon, 11 Feb 2019 16:36:42 -0800 (PST) Received: from xanadu.home (modemcable228.104-82-70.mc.videotron.ca. [70.82.104.228]) by smtp.gmail.com with ESMTPSA id i126sm11758710qkc.78.2019.02.11.16.36.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Feb 2019 16:36:42 -0800 (PST) Date: Mon, 11 Feb 2019 19:36:41 -0500 (EST) From: Nicolas Pitre To: Greg Kroah-Hartman cc: Matthew Whitehead , linux-kernel@vger.kernel.org Subject: [PATCH] vt: perform safe console erase in the right order 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 Commit 4b4ecd9cb853 ("vt: Perform safe console erase only once") removed what appeared to be an extra call to scr_memsetw(). This missed the fact that set_origin() must be called before clearing the screen otherwise old screen content gets restored on the screen when using vgacon. Let's fix that by moving all the scrollback handling to flush_scrollback() where it logically belongs, and invoking it before the actual screen clearing in csi_J(), making the code simpler in the end. Reported-by: Matthew Whitehead Signed-off-by: Nicolas Pitre Tested-by: Matthew Whitehead Fixes: 4b4ecd9cb853 ("vt: Perform safe console erase only once") Cc: stable@vger.kernel.org diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index bba75560d1..9646ff63e7 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -935,8 +935,11 @@ static void flush_scrollback(struct vc_data *vc) { WARN_CONSOLE_UNLOCKED(); + set_origin(vc); if (vc->vc_sw->con_flush_scrollback) vc->vc_sw->con_flush_scrollback(vc); + else + vc->vc_sw->con_switch(vc); } /* @@ -1503,8 +1506,10 @@ static void csi_J(struct vc_data *vc, int vpar) count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; start = (unsigned short *)vc->vc_origin; break; + case 3: /* include scrollback */ + flush_scrollback(vc); + /* fallthrough */ case 2: /* erase whole display */ - case 3: /* (and scrollback buffer later) */ vc_uniscr_clear_lines(vc, 0, vc->vc_rows); count = vc->vc_cols * vc->vc_rows; start = (unsigned short *)vc->vc_origin; @@ -1513,13 +1518,7 @@ static void csi_J(struct vc_data *vc, int vpar) return; } scr_memsetw(start, vc->vc_video_erase_char, 2 * count); - if (vpar == 3) { - set_origin(vc); - flush_scrollback(vc); - if (con_is_visible(vc)) - update_screen(vc); - } else if (con_should_update(vc)) - do_update_region(vc, (unsigned long) start, count); + update_region(vc, (unsigned long) start, count); vc->vc_need_wrap = 0; }