Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp213273ybg; Tue, 2 Jun 2020 21:54:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwp52aGwD/nYVd5/iCC/urdZMNZHUMOohQRWRzvmszkCYjjq77mE4gLREK6c9QGMgDm4sk1 X-Received: by 2002:a17:906:2c10:: with SMTP id e16mr16789532ejh.189.1591160074328; Tue, 02 Jun 2020 21:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591160074; cv=none; d=google.com; s=arc-20160816; b=YePk3RJhsQuDwbzPbgnGTNlmdDZDdgiL59niCiUhbcGmJI19PMOkgkbFXh1B6wmhuh SVxvTf9r57pVwRduNhaXOEggAB3YpU8ETdJTz22UCKIlyuc8A2IV0o6EkAJ/A6PbaXEe 2lJ1mmfeSNoZLOyXfslzxxd44QF8n27JvU0TeqaED4q2nHG5IKl36WzadWZd1jUrd2lV zKIva3GoC3ozCfzIHkeYbwu5Uj7rwn/b4eEi8sMDP5891ny/f75VeyTgfb3wOZLbeORV HW+VzwEdShdV8ofHQl06VZR2VLyO766dsO2tA4/VsRBZ6xOXrDbNqMVPgowMH/4tdvIl RuUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=9jneiIwhoTeX6/+oub23nloy5lCEM9fcOmaGR+FZzuQ=; b=x8u1dC44NUiM+wkGHqk6+VzjRqTvQsdkVNyGIZlRrG/hdFRmLwg5Yzq+0OYwauulXm /8EVm5dCwzneDXPbaiA31sIRpti59n7evRJi9Omj0QI5g/P9W2/GHowV8PL4NiTa4/FN kCNxcdGJbYCxcPzpdN6XPNzOzh0KXSyI1l3MDL1d6IMyDkmm/y0SFed00+X9Cgr7X2KU TRwk/uqQXjeko34QzIZpPSaxE9cSMx0wwm4n4JUBuqcqM6YwtgiHHlH+Uiq5eMccKOyk QeDSCF7vF6+i/SuWowASJOPT/7U4M25oNzsTrt3TNSZ6BRq3Du2Re572bbsllfe29799 ZDkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HDw5vz+X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id d19si522340ejy.459.2020.06.02.21.54.10; Tue, 02 Jun 2020 21:54:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HDw5vz+X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1725878AbgFCEt0 (ORCPT + 99 others); Wed, 3 Jun 2020 00:49:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725275AbgFCEtZ (ORCPT ); Wed, 3 Jun 2020 00:49:25 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27C25C05BD43 for ; Tue, 2 Jun 2020 21:49:25 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id e125so466014lfd.1 for ; Tue, 02 Jun 2020 21:49:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9jneiIwhoTeX6/+oub23nloy5lCEM9fcOmaGR+FZzuQ=; b=HDw5vz+XXOVCtGvAKqFpoiuh+xys7OQHwn8q7cgtFrTWNO4on7NiHA2zOuapDLNoz1 mDjMgphgtHbSP+nPF6r6uNuocnnul07gWzdPZKg8yeOA8I508mvPIQ38+zRSc5SMYV0k LCLxIsWN+n/GGOfSfY5u0ym046F9u1c1xzXxnkhmoYwjaBy/1gne1+eKYdxy0rdYn/z+ yKwRLF9QzeGTweMPvwYCYmuUGONixe9NYeKX0NVITwGONe0hYXYj3JWcqnvtiGoBJ2Zl vssvHbI8KPS+mkk++mT+d5ETK3QPsoo5iSuEFm6Fatte6kJ6KlrunflI9hESwsSrrtqF lKbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9jneiIwhoTeX6/+oub23nloy5lCEM9fcOmaGR+FZzuQ=; b=HbAj8EpDO8C7zsZG/x4MOvXpTK/KZ9UG3ApY5A7CbWHd2tR1VKmOcKc1GNEV4cyIlj T+qRQRgppLfGpI64NIYfLvH9J3XwMcHRGrDGQmXnZ/hzI4YStxbU1XEJ9tAWEaeuDQYU kGpAQGx3KZJRWJRHF01gE/NzBfJNhdRoAeJsMNvTIqlg9Yvl0r8c5Tv3WozIxL0xnk0O MoPCa4iYUbzTpcmtPCBqPCy/tO5msUWKONyG5i7/nJlghp4c3bU6wNTUqR+gV8zyHDrS IWyBhyMKmWnbh2mdCqI8oGaupM64gTmfcmKnH6gRBW1/EolSjjJ882IbEk2QYOz6cirI g2ew== X-Gm-Message-State: AOAM532sONMJg3VmygnUr5V4oVLl0rRNBmI8iBiqiChO6cZrxmXniYzV R+k78WimD4PRGYGSbgE1Vs2Yo0fL7625dI2LsgQCUw== X-Received: by 2002:ac2:44c1:: with SMTP id d1mr1384141lfm.37.1591159763530; Tue, 02 Jun 2020 21:49:23 -0700 (PDT) MIME-Version: 1.0 References: <1590751607-29676-1-git-send-email-sumit.garg@linaro.org> <1590751607-29676-5-git-send-email-sumit.garg@linaro.org> In-Reply-To: From: Sumit Garg Date: Wed, 3 Jun 2020 10:19:11 +0530 Message-ID: Subject: Re: [PATCH v4 4/4] kdb: Switch to use safer dbg_io_ops over console APIs To: Doug Anderson Cc: Daniel Thompson , kgdb-bugreport@lists.sourceforge.net, Jason Wessel , Petr Mladek , Sergey Senozhatsky , Greg Kroah-Hartman , Jiri Slaby , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 3 Jun 2020 at 03:02, Doug Anderson wrote: > > Hi, > > On Fri, May 29, 2020 at 4:27 AM Sumit Garg wrote: > > > > In kgdb context, calling console handlers aren't safe due to locks used > > in those handlers which could in turn lead to a deadlock. Although, using > > oops_in_progress increases the chance to bypass locks in most console > > handlers but it might not be sufficient enough in case a console uses > > more locks (VT/TTY is good example). > > > > Currently when a driver provides both polling I/O and a console then kdb > > will output using the console. We can increase robustness by using the > > currently active polling I/O driver (which should be lockless) instead > > of the corresponding console. For several common cases (e.g. an > > embedded system with a single serial port that is used both for console > > output and debugger I/O) this will result in no console handler being > > used. > > > > In order to achieve this we need to reverse the order of preference to > > use dbg_io_ops (uses polling I/O mode) over console APIs. So we just > > store "struct console" that represents debugger I/O in dbg_io_ops and > > while emitting kdb messages, skip console that matches dbg_io_ops > > console in order to avoid duplicate messages. After this change, > > "is_console" param becomes redundant and hence removed. > > > > Suggested-by: Daniel Thompson > > Signed-off-by: Sumit Garg > > --- > > drivers/tty/serial/kgdb_nmi.c | 2 +- > > drivers/tty/serial/kgdboc.c | 4 ++-- > > I don't think this will compile against the "kgdboc_earlycon" patches > that landed, will it? Specifically when I apply your patch I still > see "is_console" in: Agree will fix this and rebase this patch-set onto Daniel's tree. > > static struct kgdb_io kgdboc_earlycon_io_ops = { > .name = "kgdboc_earlycon", > .read_char = kgdboc_earlycon_get_char, > .write_char = kgdboc_earlycon_put_char, > .pre_exception = kgdboc_earlycon_pre_exp_handler, > .deinit = kgdboc_earlycon_deinit, > .is_console = true, > }; > > > > diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h > > index b072aeb..bc0face3 100644 > > --- a/include/linux/kgdb.h > > +++ b/include/linux/kgdb.h > > @@ -273,8 +273,7 @@ struct kgdb_arch { > > * the I/O driver. > > * @post_exception: Pointer to a function that will do any cleanup work > > * for the I/O driver. > > - * @is_console: 1 if the end device is a console 0 if the I/O device is > > - * not a console > > + * @cons: valid if the I/O device is a console. > > optional nit: add "; else NULL" > Okay. > > Other than that this looks great. Feel free to add my Reviewed-by: > tag once you've fixed the error that the bot found and resolved with > kgdb_earlycon. > Thanks. -Sumit > > -Doug