From patchwork Tue Oct 8 13:20:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 175497 Delivered-To: patches@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5695321ill; Tue, 8 Oct 2019 06:21:04 -0700 (PDT) X-Received: by 2002:a17:906:1f43:: with SMTP id d3mr20277637ejk.321.1570540864362; Tue, 08 Oct 2019 06:21:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570540864; cv=none; d=google.com; s=arc-20160816; b=QpcggA1xwjvq15RtVN6eWIXocF52si5yhzZuW7wrt5SqmkBkAz8zZn8CUiUtGDPjvd q9PrYveDtgOcKJhhc2T2B0yKXew9cOHYNbEl7Y6ydzvLKSEF5NBNqWKyiVOhMtN03abs HtZLYVR5M6QTf8RzXhRkRdYO6ezN+JYEsbZKh4LPxDAqavHgdtLqPXuL6yrKNs99vfcP +6g3x2TChro4+Dib8pYKv/GYhH8CQQqv+43AxNmC3GaFW3gCho9zaW+FGDHBse+dftH8 F0tx5avL82p4aqmrvi4h6PmVOSnrANdF1P0EWduDtAN2p3bQWnFN/1/uwGR8s0hRnL+T c2dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=zRFXe3/XZQCUi1W0+GR//OOmf/+747T61SkEsMl88/k=; b=WYz58KEjlONY60VVkg0Gq7Vno7GmIONr+tuEPVwM0x/H7Xb+UjQpEQUGGvBAcgQJZp mwDJu6BGlAwXH2jiP/claiwqr0LttihweYHgUZXaewirBcmKaHVFIQFUNAfodV+HazPU bPbkEOgbOTWkrDem3gCItsNsJqg42ICu1+Z2nbV/D6tcoui/+oqIffBNDHSfUwk9K4Yx naJle7Hxvah+it3hEwHfKW3ZdT9VfvBvjE9kj17cLfb2fUIGJbeB2++/xf+nmxhrE8AI Nab2PKl1yV28MDGJnqXmHnh49eHYMlv4teotegeLJg9w+lQGFYq7lyAYrI4zaDNOv6Nv e5hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tZfC1OM8; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a26sor5842327ejg.14.2019.10.08.06.21.04 for (Google Transport Security); Tue, 08 Oct 2019 06:21:04 -0700 (PDT) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tZfC1OM8; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zRFXe3/XZQCUi1W0+GR//OOmf/+747T61SkEsMl88/k=; b=tZfC1OM8yntNwmeY8DAkjskgZ4slX04meu2wTKakCs13kvAbXSBqEwTrQ9aC2yuPML OHcDHrf/kxg7FZQc/bw5zY+4gw2NEUUh+Kan7Efd79O7lwR4tYdG5Ez1HZlIt6tnd5g6 RQnyvNGFQZCIWBeImePzvn0xNbkGynWCXxsrKdMTufPSnkx0Nw6NgQD/t19klEMPlGia +hbI4WRCv7GGXO50twrjV6esz8V7EnR3akgbWjXhCwYSEvIvCzJ1AxoPB2Mg/6V1KdUE 19it6wJ7xMQ7755HDqWvENvwa/+R+1Kxtl2IQxVfBH7Tp1Eb6cujDx22F/QNnXvrxBnd zaSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zRFXe3/XZQCUi1W0+GR//OOmf/+747T61SkEsMl88/k=; b=ID5k2h64MA/vWlovf6k+QC8cCDqBlgxewPt+3pVYwS3OhLT2bi5zKlW38QVsOLIfnW 7hnVLCC/XeUli9HMfWRKHLYfP1SfmrDuVE+5K1pBDffglespn7wnRoa14tg+MSNKWwaP 1/Weg9AtUbruGEkohql/c0rGOtHGe2byaJuUJI0hh4fkWZKE+Tsklsj5Zrf85YWh/Koz ISC+U1QH6wMv6yLQzTTQskZMqVtG5162jKVNKg2jj1EdgGQiAWAq10YAwNvgwMskHVHC GMeyV7O9BMT131w8ORfUNpxplg4fnwLuwOwcIlfvA6VBpsa9cry44zk49jk7H0wXOqrv ligw== X-Gm-Message-State: APjAAAWgVFNPkbkrj6bMI/kvge6ccF4++4Do8d3mqCnoKOCNYDqW+riR pnx9gEH14+ZlUEID2gAQwsbQC/S1 X-Google-Smtp-Source: APXvYqwgrNAtVXxMcAt3CGH50mxfEVwuB6vCmi+Ycmt+f/kJStXemqbH+BSDPfEc5kcFu46toPhOYw== X-Received: by 2002:adf:9d87:: with SMTP id p7mr25812577wre.245.1570540863921; Tue, 08 Oct 2019 06:21:03 -0700 (PDT) Return-Path: Received: from wychelm.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id t8sm18237214wrx.76.2019.10.08.06.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2019 06:21:03 -0700 (PDT) From: Daniel Thompson To: Jason Wessel , Douglas Anderson Cc: Daniel Thompson , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH v2 4/5] kdb: Improve handling of characters from different input sources Date: Tue, 8 Oct 2019 14:20:42 +0100 Message-Id: <20191008132043.7966-5-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191008132043.7966-1-daniel.thompson@linaro.org> References: <20191008132043.7966-1-daniel.thompson@linaro.org> MIME-Version: 1.0 Currently if an escape timer is interrupted by a character from a different input source then the new character is discarded and the function returns '\e' (which will be discarded by the level above). It is hard to see why this would ever be the desired behaviour. Fix this to return the new character rather then the '\e'. This is a bigger refactor that might be expected because the new character needs to go through escape sequence detection. Signed-off-by: Daniel Thompson --- kernel/debug/kdb/kdb_io.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) -- 2.21.0 diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index a9e73bc9d1c3..288dd1babf90 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -122,8 +122,8 @@ static int kdb_getchar(void) { #define ESCAPE_UDELAY 1000 #define ESCAPE_DELAY (2*1000000/ESCAPE_UDELAY) /* 2 seconds worth of udelays */ - char escape_data[5]; /* longest vt100 escape sequence is 4 bytes */ - char *ped = escape_data; + char buf[4]; /* longest vt100 escape sequence is 4 bytes */ + char *pbuf = buf; int escape_delay = 0; get_char_func *f, *f_escape = NULL; int key; @@ -145,27 +145,26 @@ static int kdb_getchar(void) continue; } - if (escape_delay == 0 && key == '\e') { - escape_delay = ESCAPE_DELAY; - ped = escape_data; + /* + * When the first character is received (or we get a change + * input source) we set ourselves up to handle an escape + * sequences (just in case). + */ + if (f_escape != f) { f_escape = f; - } - if (escape_delay) { - if (f_escape != f) - return '\e'; - - *ped++ = key; - key = kdb_read_handle_escape(escape_data, - ped - escape_data); - if (key < 0) - return '\e'; - if (key == 0) - continue; + pbuf = buf; + escape_delay = ESCAPE_DELAY; } - break; /* A key to process */ + *pbuf++ = key; + key = kdb_read_handle_escape(buf, pbuf - buf); + if (key < 0) /* no escape sequence; return first character */ + return buf[0]; + if (key > 0) + return key; } - return key; + + unreachable(); } /*