From patchwork Thu Jun 17 12:50:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Shijie X-Patchwork-Id: 12326527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.0 required=3.0 tests=BAYES_00, DATE_IN_FUTURE_06_12,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B84A9C2B9F4 for ; Thu, 17 Jun 2021 04:53:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6E920610A3 for ; Thu, 17 Jun 2021 04:53:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E920610A3 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=os.amperecomputing.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=dPq4U+D5Bf977ilrWg+VlsoyB6mjd3F2lqX3JLwMd/Y=; b=1FKtxEMp+S+Fmm N3+mvuTWEjfFGV77viBFiINZXjLiJl7swSxkKFWZEykq4+r0mSoLARWf3a5JbYosLnwN3+U7D6rzn EX5GU8EbGvXdblsY6AuaUblkxHNV0DKvnSWdIvrytbpgm8Cez/nrLhkJ+NOl0srGmBwaO5NdfU+kh al0QDJmc/rXHWU30W6KT504RMJKWXFf1Ft7gxnz715no3NBzHC7JMByzhaKp/+ShpSLnpp4qJh8zI b1rM/1XqCURj6B4aBSgCvFlI2Lc8PxKloQvyOvgUkdTI7FwOjPEhM0tOn4X0jnhZVWeKLSo0xmfGF ZuulBPFfvhdf4Y2Dp7Dw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltk0A-008nTA-KY; Thu, 17 Jun 2021 04:51:39 +0000 Received: from mail-mw2nam12on2127.outbound.protection.outlook.com ([40.107.244.127] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltk06-008nQZ-4P for linux-arm-kernel@lists.infradead.org; Thu, 17 Jun 2021 04:51:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dV3dvmmnvTrmSMMnTG5tTKPQejHzYYsoP7A8suUR/DSnLakKlh0GtweXVmnTiQcDlR+NkKtTYvTwlv2y05Aq79kQNe0fbKSlhgZnOh7frV0bE1H6g2VGuI1fIfY0OXehguNgzQ1qDo9NZpY5wwdLPGxCoU4O8UJMMQrIXyoO8laOeVt3TrxoIhOu5pQfAuxR3pHaSnC3YVh64+d9ok0t7oS+A+ckONclUl+fcpyRY/B2Y6cKp2yYJijHAT9nHO1/HjjrVnLWtlIJ0DpuNM2gCHvF87YlebfnFDSxylXjMvTWALMPSMiY+FykV9sV0m/+K0AC9q4TF5YjbP3PwyllZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=01tPiFkVWwTy4ToBI+/9F9a3egrEWligLQpH96Fucq8=; b=kXQOWlX5O7QxSq3Ki9pfJKWWWiluOZILOY/p0+91l5JH/ZCCJHOmDRfHWtSVIw0Nu+iadF8fFGJJWoSeG58t5t/dcbx2fkOokhYytFGqq/nXAQgGjARkM0mzX2sAjNBEGqNxFxLUSbkyErmVy9VeTlspho/bcgq+gjQDwHd29uFxKnPiMDxC+95byTWVx53jqi1AKhMfTQyIhe+gyjCwxjQi2/xi83jvKPRsJsTbBhTGcOM7yLavevzSI1Rul2Vj1swC8LYm+KhiT9C1Si8LQGGhUsH/6hvYDjj5OA64FNinP6NmzF00M1RT73VtoYdy4MJGcBoNiNAQmSmvNDIFyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=01tPiFkVWwTy4ToBI+/9F9a3egrEWligLQpH96Fucq8=; b=B3qc2Rq5T+RjVxcuLDhIFS7BCYiPvN9N7VbmGL4byjvhcUdbT5S2eAKsF+NYgljcqXzX6I3/g5L1rVcZkHyluh39Pk1tMtkzKmFduaequwTdbA01lOw2ugdGlVKzDjpKwmfbNGmPDfmSd+ET1i8ACPQx+9JAQtR15AzHSGPM6T0= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=os.amperecomputing.com; Received: from MWHPR0101MB3165.prod.exchangelabs.com (2603:10b6:301:2f::19) by MWHPR0101MB3181.prod.exchangelabs.com (2603:10b6:301:33::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.25; Thu, 17 Jun 2021 04:51:28 +0000 Received: from MWHPR0101MB3165.prod.exchangelabs.com ([fe80::842:9ada:565f:8b98]) by MWHPR0101MB3165.prod.exchangelabs.com ([fe80::842:9ada:565f:8b98%3]) with mapi id 15.20.4219.026; Thu, 17 Jun 2021 04:51:28 +0000 From: Huang Shijie To: catalin.marinas@arm.com Cc: will@kernel.org, tabba@google.com, ardb@kernel.org, mark.rutland@arm.com, pasha.tatashin@soleen.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, patches@amperecomputing.com, zwang@amperecomputing.com, Huang Shijie Subject: [PATCH] arm64: kexec: flush log to console in nmi_panic() Date: Thu, 17 Jun 2021 12:50:23 +0000 Message-Id: <20210617125023.7288-1-shijie@os.amperecomputing.com> X-Mailer: git-send-email 2.30.2 X-Originating-IP: [180.167.209.74] X-ClientProxiedBy: CY4PR18CA0058.namprd18.prod.outlook.com (2603:10b6:903:13f::20) To MWHPR0101MB3165.prod.exchangelabs.com (2603:10b6:301:2f::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from hsj.amperecomputing.com (180.167.209.74) by CY4PR18CA0058.namprd18.prod.outlook.com (2603:10b6:903:13f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Thu, 17 Jun 2021 04:51:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ba1fca7f-cf6d-498b-5ca1-08d9314b9101 X-MS-TrafficTypeDiagnostic: MWHPR0101MB3181: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ReJ64yIkhQeK4t62Tu7iTQZiUKwssT4Ai9UJiW/Bk3779MtDKnviXEVR0RATN4ghRK3DV/n8OgylzKD2aMLHOYW77kZdes2OoMGGbSk8DHBIfYBnPKCPGjc7C+3SLKB+ULumwtMsHqrxbTB+iet6QsUFraYevgGPOog1Q8LT6BsnWoaAG1scdEXkbbxi/HOnr+AM253tKbGFxhc6CZ3jH+oS8nmypfARifKbDNIaK6ZG5hU5Xd2FIRU/Vb6Agrd1Y9Y9olr4FB0sdaWxwxy59ki4myDgp4NaC9g8RIu4yCS/fVh1ndT15gK6zklDGLsRNr8WsrpjJLsyFPDW6q9gm95r0GfqvwKw3Tn8Y96X13/HReEdWOe2wv4oHj08lLC3GMSYS0a2O7toVfoUwMnkRHv2coVptXQJLmfWlODZEC/ymQeWjj7NxzfCIODCWleAQIa3wWnBwGkYNrE+HsnI5/wzPQ/UW8Ge0fRuLI4X7ep4eeXk08Mm2NdfqvA5c+/ZlYTpg5O6VHHleATplSVmksGMhhiYe2NXqt3XmtQ6hlGYi9/17pAxCec0ZNa7u4+sOllILm3ey6RNOX2AMfBUl4m5n5Itffj+M+GWHb5YiIa4o2kU4gz0YdH0q7Hj/50nGN7ZEW2z6iz/5JeS1D0eoP/2C14qdG8vaqs0x3HMJIs= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR0101MB3165.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(346002)(39850400004)(376002)(136003)(86362001)(2906002)(66946007)(8936002)(5660300002)(478600001)(8676002)(6486002)(38100700002)(52116002)(316002)(26005)(4326008)(66476007)(83380400001)(956004)(6916009)(1076003)(2616005)(6506007)(38350700002)(66556008)(6512007)(16526019)(107886003)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange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aGeoyVvCpoM3WWcYbctfAIKGzrFTyJhpI2zN8bo1n49mI1IlKnVi1LZlDIx65ae9o5ovszDI0GrInWXk6xM8F2nJ4LvbHLiMUrimnLf+NiHjW27OAwtygHKoXxY9cNAav8E3CreGPCsRewR3A7ehHUKAMCdgMgXCBR6JFR3oF4qqlTa8krr2p/vnuhrMbbR/CdH3G+S/V3sdD079UxNl2tMJGNuSGgBEyPAnV5tYoaiYxHg3al7MhutVX2/3k2uNJXZll7FkXrWOwV098u0Ux3bDQ6n1sUJ6cGk X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba1fca7f-cf6d-498b-5ca1-08d9314b9101 X-MS-Exchange-CrossTenant-AuthSource: MWHPR0101MB3165.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2021 04:51:28.3374 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mSL0nMG3idIXSIzsLjC+ifVkESWj7tkSVIIdzmB9PuvYM1o03RrxTH02d3GelNMU9MxvvutpusDRSbOm0WPZiF49eke0lX2nGhTk56A2h0pTecH91KXdNp1MzynezsPG X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0101MB3181 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210616_215134_213618_D2B47CF1 X-CRM114-Status: GOOD ( 11.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If kdump is configured, nmi_panic() may run to machine_kexec(). But in NMI context, the log is put in PER-CPU nmi_print_seq. So we can not see any log on the console since we entered the NMI context, such as the "Bye!" in previous line. This patch fixes this issue by two steps: 1) Uses printk_safe_flush_on_panic() to flush the log from nmi_print_seq to global printk ring buffer, 2) Then uses console_flush_on_panic() to flush to console. After this patch, we can see the "Bye!" log in the panic console. Signed-off-by: Huang Shijie --- arch/arm64/kernel/machine_kexec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index 213d56c14f60..0ab841dab9db 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -6,6 +6,7 @@ * Copyright (C) Huawei Futurewei Technologies. */ +#include #include #include #include @@ -189,6 +190,12 @@ void machine_kexec(struct kimage *kimage) pr_info("Bye!\n"); + if (in_nmi()) { + /* Flush the log to console if we are in NMI context */ + printk_safe_flush_on_panic(); + console_flush_on_panic(CONSOLE_FLUSH_PENDING); + } + local_daif_mask(); /*