From patchwork Wed May 30 21:27:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 137289 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp5816483lji; Wed, 30 May 2018 14:28:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJGsEzVM4WWgTfcW+AeyeHksypBF/qd8qBALUSlqdLMwyS8+Lg1GMhAxEZpk8m6xKg/n/J/ X-Received: by 2002:a17:902:9344:: with SMTP id g4-v6mr4443200plp.10.1527715705269; Wed, 30 May 2018 14:28:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527715705; cv=none; d=google.com; s=arc-20160816; b=cyZj1w0vR2cQy/pQooJShwDJmhuC7HNfPrm8AhtjoVLJUXx/z7xmXHA0DzkBv+OSLC hKRbM3rH/b/wIlpgL+A2QvkNkorTshd/7BiUHB51Nx4xTlxe+hKGrgCWw2rRf+3+Zr48 UzO7Cdn82dlD0k8WepKFosTlnGoAKcW58Lh5/vGC360GRHX6odQd+6UzbRqwtD1L5pn5 1jwNNxEw/0r7luPgo8VmPDQNl3vbozxe8k7en39eE2mIz2wJA9e9gWK/ZA0ISbkvGdRf NVTpszqSpOmVG3pP77fO2kqgkt0u6ohR52zPNRRZ06KTn0xAnmzKShaC3sgyPvOI6Ut5 krEg== 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=MITpJEubxL70uT4SzIKN0Bw9x+DxazT4+YHNUQFZcJc=; b=jd2UlaKWE7pc6kH58KqeS0W1dNPNMyE/e5xUIQUD5xoj+H60JBejvEtKlengimRco7 8GnhQ6+ux84RRLV5DSkzE51+DjbyXqMDAGQOnDeIyPrOOli4hgu00EndFREyTF3o2ULL UH1K812rjQ/gseo/gk2z0eP2JLABywW43Jn+opUikRYIUIlxj6GIVDHfPcZUU01B3NX6 fTbcf3QN2q0hvsBj9//+7Fu4GEGtA2EDHbkL0m5J+zKhb07MyIcoLPd8OgrRc6QIFfDD nM8T6xbTT1xsfhAwyO7F6EiGMrAUhqJZZUDAc5CAVVKMZmDCLvtu/3veUe4SSE4POmM3 TC+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=xn8GTcWw; 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 5-v6si36237263plx.517.2018.05.30.14.28.25; Wed, 30 May 2018 14:28: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=xn8GTcWw; 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 S932540AbeE3V2X (ORCPT + 30 others); Wed, 30 May 2018 17:28:23 -0400 Received: from pb-smtp1.pobox.com ([64.147.108.70]:61993 "EHLO pb-smtp1.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932254AbeE3V2V (ORCPT ); Wed, 30 May 2018 17:28:21 -0400 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 17FEDF2C64; Wed, 30 May 2018 17:28:20 -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=OmZ1 4W9Q5TZKUZeQmrd/ZWdG3C8=; b=xn8GTcWwtooPZ9EzlJwPkgN1BcRzemaxTl7r +vekZ7AHAGBcBHypWNpaOM0fMgpneugFSa2ElkgAkTCco/4JLLRHQwUpBlbg5KLL 2LKOYiVCihpYJMEFXPDpmEew/EX7go7F5LIyZtr0Hy51WmSopUM+dm6w3f1Xe3xr WjCQzVw= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 0EBA7F2C63; Wed, 30 May 2018 17:28:20 -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 8A676F2C62; Wed, 30 May 2018 17:28:19 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 464962DA06B8; Wed, 30 May 2018 17:28:18 -0400 (EDT) From: Nicolas Pitre To: Greg Kroah-Hartman Cc: Dave Mielke , Samuel Thibault , linux-kernel@vger.kernel.org Subject: [PATCH 5/5] vt: coherence validation code for the unicode screen buffer Date: Wed, 30 May 2018 17:27:45 -0400 Message-Id: <20180530212745.10997-6-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180530212745.10997-1-nicolas.pitre@linaro.org> References: <20180530212745.10997-1-nicolas.pitre@linaro.org> X-Pobox-Relay-ID: 5F6B0AE6-6450-11E8-8574-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 | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) -- 2.17.0 diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index e7c3cabeb1..2f3d528082 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -571,6 +571,45 @@ 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 (true) + return; + + if (!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) @@ -2719,6 +2758,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);