From patchwork Sun Jun 17 19:07:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 138837 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3177300lji; Sun, 17 Jun 2018 12:07:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKXNPpIV/IbxoxFuYre/J383xMupzNyoX8HF5NQKIx9H3+ZoI17ePLFDbl9SXlXMDECrLue X-Received: by 2002:a62:d6d2:: with SMTP id a79-v6mr10643745pfl.87.1529262445546; Sun, 17 Jun 2018 12:07:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529262445; cv=none; d=google.com; s=arc-20160816; b=ojbgvlVJpZRT85U5dncpotHF0jC5KWuHjLoVBCXK2omlXpIOJAf5dofVi5i5fMz4w+ pbphjAUFZYMv89lQxjyB4fvrQUapm5y7PQzMCHGZfLv3H1D0yEbaVb3EGDmRv9Qj5Pat inJbSwK760xxHIVfrhngOXFFBe4pP4x80CVW6QGiY0xJB72YLAZ8nzq/9zv+3drkJRNI 2S2BVeIRxy63xO7JdMJclY5NhoXD7MmVpew5tPpk1Dnbi4MEZeXiwZF7rlLrn3xJqYIj hSN100LYdfuDJwpBD6KtAK1JFaoYC+xZQWU+CWPbJwJ5Iv9jIGFP63YFsgpU+cWjP8hF LCgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=9H59a7i3SGs4Jch5VTvQkD8b7wfugGD9DzfRXDOAu3o=; b=EDlPRlRPK+4Fd5TuPGauO6qWoaNVSjT/JLz5sjCSK2W13v95g1m145KwVs1IPHWjju TAqdbdy4UO0ucR1qnBdbHZneX49dzYv9rxmYNqmdjMc58qFXgt19+FXiWl7LNXUJKTmw 1NraI62lgXUpk3kMW/j/c2AlS5rP+XaQMxY23p3vw5ofgxcFBdlZ6aIPR4nyqqvmumt3 9HataRPBpqi56RK2n8wlP18gues7sIMkooNJQgFiB6+O3cFY1aSJr6/Bso3ezdS+8R5d jV6oqNGjatpbN8KHVmMPbHBRZ2jGRsUNasknTK3N6lpjt7YshBMWFvIHT9dPPYnAW8iO Y6bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=fXI0TzJd; 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=fail (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 t82-v6si13368365pfi.221.2018.06.17.12.07.25; Sun, 17 Jun 2018 12:07:25 -0700 (PDT) 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=@pobox.com header.s=sasl header.b=fXI0TzJd; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754963AbeFQTHR (ORCPT + 30 others); Sun, 17 Jun 2018 15:07:17 -0400 Received: from pb-smtp1.pobox.com ([64.147.108.70]:51028 "EHLO pb-smtp1.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754055AbeFQTHM (ORCPT ); Sun, 17 Jun 2018 15:07:12 -0400 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 3AF3AFC140; Sun, 17 Jun 2018 15:07:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=sasl; bh=9/NX KyUlCcMW8BPqNKlCzcnRQ1U=; b=fXI0TzJdJfY5u6+z4ogWiq7UvGMi6OXrMxu6 H4X1AEPxOJRf05e7uGhFOejJltGicgr1cZ4+l6ZRrMg9h411Ek0G/d80qECMCftW lv5BbLEwTCVqb/q8gwgX0UXNluE4d9ovz7d339bLVzWGqFUq6NuWe4tzUb9zvBd6 JyEf1Eo= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 330FEFC13F; Sun, 17 Jun 2018 15:07:10 -0400 (EDT) Received: from yoda.home (unknown [70.82.104.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id BEF54FC135; Sun, 17 Jun 2018 15:07:09 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 006E22DA0684; Sun, 17 Jun 2018 15:07:09 -0400 (EDT) From: Nicolas Pitre To: Greg Kroah-Hartman Cc: Dave Mielke , Samuel Thibault , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/4] vt: coherence validation code for the unicode screen buffer Date: Sun, 17 Jun 2018 15:07:06 -0400 Message-Id: <20180617190706.14614-5-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180617190706.14614-1-nicolas.pitre@linaro.org> References: <20180617190706.14614-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: A2781BD4-7261-11E8-A20B-44CE1968708C-78420484!pb-smtp1.pobox.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make sure the unicode screen buffer matches the video screen content. This is provided for debugging convenience and disabled by default. Signed-off-by: Nicolas Pitre --- drivers/tty/vt/vt.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) -- 2.17.1 diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 2d14bb195d..81129671c9 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -321,6 +321,8 @@ void schedule_console_callback(void) * Code to manage unicode-based screen buffers */ +#define VC_UNI_SCREEN_DEBUG 0 + #ifdef NO_VC_UNI_SCREEN /* this disables and optimizes related code away at compile time */ #define get_vc_uniscr(vc) NULL @@ -569,6 +571,42 @@ void vc_uniscr_copy_line(struct vc_data *vc, void *dest, int viewed, } } +/* this is for validation and debugging only */ +static void vc_uniscr_debug_check(struct vc_data *vc) +{ + struct uni_screen *uniscr = get_vc_uniscr(vc); + unsigned short *p; + int x, y, mask; + + if (!VC_UNI_SCREEN_DEBUG || !uniscr) + return; + + WARN_CONSOLE_UNLOCKED(); + + /* + * Make sure our unicode screen translates into the same glyphs + * as the actual screen. This is brutal indeed. + */ + p = (unsigned short *)vc->vc_origin; + mask = vc->vc_hi_font_mask | 0xff; + for (y = 0; y < vc->vc_rows; y++) { + char32_t *line = uniscr->lines[y]; + for (x = 0; x < vc->vc_cols; x++) { + u16 glyph = scr_readw(p++) & mask; + char32_t uc = line[x]; + int tc = conv_uni_to_pc(vc, uc); + if (tc == -4) + tc = conv_uni_to_pc(vc, 0xfffd); + if (tc == -4) + tc = conv_uni_to_pc(vc, '?'); + if (tc != glyph) + pr_notice("%s: mismatch at %d,%d: " + "glyph=%#x tc=%#x\n", __func__, + x, y, glyph, tc); + } + } +} + static void con_scroll(struct vc_data *vc, unsigned int t, unsigned int b, enum con_scroll dir, unsigned int nr) @@ -2717,6 +2755,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co do_con_trol(tty, vc, orig); } con_flush(vc, draw_from, draw_to, &draw_x); + vc_uniscr_debug_check(vc); console_conditional_schedule(); console_unlock(); notify_update(vc);