Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2953177rdh; Wed, 27 Sep 2023 19:44:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/Cf6RIwZt8FDgIDqcUoeY2G3kRVdnVMnJjt19QPxVUEcMuaVVQWBKQL19TBwyVQIowQoi X-Received: by 2002:a05:620a:7f1:b0:76e:f320:9b52 with SMTP id k17-20020a05620a07f100b0076ef3209b52mr3217341qkk.73.1695869079025; Wed, 27 Sep 2023 19:44:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695869078; cv=none; d=google.com; s=arc-20160816; b=WnhFN/tpzPGhmUAm/lXvhIlEK0mqvRmqNhFxfM0lJFbWbOw/L8mfFX30R9l1qcBEXv nZqT3vjpL44aq0uGpsroXG3V0lkWXMpVorBdilZdB89BSPZvFpea76ZPwp91kjxi5S55 NuGnheKV/1pp4FdVas4VAwvcc/Oo2puQwu3+Dhqje4H6CBK6ZQ6ZN+FTW/QmICqWW+KH wgakNg1uR6TIMl44PzEtcAXbGZ+tF61F9glrPY7409+aTofcefOLFXAF9MNiNJn0fTHK oWJHIR5JILRygVvKPnpH0vY2Ra0mARxMDwISdK2fCEMCBEh2hMQmdmHwkzBwYto3Daia QpUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=+T1E37bhnNjME4eoEghp27qqrGmE+oxsmmZezStVoZI=; fh=Z4wO0y1SJTLZQicFVzWDKsryBHoPHH4P861eZgE7EiM=; b=MykAZLZ8OxUJqmpVJ0T9f1hNqOSR2rLCYv/ZB/qNFSwlQlsMzTRuArwsBYL8FbmCQ/ GosucSWalJsDTxfTowhZWISx1CCbkSbaiyKorxVdpLOCkq6Hkai+WQFQT4HKFK6WK7gv 0z3RfAMuAdEqrQbeHnDOLig1wvIo08QY2Gpb0luSRLN6Rqxu576F1t3nPcYFcBPLEoIp CsQgbxYoku8coIgpnRmsAUGZGKziqqm//z2g4mFrJIFIg84ymskKny2IMq+ouS/FfUEW FA0y57q0mfdxfE+vaSwAIBUl+d/4AR8vLijL53Q6xh5jHjyV0haSgyNkRcYn4RD8NYCq vTvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bu3-20020a056a00410300b0068fe12efae9si17177752pfb.15.2023.09.27.19.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 19:44:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3A8D4830F543; Wed, 27 Sep 2023 19:44:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229715AbjI1Cnv (ORCPT + 99 others); Wed, 27 Sep 2023 22:43:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjI1Cnt (ORCPT ); Wed, 27 Sep 2023 22:43:49 -0400 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5757794; Wed, 27 Sep 2023 19:43:47 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=xiangzao@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0Vt.rlBx_1695869003; Received: from localhost.localdomain(mailfrom:xiangzao@linux.alibaba.com fp:SMTPD_---0Vt.rlBx_1695869003) by smtp.aliyun-inc.com; Thu, 28 Sep 2023 10:43:45 +0800 From: Yuanhe Shu To: gregkh@linuxfoundation.org, jirislaby@kernel.org, keescook@chromium.org, tony.luck@intel.com, gpiccoli@igalia.com, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kselftest@vger.kernel.org, Yuanhe Shu Subject: [PATCH 0/5] pstore: add tty frontend and multi-backend Date: Thu, 28 Sep 2023 10:42:39 +0800 Message-Id: <20230928024244.257687-1-xiangzao@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 27 Sep 2023 19:44:18 -0700 (PDT) In public cloud scenario, if kdump service works abnormally, users cannot get vmcore. Without vmcore, user has no idea why the kernel crashed. Meanwhile, there is no additional information to find the reason why the kdump service is abnormal. One way is to obtain console messages through VNC. The drawback is that VNC is real-time, if user missed the timing to get the VNC output, the crash needs to be retriggered. Another way is to enable the console frontend of pstore and record the console messages to the pstore backend. On the one hand, the console logs only contain kernel printk logs and does not cover user-mode print logs. Although we can redirect user-mode logs to the pmsg frontend provided by pstore, user-mode information related to booting and kdump service vary from systemd, kdump.sh, and so on which makes redirection troublesome. So we added a tty frontend and save all logs of tty driver to the pstore backend. Another problem is that currently pstore only supports a single backend. For debugging kdump problems, we hope to save the console logs and tty logs to the ramoops backend of pstore, as it will not be lost after rebooting. If the user has enabled another backend, the ramoops backend will not be registered. To this end, we add the multi-backend function to support simultaneous registration of multiple backends. Based on the above changes, we can enable pstore in the crashdump kernel and save the console logs and tty logs to the ramoops backend of pstore. After rebooting, we can view the relevant logs by mounting the pstore file system. Furthermore, we also modified kexec-tools referring to crash-utils for reading memory, so that pstore ramoops information can be read without enabling pstore in first kernel. As we set the address and size of ramoops, as well as the sizes of console and tty, we can infer the physical address of console logs and tty logs in memory. Referring to the read method of crash-utils, the console logs and tty logs are read from the memory, user can get pstore debug information without affecting the first kernel at all. kexec-tools modification can be seen at https://github.com/shuyuanmen/kexec-tools/blob/main/Add-pstore-segment.patch Yuanhe Shu (5): pstore: add tty frontend pstore: add multi-backends support pstore: add subdirs for multi-backends pstore: remove the module parameter "backend" tools/pstore: update pstore selftests drivers/tty/n_tty.c | 1 + fs/pstore/Kconfig | 23 ++ fs/pstore/Makefile | 2 + fs/pstore/blk.c | 10 + fs/pstore/ftrace.c | 22 +- fs/pstore/inode.c | 86 ++++++- fs/pstore/internal.h | 16 +- fs/pstore/platform.c | 238 ++++++++++++-------- fs/pstore/pmsg.c | 23 +- fs/pstore/ram.c | 40 +++- fs/pstore/tty.c | 56 +++++ fs/pstore/zone.c | 42 +++- include/linux/pstore.h | 33 +++ include/linux/pstore_blk.h | 3 + include/linux/pstore_ram.h | 1 + include/linux/pstore_zone.h | 2 + include/linux/tty.h | 14 ++ tools/testing/selftests/pstore/common_tests | 4 - 18 files changed, 500 insertions(+), 116 deletions(-) create mode 100644 fs/pstore/tty.c -- 2.39.3