From patchwork Fri Aug 11 17:06:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 134608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1250987vqi; Fri, 11 Aug 2023 10:33:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHC1zDJL49sYCGCVXx246cw22FU520VkKKEjqwuba1ySf7cqkDhbYjO/25RQlcw1GRMDztW X-Received: by 2002:a2e:7412:0:b0:2b9:4418:b46e with SMTP id p18-20020a2e7412000000b002b94418b46emr2037396ljc.21.1691775235467; Fri, 11 Aug 2023 10:33:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691775235; cv=pass; d=google.com; s=arc-20160816; b=0ZRGg6dChiXd7HOjrdIKya+Kc2Nv3JpokQWzxvbRX5SGwE2QLB35DJWfxkNV7RVl/A CXxh2oArKZmlbptCXk43jnTW3zNDwlq3P1ErrYT4aqTjdRUUkGsviUGl+JqE0AMGU52w REyjFeldDY012y1ffaV4eNvMr848Gc3djROMFPkf9I+uFsDRBYvzHcNIzl921fMm5Onr MCKsSgu5+CejpESrFvE4mcPcbH+8Ech69tJNIys+uh8F1Qfw3GLz/DyFM3GipNlCRNvw BFu024V9erjgh2adQN3XoGE+wfID+mDB4F2tNIM2F9VBK9B+UnniqVyttBbK+D2dENl4 iLGA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=5eYj+23ZC7VzOGJgW8YD6nEDB2+diEwDOwLRzF4YxgI=; fh=ZbNC38sm56YRcxo0eY5DlCjDElPeJYCNHKxhiyVbz2E=; b=zP0rmdRPe0dKsqdfXHaM0EHkBmJI/RpypywJVkPFnZDk9q8ue4azsk7YxjjO/+GB8J 6eU28yUogOoKgz3GH6tDNLtTygI88NIqQIl3DcCWFaNdlxBUt6SJ3gdW4IgVW4zXN4T/ WKEnnq770mXpyiBUg3OlFa0U9BtXHMvl5Fhf+J7PQYNc0GBYRZE779DjclbEXs5ywSmA 4GmmnZm3rg8X3qg15LhXegEwUeGLkGIJQVYGTXM6zZNk6UkURuTbbcItZb8DNacTCK8y oy8oC8nYebzh2xIkjeTMvmLNWBZj93ymkPZ2I2CW3fddAY6mWmRDuV/cobaY8iLnAFNU ZVxw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=yyk2+auc; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=OdauHP5N; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a170906060b00b0099bd1a98ad5si3657450ejb.734.2023.08.11.10.33.31; Fri, 11 Aug 2023 10:33:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=yyk2+auc; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=OdauHP5N; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236663AbjHKRIX (ORCPT + 99 others); Fri, 11 Aug 2023 13:08:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236496AbjHKRII (ORCPT ); Fri, 11 Aug 2023 13:08:08 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EE8B2123; Fri, 11 Aug 2023 10:08:06 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37BDkcuP014733; Fri, 11 Aug 2023 17:06:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=5eYj+23ZC7VzOGJgW8YD6nEDB2+diEwDOwLRzF4YxgI=; b=yyk2+aucwuKopz696v6m5YmgtC4VdhXBMGvahRm4m1IGptRzuO6sAYczSACglkGU7ZDN PwnpYmShtwMW/o4iQmI1fNNLyTZEm3C1B8Tx2Hi04MCIzUB73O7Qcd4PMu4xYvjDABEd KpF4rq0HQFzajfIxpHpWROQEWQ+17OxzGgut94p21dlwcAIKsrPpbJkKTP+6ixpmWad9 whcun7NPv+JbAQvJSP2olnXcb2JX6N1f+Eoc30vFHbfQd7OOhBWCaNX8xDAf+AEzA18x 2lit+eBAgLj7+aJVOXMw79o3FkbwEPYrD7iW5fhvtfvgvyzOPMOR1wi5oEwEyr7JR6W9 yg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sd8y3sg06-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:06:59 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 37BGOWMp012090; Fri, 11 Aug 2023 17:06:58 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2174.outbound.protection.outlook.com [104.47.59.174]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s9cva2g8k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:06:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k7ehmK/YwBRgFgbdOdb606ccT8yCogJRiYvSuFBJli2oYvHuhA+8X/5X7BS9jJeBNaBBsFtc7emFO8F+gYwV2xXR4UB9laKp8eIgxcCUJGcj9Lraw5VdhO14rkrlc8RmgAGro/P/xR2gA1IC0rEvPDGh8lVeNHTArKIisfLbX2Riq1uEmJ8CYDRaOhJyxD8eyCoibf/+ATPTIDjsl+gZQVw25H31v3ggT3Oe+mY9TEiLnoKRZqo92mqNBOP7kzmY8jgYR+WMnblM1sbE0Htm9/Ybhsbxat1g2XtyvUDlySe26wwi+JmIAC4GAhmnJdFQYRkHSwA7EtnsG7gznNFqJQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5eYj+23ZC7VzOGJgW8YD6nEDB2+diEwDOwLRzF4YxgI=; b=TW3HNCdeCOsBl/PSZIOYeemslmzuvrAEGKoI42Vd+cY+DDU9pBawyG+CC0izdu4RDVXKBKacqJwU82KPzlG58YLjcxRiuFKoavjEhvfCeM5S/0uI3DUGaO3t2ya8xDrvGs6TNcmMPnti1OunSSaf5F3ENYijZ+j38LE3RjEETsyv6B/6rXzy5madTZJxrdzZze9irwoPaRUnJC+1BjeEm0A2EGYEIolYh8viqPzE5arvxnMYYe5BOlS/mE7XHJ3Dw05OyK0RnbJttME/cyGsZf7TGqrdFOfB/vDNF18f+N8yvrISZtlKH6/Drx51T9jHmy8ZrndomA+n8b66S/pYGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5eYj+23ZC7VzOGJgW8YD6nEDB2+diEwDOwLRzF4YxgI=; b=OdauHP5NFtSYWkEf59/Q7aZr1RZzPz/uS9Pc0W1clrIeOtIuOQMjhS/tF3wYq1xpKI2XifCwiefqwyiPdFYhMzSq/JN1cT5Q1ohEeL6EwkxeeV6kWMu2bDkQtxJFi68TIYfRkSKJrS31hxxTvyMNJFqX44VPlMpuYPCpWP8r4hM= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ1PR10MB5978.namprd10.prod.outlook.com (2603:10b6:a03:45f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Fri, 11 Aug 2023 17:06:55 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57%4]) with mapi id 15.20.6678.020; Fri, 11 Aug 2023 17:06:55 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v27 1/8] crash: move a few code bits to setup support of crash hotplug Date: Fri, 11 Aug 2023 13:06:35 -0400 Message-Id: <20230811170642.6696-2-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230811170642.6696-1-eric.devolder@oracle.com> References: <20230811170642.6696-1-eric.devolder@oracle.com> X-ClientProxiedBy: SA0PR11CA0083.namprd11.prod.outlook.com (2603:10b6:806:d2::28) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|SJ1PR10MB5978:EE_ X-MS-Office365-Filtering-Correlation-Id: ba573b1c-8d8d-411c-9e2c-08db9a8d5d29 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pcn+SG+6lqi22ZZcTpiffuhPCMDdS6iya8nrUzpfa3nuF5CbTVmWiSFYgwiXPQTvyu0W9IsO2+bboGlL7JNjgzMkOdk1lUiH0cLExJ3u/VV5diYSSm0QAsQzJGDC8yYuLbbcUiLeMKX/voObc952M22+vRpfWlttjyKSDVZ8YaA2pszyrQNkBxpN8+x9KO5EqeudfEACHTMVs6GBddpPzmZC4WmXvpSE5dV5MMmGkCEg7CfuRO5yyg+7sJh7AoAq91/Rm8EmRpDtKR/HHjVqXDMVHo1zw8nIB55oY1gCVsZuQjiVWu4n6Xpnsxavnu0AVFOf4eTbYkO1YrGZdGSuf3TU3xJuBuAYMtVoH+cUAO7V0bkRXM4rzWJybDFYF8eYH5+etT/Jm2SQRNP1XDkDSCmFlhk8Jc5Bng0JWf/SxmNp0Jg484w29FPJ8xAXQb3xMOIOc6ujLJeT/7x1fxFi6X48VYBB8MeInm5wAfp8+zyOOv3Vkr0ZpgFFd6kqIKCx6YuzxMHEzv9VZSr/g/K5RwgCONoJAh2JXJxArXQCvRAz/yWJbqLXpbdewgWBnvVYeKAQ0Glgne1LfkXUcJecYrbDmcoSGIEufd/hEkU2/EQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(39860400002)(136003)(346002)(366004)(451199021)(1800799006)(186006)(6666004)(6486002)(6512007)(478600001)(2616005)(6506007)(26005)(7416002)(107886003)(2906002)(1076003)(30864003)(7406005)(66476007)(4326008)(66946007)(66556008)(316002)(8936002)(8676002)(5660300002)(41300700001)(38100700002)(86362001)(36756003)(83380400001)(921005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kfdISzT76d17SMThZJAHETmqioxtP+OlQwaaNPxbsAeDofSt6AsNG7A2lkNr2LmE+c+tcgGZy/ZUVufiqDCjEtRSsxDunMFQe5I53XDo7ezYHU0o4ckZCW3mgycO5AhFvvSSwmUyQpwrSem5ARjoM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S/aJcJ2mMtiLJrhZv9xqC6X7d1wPVcHJ6X0ZyMk1Zf/nVoe+oMif45EQAOwnpxXAmFLCBJqCL2S/AcxsWqN6we0hZyVBO3ykiGaV7GdM2ncCc4Hgewvn7MgDuOa9OyDYTYuY29DYfHEYqTqwYKma3MsLZropei0AR0uPRlcAX5dRkMnamXYSyW6gvqH+943kI1QAtMso52xFH1toWfRHBW3bzO4A/uehpnedkv16H3rI2vPK0KTmLQ5PXRVLDX2iFPiX2fjegx3naGqAWH1tzFr6+BhkqwTah6KREA45Sfckn1yqp2neo2NTNvacZ28bKWZxYq0HixkqFHeMH/d3iYJHai1JgPItR+FYI0jAwOtj7BYJx0KqwOGkN8TIyTPfI5Ib/YxE8MiggSpSmc2h9e+W5D/JxNamRwiEJZRkGxMnqENI2/MET8ESgmh9YI7EIpcm0zU5WtcQ2momz3cfMMGAXkEIwf4hMwJsddXRR/7OyPG7yyVYibjRjli+5Hcu/WvCyFZGmc7aqMTBz6KpatHhqqZC1EFTeROQuZ054Jol6dAqXMlxbIHUqjvoMN1+BbIMZq7RRtsRDwdAEGrrsrNJid06uUCfeddoNcJYtcJeualCqRMqN5Ok2GowI1zZOSDOzOTJyXCDJK75BHfI58lGjCBzYIk2j6wAjz9q+4nXysB5rp4Z7tqO1/V/MDHPCBA0wR+pgEKwZuuv/noYTLogk7bIxWUntp1OAdxzM8NHqbAhm660JvwulYCbTy3gVCrqZt8fVcIIxWvg9cORF4pSzZBJnePn79bnQjGoGpN7LW8v8Q07mJuPmMQjdQRYvs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba573b1c-8d8d-411c-9e2c-08db9a8d5d29 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2023 17:06:55.0070 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hEm5gAo0V5bX5k3a14wh/y8sFDs40P+jqWUZkpiyQtYf5aYj9vKnAysBpR0ZqjIKHE0olzBvbLsjPRXqSLgnxkudPXLuGhta6C6GWGvNCeg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR10MB5978 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-11_09,2023-08-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308110156 X-Proofpoint-GUID: ZzNvknZzyRRdzwWDUjnrKGr-a4v97umG X-Proofpoint-ORIG-GUID: ZzNvknZzyRRdzwWDUjnrKGr-a4v97umG X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773954909307531744 X-GMAIL-MSGID: 1773954909307531744 The crash hotplug support leans on the work for the kexec_file_load() syscall. To also support the kexec_load() syscall, a few bits of code need to be move outside of CONFIG_KEXEC_FILE. As such, these bits are moved out of kexec_file.c and into a common location crash_core.c. No functionality change intended. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- include/linux/kexec.h | 30 +++---- kernel/crash_core.c | 182 ++++++++++++++++++++++++++++++++++++++++++ kernel/kexec_file.c | 181 ----------------------------------------- 3 files changed, 197 insertions(+), 196 deletions(-) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 22b5cd24f581..811a90e09698 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -105,6 +105,21 @@ struct compat_kexec_segment { }; #endif +/* Alignment required for elf header segment */ +#define ELF_CORE_HEADER_ALIGN 4096 + +struct crash_mem { + unsigned int max_nr_ranges; + unsigned int nr_ranges; + struct range ranges[]; +}; + +extern int crash_exclude_mem_range(struct crash_mem *mem, + unsigned long long mstart, + unsigned long long mend); +extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, + void **addr, unsigned long *sz); + #ifdef CONFIG_KEXEC_FILE struct purgatory_info { /* @@ -230,21 +245,6 @@ static inline int arch_kexec_locate_mem_hole(struct kexec_buf *kbuf) } #endif -/* Alignment required for elf header segment */ -#define ELF_CORE_HEADER_ALIGN 4096 - -struct crash_mem { - unsigned int max_nr_ranges; - unsigned int nr_ranges; - struct range ranges[]; -}; - -extern int crash_exclude_mem_range(struct crash_mem *mem, - unsigned long long mstart, - unsigned long long mend); -extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, - void **addr, unsigned long *sz); - #ifndef arch_kexec_apply_relocations_add /* * arch_kexec_apply_relocations_add - apply relocations of type RELA diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 90ce1dfd591c..b7c30b748a16 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -314,6 +315,187 @@ static int __init parse_crashkernel_dummy(char *arg) } early_param("crashkernel", parse_crashkernel_dummy); +int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, + void **addr, unsigned long *sz) +{ + Elf64_Ehdr *ehdr; + Elf64_Phdr *phdr; + unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz; + unsigned char *buf; + unsigned int cpu, i; + unsigned long long notes_addr; + unsigned long mstart, mend; + + /* extra phdr for vmcoreinfo ELF note */ + nr_phdr = nr_cpus + 1; + nr_phdr += mem->nr_ranges; + + /* + * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping + * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64). + * I think this is required by tools like gdb. So same physical + * memory will be mapped in two ELF headers. One will contain kernel + * text virtual addresses and other will have __va(physical) addresses. + */ + + nr_phdr++; + elf_sz = sizeof(Elf64_Ehdr) + nr_phdr * sizeof(Elf64_Phdr); + elf_sz = ALIGN(elf_sz, ELF_CORE_HEADER_ALIGN); + + buf = vzalloc(elf_sz); + if (!buf) + return -ENOMEM; + + ehdr = (Elf64_Ehdr *)buf; + phdr = (Elf64_Phdr *)(ehdr + 1); + memcpy(ehdr->e_ident, ELFMAG, SELFMAG); + ehdr->e_ident[EI_CLASS] = ELFCLASS64; + ehdr->e_ident[EI_DATA] = ELFDATA2LSB; + ehdr->e_ident[EI_VERSION] = EV_CURRENT; + ehdr->e_ident[EI_OSABI] = ELF_OSABI; + memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD); + ehdr->e_type = ET_CORE; + ehdr->e_machine = ELF_ARCH; + ehdr->e_version = EV_CURRENT; + ehdr->e_phoff = sizeof(Elf64_Ehdr); + ehdr->e_ehsize = sizeof(Elf64_Ehdr); + ehdr->e_phentsize = sizeof(Elf64_Phdr); + + /* Prepare one phdr of type PT_NOTE for each present CPU */ + for_each_present_cpu(cpu) { + phdr->p_type = PT_NOTE; + notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); + phdr->p_offset = phdr->p_paddr = notes_addr; + phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); + (ehdr->e_phnum)++; + phdr++; + } + + /* Prepare one PT_NOTE header for vmcoreinfo */ + phdr->p_type = PT_NOTE; + phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note(); + phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; + (ehdr->e_phnum)++; + phdr++; + + /* Prepare PT_LOAD type program header for kernel text region */ + if (need_kernel_map) { + phdr->p_type = PT_LOAD; + phdr->p_flags = PF_R|PF_W|PF_X; + phdr->p_vaddr = (unsigned long) _text; + phdr->p_filesz = phdr->p_memsz = _end - _text; + phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); + ehdr->e_phnum++; + phdr++; + } + + /* Go through all the ranges in mem->ranges[] and prepare phdr */ + for (i = 0; i < mem->nr_ranges; i++) { + mstart = mem->ranges[i].start; + mend = mem->ranges[i].end; + + phdr->p_type = PT_LOAD; + phdr->p_flags = PF_R|PF_W|PF_X; + phdr->p_offset = mstart; + + phdr->p_paddr = mstart; + phdr->p_vaddr = (unsigned long) __va(mstart); + phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; + phdr->p_align = 0; + ehdr->e_phnum++; + pr_debug("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n", + phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, + ehdr->e_phnum, phdr->p_offset); + phdr++; + } + + *addr = buf; + *sz = elf_sz; + return 0; +} + +int crash_exclude_mem_range(struct crash_mem *mem, + unsigned long long mstart, unsigned long long mend) +{ + int i, j; + unsigned long long start, end, p_start, p_end; + struct range temp_range = {0, 0}; + + for (i = 0; i < mem->nr_ranges; i++) { + start = mem->ranges[i].start; + end = mem->ranges[i].end; + p_start = mstart; + p_end = mend; + + if (mstart > end || mend < start) + continue; + + /* Truncate any area outside of range */ + if (mstart < start) + p_start = start; + if (mend > end) + p_end = end; + + /* Found completely overlapping range */ + if (p_start == start && p_end == end) { + mem->ranges[i].start = 0; + mem->ranges[i].end = 0; + if (i < mem->nr_ranges - 1) { + /* Shift rest of the ranges to left */ + for (j = i; j < mem->nr_ranges - 1; j++) { + mem->ranges[j].start = + mem->ranges[j+1].start; + mem->ranges[j].end = + mem->ranges[j+1].end; + } + + /* + * Continue to check if there are another overlapping ranges + * from the current position because of shifting the above + * mem ranges. + */ + i--; + mem->nr_ranges--; + continue; + } + mem->nr_ranges--; + return 0; + } + + if (p_start > start && p_end < end) { + /* Split original range */ + mem->ranges[i].end = p_start - 1; + temp_range.start = p_end + 1; + temp_range.end = end; + } else if (p_start != start) + mem->ranges[i].end = p_start - 1; + else + mem->ranges[i].start = p_end + 1; + break; + } + + /* If a split happened, add the split to array */ + if (!temp_range.end) + return 0; + + /* Split happened */ + if (i == mem->max_nr_ranges - 1) + return -ENOMEM; + + /* Location where new range should go */ + j = i + 1; + if (j < mem->nr_ranges) { + /* Move over all ranges one slot towards the end */ + for (i = mem->nr_ranges - 1; i >= j; i--) + mem->ranges[i + 1] = mem->ranges[i]; + } + + mem->ranges[j].start = temp_range.start; + mem->ranges[j].end = temp_range.end; + mem->nr_ranges++; + return 0; +} + Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type, void *data, size_t data_len) { diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index dd115571f8fc..453b7a513540 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -1151,184 +1151,3 @@ int kexec_purgatory_get_set_symbol(struct kimage *image, const char *name, return 0; } #endif /* CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY */ - -int crash_exclude_mem_range(struct crash_mem *mem, - unsigned long long mstart, unsigned long long mend) -{ - int i, j; - unsigned long long start, end, p_start, p_end; - struct range temp_range = {0, 0}; - - for (i = 0; i < mem->nr_ranges; i++) { - start = mem->ranges[i].start; - end = mem->ranges[i].end; - p_start = mstart; - p_end = mend; - - if (mstart > end || mend < start) - continue; - - /* Truncate any area outside of range */ - if (mstart < start) - p_start = start; - if (mend > end) - p_end = end; - - /* Found completely overlapping range */ - if (p_start == start && p_end == end) { - mem->ranges[i].start = 0; - mem->ranges[i].end = 0; - if (i < mem->nr_ranges - 1) { - /* Shift rest of the ranges to left */ - for (j = i; j < mem->nr_ranges - 1; j++) { - mem->ranges[j].start = - mem->ranges[j+1].start; - mem->ranges[j].end = - mem->ranges[j+1].end; - } - - /* - * Continue to check if there are another overlapping ranges - * from the current position because of shifting the above - * mem ranges. - */ - i--; - mem->nr_ranges--; - continue; - } - mem->nr_ranges--; - return 0; - } - - if (p_start > start && p_end < end) { - /* Split original range */ - mem->ranges[i].end = p_start - 1; - temp_range.start = p_end + 1; - temp_range.end = end; - } else if (p_start != start) - mem->ranges[i].end = p_start - 1; - else - mem->ranges[i].start = p_end + 1; - break; - } - - /* If a split happened, add the split to array */ - if (!temp_range.end) - return 0; - - /* Split happened */ - if (i == mem->max_nr_ranges - 1) - return -ENOMEM; - - /* Location where new range should go */ - j = i + 1; - if (j < mem->nr_ranges) { - /* Move over all ranges one slot towards the end */ - for (i = mem->nr_ranges - 1; i >= j; i--) - mem->ranges[i + 1] = mem->ranges[i]; - } - - mem->ranges[j].start = temp_range.start; - mem->ranges[j].end = temp_range.end; - mem->nr_ranges++; - return 0; -} - -int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, - void **addr, unsigned long *sz) -{ - Elf64_Ehdr *ehdr; - Elf64_Phdr *phdr; - unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz; - unsigned char *buf; - unsigned int cpu, i; - unsigned long long notes_addr; - unsigned long mstart, mend; - - /* extra phdr for vmcoreinfo ELF note */ - nr_phdr = nr_cpus + 1; - nr_phdr += mem->nr_ranges; - - /* - * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping - * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64). - * I think this is required by tools like gdb. So same physical - * memory will be mapped in two ELF headers. One will contain kernel - * text virtual addresses and other will have __va(physical) addresses. - */ - - nr_phdr++; - elf_sz = sizeof(Elf64_Ehdr) + nr_phdr * sizeof(Elf64_Phdr); - elf_sz = ALIGN(elf_sz, ELF_CORE_HEADER_ALIGN); - - buf = vzalloc(elf_sz); - if (!buf) - return -ENOMEM; - - ehdr = (Elf64_Ehdr *)buf; - phdr = (Elf64_Phdr *)(ehdr + 1); - memcpy(ehdr->e_ident, ELFMAG, SELFMAG); - ehdr->e_ident[EI_CLASS] = ELFCLASS64; - ehdr->e_ident[EI_DATA] = ELFDATA2LSB; - ehdr->e_ident[EI_VERSION] = EV_CURRENT; - ehdr->e_ident[EI_OSABI] = ELF_OSABI; - memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD); - ehdr->e_type = ET_CORE; - ehdr->e_machine = ELF_ARCH; - ehdr->e_version = EV_CURRENT; - ehdr->e_phoff = sizeof(Elf64_Ehdr); - ehdr->e_ehsize = sizeof(Elf64_Ehdr); - ehdr->e_phentsize = sizeof(Elf64_Phdr); - - /* Prepare one phdr of type PT_NOTE for each present CPU */ - for_each_present_cpu(cpu) { - phdr->p_type = PT_NOTE; - notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); - phdr->p_offset = phdr->p_paddr = notes_addr; - phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); - (ehdr->e_phnum)++; - phdr++; - } - - /* Prepare one PT_NOTE header for vmcoreinfo */ - phdr->p_type = PT_NOTE; - phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note(); - phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; - (ehdr->e_phnum)++; - phdr++; - - /* Prepare PT_LOAD type program header for kernel text region */ - if (need_kernel_map) { - phdr->p_type = PT_LOAD; - phdr->p_flags = PF_R|PF_W|PF_X; - phdr->p_vaddr = (unsigned long) _text; - phdr->p_filesz = phdr->p_memsz = _end - _text; - phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); - ehdr->e_phnum++; - phdr++; - } - - /* Go through all the ranges in mem->ranges[] and prepare phdr */ - for (i = 0; i < mem->nr_ranges; i++) { - mstart = mem->ranges[i].start; - mend = mem->ranges[i].end; - - phdr->p_type = PT_LOAD; - phdr->p_flags = PF_R|PF_W|PF_X; - phdr->p_offset = mstart; - - phdr->p_paddr = mstart; - phdr->p_vaddr = (unsigned long) __va(mstart); - phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; - phdr->p_align = 0; - ehdr->e_phnum++; - pr_debug("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n", - phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, - ehdr->e_phnum, phdr->p_offset); - phdr++; - } - - *addr = buf; - *sz = elf_sz; - return 0; -} From patchwork Fri Aug 11 17:06:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 134648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1296723vqi; Fri, 11 Aug 2023 12:03:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHU+0V1YqtbDmYuiQl4eyWYG6YAiXfApnX/dxX9gDR4ZQBmFNnZvRpf36bSqcoHE1dmsJAZ X-Received: by 2002:a17:90a:49c9:b0:269:48dc:c1a1 with SMTP id l9-20020a17090a49c900b0026948dcc1a1mr2054708pjm.17.1691780625458; Fri, 11 Aug 2023 12:03:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691780625; cv=pass; d=google.com; s=arc-20160816; b=NHNn5JL93ur4S6bIZIsUqryn3zeipVGgFx2L3wr4qsxdpDxMstcJeTY9PJke8JzngH 9vKFwu85muKf8o//HQqSbcewP/+1+k6sYCbm8BvwH+tnYLaW0JppNrHtMcMTdHI3H0rI iXozRAJUkY1BWCAAZKeFEkodxGojsrLIpImkbyF4KpEwhrSHvbz3uOPWZ3i1VaQBEMXd d8ZVaYLfJCjm/PUunbBg7OqfMP61B5vqI0F0jLNLkSume5V6w8CxA9ie5cKPCxkWE0Rd X9muLemNWQcPwYnjAO74apdsGlWtn8HOSAAucushC3/CAQibL5d574/TQxNV3lVHIgmL o7vA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=neX4dgrHOHpPdCnxirrY8SJnRS3HP5J4e2JJvTSuYE0=; fh=ZbNC38sm56YRcxo0eY5DlCjDElPeJYCNHKxhiyVbz2E=; b=SC2F2bfMDailMzKQdjzfz5d+5Y08xfLeBbPAvgI06ccyz9gif/WrT3jaoVuhNsnOQb K9dg12+IOvBNQ9N9LJDImQ5sO19FoGx4nIT0YUJj26so9xuoEmxmWqu7JOtFIvSlj6zp KqkLZCUg2DPJthj0xAKa/bedZkyYq2Wo8plRPxg26ZJ+CVGBdVRtK95P2XpzqCnmU6Ah 4mTbvOr0/VMEgKgUyYyMhaY5qefGiu6da7be6gfXuVt68U7umbLx2gEWCuuAf+B6klWF dBwiW4jjIpC0EZsM/CaDpem5qfs6gQFKUoJwBwwpmIC4sxK6zsYbumt7RreKLSrwgBp8 JZDQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=v53QORTm; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Zq83F2OM; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t12-20020a17090a3b4c00b0026902b035d8si3804643pjf.18.2023.08.11.12.03.30; Fri, 11 Aug 2023 12:03:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=v53QORTm; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Zq83F2OM; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236698AbjHKRI3 (ORCPT + 99 others); Fri, 11 Aug 2023 13:08:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236500AbjHKRII (ORCPT ); Fri, 11 Aug 2023 13:08:08 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A20192D7D; Fri, 11 Aug 2023 10:08:06 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37BDWrcK002634; Fri, 11 Aug 2023 17:07:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=neX4dgrHOHpPdCnxirrY8SJnRS3HP5J4e2JJvTSuYE0=; b=v53QORTm2hzVPndas90/ZLzYey7tEOB7nRW78a7p09f/5nsK9ZZPyRKBxCEWr3VPdsrS bqX9WWzU6vx1z49k0/c4vVa6mLaP7NjA3/iN0v2C08aXtYIK7yGd3CBVgILYWNbPWPN1 A01TENapZCrinpTVWgSlk58FFYE6sQVu+Q7HlQADuZoaAvS/TpN4T5Ha59Z4aMI/oIea V+JPLt7TPLaY0Xrsh0VNgVS6+66isw4M1p4qQ8SbrDQMaQ3R3ybdo5Q2rQ7PAQBc0pFZ NmfL/7gip07+D20Lp0B4Mb+fFamBKZS6qukTXk02x08RYXR/Uj11gblDq9rYEvHZV4fU bA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sd8y5hfyd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:07:03 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 37BGM4Rk012069; Fri, 11 Aug 2023 17:07:02 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s9cva2g9p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:07:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HfrabkHC4Ocp45ftBR9NCKelEnyAvvLKtMOLA0RtczUezdCGmW3jXv7WPiKm4pcmHjsl/rXGO758s1BhAyKDxtBerGGgYKZ376+XBBaepZFK4pvhNvrBSxfVsyr/JOyuJJZabRFmGonlzsB6Y9AYkpok9YZtPVDJV5v/y42taM9+mvR4DJZNI6nNDz1NYIHvcOLNiQRAw8uoxtcrIHdglWLipf1845cTafbQj2zCw0WV+JiequtJjV4kvNTrAnp2kG4k9hXN+TyKpwWGJFAvemlC/3rZnbA1PB3DwoB4lktrxK1C3ToXz2DDMnG0/vLtci1JBEveixhp8QQ/XYV9Ig== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=neX4dgrHOHpPdCnxirrY8SJnRS3HP5J4e2JJvTSuYE0=; b=JYmw3jAs3SwmL0cMrUAnuEVY3kpOtZcfsevKX6aw2sh5ztRhrn+z1wocGa0Rd7FprrqDA8kT5rwf0jzPdK2LlOOEMLLCJQBn+E3DL2kUGAQqYEKAR/JlIsokRBluNHCULDkbfnMWqnUuajUt1YsZJJiFDXpfiLfcFYymGdCYPTziME6xrXZYpQz8jSnAz5fushuui7wF5Hx9rfLexPdM7tVCW8PaatPFB5e0OIJfkEyTEuiVSSgEyCqSnpjCy23KMq9jqHmwQtK/JYSg+Peh35zF6i614sUQOfcq8rOdtG2ysg6X/0ce9FyLqJPg+9oGDkWM8zmK9dlk/fGq6yOn+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=neX4dgrHOHpPdCnxirrY8SJnRS3HP5J4e2JJvTSuYE0=; b=Zq83F2OMwV0jI4FSPonYfRX6CUGazvwo7mDzRbFfXMUP8eIWoy2U4u0MAoHO0wUfcXPGzW2RS6W420lyLy6stXvGXdSrzv94CI9JJSTETWuQW3R+LYdZqrOAuJNrtR+qp9+7pPWE2ExkfhxznFr7Td4gJRZq9kR9Zs03HGK4QAI= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ1PR10MB5978.namprd10.prod.outlook.com (2603:10b6:a03:45f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Fri, 11 Aug 2023 17:06:58 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57%4]) with mapi id 15.20.6678.020; Fri, 11 Aug 2023 17:06:57 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v27 2/8] crash: add generic infrastructure for crash hotplug support Date: Fri, 11 Aug 2023 13:06:36 -0400 Message-Id: <20230811170642.6696-3-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230811170642.6696-1-eric.devolder@oracle.com> References: <20230811170642.6696-1-eric.devolder@oracle.com> X-ClientProxiedBy: SJ0PR05CA0038.namprd05.prod.outlook.com (2603:10b6:a03:33f::13) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|SJ1PR10MB5978:EE_ X-MS-Office365-Filtering-Correlation-Id: cf6e7094-801d-492d-4e99-08db9a8d5ed4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OBlN8TaUinOCzdd7jg11zAiYTwAXGUQdwrppZ7kGBW2MhxNsPP0De/+3oy6FyZUS6PFPJBYVNHWQMG92YQlo6aRK+lpKn0CVu6Lh3gmqTZU6jo0bI3GoLKTiep3cYK+5QcrwUALuKS9UdxhjmMh/1zr4A7Vdgs6Xs/5wk3lI9IEwWBykHeRAcXGnKT6aaK2o2GYWbJYpJ1k5Nc3vFsXO84kMXM9HW+3BAMf2pf73x0Z6OnR8FJNROGBWYjrQ6yVOJulKmH8I/zZ2ZGy8Hw1Yxqjv+VeBncvw4XOg3pMjemKkWjg0HrBs1uBs9WYdu0ePafFzYw2DFxsXMG9SvVuChSZjUwcrFdE0IDkadQIBnn8+ack+GmpeUt7v+mRFT+KXzozJnTEJoepRWfKopcDIMMcdVCFSDyaz1ZINJp/sQqEHZBQNdK9iKv8SMXaXXDq2XgK6UFjteGwAx4dkTgWV+kqcdDSrG1+1rC4/P49OolgO2beslKczEbrYJ8eWNdZdpG/T3TF8gS2XLtHHHsJYmJvQDSNZUmt1nbqr82HXRE93sJT3jt1W81pFJysP3Qo929TzWKg2mODyOpCI/5oH7twhvmbTOpSM02NkzYL1Zu24vkLr863LkZ3giQKE1LT3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(39860400002)(136003)(346002)(366004)(451199021)(1800799006)(186006)(6666004)(6486002)(6512007)(478600001)(2616005)(6506007)(26005)(7416002)(107886003)(2906002)(1076003)(30864003)(7406005)(66476007)(4326008)(66946007)(66556008)(316002)(8936002)(8676002)(5660300002)(41300700001)(38100700002)(86362001)(36756003)(83380400001)(921005)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qLpJTknDWL782SMjMMKJkEQaoijvBxRd9QKyQO1sdXsVE3rE4MNw8hwtkdCVptfNXc1mUiK0FE9Mu2QHB7FctPjKsclj1qH+Tl0Sby23oRrdVoJkMH5maL6GMWWJsyy9BlZpTsMPzVFxqsgg78EKdu1feKlG84U++nLyJxSBUIwX2YKs5o0m8vMZC13BZVmTOGvuFmgNHF5MtGLA4UrQ1CYEeL4qe0yCcxjxraIwzOUl8IuElEbIUdU4B7aPHmfoJGPDJuS+H6Su+m35eAon0mGZX4DM4CHA6sJcOXNGpefz3TI4Gq51PQrIP9CGbqj656Dov+apJwvy8nbe4oYn+iyhRSmiVnkQbehcfis0LDYzl0bQRJYfrXPxeXLDsNjaS6Epb8hzJjPEw++GuX3KZpYG/6+SqnOqkK+uMOGtGddFXAA9sycsdidkazL5nuRn0kjs7qYtiyGyrpl3vMp3wqGyU/z7BZ8UZRVsT5Hcin1txXcDDkq5Nt1THMAsm/cvkBwg5mpHvFhXNfFaZB6Hnu/7Cj+EUDKC/uTI5mQ2YmP3hNpoo51QwQ0PU457pKBxzlyNoT0IoEkzUqH9Lw0dUvaqbzY5N0TqYwAJopqL8mYKdKV17p2YWAHEOz9/65mOBXcbSr5ikGEsUIGpcaQPpREBro4S3Ihb2bCHy99O/XrLmo2DBAURqzV5CSOAzcuA4GIKFxsKXfLkfES5eDED957FmEHjLl7nrhFtS7zG2yF+tVDSR/Tpb0qsOxW3GToK21ue0ix/Zv1wlCvIv6ys4WC1PGkiYDYjjACPuM9a0Cju4YSc4wJL3bqZdNYApTjYbbGn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yZcO0/RvKToM3yTY3icqKr6mp34Nv4htK3/0xICFBKrVLlVRCUJ1uMfTwTY8PfKbhh91iu9kFTbrztSomiy2e8oy3S23wvhWAtIzoH9Nkzmk39EdpwD72wvPpv394dBqayAeSKsbMSCDLtclGKZhJZx+LFFNVuxwhNYvqi3hMx8u5Gnpp/dDmSB4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf6e7094-801d-492d-4e99-08db9a8d5ed4 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2023 17:06:57.8234 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mzsLtG0EnSTVdPvZfFmB2mgwZ17YWC8LRcTTmMi/v3rY4U/ObNsjOF+DL/RbQm6hZbwW0L5B16m3NC/fg//BwQYIh2XD3oMdbwA+QKKoCq0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR10MB5978 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-11_09,2023-08-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308110156 X-Proofpoint-GUID: rbDj_Xf5EbyRiLPZ3J31uIATVXqeHjt6 X-Proofpoint-ORIG-GUID: rbDj_Xf5EbyRiLPZ3J31uIATVXqeHjt6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773960561442837940 X-GMAIL-MSGID: 1773960561442837940 To support crash hotplug, a mechanism is needed to update the crash elfcorehdr upon CPU or memory changes (eg. hot un/plug or off/ onlining). The crash elfcorehdr describes the CPUs and memory to be written into the vmcore. To track CPU changes, callbacks are registered with the cpuhp mechanism via cpuhp_setup_state_nocalls(CPUHP_BP_PREPARE_DYN). The crash hotplug elfcorehdr update has no explicit ordering requirement (relative to other cpuhp states), so meets the criteria for utilizing CPUHP_BP_PREPARE_DYN. CPUHP_BP_PREPARE_DYN is a dynamic state and avoids the need to introduce a new state for crash hotplug. Also, CPUHP_BP_PREPARE_DYN is the last state in the PREPARE group, just prior to the STARTING group, which is very close to the CPU starting up in a plug/online situation, or stopping in a unplug/ offline situation. This minimizes the window of time during an actual plug/online or unplug/offline situation in which the elfcorehdr would be inaccurate. Note that for a CPU being unplugged or offlined, the CPU will still be present in the list of CPUs generated by crash_prepare_elf64_headers(). However, there is no need to explicitly omit the CPU, see justification in 'crash: change crash_prepare_elf64_headers() to for_each_possible_cpu()'. To track memory changes, a notifier is registered to capture the memblock MEM_ONLINE and MEM_OFFLINE events via register_memory_notifier(). The CPU callbacks and memory notifiers invoke crash_handle_hotplug_event() which performs needed tasks and then dispatches the event to the architecture specific arch_crash_handle_hotplug_event() to update the elfcorehdr with the current state of CPUs and memory. During the process, the kexec_lock is held. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- include/linux/crash_core.h | 9 +++ include/linux/kexec.h | 11 +++ kernel/Kconfig.kexec | 31 ++++++++ kernel/crash_core.c | 142 +++++++++++++++++++++++++++++++++++++ kernel/kexec_core.c | 6 ++ 5 files changed, 199 insertions(+) diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h index de62a722431e..e14345cc7a22 100644 --- a/include/linux/crash_core.h +++ b/include/linux/crash_core.h @@ -84,4 +84,13 @@ int parse_crashkernel_high(char *cmdline, unsigned long long system_ram, int parse_crashkernel_low(char *cmdline, unsigned long long system_ram, unsigned long long *crash_size, unsigned long long *crash_base); +#define KEXEC_CRASH_HP_NONE 0 +#define KEXEC_CRASH_HP_ADD_CPU 1 +#define KEXEC_CRASH_HP_REMOVE_CPU 2 +#define KEXEC_CRASH_HP_ADD_MEMORY 3 +#define KEXEC_CRASH_HP_REMOVE_MEMORY 4 +#define KEXEC_CRASH_HP_INVALID_CPU -1U + +struct kimage; + #endif /* LINUX_CRASH_CORE_H */ diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 811a90e09698..b9903dd48e24 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -33,6 +33,7 @@ extern note_buf_t __percpu *crash_notes; #include #include #include +#include #include /* Verify architecture specific macros are defined */ @@ -360,6 +361,12 @@ struct kimage { struct purgatory_info purgatory_info; #endif +#ifdef CONFIG_CRASH_HOTPLUG + int hp_action; + int elfcorehdr_index; + bool elfcorehdr_updated; +#endif + #ifdef CONFIG_IMA_KEXEC /* Virtual address of IMA measurement buffer for kexec syscall */ void *ima_buffer; @@ -490,6 +497,10 @@ static inline int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, g static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { } #endif +#ifndef arch_crash_handle_hotplug_event +static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } +#endif + #else /* !CONFIG_KEXEC_CORE */ struct pt_regs; struct task_struct; diff --git a/kernel/Kconfig.kexec b/kernel/Kconfig.kexec index ff72e45cfaef..d0a9a5392035 100644 --- a/kernel/Kconfig.kexec +++ b/kernel/Kconfig.kexec @@ -113,4 +113,35 @@ config CRASH_DUMP For s390, this option also enables zfcpdump. See also +config CRASH_HOTPLUG + bool "Update the crash elfcorehdr on system configuration changes" + default y + depends on CRASH_DUMP && (HOTPLUG_CPU || MEMORY_HOTPLUG) + depends on ARCH_SUPPORTS_CRASH_HOTPLUG + help + Enable direct update to the crash elfcorehdr (which contains + the list of CPUs and memory regions to be dumped upon a crash) + in response to hot plug/unplug or online/offline of CPUs or + memory. This is a much more advanced approach than userspace + attempting that. + + If unsure, say Y. + +config CRASH_MAX_MEMORY_RANGES + int "Specify the maximum number of memory regions for the elfcorehdr" + default 8192 + depends on CRASH_HOTPLUG + help + For the kexec_file_load() syscall path, specify the maximum number of + memory regions that the elfcorehdr buffer/segment can accommodate. + These regions are obtained via walk_system_ram_res(); eg. the + 'System RAM' entries in /proc/iomem. + This value is combined with NR_CPUS_DEFAULT and multiplied by + sizeof(Elf64_Phdr) to determine the final elfcorehdr memory buffer/ + segment size. + The value 8192, for example, covers a (sparsely populated) 1TiB system + consisting of 128MiB memblocks, while resulting in an elfcorehdr + memory buffer/segment size under 1MiB. This represents a sane choice + to accommodate both baremetal and virtual machine configurations. + endmenu diff --git a/kernel/crash_core.c b/kernel/crash_core.c index b7c30b748a16..53d211c690a1 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include @@ -18,6 +20,7 @@ #include #include "kallsyms_internal.h" +#include "kexec_internal.h" /* vmcoreinfo stuff */ unsigned char *vmcoreinfo_data; @@ -697,3 +700,142 @@ static int __init crash_save_vmcoreinfo_init(void) } subsys_initcall(crash_save_vmcoreinfo_init); + +#ifdef CONFIG_CRASH_HOTPLUG +#undef pr_fmt +#define pr_fmt(fmt) "crash hp: " fmt +/* + * To accurately reflect hot un/plug changes of cpu and memory resources + * (including onling and offlining of those resources), the elfcorehdr + * (which is passed to the crash kernel via the elfcorehdr= parameter) + * must be updated with the new list of CPUs and memories. + * + * In order to make changes to elfcorehdr, two conditions are needed: + * First, the segment containing the elfcorehdr must be large enough + * to permit a growing number of resources; the elfcorehdr memory size + * is based on NR_CPUS_DEFAULT and CRASH_MAX_MEMORY_RANGES. + * Second, purgatory must explicitly exclude the elfcorehdr from the + * list of segments it checks (since the elfcorehdr changes and thus + * would require an update to purgatory itself to update the digest). + */ +static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu) +{ + struct kimage *image; + + /* Obtain lock while changing crash information */ + if (!kexec_trylock()) { + pr_info("kexec_trylock() failed, elfcorehdr may be inaccurate\n"); + return; + } + + /* Check kdump is not loaded */ + if (!kexec_crash_image) + goto out; + + image = kexec_crash_image; + + if (hp_action == KEXEC_CRASH_HP_ADD_CPU || + hp_action == KEXEC_CRASH_HP_REMOVE_CPU) + pr_debug("hp_action %u, cpu %u\n", hp_action, cpu); + else + pr_debug("hp_action %u\n", hp_action); + + /* + * The elfcorehdr_index is set to -1 when the struct kimage + * is allocated. Find the segment containing the elfcorehdr, + * if not already found. + */ + if (image->elfcorehdr_index < 0) { + unsigned long mem; + unsigned char *ptr; + unsigned int n; + + for (n = 0; n < image->nr_segments; n++) { + mem = image->segment[n].mem; + ptr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT)); + if (ptr) { + /* The segment containing elfcorehdr */ + if (memcmp(ptr, ELFMAG, SELFMAG) == 0) + image->elfcorehdr_index = (int)n; + kunmap_local(ptr); + } + } + } + + if (image->elfcorehdr_index < 0) { + pr_err("unable to locate elfcorehdr segment"); + goto out; + } + + /* Needed in order for the segments to be updated */ + arch_kexec_unprotect_crashkres(); + + /* Differentiate between normal load and hotplug update */ + image->hp_action = hp_action; + + /* Now invoke arch-specific update handler */ + arch_crash_handle_hotplug_event(image); + + /* No longer handling a hotplug event */ + image->hp_action = KEXEC_CRASH_HP_NONE; + image->elfcorehdr_updated = true; + + /* Change back to read-only */ + arch_kexec_protect_crashkres(); + + /* Errors in the callback is not a reason to rollback state */ +out: + /* Release lock now that update complete */ + kexec_unlock(); +} + +static int crash_memhp_notifier(struct notifier_block *nb, unsigned long val, void *v) +{ + switch (val) { + case MEM_ONLINE: + crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_MEMORY, + KEXEC_CRASH_HP_INVALID_CPU); + break; + + case MEM_OFFLINE: + crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_MEMORY, + KEXEC_CRASH_HP_INVALID_CPU); + break; + } + return NOTIFY_OK; +} + +static struct notifier_block crash_memhp_nb = { + .notifier_call = crash_memhp_notifier, + .priority = 0 +}; + +static int crash_cpuhp_online(unsigned int cpu) +{ + crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_CPU, cpu); + return 0; +} + +static int crash_cpuhp_offline(unsigned int cpu) +{ + crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_CPU, cpu); + return 0; +} + +static int __init crash_hotplug_init(void) +{ + int result = 0; + + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + register_memory_notifier(&crash_memhp_nb); + + if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) { + result = cpuhp_setup_state_nocalls(CPUHP_BP_PREPARE_DYN, + "crash/cpuhp", crash_cpuhp_online, crash_cpuhp_offline); + } + + return result; +} + +subsys_initcall(crash_hotplug_init); +#endif diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index e2f2574d8b74..5d323255862a 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -277,6 +277,12 @@ struct kimage *do_kimage_alloc_init(void) /* Initialize the list of unusable pages */ INIT_LIST_HEAD(&image->unusable_pages); +#ifdef CONFIG_CRASH_HOTPLUG + image->hp_action = KEXEC_CRASH_HP_NONE; + image->elfcorehdr_index = -1; + image->elfcorehdr_updated = false; +#endif + return image; } From patchwork Fri Aug 11 17:06:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 134613 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1253112vqi; Fri, 11 Aug 2023 10:38:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF71JFXl79lGhCrGPT06+zS8WXepfYBy85to6U6F69i//zrSp8FRkREb7nYYz5/vpuG8tT/ X-Received: by 2002:a17:90b:17d2:b0:25c:18ad:6b82 with SMTP id me18-20020a17090b17d200b0025c18ad6b82mr3250303pjb.21.1691775493252; Fri, 11 Aug 2023 10:38:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691775493; cv=pass; d=google.com; s=arc-20160816; b=hrG14E48YCwfhHtxaVHQniIt+jVE4KpImCqpQD7awlee/vKh5UjfRyIYE6zWHAt+N8 xEljOatXbhM9Me/y4rETSBOHXwjdp1HZpOe85GyiviO8zjx8R54N9kfDx59fVR5wXwg1 PYgwG8BcJUrxAM75uClVrdXoKCkjMaBoDaFz2jLIbi3e9otYp59H/WAONiGdUy4uOUYv X6t0PB2Ak1UB7nE4Qn+lnblvDFd3udJQZSrqBZXJXxQfsMZ3KuKWoDYQqRnEOJHrunWg TTyWO4SVacyZFubzXWadFqsCS0LeZcZkHH9c7XK9wpFwVWOAK3yxstKPq66jgENxr3Ev kgrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=TpE1wqVtb7MplpG9Vaelj6riR98OXh5MaMtMxiY6bCg=; fh=ZbNC38sm56YRcxo0eY5DlCjDElPeJYCNHKxhiyVbz2E=; b=j0LcLMXy26q34cZGivRqy/NWe5NKf8PlnhNo5F3+ig7fAlXvu8r8zqNU9ZNoVgSzJ/ 0d5lIvExJwWQvC7KDdIfmJxC6s8p2AjrnkAHxiwjfUtsBd6AB5j+OI+pG6tuTZrq3dfz HSYgCclgSJ+oVGGLV5N5UhQ29bGlgzdt2KzhWxx/tdQ1S6DZbbkvaNLtl9TM0WNe2ffq SI9AEwBy4bJIFU1MbA3CSpaH4csoFWTqpCsFWiU0ukVYyIYXRvxY1CU9NfbPqQ7aw6Dc wduHCrwTs0jjgHxYit2s5O05SGEnkBemRydp+IQW6Ah9YF3tDDwX05OERCEnIlRIXJqs M92w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=BJ5THPA4; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=uVARqjYH; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a17090aa00700b00267ed1dd76esi5719568pjp.177.2023.08.11.10.37.57; Fri, 11 Aug 2023 10:38:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=BJ5THPA4; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=uVARqjYH; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236535AbjHKRIK (ORCPT + 99 others); Fri, 11 Aug 2023 13:08:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236416AbjHKRIH (ORCPT ); Fri, 11 Aug 2023 13:08:07 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C9301FDD; Fri, 11 Aug 2023 10:08:06 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37BDYT04000367; Fri, 11 Aug 2023 17:07:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=TpE1wqVtb7MplpG9Vaelj6riR98OXh5MaMtMxiY6bCg=; b=BJ5THPA44KkdU4QMLcj4v6tQBaiOw+9AU7LORw7UeP2LNcdBZdvGXKLZJH7QL5wvkba1 n/QgqkQgbIMeejuMAHYgLSv+HQW8NX8e77EkpPHn2RxkMFy1m2dPUPjKCWfZQE3prOpG 4Tbl22H0qSZBhXcZYtIu2ov/Tv7ivFCYBqU9XMru7ysk40VN+VIOxXb8Bo755x74G9CJ Yzj2UrMIhn60GVSPRnrq2Qe9uyPkWFxVBqqF3GjJlMqH6mJ4T1UR0n7ynwJn8Rc9WGJ7 yQJyoQibF3yUjRaH/SiY9JDCAQ42gww4P7hCTfrKp3YAHeXIiwNZg2GWdBXhRMHiWE+z JQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sd8y6sfvc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:07:06 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 37BGT0iQ011134; Fri, 11 Aug 2023 17:07:05 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s9cvh2dnh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:07:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eLRr34Hvf3bS3OEh4am44wPBRS0DjIxH/pKpr1V3IFRHxDKjt9YeH7UDgc8BrZ43m/zOzWNFmFzoeYWvKphjMpDnuhNNoWtFfxEBeXRI9ackKDg7+4BsrVXAKy0+hi335UXfv4SDS2J/NakpTho4tQqREP+knmkIXJqtHKyZTi90un/uuopIV/aWjCgY6gEuQyne318gXxO4PVKscTylE4S+UcHa9nlTMOFSY7OcvOhYDrNroJg4jfSliHN+KORSg66Ai7vaCIT3ZNVGOXkCtRrabNmGniyO8zEhPc/4zqaUvKJ+efY/npv/DrGeyCvkkKh2qomvhtWiEgLJXXrN9A== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TpE1wqVtb7MplpG9Vaelj6riR98OXh5MaMtMxiY6bCg=; b=LilzivjurDPAgwOUuV7RRdb0bZUAO1DBCWp4+i+nr0eqwX7dl/AX+aHiYR6PbQPzrarHjB79bs5a+IIYVUtyCiXeIupdkhEpfvpC73buscR40k5QuXjbXEvxmspRSBnIo9unUKzezIobZMgyEf1GLPBSiykwz2PHk00S2WzSFOqnjr15GIuOlAEgX5aVbyZJYRYASGKxphFB5JGrA9oxZolbaDpeBTqWnJ2DJ5Z4ednirtUAOUscnnl4FXtRQF46WjkawVKSdbr+sdrmoKioMzJazIhXQr+e9pQqGXDftoOeIVOAnDkc6o0wpbBh3OTr6do+1RG2YUCr+yJif+uxWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TpE1wqVtb7MplpG9Vaelj6riR98OXh5MaMtMxiY6bCg=; b=uVARqjYHUa4TgQHUkDsGfq88nYuhST6JuycyGzWZNeGBaIyZ+NWkjmUxd57ExpQGK91ViX5E0fAgE9mBlURTivDAl5Leg56VQaqTuTUGB+Vyhzpxi9nX79xXqjwvP+GpjGTFdXwrQ/fKQ5smiGD1BnjpEsZDLEcWxUb1y3d8VKU= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ1PR10MB5978.namprd10.prod.outlook.com (2603:10b6:a03:45f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Fri, 11 Aug 2023 17:07:01 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57%4]) with mapi id 15.20.6678.020; Fri, 11 Aug 2023 17:07:01 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v27 3/8] kexec: exclude elfcorehdr from the segment digest Date: Fri, 11 Aug 2023 13:06:37 -0400 Message-Id: <20230811170642.6696-4-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230811170642.6696-1-eric.devolder@oracle.com> References: <20230811170642.6696-1-eric.devolder@oracle.com> X-ClientProxiedBy: SJ0PR03CA0339.namprd03.prod.outlook.com (2603:10b6:a03:39c::14) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|SJ1PR10MB5978:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e5b8132-965c-4ccb-f64e-08db9a8d60db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EZiKz9vy+Wgi0KV4Cpr5bdRz5cdRb9vZUGV0miTRGQb+Gh5N1aoDEKozh76c1d9mKf/40zZxBYCwtcvTyCicgBmn0jb/sxs2XFTIImuugIeCzkN/ti7l3XxhHMueDnv/c44y9HEfiSC2f9SOd/Wgo94UOpVwMSyH1eEraa84dTFp8QYpNvhSCMqE3gn2OoXePRQSNhnvoGYMeLEmpG96eoDJR4QMWA9HSOiUvHhhC8999oLASlmWyBaR5HXo7H9nMwZjfgDUkOLAAFcNVbGL/box6wWNX2hrJFhZCWR22MHJztem03EtlrfOqWLAiNISBrerWo+/W1TCdjCh1JzusbvefCsmKTHbRF6/amty4dwObJ7Ae82I3+qaqrQ5IOQJToKIBDqa9WXMB3CXmKaoA3dqrZUE/HmYSIGjBX/iXmTPToV6EHnJBTjaokCpcicwhLFXjspjI1EwqKj89skz/UxPLU9CL3ZNLGYTxXdJIHLfuze0uIKxblfBK3AKIWs2ApS4HUTdwe5soca0gasT++XqW296hkgueTHGNNIKNL0ct5BFiQtj8Bospxwyd84BUwqvbfjMrzApGAl5FtH63gxxJ6GCiG4Q/6vFO8Cte10= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(39860400002)(136003)(346002)(366004)(451199021)(1800799006)(186006)(6666004)(6486002)(6512007)(478600001)(2616005)(6506007)(26005)(7416002)(107886003)(2906002)(1076003)(7406005)(66476007)(4326008)(66946007)(66556008)(316002)(8936002)(8676002)(5660300002)(41300700001)(38100700002)(86362001)(36756003)(83380400001)(921005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rMg7ShuvNFGNqr8lcc5g87jBq+Qgdsk7LSabMjXF6IX07FyPC/YQu0oVUh1lATAlgBM5TTk2R6kjptJ2M+dt1Kku2QokrSR8rFG0hV3U4R/+VQsTLzcbhRo/2M56yJ77ZxAeE3RNzsyQ92uSWeBufNiKX0KXYiytKmHS3tBBpSoYVH/eUnK/aajYWZEr7cR4Okpri6uZl72kbThA2WZZOpAX9Ztr3MTgBS+qAy/JcLI+sAIbp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fSfxHr+8s/qEK4tV8P3dSs3DKFLYSY86WhXk5N02zOXOMiniDJ5/K+M/S4yznzsEnUkSbmCuvMmOzU3tb5jRGry7EvFDDbcukG5oO0jSiBB23vwBot9zhyNbXq5gGLQLgbLFjPC1stfbok9q2aHcPUb7IzdIWQyvQJsie+YG+BXYtHOarwlP1XmkH6FyyuRqyF2MtGOYMXezV2KiK8qOF/Y4hwiOaE830dyyzZKulJaCrgyQHRxa3KJelRqY9BomyCyBTIA5phbDI42Sa3QcPq8hOp1rip/A0Cy1u02I8U6Vc2fwD1AmYUmsUcXVgQkBdLpT1qXK7eyvkHoTBK5AInaIO8SPS3hJenVvlwgr4seF7nspOb2S2DquDD29Mrl5S9Eqr09RAzj13OvlsVMQngeMctFxZ7yeaQG31HZQygd4ecoaHqfdb8Kru4W0tI/L7CDVN0ZHpKQgpK8FDxeqwr56JuDCdn46l/i3StCp1n/X8pEYKI0agiOnacmav6c5ZcwEes9hR5i92zioQ3An2JF9P3Ca6DBO8IHyJAKjWNrhgKqtYFMRRE5bJLSSUUXOGvIdI5ppiTwShFhb41LUHv0qkt8fYCwyVHbqdMr0lUdhIMy1KpdxlGxY2VoOsP4xqnEzNe8BUH9puXKmo1oU/sE5wOsImw6w23nqboUeF0rdkARFBWhL6iHAf/GlgvwWj87XQsEU//v6p2a6uSCLrTrbDmmRMUdVuui8f0wm7OINQ4T4ARlA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e5b8132-965c-4ccb-f64e-08db9a8d60db X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2023 17:07:01.2723 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bcWMiCR6tfzi3MNad+Dl9OCCj6hsLFj08QoO4YT7f7RjrBJXdt+aQA/lo5sNw2JFO4UuAtD7hU7HX354GJoSsDufx1eSGhd6v/6GrxthFMA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR10MB5978 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-11_09,2023-08-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308110156 X-Proofpoint-ORIG-GUID: Z-aVg-jZHAyDecndJUfDnAIuT68CDdSL X-Proofpoint-GUID: Z-aVg-jZHAyDecndJUfDnAIuT68CDdSL X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773955179616023888 X-GMAIL-MSGID: 1773955179616023888 When a crash kernel is loaded via the kexec_file_load() syscall, the kernel places the various segments (ie crash kernel, crash initrd, boot_params, elfcorehdr, purgatory, etc) in memory. For those architectures that utilize purgatory, a hash digest of the segments is calculated for integrity checking. The digest is embedded into the purgatory image prior to placing in memory. Updates to the elfcorehdr in response to CPU and memory changes would cause the purgatory integrity checking to fail (at crash time, and no vmcore created). Therefore, the elfcorehdr segment is explicitly excluded from the purgatory digest, enabling updates to the elfcorehdr while also avoiding the need to recompute the hash digest and reload purgatory. Suggested-by: Baoquan He Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- kernel/kexec_file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 453b7a513540..e2ec9d7b9a1f 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -726,6 +726,12 @@ static int kexec_calculate_store_digests(struct kimage *image) for (j = i = 0; i < image->nr_segments; i++) { struct kexec_segment *ksegment; +#ifdef CONFIG_CRASH_HOTPLUG + /* Exclude elfcorehdr segment to allow future changes via hotplug */ + if (j == image->elfcorehdr_index) + continue; +#endif + ksegment = &image->segment[i]; /* * Skip purgatory as it will be modified once we put digest From patchwork Fri Aug 11 17:06:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 134663 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1329174vqi; Fri, 11 Aug 2023 13:09:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHCw1iuJkwD8Hxpl0s9eLVBQH7LD8bzt2bFwcTXMlQAfYW3PLqDhBQ1ktvWliEDqMvcrs2o X-Received: by 2002:a50:ec96:0:b0:523:486f:e11 with SMTP id e22-20020a50ec96000000b00523486f0e11mr2576920edr.25.1691784581890; Fri, 11 Aug 2023 13:09:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691784581; cv=pass; d=google.com; s=arc-20160816; b=yESYttiPwz9NjPn5qyarT8iV0n97fmpL0uGCGuO+oSBBOyStpfeL0gkvhMqSGw6EyX jjvTUPy4caLHqq+KBhW0XAblzkQ2RWn+al0LrjArok9iBqB4eR4CAve75hWZXe/LXXJu Yuourpoqw61O+zeJvbtNU44cZY2sTpAUIs7FNGclbZ97fo2yWHf5Jth2E4kw6kskT4ka djbX3mvQ/CPH/hQvBtxHI9m7IgwHOfayp2G5fhTEw2GdmavR3UbpB6//OXYYy2NA76xi xWeNVS/25H+PScMkVO09xuqKoBocieb6Zslx07PHGCXigepkjrRYe+cfLTKh4hbH7C5x ah5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=58EY2p5DeyatZjE4dKQjGZFTt8sWnd82VgrLR0qC3IQ=; fh=ZbNC38sm56YRcxo0eY5DlCjDElPeJYCNHKxhiyVbz2E=; b=ypK3vKRELqbZZPQJuwmwn0xCFNJlVaMeXZUiXyR669dGZuQsdf3GYvlLDAPNi4yw3l VkL9ekGqt5eAzmClN50PFpCBMdhD4JXEXPY6AJUCVd8QN9pJ99uAAReqbRKNIakHYHNa q4++ZIfIV+Qzq0l5mvSvYJ6EzCDRIm/cHZkNVzXD94r558lXNrfrx501UK/I2u7ah8n6 N5JquwWhrpPw7+js2jIaaqMOlPUjes+U5nAPN/7kTTalG4Fba8fgCzTZXeQbICLUxwIM KPPj0apfcqbHIr1fbTWZa7GM3r9Bn0K/zltyES0Icz3g8va/2OadLygPQldbWI6lr0O9 zDjw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=R4v3fq3p; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=XKJqksdY; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a50fb0b000000b00523215dd857si3766571edq.52.2023.08.11.13.09.18; Fri, 11 Aug 2023 13:09:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=R4v3fq3p; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=XKJqksdY; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236574AbjHKRIM (ORCPT + 99 others); Fri, 11 Aug 2023 13:08:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236447AbjHKRIH (ORCPT ); Fri, 11 Aug 2023 13:08:07 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ED63211C; Fri, 11 Aug 2023 10:08:06 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37BDUUFn014430; Fri, 11 Aug 2023 17:07:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=58EY2p5DeyatZjE4dKQjGZFTt8sWnd82VgrLR0qC3IQ=; b=R4v3fq3pn8MeR+GUHSbusfedC8cKy0vymUn59kf/0iBDxAGSO1Trfm7HT0mg8mB7jv5L BNbamqXdctF4SZIg2cOjawCf0QMRAX6YW4hSXFPjx3In61zFMberMrlhyhhuxvGiSNZM 2Cjoi3gs3nT+JqDA+5MHhytU5hGZI9jGD54p+8P+AAwUTKUTn3vo0I9MC2PcuBwl3pPB fRr+2pp3OoSmvcbqRPmmzGTNg/9Ta9zCSYs1o2FEZml9Iwvhc/VVEf04VQMhBvlTePhM G6Kdly9K/+IVsrfXqrMtzRap94UDyq40Y+0aUrH1FQox8/rk3pO4ydPrZ6PJyi4tWYAn ng== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sd8y3sg0f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:07:08 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 37BGQVTp000953; Fri, 11 Aug 2023 17:07:07 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s9cvgj03u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:07:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bu4KczXbLoTt4ffKLKkJtKPw+2+iCjekBEOVVqmb1XuGNvNtU5YqnevZZEkqp5x/9BizJQ6cxxT4EWWYlWlmDAxRmEJlJXdDZlnKO8Yw16YYzsc2i6sSSHbN9QN540S5dWXkPEyMVpBGDKau5MsFnFMj02tnaleCTPzDVq7jwA8vrJjq8dLGeRkuZcJwhl97A5Qjm0PynBYmYqzbi6IDt0aZ64LPneClIGQXTO/ThsXyRsE4eDGXQz4+hHr8MM6Mc1VYzxCS8zsFm4z5ul2E1kBg62hjisgBcC6fwkYyDPtzhadJ8MlJNDzGxWoHuSeXLFAsqP+oDqiuYVzrdkRo8w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=58EY2p5DeyatZjE4dKQjGZFTt8sWnd82VgrLR0qC3IQ=; b=FmJF6dpRDDaq6fhNxsdT4nX8+oRNjxgURCiuuVshlhs6/W30RDKBLi+PGPwUbJVA1670khz3ehXG4QiKVvgql+X2p8ABLsaD35Vpxl4tg7d3M9a4if6QU0ngrX4d4DjuiXNUa9er58dJquZZ9SG1ZBTyAx3XS/qsOxC8DHROHrc6DqjUjU+Alcm7X9V1iXgBD3gMSk+1awXHQMT8rVmXMnVvtfr4Jrr+4/nfXSWHdiciHJ8qCgWytj8sqPVgCbx1sFGVPu8EjdgsOyvhpIWfTpW9cxgHj4rhekx6y4zi22OrnbrvLtHzrd1ZtwNChMepDFJEi6FqxYq0TkzN0lwDIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=58EY2p5DeyatZjE4dKQjGZFTt8sWnd82VgrLR0qC3IQ=; b=XKJqksdYtfn7hZUybrOS1OJ+7GkKt5PIfbepwcpjUhJfQVvEaeOF5zh0dUo03FqazmoGJYVMVcBcOOuf8pS1ZMyApJ7xeCvJctTMLfRMaCokxEBTfpJf0mn2qHeN7WK3gb7uO0KEqUlwVwLfgZi7qYMIBuschPb7nyewxitWx2U= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ1PR10MB5978.namprd10.prod.outlook.com (2603:10b6:a03:45f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Fri, 11 Aug 2023 17:07:04 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57%4]) with mapi id 15.20.6678.020; Fri, 11 Aug 2023 17:07:04 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v27 4/8] crash: memory and CPU hotplug sysfs attributes Date: Fri, 11 Aug 2023 13:06:38 -0400 Message-Id: <20230811170642.6696-5-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230811170642.6696-1-eric.devolder@oracle.com> References: <20230811170642.6696-1-eric.devolder@oracle.com> X-ClientProxiedBy: BY3PR05CA0033.namprd05.prod.outlook.com (2603:10b6:a03:39b::8) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|SJ1PR10MB5978:EE_ X-MS-Office365-Filtering-Correlation-Id: 45421ae9-61c2-4030-dc68-08db9a8d62bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yzZ1it+4Vnavit08LD2mAG4Cux7Y4eB+u4D8sWhD9/dZS63UNfJV66KyPDXvz6M4hrxKDa04trTYMvGyOo0lzUN03EMxHackHU/LRQJCVHKkbYaQIUEgHi2fuA0l/+woKTbHZQJBcQDbwAjOAvuklkj6PbC3mzsg8mjGBJtW+pZ9pK4t5TjxIkXJ5gFk9l2wwTxytYJm+urMHUUuY0G/grFOTz/CzBUq+WrOvAsAlMCFhXG1CD+r0vrF+mor1Ed/SWltqB1Otq4hyTcVf+m19+6Mdvaij7VQOdu8TApm3puFne1LNoB6nwKCNIYdfGOTVVlvgeCW4gMgRcfakZBIu7QmcD1prjVxd/TmrwABn+IV1beJZEscAnQKAatVEujegAhdwtTirxFbrQaSMLq3KjkQYgy/6YzPHY+962m9z5xXEdf47rwe680AF5GvqnXC2tYH0KBdfglQB3V249pl8Gq5Vl8BKjYCZ7VTu/zVEi5jbawKoaKIANFZEGRfD5nBJYMJPfsgZUjFZ4QoBSr412UDrJWRtWYGQvdRsj/jwF+JhUckYMLHRBhCGvB15NSd5pPBQhpMQn1vrQ0dXBC9mQDRc+iifY0+UdotFB79Qwk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(39860400002)(136003)(346002)(366004)(451199021)(1800799006)(186006)(6666004)(6486002)(6512007)(478600001)(2616005)(6506007)(26005)(7416002)(107886003)(2906002)(1076003)(7406005)(66476007)(4326008)(66946007)(66556008)(316002)(8936002)(8676002)(5660300002)(41300700001)(38100700002)(86362001)(36756003)(83380400001)(921005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LCjmMCAuDfwiikr3tqhiK/xnjkwegErjJquxwBAmAGk1juN8aBkpW8prYNYima2gEBgga2OZjauiwt79Ic/pr4feXqfpWZlvxIS5BsJcXOy1eppw8xO5RLhg5bLJc9I6RWxzbrJX6tQO5cZfKpF2JtC342TWjqmpvPCAzxJnDsrGBo5E+SYg5+6F8wfx2H/7B98a2IFECNQKavWisQEIawE7bcHxlsPKPIn6bOtB0YVsJAVnOWijKUfgdoyzqYfH90kC28hV5sTthZSP1yT2lS/bOSAomQNMplawLDhsMs6KaQIMKZ1FR0lKtCZg8Ki9OCXKU8dbsecfEDn9W/4pEiErCzD52jcKi1z2GmzHZbfatYR+u8Tz0QKXaVjuYtyOy3Ng8bxzJBktGtGyB94A+4X6F4XbUVO0LN9ZrZ73Lo/JZXMMUETASCrzcKKuDhWGTBZKI9qmyJsYJAFKv6hFnNCDFnKHvfxaPzH8RxeU1OOqLoTWqVOhgwpHnMwEJsIGeKetFhfz3JZpSI5+JrROF6AjZOiqP/vXeOSeRLbDpMuKTgrkzXFHmRpyztHupu3lrb2e1chXQrS3pYBKUM9Vsf0skG6tqwF9aevT69xBeCvRHpmJfw/dnzHvYFZhl5RAsIK7A/Lp5e83jVM56TtokMZFGkcIZjVBwsG1xkuFyHrMULkrnmzYxukdXWZc+bePHR+Qcdb86yH75+ZOklOHsA+QNNGMO/4ARwO1Y7wspukecbGGu4+hog1na1WunPRqRGGPFMk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0i1WGx0R6cihTc2++lo8VPgiGBD9xw7JqT2APnTSoh9tipvuHqHyVo4U+GxIB621SG5IIwG9tajcw47/0CHTdBgK+jENIrHiYEifsLLuPsBAODrLqw/IoPU/XVZmLDULkuHmWqMXsVneD7nGCnkNpO4duoGXdcSMd1ODx8fnAVZMCs9elL9ArkbAH4LFjdRsU+WE3PdFuuM5/+DpAGwZoeaY3UDPuHiz30SXJv0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45421ae9-61c2-4030-dc68-08db9a8d62bf X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2023 17:07:04.3284 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UQXcHcm+PNSCJW+TY112MjrPtHnf97ywZ4yP1gwmSVO9PPfax8x1Tu4gn++PXsQOw/A5snf86ixaWIOrAhtHpMAbH4jMh61KVPFb1eOmG3I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR10MB5978 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-11_09,2023-08-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308110156 X-Proofpoint-GUID: 9lmk4W8VAyMJlMqejNZ-FlRFQGmgMdaY X-Proofpoint-ORIG-GUID: 9lmk4W8VAyMJlMqejNZ-FlRFQGmgMdaY X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773964709991393296 X-GMAIL-MSGID: 1773964709991393296 Introduce the crash_hotplug attribute for memory and CPUs for use by userspace. These attributes directly facilitate the udev rule for managing userspace re-loading of the crash kernel upon hot un/plug changes. For memory, expose the crash_hotplug attribute to the /sys/devices/system/memory directory. For example: # udevadm info --attribute-walk /sys/devices/system/memory/memory81 looking at device '/devices/system/memory/memory81': KERNEL=="memory81" SUBSYSTEM=="memory" DRIVER=="" ATTR{online}=="1" ATTR{phys_device}=="0" ATTR{phys_index}=="00000051" ATTR{removable}=="1" ATTR{state}=="online" ATTR{valid_zones}=="Movable" looking at parent device '/devices/system/memory': KERNELS=="memory" SUBSYSTEMS=="" DRIVERS=="" ATTRS{auto_online_blocks}=="offline" ATTRS{block_size_bytes}=="8000000" ATTRS{crash_hotplug}=="1" For CPUs, expose the crash_hotplug attribute to the /sys/devices/system/cpu directory. For example: # udevadm info --attribute-walk /sys/devices/system/cpu/cpu0 looking at device '/devices/system/cpu/cpu0': KERNEL=="cpu0" SUBSYSTEM=="cpu" DRIVER=="processor" ATTR{crash_notes}=="277c38600" ATTR{crash_notes_size}=="368" ATTR{online}=="1" looking at parent device '/devices/system/cpu': KERNELS=="cpu" SUBSYSTEMS=="" DRIVERS=="" ATTRS{crash_hotplug}=="1" ATTRS{isolated}=="" ATTRS{kernel_max}=="8191" ATTRS{nohz_full}==" (null)" ATTRS{offline}=="4-7" ATTRS{online}=="0-3" ATTRS{possible}=="0-7" ATTRS{present}=="0-3" With these sysfs attributes in place, it is possible to efficiently instruct the udev rule to skip crash kernel reloading for kernels configured with crash hotplug support. For example, the following is the proposed udev rule change for RHEL system 98-kexec.rules (as the first lines of the rule file): # The kernel updates the crash elfcorehdr for CPU and memory changes SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" SUBSYSTEM=="memory", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" When examined in the context of 98-kexec.rules, the above rules test if crash_hotplug is set, and if so, the userspace initiated unload-then-reload of the crash kernel is skipped. CPU and memory checks are separated in accordance with CONFIG_HOTPLUG_CPU and CONFIG_MEMORY_HOTPLUG kernel config options. If an architecture supports, for example, memory hotplug but not CPU hotplug, then the /sys/devices/system/memory/crash_hotplug attribute file is present, but the /sys/devices/system/cpu/crash_hotplug attribute file will NOT be present. Thus the udev rule skips userspace processing of memory hot un/plug events, but the udev rule will evaluate false for CPU events, thus allowing userspace to process CPU hot un/plug events (ie the unload-then-reload of the kdump capture kernel). Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- Documentation/ABI/testing/sysfs-devices-memory | 8 ++++++++ .../ABI/testing/sysfs-devices-system-cpu | 8 ++++++++ .../admin-guide/mm/memory-hotplug.rst | 8 ++++++++ Documentation/core-api/cpu_hotplug.rst | 18 ++++++++++++++++++ drivers/base/cpu.c | 13 +++++++++++++ drivers/base/memory.c | 13 +++++++++++++ include/linux/kexec.h | 8 ++++++++ 7 files changed, 76 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-devices-memory b/Documentation/ABI/testing/sysfs-devices-memory index d8b0f80b9e33..a95e0f17c35a 100644 --- a/Documentation/ABI/testing/sysfs-devices-memory +++ b/Documentation/ABI/testing/sysfs-devices-memory @@ -110,3 +110,11 @@ Description: link is created for memory section 9 on node0. /sys/devices/system/node/node0/memory9 -> ../../memory/memory9 + +What: /sys/devices/system/memory/crash_hotplug +Date: Aug 2023 +Contact: Linux kernel mailing list +Description: + (RO) indicates whether or not the kernel directly supports + modifying the crash elfcorehdr for memory hot un/plug and/or + on/offline changes. diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu index 77942eedf4f6..b52564de2b18 100644 --- a/Documentation/ABI/testing/sysfs-devices-system-cpu +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu @@ -687,3 +687,11 @@ Description: (RO) the list of CPUs that are isolated and don't participate in load balancing. These CPUs are set by boot parameter "isolcpus=". + +What: /sys/devices/system/cpu/crash_hotplug +Date: Aug 2023 +Contact: Linux kernel mailing list +Description: + (RO) indicates whether or not the kernel directly supports + modifying the crash elfcorehdr for CPU hot un/plug and/or + on/offline changes. diff --git a/Documentation/admin-guide/mm/memory-hotplug.rst b/Documentation/admin-guide/mm/memory-hotplug.rst index 1b02fe5807cc..eb99d79223a3 100644 --- a/Documentation/admin-guide/mm/memory-hotplug.rst +++ b/Documentation/admin-guide/mm/memory-hotplug.rst @@ -291,6 +291,14 @@ The following files are currently defined: Availability depends on the CONFIG_ARCH_MEMORY_PROBE kernel configuration option. ``uevent`` read-write: generic udev file for device subsystems. +``crash_hotplug`` read-only: when changes to the system memory map + occur due to hot un/plug of memory, this file contains + '1' if the kernel updates the kdump capture kernel memory + map itself (via elfcorehdr), or '0' if userspace must update + the kdump capture kernel memory map. + + Availability depends on the CONFIG_MEMORY_HOTPLUG kernel + configuration option. ====================== ========================================================= .. note:: diff --git a/Documentation/core-api/cpu_hotplug.rst b/Documentation/core-api/cpu_hotplug.rst index e6f5bc39cf5c..d6d470d7dda0 100644 --- a/Documentation/core-api/cpu_hotplug.rst +++ b/Documentation/core-api/cpu_hotplug.rst @@ -741,6 +741,24 @@ will receive all events. A script like:: can process the event further. +When changes to the CPUs in the system occur, the sysfs file +/sys/devices/system/cpu/crash_hotplug contains '1' if the kernel +updates the kdump capture kernel list of CPUs itself (via elfcorehdr), +or '0' if userspace must update the kdump capture kernel list of CPUs. + +The availability depends on the CONFIG_HOTPLUG_CPU kernel configuration +option. + +To skip userspace processing of CPU hot un/plug events for kdump +(i.e. the unload-then-reload to obtain a current list of CPUs), this sysfs +file can be used in a udev rule as follows: + + SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" + +For a CPU hot un/plug event, if the architecture supports kernel updates +of the elfcorehdr (which contains the list of CPUs), then the rule skips +the unload-then-reload of the kdump capture kernel. + Kernel Inline Documentations Reference ====================================== diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 52df435eecf8..5fb0c89e1ad5 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -282,6 +282,16 @@ static ssize_t print_cpus_nohz_full(struct device *dev, static DEVICE_ATTR(nohz_full, 0444, print_cpus_nohz_full, NULL); #endif +#ifdef CONFIG_CRASH_HOTPLUG +static ssize_t crash_hotplug_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return sysfs_emit(buf, "%d\n", crash_hotplug_cpu_support()); +} +static DEVICE_ATTR_ADMIN_RO(crash_hotplug); +#endif + static void cpu_device_release(struct device *dev) { /* @@ -469,6 +479,9 @@ static struct attribute *cpu_root_attrs[] = { #ifdef CONFIG_NO_HZ_FULL &dev_attr_nohz_full.attr, #endif +#ifdef CONFIG_CRASH_HOTPLUG + &dev_attr_crash_hotplug.attr, +#endif #ifdef CONFIG_GENERIC_CPU_AUTOPROBE &dev_attr_modalias.attr, #endif diff --git a/drivers/base/memory.c b/drivers/base/memory.c index b456ac213610..15bb416e58ce 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -490,6 +490,16 @@ static ssize_t auto_online_blocks_store(struct device *dev, static DEVICE_ATTR_RW(auto_online_blocks); +#ifdef CONFIG_CRASH_HOTPLUG +#include +static ssize_t crash_hotplug_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%d\n", crash_hotplug_memory_support()); +} +static DEVICE_ATTR_RO(crash_hotplug); +#endif + /* * Some architectures will have custom drivers to do this, and * will not need to do it from userspace. The fake hot-add code @@ -889,6 +899,9 @@ static struct attribute *memory_root_attrs[] = { &dev_attr_block_size_bytes.attr, &dev_attr_auto_online_blocks.attr, +#ifdef CONFIG_CRASH_HOTPLUG + &dev_attr_crash_hotplug.attr, +#endif NULL }; diff --git a/include/linux/kexec.h b/include/linux/kexec.h index b9903dd48e24..6a8a724ac638 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -501,6 +501,14 @@ static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } #endif +#ifndef crash_hotplug_cpu_support +static inline int crash_hotplug_cpu_support(void) { return 0; } +#endif + +#ifndef crash_hotplug_memory_support +static inline int crash_hotplug_memory_support(void) { return 0; } +#endif + #else /* !CONFIG_KEXEC_CORE */ struct pt_regs; struct task_struct; From patchwork Fri Aug 11 17:06:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 134656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1306755vqi; Fri, 11 Aug 2023 12:23:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9eA25Sc+KVptqaavJFfsCwe5k50APT3IbCqQEGa8v53xQAk8vsRisPNB+sGfc5x0FEonb X-Received: by 2002:a05:6a20:970e:b0:133:bc8:e362 with SMTP id hr14-20020a056a20970e00b001330bc8e362mr2523170pzc.24.1691781801340; Fri, 11 Aug 2023 12:23:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691781801; cv=pass; d=google.com; s=arc-20160816; b=ROWAlmLIJMrC/ak8QC7GMUw9SRjlv44wiETORV9LGxKqKTgzXOhpkAVDCx184z/BIU BKKnFnd0gIG47hOwF8A8HZVvOExYpAbxvxtMsIoyq67UO9UmSOwD6mhBuNno4owCD2d5 H+0ZM5tgRvM/UMK1WusPxk9anRnDdVnRFvVwyn4OZwccM76M08V5yek+CPWsvSb0UUJE RsgSUUNGKqsmRLsMVKd2LRiq3LJrPyoD+AuBYlHQV26+Ynz8UMbPmn8PPBle5l5EBzOt L9xrrHonR1e7kA3r+XYym+APjeyKatg/Kii0CE4ibG5LDovaLIdJKU9ppG2wMK34tnGD /Kkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=WFw7v7cjxpNNgU/vF/xiNsFjyDrsUC6p0fWgxylqC5Y=; fh=ZbNC38sm56YRcxo0eY5DlCjDElPeJYCNHKxhiyVbz2E=; b=odl9fxyKFFwTj68xiTxYgOqX73wCpVD7/c4h7d1VBI2PKPcKSUrD2BO/l6r7fUZM/e ItbnhfsURLi4ffZ4uMbxxjG3CvJlxlvqM0/9zVFrEFMOQVbBTCE4wGGUhT3t5F0YLEiG Y7DEKOMLkDLdGBe0lDAzWmIwS3Zj3DMgec9RY0VAFw8WnoVMa91eL1xW8QTaRqKQfwQI c7OJ8oumnQE6WHmBKi/J03Xy+uMzGgxlrZN1bRALE00DOjpf6lAwUjYNPSFJz2G9l0vk LGzpR57mg2PGOXL6gzCq+junFqMPtNYUHPV0xioJnWLFH9+aWrjjMttGOQ6RSKFcVmvD SkUA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=TrBNtMgu; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qYYOMBYJ; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a056a00199500b0064d28b68d8fsi3894951pfl.94.2023.08.11.12.23.08; Fri, 11 Aug 2023 12:23:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=TrBNtMgu; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qYYOMBYJ; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236710AbjHKRId (ORCPT + 99 others); Fri, 11 Aug 2023 13:08:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236515AbjHKRIJ (ORCPT ); Fri, 11 Aug 2023 13:08:09 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A188C19F; Fri, 11 Aug 2023 10:08:07 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37BDVqjG003568; Fri, 11 Aug 2023 17:07:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=WFw7v7cjxpNNgU/vF/xiNsFjyDrsUC6p0fWgxylqC5Y=; b=TrBNtMguIeErKsCeheBg2kb7kchir7gKfI/QR7NFG+rv7bOdT2ZdXlYlRjW9iBboj9tj kPErylJZJaFISA68Ba4S9jA9YthFoFUZf/v8dPOnLnhOtK94t8jynYA/6UEwJFgyfEX0 I9sZitvmz/mVcq+cM+V6mO74uSSm2DekN5mP7XE8bpwg2Q+cmzt97anhKHV/Yq+Cxrrm lbaVRjAubEEgWVPE8c8ZEa5XOu0AuW2vRFDvl/RnpKNI92WopEVtVU+o7Na7yqB/KfeJ m00jyqqGLCkuu8W5f0gCphxmKbahm6XkXfT9afq1fqMVhKtocvG06SDq6lQWB13VzfyM 0g== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sd8y6hf9q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:07:10 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 37BGO9vL000381; Fri, 11 Aug 2023 17:07:10 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s9cvgj05m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:07:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eu3vIlWncefEwtHGhnthPpPkg8Rqs1gOp5aF8z56UGvWV79+zb2HU8Iy1bugfLHKS3CTaMTfIhm47ZVuBjxzueOiiEJ4M/K/9ZtS08yFbtk0i69OQXXA7OWBIvwkAHxC5bs83txOVu61WvVmcXUJDK5L3MLKYOfuDgwAzNx9u29pcVo2licgWxYpYZAswx4MMOPCQ/dd++Hw9gnJFti7cYuo2IcvvoWnFqzRU0TacoH/FB7KuTgOotS2XHvhXljnyPisUyyin2geWFOSdjGF/4LxIKmaj94D+oAHigbnUhEPtX+Ol4Y0PVVyCyqA7W+r3jZJvQRwV2ZrwUkSdw4mIQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WFw7v7cjxpNNgU/vF/xiNsFjyDrsUC6p0fWgxylqC5Y=; b=PcVKXtTLGbXTkZ3PgV0+Ujye82lvF1qa4cQJ06B1nfc1R6XY/YSCfIAHfZMNWsqMB1cvvp+veaQSvPJvvWVjEc/LZLMrIlQQqWTsPXN49a4NX9lGG5KWBvEIe5gHPEnuK/QlcltADNRACBQDxDRI8rdMptQMRDfoptrwcA/dfOEJ8Ns/1MDRkQolu2lUO/8YnGVQe897T7C58HSnxq/tgAoW2k+z978VlkU999/+OP5YiAkP7RFKZddOdKThVxxJuMAE3UbHxQEIFKr2zIbu0X948MqgEfGJXF/73fMzeEh04D1uCDYWhr7kfHAIYDIaLPypf9MGp5H0KI9FGw4HNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WFw7v7cjxpNNgU/vF/xiNsFjyDrsUC6p0fWgxylqC5Y=; b=qYYOMBYJ4sMspvcGFiI6D9YECgNgUbK4XIHzwg9+HZc7Dp3jC3yoHuQibFVlnG+YBi0dyYItSRyu65Cp9ojVVQoiWg+aj9Nx6rxRJavhRcjIzZ2tSrnp335pGvrWlaHPNMa+7S3FXqTRHCkrRMMgicr2Uv9keWi8EQcHGQF+XG4= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ1PR10MB5978.namprd10.prod.outlook.com (2603:10b6:a03:45f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Fri, 11 Aug 2023 17:07:07 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57%4]) with mapi id 15.20.6678.020; Fri, 11 Aug 2023 17:07:07 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v27 5/8] x86/crash: add x86 crash hotplug support Date: Fri, 11 Aug 2023 13:06:39 -0400 Message-Id: <20230811170642.6696-6-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230811170642.6696-1-eric.devolder@oracle.com> References: <20230811170642.6696-1-eric.devolder@oracle.com> X-ClientProxiedBy: SJ0PR03CA0109.namprd03.prod.outlook.com (2603:10b6:a03:333::24) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|SJ1PR10MB5978:EE_ X-MS-Office365-Filtering-Correlation-Id: ac66a6df-9d44-4741-dd30-08db9a8d6478 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bYUxZv0AT5ZNNq+8IrTOM6Q0qjfJcZ4SAWKkdAjHeSA6fWOUNc4+4XUZk842jZn9RasFdqCP23mMDwpzmvdgGx1DsU4UqncrDqACFpiipG6wd4oMNMjddP0qrKhaORFp9bPfEZkPrmXjwBrnW3u8yPsSPmuWPOM/rBGmT2/bitRBYca7Gm/aWqQVRnUlBD8Ao7LFSWBZw0foOeKv3a8xOvUcDTmAPPvAvbYBqqS8YgKwM+AHVyPKfYAeKXNajHNMFXsKA/N7AIoIUaechQ/wjw2cMObk6DP1ycPTAD4EMaC17yq+bIJajmRDRqqN3NkTJ7wThQVlle1h8LOoAbcLtk6bcpujRt57Q4e5OWgv/n3RXMh+3SPWkqEXk/h34v5kRxjPBcIzug0AC4sAsQDY8LcdgUyKA/9VR3czCOrIs8ZZgLimwLaMJNSOJDvdawWT92v0v/kXht7kEhx+JHrLfoO5JSVuNL6doVwpBOkHLOGXlG4q9u8ldKtVfwUt7ihEe3IhtNplMSlRpckTe5LcVjbIOQo2fTrwo2HmIE2Ei+J55yxw2rgRoE7+xboneQM0dtY3lTqayqoZyChrVhW3xwC9r2IZGDOkwd0TmBspMl4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(39860400002)(136003)(346002)(366004)(451199021)(1800799006)(186006)(6666004)(6486002)(6512007)(478600001)(2616005)(6506007)(26005)(7416002)(107886003)(2906002)(1076003)(7406005)(66476007)(4326008)(66946007)(66556008)(316002)(8936002)(8676002)(5660300002)(41300700001)(38100700002)(86362001)(36756003)(83380400001)(921005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rwTo4uvCobBpSt63e4HT+TkAlVZ1TClEcN54qb/Y8QpABJlfDhzKdZuph4ad21E6nP/nQZpZD7Q0wdM1b9nozYu95PMUNfGtY+lVh/qhw2C0SBapkkqWlV6s1jzGRnoryYtmO2DAUlupx86NfWmIbEVBTblxqeXaxR4vNsUT7DVboBLesMmY4Q9V/xwFxZpo+8sSPnb44kdKAH0YNFo9MA0ZEBfHxa5vmlthj6lXi58CDZLvjygJKpYAzXoiEt/813V1szqTsFwVrdfeQwpAQUAoj3v1WkkQDnNiB+5FTuRYALTU4myicW+ZYmBFLEvZzWjNjDC6gnIePQWP+7l5vf3zD4hYealfNx2FM5Efhxlw/8Srv9L4qLTSY7fTJMA8M+ZpuUj4zhmGOyJhGGJ6xWExXsncu9Eaq8cpiH5K1RstwMRu5/i1SZm1niVKb3cpPXiVz8BmxMgFQZ6gcM6Xle9rNL8e0dT/odIxiO1j3H4glX510OmEdaI9UVn90C4k1C0CbOm1AGyMUH4xAxn6Xzpl/ZL10PxUjYyc3q1BcxRC/APHaFOF2F5u2f8DIwCLxeShrl7k3EkMT1ZW4IJqlr4SLeuCgpNxSADCVexqJF4KmXSKUjhkB0c7RNZr/z07J3fs8qFGjz1kYklxM8ggTtkQCl58Krg1ntFV6aCoDUTRRFfKWvgwJ2BG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bYikBCKqCBn0dbNSzbH4HCAbSC2z6pge/jOO4m0NLav6yDG7sOiWh6S2ZZCQNQnZFJZaeJ7OjoIlkL1a3z/Q+XgTubuHRGBm8vMw0JyFtTXBY2VtxfIYyfwMV+IONN/wWO+Z45CJ/YSZjXUqwKG8uCtUbUUVpo2GFNgT6hjrNrTn5CpjtoOezd8M/00iBuFwUGZXQn77/pyCNYn0TEiAVgBt+2AlFfIYT2jtZzr/P7yWm8y3nDtxxO+Mf+AH9oYTNaLMRA/GaAE7cJ2PMcwGehCufzjSH7MxwP4NmCVa88= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac66a6df-9d44-4741-dd30-08db9a8d6478 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2023 17:07:07.2687 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: K1GVLwGTLgYB+6vGKnDalxyoPgG1glWFavfwT9mKaL6CheAUiiKd4iGD8rdfaFW8pA6xME3GJwSMVU1Cljmdpi5ZptkzIEu81uasbqEueIM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR10MB5978 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-11_09,2023-08-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308110156 X-Proofpoint-ORIG-GUID: ZnQ-vwuO36tRcFB4bwYwLnINuuKUf3BA X-Proofpoint-GUID: ZnQ-vwuO36tRcFB4bwYwLnINuuKUf3BA X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773961794145086769 X-GMAIL-MSGID: 1773961794145086769 When CPU or memory is hot un/plugged, or off/onlined, the crash elfcorehdr, which describes the CPUs and memory in the system, must also be updated. A new elfcorehdr is generated from the available CPUs and memory and replaces the existing elfcorehdr. The segment containing the elfcorehdr is identified at run-time in crash_core:crash_handle_hotplug_event(). No modifications to purgatory (see 'kexec: exclude elfcorehdr from the segment digest') or boot_params (as the elfcorehdr= capture kernel command line parameter pointer remains unchanged and correct) are needed, just elfcorehdr. For kexec_file_load(), the elfcorehdr segment size is based on NR_CPUS and CRASH_MAX_MEMORY_RANGES in order to accommodate a growing number of CPU and memory resources. For kexec_load(), the userspace kexec utility needs to size the elfcorehdr segment in the same/similar manner. To accommodate kexec_load() syscall in the absence of kexec_file_load() syscall support, prepare_elf_headers() and dependents are moved outside of CONFIG_KEXEC_FILE. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- arch/x86/Kconfig | 3 + arch/x86/include/asm/kexec.h | 15 +++++ arch/x86/kernel/crash.c | 103 ++++++++++++++++++++++++++++++++--- 3 files changed, 114 insertions(+), 7 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 7082fc10b346..ffc95c3d6abd 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2069,6 +2069,9 @@ config ARCH_SUPPORTS_KEXEC_JUMP config ARCH_SUPPORTS_CRASH_DUMP def_bool X86_64 || (X86_32 && HIGHMEM) +config ARCH_SUPPORTS_CRASH_HOTPLUG + def_bool y + config PHYSICAL_START hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP) default "0x1000000" diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index 5b77bbc28f96..9143100ea3ea 100644 --- a/arch/x86/include/asm/kexec.h +++ b/arch/x86/include/asm/kexec.h @@ -209,6 +209,21 @@ typedef void crash_vmclear_fn(void); extern crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss; extern void kdump_nmi_shootdown_cpus(void); +#ifdef CONFIG_CRASH_HOTPLUG +void arch_crash_handle_hotplug_event(struct kimage *image); +#define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event + +#ifdef CONFIG_HOTPLUG_CPU +static inline int crash_hotplug_cpu_support(void) { return 1; } +#define crash_hotplug_cpu_support crash_hotplug_cpu_support +#endif + +#ifdef CONFIG_MEMORY_HOTPLUG +static inline int crash_hotplug_memory_support(void) { return 1; } +#define crash_hotplug_memory_support crash_hotplug_memory_support +#endif +#endif + #endif /* __ASSEMBLY__ */ #endif /* _ASM_X86_KEXEC_H */ diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index cdd92ab43cda..c70a111c44fa 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -158,8 +158,6 @@ void native_machine_crash_shutdown(struct pt_regs *regs) crash_save_cpu(regs, safe_smp_processor_id()); } -#ifdef CONFIG_KEXEC_FILE - static int get_nr_ram_ranges_callback(struct resource *res, void *arg) { unsigned int *nr_ranges = arg; @@ -231,7 +229,7 @@ static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg) /* Prepare elf headers. Return addr and size */ static int prepare_elf_headers(struct kimage *image, void **addr, - unsigned long *sz) + unsigned long *sz, unsigned long *nr_mem_ranges) { struct crash_mem *cmem; int ret; @@ -249,6 +247,9 @@ static int prepare_elf_headers(struct kimage *image, void **addr, if (ret) goto out; + /* Return the computed number of memory ranges, for hotplug usage */ + *nr_mem_ranges = cmem->nr_ranges; + /* By default prepare 64bit headers */ ret = crash_prepare_elf64_headers(cmem, IS_ENABLED(CONFIG_X86_64), addr, sz); @@ -257,6 +258,7 @@ static int prepare_elf_headers(struct kimage *image, void **addr, return ret; } +#ifdef CONFIG_KEXEC_FILE static int add_e820_entry(struct boot_params *params, struct e820_entry *entry) { unsigned int nr_e820_entries; @@ -371,18 +373,42 @@ int crash_setup_memmap_entries(struct kimage *image, struct boot_params *params) int crash_load_segments(struct kimage *image) { int ret; + unsigned long pnum = 0; struct kexec_buf kbuf = { .image = image, .buf_min = 0, .buf_max = ULONG_MAX, .top_down = false }; /* Prepare elf headers and add a segment */ - ret = prepare_elf_headers(image, &kbuf.buffer, &kbuf.bufsz); + ret = prepare_elf_headers(image, &kbuf.buffer, &kbuf.bufsz, &pnum); if (ret) return ret; - image->elf_headers = kbuf.buffer; - image->elf_headers_sz = kbuf.bufsz; + image->elf_headers = kbuf.buffer; + image->elf_headers_sz = kbuf.bufsz; + kbuf.memsz = kbuf.bufsz; + +#ifdef CONFIG_CRASH_HOTPLUG + /* + * The elfcorehdr segment size accounts for VMCOREINFO, kernel_map, + * maximum CPUs and maximum memory ranges. + */ + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + pnum = 2 + CONFIG_NR_CPUS_DEFAULT + CONFIG_CRASH_MAX_MEMORY_RANGES; + else + pnum += 2 + CONFIG_NR_CPUS_DEFAULT; + + if (pnum < (unsigned long)PN_XNUM) { + kbuf.memsz = pnum * sizeof(Elf64_Phdr); + kbuf.memsz += sizeof(Elf64_Ehdr); + + image->elfcorehdr_index = image->nr_segments; + + /* Mark as usable to crash kernel, else crash kernel fails on boot */ + image->elf_headers_sz = kbuf.memsz; + } else { + pr_err("number of Phdrs %lu exceeds max\n", pnum); + } +#endif - kbuf.memsz = kbuf.bufsz; kbuf.buf_align = ELF_CORE_HEADER_ALIGN; kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; ret = kexec_add_buffer(&kbuf); @@ -395,3 +421,66 @@ int crash_load_segments(struct kimage *image) return ret; } #endif /* CONFIG_KEXEC_FILE */ + +#ifdef CONFIG_CRASH_HOTPLUG + +#undef pr_fmt +#define pr_fmt(fmt) "crash hp: " fmt + +/** + * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes + * @image: a pointer to kexec_crash_image + * + * Prepare the new elfcorehdr and replace the existing elfcorehdr. + */ +void arch_crash_handle_hotplug_event(struct kimage *image) +{ + void *elfbuf = NULL, *old_elfcorehdr; + unsigned long nr_mem_ranges; + unsigned long mem, memsz; + unsigned long elfsz = 0; + + /* + * Create the new elfcorehdr reflecting the changes to CPU and/or + * memory resources. + */ + if (prepare_elf_headers(image, &elfbuf, &elfsz, &nr_mem_ranges)) { + pr_err("unable to create new elfcorehdr"); + goto out; + } + + /* + * Obtain address and size of the elfcorehdr segment, and + * check it against the new elfcorehdr buffer. + */ + mem = image->segment[image->elfcorehdr_index].mem; + memsz = image->segment[image->elfcorehdr_index].memsz; + if (elfsz > memsz) { + pr_err("update elfcorehdr elfsz %lu > memsz %lu", + elfsz, memsz); + goto out; + } + + /* + * Copy new elfcorehdr over the old elfcorehdr at destination. + */ + old_elfcorehdr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT)); + if (!old_elfcorehdr) { + pr_err("mapping elfcorehdr segment failed\n"); + goto out; + } + + /* + * Temporarily invalidate the crash image while the + * elfcorehdr is updated. + */ + xchg(&kexec_crash_image, NULL); + memcpy_flushcache(old_elfcorehdr, elfbuf, elfsz); + xchg(&kexec_crash_image, image); + kunmap_local(old_elfcorehdr); + pr_debug("updated elfcorehdr\n"); + +out: + vfree(elfbuf); +} +#endif From patchwork Fri Aug 11 17:06:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 134622 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1256791vqi; Fri, 11 Aug 2023 10:45:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNPZlUjLAhzQILMGyqg6UfxuICEGA0Ar/N/etO+vXIWByiiEN5m7n4Xq1M+uQQaxq/FAQt X-Received: by 2002:a05:6a20:244a:b0:12e:98a3:77b7 with SMTP id t10-20020a056a20244a00b0012e98a377b7mr2749477pzc.59.1691775954815; Fri, 11 Aug 2023 10:45:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691775954; cv=pass; d=google.com; s=arc-20160816; b=FnAXDRznm8I4gXqTsh1BL0oxeQBnF1SB19+/B/Pv+Nz+ZjVfvadfH3b4q4B9jYt0AI I4gfAfanB2QUYfS+IR0ceeskNRCvYgWAb7Ubz8kLsvDFxe4+upFjb7Zjd8wT6JmTj7WS ebYvFGmNVMUmser39OjhaCoXfKBraexO3PGm13fimVS/LIR056ZECZ5Kl+Zo+DAhSyBm wn3cLz7Ja/uVP8+i8X4z/2VspXsf1Tzdw9tDrz23XLUsjzIuUnLjH3Z/aDpZfXzLd57C Nw3G+L8pHGAIQoVgyVU/dnU/2rHtapOzrXozZTSmmzd7Rlyp9V2iVF4u8B9ItNugq5j2 tPxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=MSKEXyVIenyIhnny+0ljW8sRLv+oqrr3PdZEtUnoGB4=; fh=ZbNC38sm56YRcxo0eY5DlCjDElPeJYCNHKxhiyVbz2E=; b=p8xWJMCc6y1SgbXGuaoPTyG22b5ixP/ML4LTV7o4WD8b6gelYZ52It/OpuESmEPpYh TaqS1EM7u7A745HHW2bSwHihRLA0UhCJLpI1/fBwqDAd2OffhoSyQTqg1zxV4BwtoOLZ ugQpcc5SPITyHiLVN8rtePgciYQpcPKPeb2LStc01sVDqqtXPOKtufkvc0GqTPN+gEtl oYZdR5UBYftRJsQODPQrYCCRRU/nHJuixf0UHC8SfznCWW/1lDh6+OUbdhslfrV/BtoB G4PtOQIauM0QbKqC9h6H2ww8fBdeS7KLzUuEWWfolT47z5WdGgVTUGNp77K1g+JIsddX IU5w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=4ESQ0fuV; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WFtIhmRc; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b20-20020a656694000000b00565333417aesi3745785pgw.108.2023.08.11.10.45.37; Fri, 11 Aug 2023 10:45:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=4ESQ0fuV; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WFtIhmRc; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236741AbjHKRIi (ORCPT + 99 others); Fri, 11 Aug 2023 13:08:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236540AbjHKRIL (ORCPT ); Fri, 11 Aug 2023 13:08:11 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AC791FDD; Fri, 11 Aug 2023 10:08:10 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37BDuo7i003538; Fri, 11 Aug 2023 17:07:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=MSKEXyVIenyIhnny+0ljW8sRLv+oqrr3PdZEtUnoGB4=; b=4ESQ0fuVQ1wBn6eGJfxU2LaSH6oVjbQOptiEhCAM5gt67UOIi/V4YIfj3iC/CDbIYPiM kkhCBZNiM/kIToldeaNXhwoSJIj06dGmkyYnnRg/5fubbr3LelxpJEWs4rhtrsmyAwHs FblZ60grlgW2u9ydSkXENmby5QrDFNKBm2nhK0loTLFXiMnP6pVni/83iEmZLri1ygpf KfWdmwSz+4fddtnjUE73owiSFctNNIpVmACVSz+bbtdq10dE2UbQPK+nEjdqlxhqvwZh NURw9Am2kfKcQvHH+RDMNd8N/RRL0NiJ3AeZVRfRpDCck239IROwwtZhSt2N6pKMnOTA MQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sd8y6hf9u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:07:14 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 37BGNsqb012089; Fri, 11 Aug 2023 17:07:13 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s9cva2gg9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:07:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lzB1Nre+X8/MGdGZtyX3xRJ0oOetH6NwqJmL15FqC6UQkeUCuYhEnsg/YNIEmT7kzieORcOW1jvxf6P0Rcn0pUKlfaWMZtqwt6+pJWWGFMDtR2Nl8i6bWt5zxrZKUI5ZekH5voDxei2aEjVJOrZFGrhI1dPKJhmpyWERKihu6csk/gavA/ktsYFLkxlXVUMjWVeD6mxWshSP5/GZnLN5iyZN2yrSVqAmjoKJ7OWDPg60xtCbGaB3U6wUi8BG0p1IlNoNdM5nXSOeBGnczWHgXmltfFDC1/TbIf1TwVANmmw7iKY60JMh50dkEK7tw5kKJBmqC1kC12xdmGG1s//1Lg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MSKEXyVIenyIhnny+0ljW8sRLv+oqrr3PdZEtUnoGB4=; b=ZSjFoYylWQJJaTaUiTTbKXFOkHhT16GCgAc7hAFh9hRg4HayI45E/HX6atYwac+u3InI9kTKtqmdTQ6rBMofhNQtNV7zHUvkLq5mIgVzAZjSsZ7eTWoEtWl0mbhA6KqTZgDPQWOYMGCTp0s9FD91C4v0IuTtMkzlEJ1AoSNJInp3QyaoI6JWA0VhFIDWRJ5EMGHdfpl1Wgj1pjDyw7IxKrbu3Lvfo8hwwoPgP7jRfi3gd0hEW+y/dkS1d1Cm9/3i5Wx1pCOrzfIC7YsvmVE/D6gdaiQs87dKqkabCHuv1Mc2HYdm7KPoU9FAImkxFkJvIEBLA6FA31ZZ9jARKNBxXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MSKEXyVIenyIhnny+0ljW8sRLv+oqrr3PdZEtUnoGB4=; b=WFtIhmRcMNPaBtO7iM8rl/jptNiXsdpof8fCvGgVFGdXlXrHDHVMTjh8M9LoQ0qX7lb+E30CSmyTUo1d1upmWNGAOlLd/k+Wbujw2cPdQCN2lHN5upmrXRGx8HyQh5L8AbHAfmCNgO62WIi5brWqzlAGRjy1fbMExMXFb1Bkuco= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ1PR10MB5978.namprd10.prod.outlook.com (2603:10b6:a03:45f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Fri, 11 Aug 2023 17:07:10 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57%4]) with mapi id 15.20.6678.020; Fri, 11 Aug 2023 17:07:10 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v27 6/8] crash: hotplug support for kexec_load() Date: Fri, 11 Aug 2023 13:06:40 -0400 Message-Id: <20230811170642.6696-7-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230811170642.6696-1-eric.devolder@oracle.com> References: <20230811170642.6696-1-eric.devolder@oracle.com> X-ClientProxiedBy: SJ0PR05CA0190.namprd05.prod.outlook.com (2603:10b6:a03:330::15) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|SJ1PR10MB5978:EE_ X-MS-Office365-Filtering-Correlation-Id: b34e8b2b-b64a-444d-703a-08db9a8d666d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1hnZjtInIfPC9Z2U+e10gW5b/dOx0jL7HvZY9fu+UFF9RbFLtJQrJ+VIBnj95uIdu0gjm9NCAVaZeSBeQYyAkzDmw3UPZYPv6ZEq/azxnoMUWdV4y2QxoOiNHBZyI/SVaELFMHZ6mo4zMtlc5PgG3eA190y4A9BVtNnrwVjolwAkGPF/lcoiwaT5OrSc7Eg/SuVqLYxLcTDbrKLsQW/7scZS6mz3enkMv98a4dfzppmICCyppW6p8VctElL7IbLOeR58SSpg+wLz1eO3GaZWF/ZO5B63I2y2shsKyT+N1qV4ljQIgEHsWj40zX+YC2OeTS/RxN1gcj7WIbr6D83TZlaeaoaQUdYF/1FtmfVv80MFWtETdo4+LyXZbqup20zY+PtQUKrPfxaodXC3afa9LRf/dZGm5rIxyYijCldVztPKBB80dn0C1STlEV/vxhmg4IxHgfEVMkGMElbX20ssZ3qGz6Mz/FMMX6JwZlwpz0RzcQJGpdjgO4OzOURnru+HaH/QiwpIwY+4YesBOueDG9CF9oQRItCjPLcYuIUs2SPTr8wp701fU3JHbb4iNsEv9aNuKbegougUrkiS4IRGR1zCn2fUF09DABsc4P53dks= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(39860400002)(136003)(346002)(366004)(451199021)(1800799006)(186006)(6666004)(6486002)(6512007)(478600001)(2616005)(6506007)(26005)(7416002)(107886003)(2906002)(1076003)(30864003)(7406005)(66476007)(4326008)(66946007)(66556008)(316002)(8936002)(8676002)(5660300002)(41300700001)(38100700002)(86362001)(36756003)(83380400001)(921005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7ea2y0lPx8YLphVkw0bGSxX1kvSUC3TXwrdxPClFShaS7T2JMyOutLBzx1WPzeJcob4drM5FBueec88ZFkJPXdFYxWvlcFY5pO2DH7O/BY7ecTf/UcjTzTAw1x0WkxPB6BugBKhdu9sE1gu3mBGyZPegAHZFuyzshFgytGtxxgHiFRQv73/su3KE+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JduNhsBQhb/oqBmAdS3Fbm6gaQqiWDI9ZXe6rz6I8WJs+rf75da0KGCWeTkfol1m2K+qgpqe5KeHlmSazjjZTj92ZAdxGuo1NfTU9uJhQVjdLM4dkE790ETEvFf3FEUDv9Y000rVO8y4IOxwXKySlvVilo09+XsdLfcT7DvujhYYuBctSSh9C2gv6DVhhfEN8XwC7bPWZxuV44kWOHCAmfGy172RTwe+UXbz0PIdhvqH3mxCGyRG4/BinXsI0srFFB4gg9pGMgXTk2iae5anlHa45L4SN2yUH3xoURNlQKnsC0Om9o/fXXyMZB8VaIiFZVe3KmiYqkf+Ee4PMSM5vaYB1XYkZYBKbV+5eIEl9qA6fJxjzKr/5JyQipJ6rblbxfdKRr9i0fqPPA7e/lhP/AjtajQEPlhL9lhJgjOnBrEcDQWTVNFrVQoKJcoxpHw4jc6HYl4lu0ePvRhB8b0T/niOoARS2sz0wgl6I5GaAUbxicHXn1RrhbMigpRzf5v2310AoTPQticUz57XiBiQJQU/RL4fFE1cplqusuadEDnPJ/c6z4Y9P9xXkv/kUftSkbBy+lVhwBu2yR+xeNGMaZIFF0sDayC71jkMzWVJiAxou4PtSrC98hCJkhK/2R/Q3N/Nw8iqaBGQbU5n8MX7m3fryv1c059l6XUmU40QtRaNWbvFyUbz/oqt07QVhDFC7Dgbkr1/d3FDDThaMgjzwyXREjpSDZnn2joZjiwySyIMXeY4lkUXAWgHzRvEw3YY/ce9Gh5sGi8PzuoVH3VxTdcvQJKHP40wVuDyk2KRB3v2hfM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b34e8b2b-b64a-444d-703a-08db9a8d666d X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2023 17:07:10.5202 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hJiks1QUxAJ4x/KksM6jN3aQPb1IFC7BkPLf/6Zm6a5Jl9JEJ9c8AnzGfacGsHqJ0iH9fkfivuz2BS4qUw3EvCb4/axVAJruRPTQlZpdGl8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR10MB5978 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-11_09,2023-08-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308110156 X-Proofpoint-ORIG-GUID: 7AikSRarhnyBDRmsWvxd7m9C-WrMrous X-Proofpoint-GUID: 7AikSRarhnyBDRmsWvxd7m9C-WrMrous X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773955663405264674 X-GMAIL-MSGID: 1773955663405264674 The hotplug support for kexec_load() requires changes to the userspace kexec-tools and a little extra help from the kernel. Given a kdump capture kernel loaded via kexec_load(), and a subsequent hotplug event, the crash hotplug handler finds the elfcorehdr and rewrites it to reflect the hotplug change. That is the desired outcome, however, at kernel panic time, the purgatory integrity check fails (because the elfcorehdr changed), and the capture kernel does not boot and no vmcore is generated. Therefore, the userspace kexec-tools/kexec must indicate to the kernel that the elfcorehdr can be modified (because the kexec excluded the elfcorehdr from the digest, and sized the elfcorehdr memory buffer appropriately). To facilitate hotplug support with kexec_load(): - a new kexec flag KEXEC_UPATE_ELFCOREHDR indicates that it is safe for the kernel to modify the kexec_load()'d elfcorehdr - the /sys/kernel/crash_elfcorehdr_size node communicates the preferred size of the elfcorehdr memory buffer - The sysfs crash_hotplug nodes (ie. /sys/devices/system/[cpu|memory]/crash_hotplug) dynamically take into account kexec_file_load() vs kexec_load() and KEXEC_UPDATE_ELFCOREHDR. This is critical so that the udev rule processing of crash_hotplug is all that is needed to determine if the userspace unload-then-load of the kdump image is to be skipped, or not. The proposed udev rule change looks like: # The kernel updates the crash elfcorehdr for CPU and memory changes SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" SUBSYSTEM=="memory", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" The table below indicates the behavior of kexec_load()'d kdump image updates (with the new udev crash_hotplug rule in place): Kernel |Kexec -------+-----+---- Old |Old |New | a | a -------+-----+---- New | a | b -------+-----+---- where kexec 'old' and 'new' delineate kexec-tools has the needed modifications for the crash hotplug feature, and kernel 'old' and 'new' delineate the kernel supports this crash hotplug feature. Behavior 'a' indicates the unload-then-reload of the entire kdump image. For the kexec 'old' column, the unload-then-reload occurs due to the missing flag KEXEC_UPDATE_ELFCOREHDR. An 'old' kernel (with 'new' kexec) does not present the crash_hotplug sysfs node, which leads to the unload-then-reload of the kdump image. Behavior 'b' indicates the desired optimized behavior of the kernel directly modifying the elfcorehdr and avoiding the unload-then-reload of the kdump image. If the udev rule is not updated with crash_hotplug node check, then no matter any combination of kernel or kexec is new or old, the kdump image continues to be unload-then-reload on hotplug changes. To fully support crash hotplug feature, there needs to be a rollout of kernel, kexec-tools and udev rule changes. However, the order of the rollout of these pieces does not matter; kexec_load()'d kdump images still function for hotplug as-is. Suggested-by: Hari Bathini Signed-off-by: Eric DeVolder Acked-by: Hari Bathini Acked-by: Baoquan He --- arch/x86/include/asm/kexec.h | 11 +++++++---- arch/x86/kernel/crash.c | 27 +++++++++++++++++++++++++++ include/linux/kexec.h | 14 ++++++++++++-- include/uapi/linux/kexec.h | 1 + kernel/Kconfig.kexec | 4 ++++ kernel/crash_core.c | 31 +++++++++++++++++++++++++++++++ kernel/kexec.c | 5 +++++ kernel/ksysfs.c | 15 +++++++++++++++ 8 files changed, 102 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index 9143100ea3ea..3be6a98751f0 100644 --- a/arch/x86/include/asm/kexec.h +++ b/arch/x86/include/asm/kexec.h @@ -214,14 +214,17 @@ void arch_crash_handle_hotplug_event(struct kimage *image); #define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event #ifdef CONFIG_HOTPLUG_CPU -static inline int crash_hotplug_cpu_support(void) { return 1; } -#define crash_hotplug_cpu_support crash_hotplug_cpu_support +int arch_crash_hotplug_cpu_support(void); +#define crash_hotplug_cpu_support arch_crash_hotplug_cpu_support #endif #ifdef CONFIG_MEMORY_HOTPLUG -static inline int crash_hotplug_memory_support(void) { return 1; } -#define crash_hotplug_memory_support crash_hotplug_memory_support +int arch_crash_hotplug_memory_support(void); +#define crash_hotplug_memory_support arch_crash_hotplug_memory_support #endif + +unsigned int arch_crash_get_elfcorehdr_size(void); +#define crash_get_elfcorehdr_size arch_crash_get_elfcorehdr_size #endif #endif /* __ASSEMBLY__ */ diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index c70a111c44fa..caf22bcb61af 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -427,6 +427,33 @@ int crash_load_segments(struct kimage *image) #undef pr_fmt #define pr_fmt(fmt) "crash hp: " fmt +/* These functions provide the value for the sysfs crash_hotplug nodes */ +#ifdef CONFIG_HOTPLUG_CPU +int arch_crash_hotplug_cpu_support(void) +{ + return crash_check_update_elfcorehdr(); +} +#endif + +#ifdef CONFIG_MEMORY_HOTPLUG +int arch_crash_hotplug_memory_support(void) +{ + return crash_check_update_elfcorehdr(); +} +#endif + +unsigned int arch_crash_get_elfcorehdr_size(void) +{ + unsigned int sz; + + /* kernel_map, VMCOREINFO and maximum CPUs */ + sz = 2 + CONFIG_NR_CPUS_DEFAULT; + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + sz += CONFIG_CRASH_MAX_MEMORY_RANGES; + sz *= sizeof(Elf64_Phdr); + return sz; +} + /** * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes * @image: a pointer to kexec_crash_image diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 6a8a724ac638..bb0e614f2a05 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -335,6 +335,10 @@ struct kimage { unsigned int preserve_context : 1; /* If set, we are using file mode kexec syscall */ unsigned int file_mode:1; +#ifdef CONFIG_CRASH_HOTPLUG + /* If set, allow changes to elfcorehdr of kexec_load'd image */ + unsigned int update_elfcorehdr:1; +#endif #ifdef ARCH_HAS_KIMAGE_ARCH struct kimage_arch arch; @@ -411,9 +415,9 @@ bool kexec_load_permitted(int kexec_image_type); /* List of defined/legal kexec flags */ #ifndef CONFIG_KEXEC_JUMP -#define KEXEC_FLAGS KEXEC_ON_CRASH +#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_UPDATE_ELFCOREHDR) #else -#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT) +#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT | KEXEC_UPDATE_ELFCOREHDR) #endif /* List of defined/legal kexec file flags */ @@ -501,6 +505,8 @@ static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } #endif +int crash_check_update_elfcorehdr(void); + #ifndef crash_hotplug_cpu_support static inline int crash_hotplug_cpu_support(void) { return 0; } #endif @@ -509,6 +515,10 @@ static inline int crash_hotplug_cpu_support(void) { return 0; } static inline int crash_hotplug_memory_support(void) { return 0; } #endif +#ifndef crash_get_elfcorehdr_size +static inline unsigned int crash_get_elfcorehdr_size(void) { return 0; } +#endif + #else /* !CONFIG_KEXEC_CORE */ struct pt_regs; struct task_struct; diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h index 981016e05cfa..01766dd839b0 100644 --- a/include/uapi/linux/kexec.h +++ b/include/uapi/linux/kexec.h @@ -12,6 +12,7 @@ /* kexec flags for different usage scenarios */ #define KEXEC_ON_CRASH 0x00000001 #define KEXEC_PRESERVE_CONTEXT 0x00000002 +#define KEXEC_UPDATE_ELFCOREHDR 0x00000004 #define KEXEC_ARCH_MASK 0xffff0000 /* diff --git a/kernel/Kconfig.kexec b/kernel/Kconfig.kexec index d0a9a5392035..6e5350d2d7a6 100644 --- a/kernel/Kconfig.kexec +++ b/kernel/Kconfig.kexec @@ -144,4 +144,8 @@ config CRASH_MAX_MEMORY_RANGES memory buffer/segment size under 1MiB. This represents a sane choice to accommodate both baremetal and virtual machine configurations. + For the kexec_load() syscall path, CRASH_MAX_MEMORY_RANGES is part of + the computation behind the value provided through the + /sys/kernel/crash_elfcorehdr_size attribute. + endmenu diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 53d211c690a1..fa918176d46d 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -704,6 +704,33 @@ subsys_initcall(crash_save_vmcoreinfo_init); #ifdef CONFIG_CRASH_HOTPLUG #undef pr_fmt #define pr_fmt(fmt) "crash hp: " fmt + +/* + * This routine utilized when the crash_hotplug sysfs node is read. + * It reflects the kernel's ability/permission to update the crash + * elfcorehdr directly. + */ +int crash_check_update_elfcorehdr(void) +{ + int rc = 0; + + /* Obtain lock while reading crash information */ + if (!kexec_trylock()) { + pr_info("kexec_trylock() failed, elfcorehdr may be inaccurate\n"); + return 0; + } + if (kexec_crash_image) { + if (kexec_crash_image->file_mode) + rc = 1; + else + rc = kexec_crash_image->update_elfcorehdr; + } + /* Release lock now that update complete */ + kexec_unlock(); + + return rc; +} + /* * To accurately reflect hot un/plug changes of cpu and memory resources * (including onling and offlining of those resources), the elfcorehdr @@ -734,6 +761,10 @@ static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu) image = kexec_crash_image; + /* Check that updating elfcorehdr is permitted */ + if (!(image->file_mode || image->update_elfcorehdr)) + goto out; + if (hp_action == KEXEC_CRASH_HP_ADD_CPU || hp_action == KEXEC_CRASH_HP_REMOVE_CPU) pr_debug("hp_action %u, cpu %u\n", hp_action, cpu); diff --git a/kernel/kexec.c b/kernel/kexec.c index 92d301f98776..107f355eac10 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -129,6 +129,11 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments, if (flags & KEXEC_PRESERVE_CONTEXT) image->preserve_context = 1; +#ifdef CONFIG_CRASH_HOTPLUG + if (flags & KEXEC_UPDATE_ELFCOREHDR) + image->update_elfcorehdr = 1; +#endif + ret = machine_kexec_prepare(image); if (ret) goto out; diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index aad7a3bfd846..1d4bc493b2f4 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c @@ -165,6 +165,18 @@ static ssize_t vmcoreinfo_show(struct kobject *kobj, } KERNEL_ATTR_RO(vmcoreinfo); +#ifdef CONFIG_CRASH_HOTPLUG +static ssize_t crash_elfcorehdr_size_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + unsigned int sz = crash_get_elfcorehdr_size(); + + return sysfs_emit(buf, "%u\n", sz); +} +KERNEL_ATTR_RO(crash_elfcorehdr_size); + +#endif + #endif /* CONFIG_CRASH_CORE */ /* whether file capabilities are enabled */ @@ -255,6 +267,9 @@ static struct attribute * kernel_attrs[] = { #endif #ifdef CONFIG_CRASH_CORE &vmcoreinfo_attr.attr, +#ifdef CONFIG_CRASH_HOTPLUG + &crash_elfcorehdr_size_attr.attr, +#endif #endif #ifndef CONFIG_TINY_RCU &rcu_expedited_attr.attr, From patchwork Fri Aug 11 17:06:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 134614 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1253316vqi; Fri, 11 Aug 2023 10:38:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGMr4qGfm4385Q5JpbXuO0ZtJbiu5iRFl8EbFPywWA7qWAhjkxokxMh08zkxYVyc1JlqVUr X-Received: by 2002:a17:902:d507:b0:1bb:7996:b269 with SMTP id b7-20020a170902d50700b001bb7996b269mr3405681plg.19.1691775516642; Fri, 11 Aug 2023 10:38:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691775516; cv=pass; d=google.com; s=arc-20160816; b=P/5BfGGmL2OsewlwiJ6efcdWsJstFM5A+beazhOijtAy6WsZkhTV44Y/VTCTCip/z6 XmbU8lK9bTWMjBVZZrB0FjorVCNHxtRYCMxYwLJsuUdXFnb8IzOABVqu0FRJnQHudrrj kLTAXfCIVqTwuzFQOSNxGuRZzeSNEgMAd7F3hgWU1WL/77x7kgQUNxg0H8VKvvXH/Ccp CG5C+e/3tw3biD2DQkj11w8/fPHSCnHBn4gxddPq+P0bfSko5a+N1T+6/+dbj+IrH2HM Dpw9aYAFScjyZ95nkpeTP+pP3qb1/IEDeoi7nHDj6FooMrfXqSKnbDbL8YKwCRjtj24G 4LAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=kqZzUcUI7g9GrNNQb568EFpHtig8R3NmjYR2Lpu3gEg=; fh=ZbNC38sm56YRcxo0eY5DlCjDElPeJYCNHKxhiyVbz2E=; b=iIL9XPXibqCsbNqxMdGre43ScA7kDppU7bev4dRezVOMHsJh6VhgW1JVeRdTn5dYWk vnRc6QbbK3XRnouWrZibp5ZF4cZZ6BH/lJwThTMh7jH6J11ItiCGIddiyYodxEBnjPWo 9LVCLT4Ao2wajKBltQsX1QAQJBPDu04VfiubSNq17tdgRsTe1iFXX9gZ5DEpYHtp+xn5 B7654CbaRJNKsmfsXitC8p/JsTArzHavEWgA0LDFdoPqphOk/JnPE2OlMssB7qav+P4l ok+gNOxRJtFcJHioQU82SidtDI6E2wifFE17xLcvQCPfiVEGu2AzDzH1dEY6Itk9wdGV kp6w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=Z83Xol3J; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=0Uo+xZqC; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id la14-20020a170902fa0e00b001b8b7460620si3513932plb.181.2023.08.11.10.38.23; Fri, 11 Aug 2023 10:38:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=Z83Xol3J; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=0Uo+xZqC; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236749AbjHKRIm (ORCPT + 99 others); Fri, 11 Aug 2023 13:08:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236565AbjHKRIM (ORCPT ); Fri, 11 Aug 2023 13:08:12 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0D4B30D0; Fri, 11 Aug 2023 10:08:11 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37BDbULM002246; Fri, 11 Aug 2023 17:07:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=kqZzUcUI7g9GrNNQb568EFpHtig8R3NmjYR2Lpu3gEg=; b=Z83Xol3J0V1agDXYpVQMlh5oQp3Q/uKVLAY39czzfrpu97wyjkguwYn8nW2oCwDaGjSL CoJ2nBuqEpq8c8JzgTHsf0Sd/Cyp7tfV4W7DAWmnN8E5BhmLaUDa8wY40lFmqMqA19rn XbgqYgyvv7h2OiGjang9H0NDC2MXOEbJPU7ylGmLN62lYyWwG5gK8DWk1FWFGv3xRAY8 32zzSwaLZAF3CG7tjW2MrDMO4TTWS8klsr/rDk9UaUOAw8kqTsfX9wW27XWeY7jugS7T L1EGIgVwVEe960PupUaXC7tEjjABVCOmpci7y1ZpKRqcOQw/YLwVUvSDYchkdw2BYWYM sA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sd8ychg4h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:07:17 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 37BGPusc033488; Fri, 11 Aug 2023 17:07:16 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3s9cvakvr2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:07:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D8SjkvOOonGzjQePnK4CiE9gfzGqNM3bvza9zceS3ViZ+5SoMXNj5WOG31pxMnPkcMrJ/oegU5U+k+clZA5nrRi6nsMyOT6Hn3/138byX+i8pWRy5FcwvzLGP4vwIFr0gw2na6a5l53ZswNKOaJeFgtlyXs5pYE5Z274iAmgRM5XZR1o9RKEaZPgfPW12XxTZlldR+JAJAZdgFIsg/1pHVf08gFBiYH9yj1Q2+2ceTc00v8zeclEnpDawB6TJtwDQCqBgsiSUZ7trh8zDl8bPonRUTjrGjETMlQioEgJcMOZng+2Mr4ckUIB0AVajcHNntU8j7db/na8ENcO/g79Ig== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kqZzUcUI7g9GrNNQb568EFpHtig8R3NmjYR2Lpu3gEg=; b=fnOdsQcr1dGNeqHvFonvtT31fM+IYcDWoi1sZhOw6ZWyhRVpYBRWGyEIohrJNF54laKyHiJzG/PoVYWkUe7ed5omREY4lIrObqPGxGsPfHy2uwaS5IuapAgGpVHc/C+UXwQiUEV3r+W8a1MaTEENOWMKtLWZ1gQ43iZlxkbHq5YXbDJSqoSTQv/xPD58+8y5MNK4NZTkKlXqEhbbYb12PDfjhYnIVYeYS0Bha+LnTvSm9gHVDFUCerOQFzaEGLmI74IoT+yLdfN56UN/bhLVFuGJRZdgVLx0s8JkR1RUV3dgO905Sz4DTFdXbqs/G2C5GAbXpjN/sonaAAZ8jGmm1w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kqZzUcUI7g9GrNNQb568EFpHtig8R3NmjYR2Lpu3gEg=; b=0Uo+xZqCxDgZR15i8vPq9u/+GxqwOeMLoLiWGuw5TNtyFTWqOsXGUR1aZvaX8yoVkeglZahMlaF70mdD0G+48BEFYz+Vv7uXMbOM1bMQIab0Kk1xR290O8idWrPF+FGBSNn5IeoEW9l/I4kJxv5/7rqEdzW3a7OW2DzCz5SOUf8= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ1PR10MB5978.namprd10.prod.outlook.com (2603:10b6:a03:45f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Fri, 11 Aug 2023 17:07:13 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57%4]) with mapi id 15.20.6678.020; Fri, 11 Aug 2023 17:07:13 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v27 7/8] crash: change crash_prepare_elf64_headers() to for_each_possible_cpu() Date: Fri, 11 Aug 2023 13:06:41 -0400 Message-Id: <20230811170642.6696-8-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230811170642.6696-1-eric.devolder@oracle.com> References: <20230811170642.6696-1-eric.devolder@oracle.com> X-ClientProxiedBy: SJ0PR13CA0130.namprd13.prod.outlook.com (2603:10b6:a03:2c6::15) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|SJ1PR10MB5978:EE_ X-MS-Office365-Filtering-Correlation-Id: 723ce4f1-516e-440f-f6c7-08db9a8d682f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /5VCZPgAMFvYN8YznkcxvPPnDwYjIrw5mktrrXU+Szj/7o2XOtpSAcFz9eIQHjKMI1cgUBoBuaAeRE4sIrm1yugo2RKG501qVPSBs5PD6/xtsPfNKjybaXTpKGtXfypx54MvTeACt8uVONkbZ0dxHYKhRhja00vJLJnaUGz9F74UKg25vxauxUJsx7dEvRkmPP7RWcvS6O+I6OfwzYd/Mw+DjinzmtnmyY6WCn5LtnPJy4DViXqmU38sPvJJqnQUl1G/tKkd0kyZ6MEuQM1CgJGuI0xyljrWcp6M/lCaI/NxnY9qPE3o1dedFV83I6b3olsJqS+gr1hvQkDr5OBnN9t/YNRhhwFA1Va5q4BknATBYxY/G5c5l5pgt9mFGI07m4LaY49D6s77cOAGKKz3zGBZOvpKINS5ow2Kn0TywU5frreluK9vWl6ePBru+XwDgFRFq6slpiHFhnOh4IwYLyeNQiobTMCGbfBz8jfZSERiH8OiNtL7+/jckOyzR6z485ycMewW2gGih2uPXTS32f2mCNH2NWgjpoGwzzMtefJeGVwKE6hN4nFYZ0otzlRJIYm56zjH/B4jpPsTlM2Hh1RahpGwN2+ZTNFugD+Akd8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(39860400002)(136003)(346002)(366004)(451199021)(1800799006)(186006)(6666004)(6486002)(6512007)(478600001)(2616005)(6506007)(26005)(7416002)(107886003)(2906002)(1076003)(7406005)(66476007)(4326008)(66946007)(66556008)(316002)(8936002)(8676002)(5660300002)(41300700001)(38100700002)(86362001)(36756003)(83380400001)(921005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OGtu0+J8dNMNlkIPSme2PosuiRf0aWXn7CWUKtH2MXzmPralM/N5l1fI3DYbiBzZ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ZZnlat1JjL0V9o1hAtsCI+vP6oX2AvHctQGBdK36gGLj4k4x6YFJy8r0Pml8mWOCkK/X2HdCwflhcvjKgh+WwJZBVMw5o6AudC1aWkU7Nq9eSm3jCdZCl/JTVLHcVDuUoDUhLzMTuW0+76cmAcfT8sHBcrs1ggCoQ1ODZt0BBcaGz9wsb/6LlZIZKgBqzg0Tr2W3QH5DsMEeLlrTBsYJ6wdQtUavQvSAJQNLTLkiWf+tXHH8UVo/m5O+k5Khlx6Y1AgHUHEDG3bKrHwKc4RTW770iVxA067d3hGZwSuGgggLUzOP/1thDa7UufAf0+TDRirAdoC/khZr2gsuJIAMYk0VYU9Sli4RbfzEM6sORrxzkTY2jXfzj0qFuomSwm8CToAXaK0KpVbsQpL4eWYXfFM4orIXRylTxatAPiN22VnXKtY0ISi15MShrLpxyZbdiigwxEpZ+ccLaSkZPiG2GXGaCoZe5SHCjdV3zTLfrlgij2EDmx6Ne2whmSMOK7t+ng+w07C0PoW6t/fBHcbOvtvHnb9epA7+ocQw8Ftj40QEcN/tQUfUk4reTR7MvApbccQ1/Yp8WKYqReQyiNwiKIzUQliNDCI1zyYl0JAmSHgeorIQDU+q7IoUCFP4j9Rw3MmgU4Pbh9tDGvJyexINJcfHHxS+YEwTYQUhWXWRGrDnt9juo8LQ04kUUa2Tlr6vNl95uF0d/XXMOfSQsNzoIFPNFdYh+cUsawo7pq5ZpRFOi1o9CPrLOvqC4h0FoTstB40oBeNJeBX+bmoMMP+rw8vxNeUpvSKuwgHYO0fSc4H+seuu/lcvPTGsij5YunEdtbVw4yj/JB1TtG69NPE3XC5XuslLwy+gUUbfWiE5RqVrcxtCu/Tpa3/WKvXTacIycxztwyk8wUFXwc4GNc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 723ce4f1-516e-440f-f6c7-08db9a8d682f X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2023 17:07:13.4498 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vgskGlM2/a48AMssLoE9cXLeb/PzgJXgFR6ZAoOnwMLStxqyrPWGm4MLmGI4uLmqJx1x2Jz5m+/6mtgsZUHQuY5jgyl/dtBGpgSKmqELZDE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR10MB5978 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-11_09,2023-08-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 bulkscore=0 malwarescore=0 adultscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308110156 X-Proofpoint-GUID: Fy35Q8OkgxJX8fUMFE--nNe8DJOVb3Ui X-Proofpoint-ORIG-GUID: Fy35Q8OkgxJX8fUMFE--nNe8DJOVb3Ui X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773955203943770418 X-GMAIL-MSGID: 1773955203943770418 The function crash_prepare_elf64_headers() generates the elfcorehdr which describes the CPUs and memory in the system for the crash kernel. In particular, it writes out ELF PT_NOTEs for memory regions and the CPUs in the system. With respect to the CPUs, the current implementation utilizes for_each_present_cpu() which means that as CPUs are added and removed, the elfcorehdr must again be updated to reflect the new set of CPUs. The reasoning behind the move to use for_each_possible_cpu(), is: - At kernel boot time, all percpu crash_notes are allocated for all possible CPUs; that is, crash_notes are not allocated dynamically when CPUs are plugged/unplugged. Thus the crash_notes for each possible CPU are always available. - The crash_prepare_elf64_headers() creates an ELF PT_NOTE per CPU. Changing to for_each_possible_cpu() is valid as the crash_notes pointed to by each CPU PT_NOTE are present and always valid. Furthermore, examining a common crash processing path of: kernel panic -> crash kernel -> makedumpfile -> 'crash' analyzer elfcorehdr /proc/vmcore vmcore reveals how the ELF CPU PT_NOTEs are utilized: - Upon panic, each CPU is sent an IPI and shuts itself down, recording its state in its crash_notes. When all CPUs are shutdown, the crash kernel is launched with a pointer to the elfcorehdr. - The crash kernel via linux/fs/proc/vmcore.c does not examine or use the contents of the PT_NOTEs, it exposes them via /proc/vmcore. - The makedumpfile utility uses /proc/vmcore and reads the CPU PT_NOTEs to craft a nr_cpus variable, which is reported in a header but otherwise generally unused. Makedumpfile creates the vmcore. - The 'crash' dump analyzer does not appear to reference the CPU PT_NOTEs. Instead it looks-up the cpu_[possible|present|onlin]_mask symbols and directly examines those structure contents from vmcore memory. From that information it is able to determine which CPUs are present and online, and locate the corresponding crash_notes. Said differently, it appears that 'crash' analyzer does not rely on the ELF PT_NOTEs for CPUs; rather it obtains the information directly via kernel symbols and the memory within the vmcore. (There maybe other vmcore generating and analysis tools that do use these PT_NOTEs, but 'makedumpfile' and 'crash' seems to be the most common solution.) This results in the benefit of having all CPUs described in the elfcorehdr, and therefore reducing the need to re-generate the elfcorehdr on CPU changes, at the small expense of an additional 56 bytes per PT_NOTE for not-present-but-possible CPUs. On systems where kexec_file_load() syscall is utilized, all the above is valid. On systems where kexec_load() syscall is utilized, there may be the need for the elfcorehdr to be regenerated once. The reason being that some archs only populate the 'present' CPUs from the /sys/devices/system/cpus entries, which the userspace 'kexec' utility uses to generate the userspace-supplied elfcorehdr. In this situation, one memory or CPU change will rewrite the elfcorehdr via the crash_prepare_elf64_headers() function and now all possible CPUs will be described, just as with kexec_file_load() syscall. Suggested-by: Sourabh Jain Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- kernel/crash_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index fa918176d46d..7378b501fada 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -364,8 +364,8 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, ehdr->e_ehsize = sizeof(Elf64_Ehdr); ehdr->e_phentsize = sizeof(Elf64_Phdr); - /* Prepare one phdr of type PT_NOTE for each present CPU */ - for_each_present_cpu(cpu) { + /* Prepare one phdr of type PT_NOTE for each possible CPU */ + for_each_possible_cpu(cpu) { phdr->p_type = PT_NOTE; notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); phdr->p_offset = phdr->p_paddr = notes_addr; From patchwork Fri Aug 11 17:06:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 134653 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1305841vqi; Fri, 11 Aug 2023 12:21:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrNPXVTMMd/Z03bzRTEHybapzkt5NGp4pL8EkfOqKKapKlNr5P/YlmuVRdcXp3oHzN1Vl4 X-Received: by 2002:a17:902:db06:b0:1bc:8249:2533 with SMTP id m6-20020a170902db0600b001bc82492533mr4164763plx.42.1691781682936; Fri, 11 Aug 2023 12:21:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691781682; cv=pass; d=google.com; s=arc-20160816; b=Z+frZQ0bFsUwYXbo4Za0XKRCNlIQVjKCDxmY7S/X1XlBa/+SNYlTHG6xhP3O/YM0Lm +Zm8StGhpj2Io5GGzEiWCehPXQTpXaIGDKBWCsQvtKbzIa1mAfhY+nQi/jQ4zNxAu188 4aOUi6Dw6dPzSs0NeficvE66AI9w+onRBzTscH7bmPpQfOTKuCTP5VcDjj0M+xLORHGs vDrtZ4e2Out8B5NRJjqv6gA73OPoyUTqinaJe4F1zPaI6eJwhNNBoylEqe0//MHc4fIP OUoSgXreghyZMmmQz1Gld8Ejql4DFsVYXoW5R4H5Md7AZV+zlXf+dQoANceBjRXo5mb7 wbYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=o+McSM2gKtujfwRfyeOsaE02Y4bKTLqqTyQF/lTUOqg=; fh=ZbNC38sm56YRcxo0eY5DlCjDElPeJYCNHKxhiyVbz2E=; b=rCgRsUwU4EPHz/yGeHNVNB49HICjO7yl/6NX0KMvpUPgF8klDtV7QMyB8fY9HyDEsz poXpOSCyQfjXZLKN55dODJ+ehm2fxRuacU664gub/7888tyC6pNid2yRsK8QEw1Ur4zE /qLpfANBruHM2aAgKz4DthTgxgdzcZxrTPTqBTD1eoOboLYeqZOShQK9ACkgpqqU52IY Ret7A/tWdQ0jqqnTI9HQOkafSpHsSLoHNldVoW+kOBUbf7kSXqc/9VTLzn2kMCQcsL6l yai0tePJsLkbB6skRotJ7lgs5Q58rSYsWGrvAcDCQo/SmomzCX1ODl2i5ABOvqwrwJDB qt8A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=lgaJD46Q; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="t8um1F/K"; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12-20020a170902f60c00b001b9d2010c39si3827470plg.192.2023.08.11.12.21.09; Fri, 11 Aug 2023 12:21:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=lgaJD46Q; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="t8um1F/K"; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236726AbjHKRIf (ORCPT + 99 others); Fri, 11 Aug 2023 13:08:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236504AbjHKRIJ (ORCPT ); Fri, 11 Aug 2023 13:08:09 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E666730CA; Fri, 11 Aug 2023 10:08:07 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37BDLQYa006209; Fri, 11 Aug 2023 17:07:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=o+McSM2gKtujfwRfyeOsaE02Y4bKTLqqTyQF/lTUOqg=; b=lgaJD46QDEz0RB7w0/dNRKzErz6jXRofjGW9vyWRddJDD9FaaX+zeleeJW6fLOVfEVUU 0NgNaycxd7MDwOe8g6d1xXaGB3ks0fk0N2NHQIpK+juT9I1MiQfxc4RHULkWiqjseiu7 dTbJ1rqTaoAjs6Cc47whaAmCufpCMBv/yq9JJdARLERHZ+rgx5t2AB539sJgsxcnRyCe Z1BcjnF+cXhfdghnrNg0uXFW4OrZ1KSsu6CyrMSNGaN7rXpY3oy+SeQTC0nhi2eCbOoK dEjV9Lrckx996wDUfadjIpkLFifApDKcqGqRd6BeqTdgOdW9+uXxSEx58DzzYtQ1JHo6 4A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sd8y49gvf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:07:26 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 37BGPJGk000435; Fri, 11 Aug 2023 17:07:25 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3s9cvgj0bp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Aug 2023 17:07:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gY5+AYyFPbYTtNecgDP6xJTM4gf2PIYBTe2n3GHPNupaeIY6Thu10bVoKgjVpXyhqNsevexc3kKN/Vi8gtGhLX3F2Q+knrksFSRQhwd+79Qm5/vffLNdrbawDHiQGAo/PgAxHBMgxSaNaDn2NGDDUpfAlJYIbKlEKM2oZgh5pEQiKnkAA+iha6UIw65Mpq2NhEvbgBpdqcdb3wT6f9fYa+qkasWic66rX26ReZ5CX+dTsEcwrJeJDKKkn884bRq2TcOykBAKTRjXzm1KTDJ28w5V0J7O0DbvjdUXoBDH8CeZFtKI/CTbxOC0Eaodke3hgKt3XDCLxzK9SP7KVCGO9g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o+McSM2gKtujfwRfyeOsaE02Y4bKTLqqTyQF/lTUOqg=; b=TcqVRGozPK5rhWd1N8K/QbnUyjJNLA1elXO5gMPgTN7rt//H4pkHXOL0OHo97fe/HpCvTvW3+dEUrE1vdMzgM5NJnq0olycox87RrVcLycXT+wrpx8HieEoEQMpFBqiswwKA2XMUgm1h9lrztXMCfzpnk/E2UShEnVAfAZGWTTG9yjb1z0BXo3bgQ6x+WhDaLIp0zIk/G9hzri/O2NTQf5HAy0+3cq99CbFrdHNHNW9Is7XP9KUKEB0Cc8j6iI4ykKger5W5NI9xnQI5zpMZBJpM0gFT3lsGuz/8TTYiza6hRIlGAkLWj2eN/TB21oI0cKL8v1cjBknSl98MJgC1vg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o+McSM2gKtujfwRfyeOsaE02Y4bKTLqqTyQF/lTUOqg=; b=t8um1F/Kzv8Z2nUFjy7LAw6DG7+V0l/V8QjymYBgVC4TLp8JN7g6HWdg2LnoiFIwNxuxb2EK1iNThpdnuh9uhZoUZp648DfQjPnbYl37DEqBPJF57N9mb50xrTT3gv+t3N2OdccAOcbfY5BUjYvYdhKrHe7acVr49ucmuH4w87Q= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ1PR10MB5978.namprd10.prod.outlook.com (2603:10b6:a03:45f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Fri, 11 Aug 2023 17:07:16 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::be4f:55e6:89c5:4f57%4]) with mapi id 15.20.6678.020; Fri, 11 Aug 2023 17:07:16 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v27 8/8] x86/crash: optimize CPU changes Date: Fri, 11 Aug 2023 13:06:42 -0400 Message-Id: <20230811170642.6696-9-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230811170642.6696-1-eric.devolder@oracle.com> References: <20230811170642.6696-1-eric.devolder@oracle.com> X-ClientProxiedBy: BYAPR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:74::23) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|SJ1PR10MB5978:EE_ X-MS-Office365-Filtering-Correlation-Id: be543831-d258-4bed-cdea-08db9a8d69e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NbRgzrbLGIerVN6TYYHzfBQMU5KwxuUdhVTdm6MleaFOrO/+Tpn7fk3yoTTeb3ggCDTa+dgHlT7ULRu6kNzU221haocJO5K7jIJsx5W+QpV/dj/WFoF9FMdJwlXiv7YyVV9Ba1+75cPmFz6YO864sLmmn7uCbnQy0Pm1ERrOl3eu5MzV1rORPHlHIHS1stQyB6LL7ATan+5ng+SR+N1QIlZiK5kb9fbfny5Ry15q79+tcSG1xVybkeIV/KDE4/5RIbAtaXIXbJeDHBiJaxhMRnAVeGrpP4YE3KVPag//RktqjA/rMh4L8orhZFR+dMMIIJ+a7mDt69EFdzF76Q0WJvNfbePL+fXFNsGA0gF3/0IH8RbqALnYZlVTcX4p4Goeej/ndm8mxAuUoh820mbM33P3VqvQt7QUlyFD2WMRf0oefXmnsZJwuMC0nGCfKqmxxFfANayv8asN2gjkAh2PbjkZqHOtk2zVITl987mk3m3IOPAXuxrpmoLRUEYF5wRg+Cws1LrymFnAgWnMBVzGJHsfz+gcfaqc8ZaYPdqPlsbRCvCWZjOwjOy++om0h7PZ+G7MDCggkm1F4GrCGwtdQ2HZnh5USedBqFPuc36L7YA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(39860400002)(136003)(346002)(366004)(451199021)(1800799006)(186006)(6666004)(6486002)(6512007)(478600001)(2616005)(6506007)(26005)(7416002)(107886003)(2906002)(1076003)(7406005)(66476007)(4326008)(66946007)(66556008)(316002)(8936002)(8676002)(5660300002)(41300700001)(38100700002)(86362001)(36756003)(83380400001)(921005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rXmUMaZyptWiNWWt6YqcTHzWlQvQPeY5OqIDG4BtYojjk7uS6PeDSb+0WO2ljlele7kieZpLm0LtduwmXVaI6eVrukHdjcq31FrICmgrxcKNMFQocmbuBMvMyeMJsqsyDYaRFzs/ZO4TCmali2gPVYsbwFnJdl9Bb3YCX02Svv2G9Yqk8bdGn9Jet461kz+J/A2J2qTMKrIGj5aMWeAEi0mD/NYDm4uQubQDrlSORY3V9BY1zmnsOz8Oe1bApvjjbozkLzfgDGVjLxs90kXkcn0Sm2RzJoaRHxvzSpqJaMLskl35J6lpaJSN3mDNOfgTXyd2KedTiNojlonZ4+Wz5MTIMegUruxJCsrEWO+wYmHUew8pvBQ6P4PPf1ifwKzMKjugVXw/45CZInIE33yuvNQAuuwLu7kd1eZvYS6i0Vex3M6VYhUB8YWGWKCJPnBhumutFDmLfb0lEzoyYWlEGc/k5gHdljda8Bo5bDfzPE8cdSMpwFWxYCyekaBJc9lTlc+ztD77HBI2rbdlmJ6yBNGo9NGqR3ad5XYFRip+UvByeHLzKxOLAs6gYK4wYa2gP2/9Md9CrofDNWwinGdyyGYD4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wfYRQNFq52YblXhTNW3ya5twz/cAryU22E6V9PCF+vY5S5GL1tn34l6HMbzlGDvVAmXcqOHAJ00sS6Ce3hjGAzmL5MoaGt1ATRBoEuY8VsdYEik0oOYxMeyzkrH3lsA3TweFIt1/3j9rCnbesFxKqlxJ2/9R8C/6vTu0hvl+AM91Tu9ZIa7DakUz9Wrl0OKhIRwn5aLfsTKh+2DubUfxnAayaTDqo1psg8MDe6+gewB4O1CcY3aezi+ahMOFCB5VIUAu19S30YTSY+MT+gLE7Y1Srpcai4hLgi344kbLHdVMJ1hfArZmjM8SX5gvtWcaPKDlhO8ZYLXEEbcoRjb4AyAyBlwRnZAU91sQqBBy/OMmXpD5qcKlmj9rpoiNG57/9wy5FTNdTNwpJe2U= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: be543831-d258-4bed-cdea-08db9a8d69e1 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2023 17:07:16.2956 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hMvqRlL+7lr8IMQhNSnolQEElqjhZVEFv2OplbAv9e5X8IKdeVSPJ9ZoGFWpzTg+l3fmi4kW8dfZ5TSoQOUrkUk8KzI+1sxPbWUg3RSVfCM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR10MB5978 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-11_09,2023-08-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 bulkscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308110156 X-Proofpoint-GUID: bu5R73LzN88UCxlltWa3cN5NiCrm7_MK X-Proofpoint-ORIG-GUID: bu5R73LzN88UCxlltWa3cN5NiCrm7_MK X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773961670089362537 X-GMAIL-MSGID: 1773961670089362537 crash_prepare_elf64_headers() writes into the elfcorehdr an ELF PT_NOTE for all possible CPUs. As such, subsequent changes to CPUs (ie. hot un/plug, online/offline) do not need to rewrite the elfcorehdr. The kimage->file_mode term covers kdump images loaded via the kexec_file_load() syscall. Since crash_prepare_elf64_headers() wrote the initial elfcorehdr, no update to the elfcorehdr is needed for CPU changes. The kimage->elfcorehdr_updated term covers kdump images loaded via the kexec_load() syscall. At least one memory or CPU change must occur to cause crash_prepare_elf64_headers() to rewrite the elfcorehdr. Afterwards, no update to the elfcorehdr is needed for CPU changes. This code is intentionally *NOT* hoisted into crash_handle_hotplug_event() as it would prevent the arch-specific handler from running for CPU changes. This would break PPC, for example, which needs to update other information besides the elfcorehdr, on CPU changes. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- arch/x86/kernel/crash.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index caf22bcb61af..18d2a18d1073 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -467,6 +467,16 @@ void arch_crash_handle_hotplug_event(struct kimage *image) unsigned long mem, memsz; unsigned long elfsz = 0; + /* + * As crash_prepare_elf64_headers() has already described all + * possible CPUs, there is no need to update the elfcorehdr + * for additional CPU changes. + */ + if ((image->file_mode || image->elfcorehdr_updated) && + ((image->hp_action == KEXEC_CRASH_HP_ADD_CPU) || + (image->hp_action == KEXEC_CRASH_HP_REMOVE_CPU))) + return; + /* * Create the new elfcorehdr reflecting the changes to CPU and/or * memory resources.