From patchwork Mon Mar 6 16:22:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 64920 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1941786wrd; Mon, 6 Mar 2023 08:36:43 -0800 (PST) X-Google-Smtp-Source: AK7set/NPiRFvvf27hWA4a/0Jp8YxLLAuClqaAo0NeXhOeWGfj1hoVTsXCDKiMW6sXB0XYbsOc7V X-Received: by 2002:a17:902:c10a:b0:19c:e664:5e64 with SMTP id 10-20020a170902c10a00b0019ce6645e64mr11084831pli.2.1678120603027; Mon, 06 Mar 2023 08:36:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1678120603; cv=pass; d=google.com; s=arc-20160816; b=bbAk4/42uN/TovJyvc05gpJb0GWxkse5vbCq/X+1Gsxi9gcb1RqODBvDDyPESxDzLC qymkDcUaSBtUXsh166X/Tgd3jDSxgSPIP89yINAxlTUBBpMvvT8qH8qvu+fn1mTVvUoo ejxeQA698/Xj0EuYCaaLy176jpB4hWFahktV4XGVxohRczd0EpCH6IbAcN4fvsHlTI4d q58mFWPaoEXh1MaWPCEHJBe4wgeyGKmzhHXHjxU8jV3udlKjNXO9eQw2M2BSZg3E85eq SjCe94FQ0E6AKm9edpLETJxeroUk4sSMor9gaMfAQCymoLt1VPAbsbvH3baTg2pkMJRD 3sBQ== 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=0sBOBhpEoQMqxX3CYrsQSHX/nxiAqsT/1UeBSsRmoY4=; b=jMn6S5TuQGoYWIG5E9MUHuVMDMMfw1c/BJ3LqjEfsgRmYequHFJ6AttrnGQ4o+UPg3 DSYHyDVorybb3njmmxWxs09UacFG//HxmG1QnHPLvUQLp5IO9zT8WBtXO6NhPW1RC/M9 2jaMNu04uFmxxJvS0Asjq+5dMV8NJVN+a1QwucZLwueYYmvU5qN+o7EtdG7+YoFi4Mk8 eFSwd6qW2hinmtFvcwN0IYkCFiqyvYFNwco6yccri2m2h+XjAhJrCAZt/jJa8w6pdLyS IEmotH7OilUqL4tA5/089hEvlgA9Yhdmvi4F5TKxoFEUhaC5+IpU43HuMQeSadZVSFFW xNAw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=DKwkiofY; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=PaJ8mRWI; 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 y3-20020a1709029b8300b00198a715d260si9027524plp.565.2023.03.06.08.36.30; Mon, 06 Mar 2023 08:36:42 -0800 (PST) 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-2022-7-12 header.b=DKwkiofY; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=PaJ8mRWI; 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 S230149AbjCFQZl (ORCPT + 99 others); Mon, 6 Mar 2023 11:25:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230114AbjCFQZY (ORCPT ); Mon, 6 Mar 2023 11:25:24 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D2046A4A for ; Mon, 6 Mar 2023 08:24:11 -0800 (PST) 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 326CxGKT013918; Mon, 6 Mar 2023 16:22:44 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-2022-7-12; bh=0sBOBhpEoQMqxX3CYrsQSHX/nxiAqsT/1UeBSsRmoY4=; b=DKwkiofYwMMGBDgGZLytpLBLwsrS9GkaUaLp9AXiEl9Qi4MlLbdYIaqZ+gSTXqp0kuz4 wo4k4DTBtN6snqohXKh/ghIwoPXfnsQVqj6FsbdcIZbfCvGAfK44KLzMZM7b1xsvdtZ9 uwEXRpUcgcK/QuZQ3AH0MFuzw6BjiNiM8oGKXBnwNKYollTnvfdR+ypXopCuEYLIHLWz u8IZWdW6Rqm9jXobaLUZNQsrkQtC20LpWhKKQf6jeWh3wHH11NvXmoidu1192bBQo1fK 6o5D/xA2O3nOLkaRJdbvqz8HJ2Z8Hxe/rTqhAYlK04jBQ+oEA+dbZFEh6lopv4uSWDkH 4Q== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p416wka94-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Mar 2023 16:22:44 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 326G4u6r026640; Mon, 6 Mar 2023 16:22:43 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2106.outbound.protection.outlook.com [104.47.70.106]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p4u1dq61y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Mar 2023 16:22:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SVe6Wcnfu4QQsEWIKpxqNyKRhT3hggvu68LwH/7tbCaQfFPjLUXBhSubIwu+HGpfPScMHjiXFpvClZUiDnxtVBW6ewex7yv/U4n7lxZp1pZbIDApzCX8/3nVwcpKp9O+ng0hBQEPWqr5DViIo1gSUx4rgRTHe9NJzNjEm4uKuar47C3ma8f14CBxdUM3+fmFp8+LRt4MU4bHWQPTDq2Yr5jMTwU4/kGJ1SGYfa25QOaUUeEURYWbXMl+AGA64G8sQnXcE+yyX3ld8A+Hb83kJidEM/mH/CRvRNDSINXS7QRuVKhUNWej9YC5xnIuj4siHNIs1dFXw1dufEa7nlDqcw== 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=0sBOBhpEoQMqxX3CYrsQSHX/nxiAqsT/1UeBSsRmoY4=; b=aZAQ0YggQTQ6SfW28sh8dcRV/mD7iSA2OkfCRGP6GgRChq0Sktuq4M4MLbgCpguqk93t6jiSMf/vOmOciofUomvDA9c/arM7RJ38n4EuhzGi1wbjSx7DhcFgyI+/0Edx/x60B0Epef44Uh8OP3Eo293ouuIR/qm7zwbeAVAp32VXoENb6Hu82mIJ+dhhoDBdevFwhDPAv70Wy0JbZ+eOulFfVm1AhL5DzhSxRwc0mDB7etugF56aKjJoKT8S0AVgxHj1L1eHqBWm5WTsI+ceTfoDxTTUenfFZo0cdhVF/WhlZc3zCLcP9jli0t2YPe29Ws0O7zC3dvJQKl9Jd+fRYA== 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=0sBOBhpEoQMqxX3CYrsQSHX/nxiAqsT/1UeBSsRmoY4=; b=PaJ8mRWIohRSp9dpEh7wzwi4jE+c7S7ElpE2Gg8wEPNB1WpPS1mEUHqFiNoNCMGvc2Dqs6RGjtAkbf6Fq7mMIarGkge1p5r9Xo3gcciVefQSEnsYm6QW7rv2vvO0kv3dmee30H9MV6NTSI69L+CGcqB9+K9vE7Oe8YggG5azf4o= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH7PR10MB6530.namprd10.prod.outlook.com (2603:10b6:510:201::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 16:22:40 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38%8]) with mapi id 15.20.6156.028; Mon, 6 Mar 2023 16:22:40 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v19 1/7] crash: move a few code bits to setup support of crash hotplug Date: Mon, 6 Mar 2023 11:22:22 -0500 Message-Id: <20230306162228.8277-2-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230306162228.8277-1-eric.devolder@oracle.com> References: <20230306162228.8277-1-eric.devolder@oracle.com> X-ClientProxiedBy: CY5PR19CA0073.namprd19.prod.outlook.com (2603:10b6:930:69::18) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH7PR10MB6530:EE_ X-MS-Office365-Filtering-Correlation-Id: f8b5abeb-cb1c-4d85-eace-08db1e5f01df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PU+2sWhK41jY98KoFRmTzCfli7uHXrctrBfXo1Fhxu5jjX2kCnmKRqy+pHiq7GG5ld2SmfMcSHC2l1TkEswIzPjUw4v59vIOYCPOYVPjYtI+hYBxPvYplhmIn7gmpW4XF2ss9J/q+WJIk6XbIG/76tN3DBO6PJPWfyenZHrZowapUbrg15NQvet5EAVk38gOAft6hx4irZ8k+w/7L9kbfd1MeC19u5VXCSUoVuqXJNTVmWL1ELwQ2Wno06v8FNP21XE8cMdG6grKerlIbNWvew9UjN1rmevxH0W04zOsgt/sR6CK0WsPLQHh3C+m7Ic3QeRdEGb8UhJySip5mFM9eeQDDdrL0sad+vJfRIOU4Wttg+TmmhL4nMxmjXu4PZIxBy1kTtFZdUfZqsBXlcJ6UNUv73bOB2VpPy3Cg93KUk/3z3mDZ26gEEEVI1Cy/g7HoDrHvmGAlPaSjngI2Vsv+vQl5DW21X5sccOzNYYgtdo6n9blndeQiPVaQ7DX2dnne4FSsKZcnNP6zWAkCzr6nLTWTJ6NdzEPvYAuSAa4DeKN4I3CUQMStb6fVJeAUFQVeDjAX3mzNNM3KYbO53EfpfKDReTH8LpWmKKiXau0OLpzZRHYXWPA8K6xkIYJGrB7Cy/6R2xaBD7dx02fpZV39A== 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:(13230025)(346002)(396003)(136003)(376002)(39860400002)(366004)(451199018)(66946007)(66476007)(5660300002)(4326008)(66556008)(41300700001)(7416002)(8936002)(8676002)(86362001)(36756003)(6486002)(478600001)(1076003)(6512007)(186003)(26005)(107886003)(6506007)(6666004)(2616005)(2906002)(316002)(30864003)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 56H34vb0m5R0v1v2bSftnOKok8kE9a9ywjjGePOwDvb9N4YPmqqvlxd3BgFNHo88S0tCsVKmHeetmjo5wqfoVDooVZN/FmvYqcwHc3I+mNIP9xXZoKvLWwWJm9fSaYnDL2SRozB2/rqS8SbKatb1TXOQGVOqf15attZsTJCmDzlXsajZN/28+CWX3kUlDdc/EOlotqC9Mc5gWwevmZjCud0CSwTXcCE9fGl2xUL5Zpqp2EONzR4OBHAtEga/mjaixSCkDfSn8FEP0yYsGevHitN2lVleSz5YdogHPuo2rHTqA7bAt8VwuAQBk+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+r/5XdMSdcARE9jhcPosdAntwOoCDwJvkNLR6vrG2huDNy1UnBs180w8UhTauBn4AxJ5h0p/09KujTruj+baTMG3hMX7x7Dk4lxngosXv2B+2Cmatop9MbTHd1DOLKuol2+0w77xhKFuhbnYErn3XYarUyG8CfAhfL6GyUWjtETB7ztFD43WFrS1s8obrUP5P9J1hIgS5O5ONO9eFBgXAyrVzYMUapxzunM9BkLLFBhwOvbUNEiIZuU0jnV5JgKm1ECy0ClUtJZKJzAg8NJulGDV9cDRNJ04QtLh9aP7LXZM1Sm0NNsllif+Nt2ss6eDx3i/gDj8BKt4RmdYn25geKAn14/0vrs/VK4Sl6SyHSv4aapJzEYf2wIpF2dluEsqDydeHytZrAOn3THgtxTtUhs+vg9PYLmzmhaxdY4TMASLntmAPdEA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f8b5abeb-cb1c-4d85-eace-08db1e5f01df X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 16:22:40.7265 (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: u8WMgCkjmR0bv4G36ne3lqwVfb/Yjc2dn4Q8WMghoQDk03Kh3bcziHhbRSpSBQx3gqFr/0eHNWsp/oRFsvmzOmPQ2yPN4ByfasiNVbLiwM0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6530 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-06_09,2023-03-06_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303060144 X-Proofpoint-GUID: dxgu-m26yJTBGYJ1aKrcJLccxIgfmOxB X-Proofpoint-ORIG-GUID: dxgu-m26yJTBGYJ1aKrcJLccxIgfmOxB X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759636989254453766?= X-GMAIL-MSGID: =?utf-8?q?1759636989254453766?= 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 --- 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 5dd4343c1bbe..582ea213467a 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 { /* @@ -238,21 +253,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 87ef6096823f..8a439b6d723b 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 dd5983010b7b..ead3443e7f9d 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -1135,184 +1135,3 @@ int kexec_purgatory_get_set_symbol(struct kimage *image, const char *name, return 0; } #endif /* CONFIG_ARCH_HAS_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 Mon Mar 6 16:22:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 64926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1942155wrd; Mon, 6 Mar 2023 08:37:27 -0800 (PST) X-Google-Smtp-Source: AK7set+ZfN9wKHHVNx0qbewEYvUsSvwg8ZCbYDuP5FEUA9ItRcYa+de83h3lipnD3pR1moTij48e X-Received: by 2002:a17:903:2288:b0:19a:9dab:3438 with SMTP id b8-20020a170903228800b0019a9dab3438mr11649986plh.2.1678120647086; Mon, 06 Mar 2023 08:37:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1678120647; cv=pass; d=google.com; s=arc-20160816; b=qqVGWghZH+5ZonUfQPHeMGK0q3yerCzLiuWOdWHr6guBpU7s9401EazNMihqdnRmSP k+QTre0ADVPJ7VZR6dRcJmw8pqH3ikBJIS8wg9kuE2cefN04TU8ap9ZzeEF2JfqO/ZwU jwT3hnn1UhtP3JCiMsbAat2mtqr0zno7toQgu8wYbYolq/W7AaRaE9uLFESiQs2Cy1m5 EisA/dc4nIAcwP24H4L6SDuw3y1c9sE2qJfaC38Cv53kGRbkVZUtydjO5gsy41v7q7FZ FmikTdmk+9fhsSysqQQuRZ2BkreFLBZbZ2k3QT32CBHY+CUJLgHujaWa9V1Xxw+53/ZG PO3w== 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=5RR+nmTV8tgATzAsxhlutWv9tznrbgyvKV40fB48SPI=; b=TRmD2PnGKVjL2n+fqGxHkmFPObm/EO3awWbNNB1tUg/tMHqmfY0hPRirjMbV0CaSpi eUTl6QrhOptg2mv5bDQ/KCybZRXwLG25FxWTj0PEQerKlWkg5JBxvNGPNG2hmCImfD07 wEHmlHDB0dR+iJ6l5IBXg4T0L1f4+xe2K/jyhXTLr6W2o5Z4PMugqEVAMAIOCUqJzFFu VBukwwhNdy+tso6i0CDdapQ1b6ii+Le7D/QZiwKIMeOakAvGBk8D1HKFl2EQCOUVpSgc DHRhPeUcerdUEz5J1YZqd0ZaMlvIz31aaOkXqqkwDNE0oIZY5iu4oZ/cwjEjpskvyajj om5Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=uVpXP1yM; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=d2PQ22Jy; 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 q6-20020a170902dac600b001968124dc22si10479635plx.560.2023.03.06.08.37.15; Mon, 06 Mar 2023 08:37:27 -0800 (PST) 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-2022-7-12 header.b=uVpXP1yM; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=d2PQ22Jy; 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 S230125AbjCFQZo (ORCPT + 99 others); Mon, 6 Mar 2023 11:25:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230120AbjCFQZZ (ORCPT ); Mon, 6 Mar 2023 11:25:25 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BB0339CE7 for ; Mon, 6 Mar 2023 08:24:14 -0800 (PST) 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 326Cx8M5009619; Mon, 6 Mar 2023 16:22:48 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-2022-7-12; bh=5RR+nmTV8tgATzAsxhlutWv9tznrbgyvKV40fB48SPI=; b=uVpXP1yMGBLYwdpVljgziZpud8eqbULPdQXNfMMmKm8+fW/+MuvuHIZ4vPPfzzgsgYEg j/8YAIPBzKwMDUGmqjx5xaiw7/C9g0bZl6DLg2DVm8x/AU6hTPPdIKDj3M0h2+WIBUeg /hgzfFnzJd3upVlrk3eHWkK6ukB2h8v+ySvh8b8tD9xIjcOCu2J3H1nY7ft0dMRpPLNP mcDdAo3HAm4qrFE4ubC/FUijkupWH7zeSjPcR1TpPx0u1k19uMda1mQRbc5J++zpiP+Q Y9++qCouMv17eOggXsFtS3KdAVu1xJcdnDq+MzUzScrXxKYBy/2bz1w/UslwRckQxXpm Ig== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p4161u9pf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Mar 2023 16:22:47 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 326FJ6EJ037036; Mon, 6 Mar 2023 16:22:47 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2102.outbound.protection.outlook.com [104.47.70.102]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p4txd75uv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Mar 2023 16:22:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DL1rZrlAFp/y98cCHE2bQG1df0lvy1LVQA+KDsny+ZEDN7UfPAc+xXCclohB74bCp3ltFzQ4Vz3l4fGxgCGSpdF6cUbY0+E/5j0yDZRc+qqXZ166XIU7xQvN61HLDN67rJws9Fatsg9sWUgOepJQvK1iUf1luvSEZ2mtzMbEdnrqQDCZ1JoBjlJ24M0vTqPwtrAqf0i/2yONLz+IxJUjWktuid5vFJc8HJha/N/Jn1P6ewt+N8AEov9bV6+pCGzocFdOEEu3RVG4GzwcFzUNwJGrGffXbfaw6VO6vQ1i8Jyw9ZeoNyusdF9sEPSz6u7jURhByPIK9L+UVBe3NsQdyg== 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=5RR+nmTV8tgATzAsxhlutWv9tznrbgyvKV40fB48SPI=; b=JpgMxpRWrI8pby1FyyXeFblvy9leroWzL8dfrESz6egDphmdc0UE+4FNXfRtz1/BWdqB23kKI9kvfOH2diUN+uhopYbuFbicd31u5Hh39XGbsTdgKW47hwmMzkVg9lInEy8lWsuKBdlk3Ab0UDuVLIijsnO+dViPMn1AiG0PZ6Ycd2UCN87/3JU0XPIjojB2kOGyZj2SkAxOvQNVCX/PUg4nE7xkHK0HeGf0EOP6RWf4mliEU+7eMwJRPTOMtXCqaeG+f/gDbPfhY/OIK2EnVGVgl2lqDF6Id8ws6q2/lutp0KriuZa7z/lvCrOTSH3AZi+5m/oF1q0ofhXT2nW7FQ== 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=5RR+nmTV8tgATzAsxhlutWv9tznrbgyvKV40fB48SPI=; b=d2PQ22JyN67p7w6t3e1Cm4kII/SGiiR5mwjLJv+rJ1adHkVcHUK0oPe1aycO8jGETT2TGwQ8ojD2v3oqnqbh2ZHoH79gwsSufA4tRrQ12nvvBFKXOqqUky/oOfDwPfJQOqbEL4LL3vHxthaBqjO1BzlxzeWwItU77nwi6v7kCDY= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH7PR10MB6530.namprd10.prod.outlook.com (2603:10b6:510:201::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 16:22:43 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38%8]) with mapi id 15.20.6156.028; Mon, 6 Mar 2023 16:22:43 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v19 2/7] crash: add generic infrastructure for crash hotplug support Date: Mon, 6 Mar 2023 11:22:23 -0500 Message-Id: <20230306162228.8277-3-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230306162228.8277-1-eric.devolder@oracle.com> References: <20230306162228.8277-1-eric.devolder@oracle.com> X-ClientProxiedBy: BN9PR03CA0477.namprd03.prod.outlook.com (2603:10b6:408:139::32) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH7PR10MB6530:EE_ X-MS-Office365-Filtering-Correlation-Id: b20e1063-2285-49d4-eca4-08db1e5f03b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Uf97XHhmlcu4mqDKMXWS5lX+60YzikqPd3vTricm9TyRTwFam4J0biZh/Ir6zfJS0SZfWt6Bkm6c9xlKOaoff+S7w99VB8RvfpQf0atDgJuhvmPKUZZfPTe6rIYhI+nNAH/rgke289b/gl5+D/pJj/q5P2tg/YnddP1EqZl4MIbTcSffGwFmw2BIAX77qoSDjd6MskNezRVmNdKLygUv/cVDAJ7RCM/ipq5ndRoZjampZ6AnVpDdz5zSFGsB8BsDLSzWQOoiv4Mmy8NkYO5gHnG5g1HUdwuzsKR7gXmXZsy/vryg0wjHcSAspY2jC8uZYSzGHMHJ0eLHN/+agWRyOlVj3qQ0e1FSEUr07U3a0jFTf8vXmg+iIFrSoMase1En+VfWcX5PtEVteKV2SioDPlyanhCTdiXZyuMJclRey/wK9esop1HaXxQWskLJqah3Zii5zuaaEy3iylf/IRDBeFv2tDNVr9j79tFNBfUGdccb1tVJtu41bmQ0jNv75hF/VZTx2AZXPoOO3Tht0WCv4ttG2zpyrtex60AJ03yamrWeqrvsboepzeVaFYGlKAEOpk05HkI3y43e2UZNJFTVa8pjyOQC2C0ehhqYchas/lbKOaah0T/Jjohbeh0h3fOprj3FnEePa8l4E8XHP0RNiUbJLChxkFqI16Nm2e9SwD/gITyivsXtFfsytUfSX9Pt 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:(13230025)(346002)(396003)(136003)(376002)(39860400002)(366004)(451199018)(66946007)(66476007)(5660300002)(4326008)(66556008)(41300700001)(7416002)(8936002)(8676002)(86362001)(36756003)(6486002)(478600001)(1076003)(6512007)(186003)(26005)(107886003)(6506007)(6666004)(2616005)(2906002)(316002)(38100700002)(83380400001)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /1yNF6iZZ7ADMWFmJYeNR4cE0Xf+FZUrHJeg6CGCYSk/6I02TS5c8cwGHuD9Stj/fxsvl37e86G9C7uXjrY3VoEV8bsBuwg7kEiDhzJtQpHrczs5JqmsPeLFpqLKmYAQtWbHbQo+mcEZ1oPWZcQw00RCt/RuolRZdG2dP6tZA95HraavBquujvx2AVoqQdPO50+17XkmkNaXMmwEPp1nSlDFpzOe/w7MkM9K6r+Ph0YP/3FFIpEUmnXI3HYN/0YFwZwew7CVV0NBhV67IIgVQ6MhQztm8g2PFbnJHvKiNWfSw7z7zqFKo0aUm1FmYVKZ4gUFmVpnFLykJKeb0yMJS3mQWfDTW++dZoNwr5dqof2WpRsnMTP/awhCq3iBw0lL/qbc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+LXI94VUwtXAISJqpNqZeTPCY3OLb1v0/xFK9kTuygQ9bJUqpowCflOd1Uh1ef4SDnEcxWrGWvZN/YuICjI2Sos2F5go5SzJrFiGULKLydRavmO6vJfZwHTq9hdzXYdh1Pl81MkQkUAXXTfzzSPbMCUkRljdBw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: pK0idrH0q4a8u1SKpOTBlPxmwO5v+gr/jkIwDkdZa0tOH4HKmpETJfaD11yg2x0x1oltmQYQDfLy9WYdHRL4F1Rml9U++e22eFU7dNBsH+1kdKRBNxxlI58mr1kAt9nA2t5sdV9g5DgUov8EcuXoFAOBdzIXKaFMV3z7zV1UxchEPEVC5iqLbjJEkI+FIM6eEoQICc8BEbgC+0MJQ7UNaEU/88R1VwWKVQbLO14wNDoYqx3455C9JmGlU1m8yh/SGYxBo2oV4d8ZSigTAxUuZK2qJbw6+imzfkyuTBgxeF/DeP4tynfoFZ5sfU3wtGgeQJ1870iznH32vqdQ/YlLFkxsokjUrdRmvY9x18pi+fre7XYByEF+5G+U358kP1y9Y5P19GdjVyobZJPejmk1wiVErLmzsKAlILgBoL0BEVSUUc1z2yCJpNxubdSIjBoHaIgdH7i1xkJjr63Rl7XjSSAaztm+o9bUuVpcbe8ZpVxLQ1krTZWu6kwRCFuvORlMrJ7LWLbJXujhBHRcGb9C3Wg1qhFIPpH5svPoShbopNgH8wDyuhD9barA9ZbZvrnJisnaBudosUz1oSBApGaeEJy94oYzll9McwCF1D984DY2tEHmVvYBzQy98BzL5R7FdMjIxq7szImgMUWOrwNvxh5STZoPwSyoQOFN00XykSm7Tla+f+I5pKeHXfphMMhOTdV4WmbEXPEcfEMYIP0z2xi8d5ViIjjvUOAK1D0C9i/j8KObF4hILpNZqYhp5/7X+6FZoym8Ge6AQ4JILteq3un+xjyhWjDXiRk4W3iTldm2rzJdk94F8odyu4a5EYTSOL5dRnBgFDvW314mVM5quGvMS8dJ3BH4xF/jt9mnkg5wSOK9kh5dcaD3tyzuWpdIJH8liyGS1qZQ81AytSN1jVmPx9r+Hibe80imuhkkYUU41Kx0xZIXIAX/kNQGDLLGQ3cG+ncWmI13gIPzVF768ReZXqYiWoD/YApYrsLu88TjomwYv3HPbLje7RRYSGy4HRtYJeuD2NUyxdlK9vrNltyTuQze438muGn4R9iTQljp+yzdCWmKrZC8PpGCyq5wjzhgJi0zAco1m5RWE1B5Kvnf+hyItuHZ96pkrqyPiVD/E6I03kL5v1HzoIcWUQJqnfRXaxB1CkoaQ4YurxjjgWs+fBYJCao4mFIQIDsvp2E= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b20e1063-2285-49d4-eca4-08db1e5f03b5 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 16:22:43.8068 (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: 76tKrDMlIVp6E4l5TWsPJOCCIn5FYGt+uwoZsv44kg8RV05xRbFiW+AIB9y7hWkni0IQtuXyrXg37WKJVRnlKLT+TMu7DvYIE6iAj1DABCk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6530 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-06_10,2023-03-06_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303060144 X-Proofpoint-GUID: hH7Yrzb8k6Y9HokLVbQm2WCLwI0MsFJ6 X-Proofpoint-ORIG-GUID: hH7Yrzb8k6Y9HokLVbQm2WCLwI0MsFJ6 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759637035214045042?= X-GMAIL-MSGID: =?utf-8?q?1759637035214045042?= 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, this 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 the discussion in the patch '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 --- include/linux/crash_core.h | 9 +++ include/linux/kexec.h | 11 +++ kernel/crash_core.c | 138 +++++++++++++++++++++++++++++++++++++ kernel/kexec_core.c | 5 ++ 4 files changed, 163 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 582ea213467a..2dcc4d65f5a9 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 */ @@ -368,6 +369,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; @@ -497,6 +504,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/crash_core.c b/kernel/crash_core.c index 8a439b6d723b..dba4b75f7541 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,138 @@ 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) +{ + /* Obtain lock while changing crash information */ + if (kexec_trylock()) { + + /* Check kdump is loaded */ + if (kexec_crash_image) { + struct kimage *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); + + /* + * When the struct kimage is allocated, the elfcorehdr_index + * is set to -1. Find the segment containing the elfcorehdr, + * if not already found. This works for both the kexec_load + * and kexec_file_load paths. + */ + 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(); + } + +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 969e8f52f7da..f2f9d41ce5df 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -276,6 +276,11 @@ struct kimage *do_kimage_alloc_init(void) /* Initialize the list of unusable pages */ INIT_LIST_HEAD(&image->unusable_pages); +#ifdef CONFIG_CRASH_HOTPLUG + image->elfcorehdr_index = -1; + image->elfcorehdr_updated = false; +#endif + return image; } From patchwork Mon Mar 6 16:22:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 64981 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1965963wrd; Mon, 6 Mar 2023 09:18:29 -0800 (PST) X-Google-Smtp-Source: AK7set8E8fjl0NH1vQjFs5V/Se0V9+61fgBLmcT0trJdPXctEr/+jP/1Cr4/gw0Pjc/F4MNhzC6X X-Received: by 2002:a17:90b:1b05:b0:237:aa9f:968c with SMTP id nu5-20020a17090b1b0500b00237aa9f968cmr11875305pjb.34.1678123108775; Mon, 06 Mar 2023 09:18:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1678123108; cv=pass; d=google.com; s=arc-20160816; b=MKGNEzYf1gUsqC3l4XV8Fato+L8FQOK6x3e4/5wejmq8x8O3DP6Csf9zGXktZrjXct ncYRHkeUTRKaA2oL+jf4FMePtY9EOn/iIfFkkBdkg6ytx8fgT2pZiOt76+ChMHwLkXdY reQCdCeKgX9J+HAXb9Ug9mDjqgASZNe/KffgOyi6hHFIffH1HJFsur7HRGrjyK5WYfH4 SxSAYQEkF/xw9mBkbC01m1XNOfTbenGykPZrI90XtsHR4mu9TO5ezDryvDm8LzA4cAQQ QRviSMtRy8SZp8mhoeGGthck0pzDthtyomr6zlhFtbmueNXk2eXdIm4DlWO3FCYnGd6r IFKA== 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=6CqhGscKm+RbjxnqUALkbeSZPYrNnXQIJKdLT4wiIfg=; b=aPgj5yjeICzfIr4n76+osNrs7tqFe+qH8qAwfNslJOl1nYOE63QujIN6Xu5VJqQahR Bltsl7NRmDM0zcS2K0Z1SdSku19VJR/rze80Hli2IPKzyrDZ2cSndk1ggIQ4RCmc1gmA cB6HASeKyfnP6jsuPit7sUaWB9uLT7fY0TS8NpMjqtSitYgUZUThssf5ewm6SjmxFd/z 1I3NvpatMCTh7kuHfewCghlSqU5S0Wt9hEFEkNBfeWze/5EcgTTMOMC0BSOpSpCG5Gke R29Y3N/iAKxWVWhYVgDYhk6qDmUySp3C84EbJTvixKfG5ufuVtEGuw7qeYunGIhtd1Kr EQAg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=eNtPGeZb; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="p/u0kX0D"; 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 ce3-20020a17090aff0300b002342e691837si10425111pjb.21.2023.03.06.09.18.15; Mon, 06 Mar 2023 09:18:28 -0800 (PST) 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-2022-7-12 header.b=eNtPGeZb; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="p/u0kX0D"; 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 S229643AbjCFRHh (ORCPT + 99 others); Mon, 6 Mar 2023 12:07:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbjCFRH1 (ORCPT ); Mon, 6 Mar 2023 12:07:27 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E96A6231B for ; Mon, 6 Mar 2023 09:06:51 -0800 (PST) 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 326Cx8M9009619; Mon, 6 Mar 2023 16:22:54 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-2022-7-12; bh=6CqhGscKm+RbjxnqUALkbeSZPYrNnXQIJKdLT4wiIfg=; b=eNtPGeZbtyc7qgpNnD4PRFMSD+7fRzL5MR/nk5mJLfBfkiY9DR0EFtR3KY2SRHloYcN9 bmP2XgxWxBGfzxiKnCSuKcyME3CGjSzYLjoYcv4G31+PkdgpRXbGjKVtGWQbg5RWoneS AOc1O0FBNYwybLzKevxKFuOr4aSsCYLn0hddMMFT9RFR8LZdyzp1y1nXwEAGcw7Zt37j 7I/iO7zbcXVFJFEVCdI+79+9tmUXXOy37r2KS6YolA96DmEexclHf9K+PharqT4gkKUL scScLqp8Jjy30od7yO76IzGy641WMSEy8UFADV4VV83CJYmQKILpzwKNX0fQj/WF9NtG vw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p4161u9pw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Mar 2023 16:22:54 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 326G2Ms8023373; Mon, 6 Mar 2023 16:22:53 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3p4u04xtjx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Mar 2023 16:22:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k42So/004rzwP/Rx+fO0Ur5Z9bUi7M+m8QLwtOlMdLoHCk9Sd82xrI/k2ZPKDR8GB0ZBt5Sg/G8jTtNfwQhOjWKElHxYEgsnceqe2DIw056Z+0J9RSgrZfNNbu9z3lVjbjmwKoRzfycBHpEaFscXdc0oKK30glB8ZF0Omw0Wi+oMyRox9geVl5N9KRgSK+l9MLmxc8uxVZwyPXCbQM8Zf38xvOcsXarv49zM7kVqBFUzRWixU6ikiRSV2goTWi4om4V9o3mzb0v07mxteizkD/sOOiW4OFgszPig2N6b/JESFkhRWXN09PenA6eWOCjcPxpLJZntn5ntebznrPsVoA== 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=6CqhGscKm+RbjxnqUALkbeSZPYrNnXQIJKdLT4wiIfg=; b=hKdiykFuzTgSyhfocvhqWDF/myan+Df6NOJ4PsyQ2sqMROYqyelRsmw+ziQOclNuDRN+gn37YCrnvlPcWrUrZgeoxZABhQe5uO1ajhZKOe+9zCUyVYum/wxdCmJAiaa7ZGixGZRRsycUCuX/GoGR9rdHtty3HRayMR7oZGMqvtTHZUWaTKlcbWvpQmz/RNodfbUy/iG+5oUCPzL9BWqwFhQ1LU2oyWN+SM19OzRebrrJ99/bJ4ZHIj6W133fht9eKcNtQp0wpSCpT4ZNTiNks9z1M6JxORfKnIpSZJ5DGaaq/Rmu/LpFN5WpzhAAkloUntCGRgtgjCTOl/w53lRBhg== 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=6CqhGscKm+RbjxnqUALkbeSZPYrNnXQIJKdLT4wiIfg=; b=p/u0kX0DEmengz/lWudcpzOQIweADsRmAmrVxBUVmBnuIp5kdKOBdUXo/IcBQcjdY95lOHHwhkoVWwrUZXrJru33q78Ac01SYTCjMWzVo9ZiQQGdfHP+3Khxk0yJUW1AP9OyliYoIHiCqgr63zKM4zsUGyYUzGJ6/YsHkLDH3v0= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH7PR10MB6530.namprd10.prod.outlook.com (2603:10b6:510:201::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 16:22:51 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38%8]) with mapi id 15.20.6156.028; Mon, 6 Mar 2023 16:22:51 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v19 3/7] kexec: exclude elfcorehdr from the segment digest Date: Mon, 6 Mar 2023 11:22:24 -0500 Message-Id: <20230306162228.8277-4-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230306162228.8277-1-eric.devolder@oracle.com> References: <20230306162228.8277-1-eric.devolder@oracle.com> X-ClientProxiedBy: GVAP278CA0016.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:20::26) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH7PR10MB6530:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c23c744-bb18-4dba-7814-08db1e5f0828 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eIHDdnm9Ioum+MtGOsO3ObNVmKA/d3Gp7hwOoXV3vCUT9AjokTQ77pvy/sNS4HcT8XTDEjlgNeoheqO82gkknxT0AtWWma+k3icArgTCxq75Bc1691ZB+lOFTd2eMmzNFlrc9LuHcY2lukpZpnG3CaVQLuI1hUuTyzgCGrgxyzizGnZnoKfyiHuVQLRgNj+fQrQQXZnv8nOSQz2BT7O9smtLzHdoIhXYh8r4ctYyScWuNBTrSiL9xid66EsQIr+gTr5GzMA6luHK8lPaZxAUl2PJ6zsqmaO7UsUUsQcTTRdz5b1HmnS9rOGFBqIYuHmHYUq0xdfGLeQFR5fHeuzvdYVpW/4B4QVoPmB+MIwJs6uXcQU3gRxR67QWkV0WoDLqyK1WVLyhHijfluLRnsMMmpxJYXvIRkGjNPAVrwjUtawVPvlO11oxpl5tPAs50d4V9MRQ1sJWXY5LWumfcoI9P/6nQC4u0K95B5iTVjrzmlwYBhZMdRBiiaKBlFFZevKCRAgk8OuvvJnOzb0wMYlLa4P7oQig9DH6H2Ft/IUR+WhiDZ1RG1f9cGeXW8C0typES5Ph492ziYRHJlXxGHbMLnBKG/WEtH6FwPOy1kh7H+TDONjRIafypbSBaTSt+VPf5Z+hakOKm0eZrFCD7O5OOw== 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:(13230025)(346002)(396003)(136003)(376002)(39860400002)(366004)(451199018)(66946007)(66476007)(5660300002)(4326008)(66556008)(41300700001)(7416002)(8936002)(8676002)(86362001)(36756003)(6486002)(478600001)(1076003)(6512007)(186003)(26005)(107886003)(6506007)(6666004)(2616005)(2906002)(316002)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Dq3aVG/6nch6PNj1bw319vgaD7ihAIUjDanKcS3/NDZr6rNUGyKB0+1H2Tp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TYIwP50Jb/wMri6Wf7laAU09yflqJXTG9o94jDDX4po8C8mSJD8jpzu7Gxrw3cE+oU6t/sVfbnah9yatdr0AVRSlKJjFt7WRaIQJcMAi3jPgaE8spXuvY5eoSbNzrgVa+YkaT+mnflXOYKhBb8Ttv8DktnoBwnI7xntZeV112MYwOdDli1Z/Qb+M+1MJ4Q2BM7BRfcZUUwnb2TUlpvnplo2bh8HGb6gLeT0QTZZAX4dyJ4xOYJXQDkWxaJKpgeU0sn2K1/jtP1eEHHNGN2siTc+Nn31E1cUVBo+09G3mhoTMbdhwE455SFk9qwncEWp/VkM8ef2XTTAYlfdCV+L+XkblXYD4sNQFGaDYNHgI8PdmMe0mTdVdLPCA6xy7nlojVt+LNp2f48s7sTnVM6t9cf6Fpybm7kb3N40Vx7pyyEkEhbOvKt0wf1YywCd5z/biWrjRSZMvZPi7shr3/YPOcd9zwnKjs27hIRYeG3y+bbhpdl/+UnIevAr8u8PK3WUSNYksY+/eyvPx4MZ/yY/Wn6X8yR3G5ZzulBPSg46r7LoMlfE1Dl1mqmMWUOZJR78r4D9uPOOIzQOQzx/5Ry4MnuXdYdw+yekI6LoeAYsjOWN8Hk2DKbsMRPn0KWm0DHGDzKs0JfsznOWiHVZY1zwQyQcAAr+aPLM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c23c744-bb18-4dba-7814-08db1e5f0828 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 16:22:51.2528 (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: /tiCyj6jx62GpkVBPh3PlTl8QMstGzTxMR+/kYX/BjtJj4mBdgNGvh1g1E1HvE7U8ZTmncAaYTgLIIvydZg1SwUpcARkIA2tQXu/a7/3M7s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6530 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-06_10,2023-03-06_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303060144 X-Proofpoint-GUID: h59y_Jzw1KzktcExkOQbg5HzXgKko7Fq X-Proofpoint-ORIG-GUID: h59y_Jzw1KzktcExkOQbg5HzXgKko7Fq X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759639616878800812?= X-GMAIL-MSGID: =?utf-8?q?1759639616878800812?= 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. This digest is embedded into the purgatory image prior to placing purgatory in memory. This patchset updates the elfcorehdr on CPU or memory changes. However, changes to the elfcorehdr in turn cause purgatory integrity checking to fail (at crash time, and no vmcore created). Therefore, this patch explicitly excludes the elfcorehdr segment from the list of segments used to create the digest. By doing so, this permits updates to the elfcorehdr in response to CPU or memory changes, and avoids the need to also recompute the hash digest and reload purgatory. Signed-off-by: Eric DeVolder 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 ead3443e7f9d..14e55fbc1ad7 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -723,6 +723,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 Mon Mar 6 16:22:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 65034 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2004928wrd; Mon, 6 Mar 2023 10:32:19 -0800 (PST) X-Google-Smtp-Source: AK7set+0VsP/QCpmU6hx2VE8DDbKWkRWkeWi+lU3NeMMuOXcO+HMn21ZjJGl7CeMuGHko3xmL4Ix X-Received: by 2002:a17:907:7fa7:b0:8d7:6699:3bae with SMTP id qk39-20020a1709077fa700b008d766993baemr13931551ejc.57.1678127539286; Mon, 06 Mar 2023 10:32:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1678127539; cv=pass; d=google.com; s=arc-20160816; b=PoPkl/VI/K98mrgc62NtfeO1C4E7qjj/0/I/aUhNFrI7eEWAor54SPp5HI0mG9a73R KVQ5UIAw31WIdqEvd/HBB9T08XW5aY0m8NXadUwstfuwXvkseUR6v/HRVBD0t1GWX5M5 OLtEFz4d+IqmxeXIpYuTelng2t9GtWukNpU/k1nJZGkuxpxWVy/DeFy4COP7jMfbBWSF SrN4stB9LRL7OYaXRfKIhNdkKBjqF0VTglCnVBoBwrdS/c+fEU5gSHW3X8clKnC1KZlc MDP2M+j3iXWLxvV7X1ay271l4VNLPkkLXu+tc/V+1tbHLyGa7smAyx/fG/2tOauImtZy dFtQ== 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=qHm4Qdh/f5x/LfFaP6306ySB97O/QRQxfBSmKTnF90o=; b=FggT6q//tIY1v42S7pYaNd7eNazrHToCtYDpcJXATYSoz6TNwLyAwbbxxMjDe9dOsU Y+cJFJcndZTwfN1fBQ9yQq9o3lrHK1NLjGlheaHvdxauU3U0mref6nKreA5Wp9AWnfQI YXqrK7WHuILd6VCAFvMDvHmr/cglvLWcsmftexUTKTesiVFR/Na1zzxsgHi2btVg8Mea SCfXatuelqQuBlKejF+07UcdMRLXF0hicP46oG7t4NafQK2YQhgKvP+JPXwnCa8n0R6W 3cTwhFVr4nDDB2JCf1xgWW0yOycmANn/5RWIjSJ1GL/Nijr8hFNWWJ5eQ2jMuo0+DHOG EYeA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=OAHwFF06; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GqV6Bilt; 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 xc7-20020a170907074700b009149300bd03si1298110ejb.726.2023.03.06.10.31.55; Mon, 06 Mar 2023 10:32:19 -0800 (PST) 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-2022-7-12 header.b=OAHwFF06; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GqV6Bilt; 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 S230182AbjCFSPS (ORCPT + 99 others); Mon, 6 Mar 2023 13:15:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231302AbjCFSOx (ORCPT ); Mon, 6 Mar 2023 13:14:53 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0722932CF2 for ; Mon, 6 Mar 2023 10:14:19 -0800 (PST) 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 326CxG2B017856; Mon, 6 Mar 2023 16:23:04 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-2022-7-12; bh=qHm4Qdh/f5x/LfFaP6306ySB97O/QRQxfBSmKTnF90o=; b=OAHwFF06UUoX6W6pTky3mqRoAjH9o6RRKMcvwqt5W3EvE4ZVJKh3CEZMaKFTD2qocRti PgGF8BgXsN2zMLDC4nq1sbSyz9IEoarXc4h7BWt8QacsCvCvkmnBCHvGhSXYPQrESnX1 ZKcYgm3g8VHo1RgaHXxE1m+dcD0bAtNWn7Hk4XmWgNgR1yVVEd8J5zy7Nw3s3tb7+xRA Vswgtm3hTDYwC91utDfyKB/T/cHXJsTOAXFR+IDiuM6o1KHkPFAucFAMJ+JYJnfPQWDK Gi5hP97sS/WfFv3rifss0LLoC6tTwSCl14+d5g89BHnuo5+RTsDq7jjMP1SPqOx4c0FE Eg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p415639yq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Mar 2023 16:23:04 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 326FmI8f028608; Mon, 6 Mar 2023 16:23:03 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2174.outbound.protection.outlook.com [104.47.59.174]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p4u1dq69t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Mar 2023 16:23:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F1k9CYMomCezSxR0Uhks/6hU9xQEAous7CP4K1n+Bt7PFAPutUfeub205AnPyFHiqH70FI9siNckemKTQpmH7YKn+od1qRKj5Hzr7t4dl8bDreNq02aBhqf6hWBPMdwpn9hDRmn9j8NlcAQC43XptQkJ3/vwMv9Mln8zYd01rir21pV2wNiyN684xa1iCeS/CEiNFiFWdEf3288HyxUkSsNUvvbnYMv+UpBz80Nxl6/nZufQI3Y6iGy+k/gFEVkqBwXX6Z9QLZ3D/E95SU5LaGLXYeC/wsW1SM/Lvw9KgF2XLMPcKWV53Tlhk2NVeJqvpCBWjOezS86KPy0+qKo+eA== 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=qHm4Qdh/f5x/LfFaP6306ySB97O/QRQxfBSmKTnF90o=; b=eoOpuSHaFRbGREBG7Hz6tkJOoNkS6U2JiJUj3WDpSF7TQLsYCndGn7rEwS2KbS0+xRpatAKcX4h+LBRtjAENxF3+WPzx26fL6hPMJdLfx9bJB5YyMGRnQtxGXv1vCpTR/QDS92Jp2HlfwF2HFJUfIowjAdZPHnkCRB7ecTBxpcyQSbiGFUaGWDabErLk7CgeWJ0UdFUchitT4jIapgIz5/q+Eq8dgHwiDtW4IJnbeHN6Pbiwo9DkGSClDA+ZWyk7TaB3pQOoivDvrKBB0xzN0q1xibNii3w00g+3yF33QFj+X50sAH7wnVSQGSX9RsxV9FkyiEwvRGVaqNGSb7zrNw== 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=qHm4Qdh/f5x/LfFaP6306ySB97O/QRQxfBSmKTnF90o=; b=GqV6Bilty2QeAf1yufDQblAwLBvdpmx17wURGbkAImfYllf/Ds2eeRHtSClMXVeZwBVk1MEFquk8ue2ibSdDDG8hslWjiw2s5oecAlFIKsAqsNU4J2PZtPgQQ3+3hKeK81sPeaaeBz6slIzKYRqOclr6ebLR/WSPagmxlj59pwI= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by CO6PR10MB5537.namprd10.prod.outlook.com (2603:10b6:303:134::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 16:22:54 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38%8]) with mapi id 15.20.6156.028; Mon, 6 Mar 2023 16:22:54 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v19 4/7] crash: memory and cpu hotplug sysfs attributes Date: Mon, 6 Mar 2023 11:22:25 -0500 Message-Id: <20230306162228.8277-5-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230306162228.8277-1-eric.devolder@oracle.com> References: <20230306162228.8277-1-eric.devolder@oracle.com> X-ClientProxiedBy: BL1PR13CA0120.namprd13.prod.outlook.com (2603:10b6:208:2b9::35) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|CO6PR10MB5537:EE_ X-MS-Office365-Filtering-Correlation-Id: 15a7571d-70f8-4c4f-4b8c-08db1e5f0a03 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0wlmUdRp8XOB4gTZlYwH9mEgPvl9k3siizImAeyZrVl851dsqDMgcFT/Mk92R64edkl5fMhB1xg0VpYEbcWecmOdM0bd25jL/8zIqkQc9FFo4/3rJLiKvyjjzOIESQleHfSQMKGgU5LUSWlJV9LYU2FdBBmqLz+nqwla30klGZkvJqSZJP2DzsJmRSUiHGV/7h5lV9+/B/gjBiE+vsRCUnbMsRexXVd5q5jASErQyMEIZAPw/IDBYKAjK+I0xDIqUAKIjdij4OrcJ0ObL6i8Um+A2YsJGHvGA2wb4B8iPzSrpqfRXwnGaOfqelRFw20EAnxLGXk2zBUOCcb42/4w0vUeoDYLtL1H8vqume4S0MDEh7YmFvFIvJfDGEYGZfU2GXsf987hE584huafxnGtH1TZwoYrdtQR7MAQBMiJmWg4dHJRMu7023sS4E1B99zoxsq3BRVfI497Jytw5D9nMVK0yZ360lJM6zZ1EPjFUy+2YWpjL4O3WbWcsdzFKbPS7JxVf9wb+yYpV7V6b6uy1nUR131Bpn4UWq0svH23eK5AFIY/J/Yuin6AKsZY1rgSnEk4WJvVX9fnigLW9eKyjUlGfvI17cIsb2hsLXRlhkGxCq9NoJcwNt35ddeV1dX+8npZzqSt38cDh0M68dPTDA== 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:(13230025)(366004)(396003)(136003)(346002)(39860400002)(376002)(451199018)(66476007)(8676002)(66946007)(6486002)(478600001)(316002)(41300700001)(5660300002)(66556008)(4326008)(86362001)(36756003)(1076003)(186003)(26005)(6506007)(6666004)(6512007)(38100700002)(107886003)(83380400001)(2616005)(8936002)(7416002)(2906002);DIR:OUT;SFP:1101; X-MS-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Da+At9me14ETUHCL9/rbhC6pA27oQrtN0sxz3FEIKfSMltG07ZDYi02tL/ACoM86/cRb6E6bkuuCoVoVixWAg90Zv2I6xoGHBAUJN4iKatdU1/mRZQtC4bB+BJTXSY4LVtw25sSujGxAy/AQr7q89D5cCIGlpiIYn5OnFDWitzwqgsyFP0crkDfztFCwieTfCCfugUUx/QNxCBlcq4ukAnnSPLghqxfMFpJGEQIGWJD5QWGPyXAzWqWMQwwtOsqhbmdxvdg596NBkW5vaywUsPQVzitfR9QElDJko8Mq3uvXONQ8ODDUz6UEw5nB1bsaNGNOlRSoRSp0AXTmPgZdJdCDZcsqzNvZHukULmvuRcfDOy1DWx26bWM9TMbANVQlm8BDQtQ9G314q95nkfbVTqUwDGsUl+rJWJSc4p5lgNFyeYJMv8I0DKbsSKCFGkgI0ac29sEqdc1DHPb4gPACYKDIvt8w9z5Gb6Wd3UPKLWUQthmdkUSyrPjS8E1yQxBA67/+5tcub/mggsGJinG2bWJvmYLMrNnExjRqWzxoCiLWupFLHBneup0OgQyFcThRRFdL/yf1BFYg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 60MAULtsSWBlVnjZQSL4MdlVDcp4iKSfm7o8TZhkqPPGn9iXKdMhKX4k29Qi0lFrUNizyPBHcGRdJx5zXblG801ODSW6c0evx7Yv9sECXLL8nuw/Spc57WEAuuEMyidY/0zOzj544sqeIeSVIjVKT52eRrRox/MUxHVEmrp8h3g72NAv9qAzOqdsUwBD2+IvKjRZY7XKG6XFWimXsyicPrYarvVvNBWqSG/z/SZEyTwxDNrubgAHGz1lTwgYRmB+656W4D/cl0mY4nPTBf6MejiBKzOQBpwjehd7gJTr+niMXptxO0rZguEBchQnoc5LxlCYYqRRVNHhSeo7L+yrxiMljvMXRImmds5laBX2PYkIqL6CCbuc88wFUzSewbkttXPJ6QNi5GbSjkw5TC2PlrFdvVpyGX5160IiuJ/BHiLgHZKUqBShOLliV4uWwZ/q2sr6PZVd/J9fSCATSex9WAynCdsYSTXYHGEvGudauybD4VZikf6A1tWh2pbgiZReUv0HsjstRZrQV7q0mKjaPJWNYHnRR5wVrCik9FY66cH7VVVOhSu/vxXUYpf5lXb3+vuiMcQ8hQexeQDtPTkYIj39380j416DTpMkgulMsTK09ZcIMWEkL3onslGDZ09S7bTgfOHNr/UvzitBorhwttaC+1uq3r95BpRU3txGkFXVRvN1RnHuN9WGQ+KT+UgrjmrJsSLDKIKA24F5vqOQGPCvRQVbEmZCCZ4V/8SFjiV4OREdf57sZwcC+CkmuiTHQaUrmXa9fW4YIpxSecJpKkrP+r3bjjwYovzf2LLguC9naI+PbmegkIz6GjSNG7X7EVu+/sjNi7D6uwmzgXg1eEQi45dx3acIdfMv+JyIl9YH+YaBUFNtjaLaayXHHdvWZHy/WyYnlYDvJ6flT2bUphEtApUi8EN/IIHrl2yJe5RUt5bRXAV9yNocXUsUM26z+D7wdycxnmIsEIqSaP0nYr2ftL5nH5EFzQMqSX0Ev45eLoDNJh4YkP/9wX6mqa+8zNBA2xZ6wLF3jO8Ug9IvtXjdmmiCSm+eWBEDnUKlsFWwdGN6CA4GxUlx8+guGwXPb+ytS3LMEbay0wxrswPwTDo76Uq//Xq2j25z1Sz+ffgdTjpJZ9Bpynv09WjsZEE82d4aN4jEMiEURG9W59XZXGuRaYHdnBWfQhkA3m0synY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15a7571d-70f8-4c4f-4b8c-08db1e5f0a03 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 16:22:54.4583 (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: NWzXnXJC4PF965AVGQeKykPU11FLXxvSZnF4CfdVN6aBjFH8GstuY0Q1QlCBszm2GFnH5WU9qktvrz2AbaZxJPDLN7PQteCjvGOn/L76PY0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5537 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-06_10,2023-03-06_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=965 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303060145 X-Proofpoint-GUID: gZTZcFJKDafMaPLIYcz36hJ4-YOOaTM_ X-Proofpoint-ORIG-GUID: gZTZcFJKDafMaPLIYcz36hJ4-YOOaTM_ X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759644262852528559?= X-GMAIL-MSGID: =?utf-8?q?1759644262852528559?= This introduces the crash_hotplug attribute for memory and CPUs for use by userspace. This change directly facilitates the udev rule for managing userspace re-loading of the crash kernel upon hot un/plug changes. For memory, this changeset introduces 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, this changeset introduces 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 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 handles updates to 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 change tests if crash_hotplug is set, and if so, it skips the userspace initiated unload-then-reload of the crash kernel. 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 will skip 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 Acked-by: Baoquan He --- .../admin-guide/mm/memory-hotplug.rst | 8 ++++++++ Documentation/core-api/cpu_hotplug.rst | 18 ++++++++++++++++++ drivers/base/cpu.c | 14 ++++++++++++++ drivers/base/memory.c | 13 +++++++++++++ include/linux/kexec.h | 8 ++++++++ 5 files changed, 61 insertions(+) diff --git a/Documentation/admin-guide/mm/memory-hotplug.rst b/Documentation/admin-guide/mm/memory-hotplug.rst index a3c9e8ad8fa0..15fd1751a63c 100644 --- a/Documentation/admin-guide/mm/memory-hotplug.rst +++ b/Documentation/admin-guide/mm/memory-hotplug.rst @@ -293,6 +293,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 f75778d37488..0c8dc3fe5f94 100644 --- a/Documentation/core-api/cpu_hotplug.rst +++ b/Documentation/core-api/cpu_hotplug.rst @@ -750,6 +750,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 +(ie 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 4c98849577d4..fedbf87f9d13 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -293,6 +293,17 @@ static ssize_t print_cpus_nohz_full(struct device *dev, static DEVICE_ATTR(nohz_full, 0444, print_cpus_nohz_full, NULL); #endif +#ifdef CONFIG_HOTPLUG_CPU +#include +static ssize_t crash_hotplug_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return sprintf(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 +480,9 @@ static struct attribute *cpu_root_attrs[] = { #ifdef CONFIG_NO_HZ_FULL &dev_attr_nohz_full.attr, #endif +#ifdef CONFIG_HOTPLUG_CPU + &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 fe98fb8d94e5..a3f37cb57d79 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -495,6 +495,16 @@ static ssize_t auto_online_blocks_store(struct device *dev, static DEVICE_ATTR_RW(auto_online_blocks); +#ifdef CONFIG_MEMORY_HOTPLUG +#include +static ssize_t crash_hotplug_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(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 @@ -894,6 +904,9 @@ static struct attribute *memory_root_attrs[] = { &dev_attr_block_size_bytes.attr, &dev_attr_auto_online_blocks.attr, +#ifdef CONFIG_MEMORY_HOTPLUG + &dev_attr_crash_hotplug.attr, +#endif NULL }; diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 2dcc4d65f5a9..5a0369b14d09 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -508,6 +508,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 Mon Mar 6 16:22:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 65033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1998673wrd; Mon, 6 Mar 2023 10:19:15 -0800 (PST) X-Google-Smtp-Source: AK7set+6ZhhWKsVYnRY+EJfR0ceCag0npIt9ssc8UWYVRVrS1YSXaat1XzgORXOwsEoKKr5DtxxU X-Received: by 2002:a17:90a:4146:b0:233:f393:f6cd with SMTP id m6-20020a17090a414600b00233f393f6cdmr12582089pjg.5.1678126755468; Mon, 06 Mar 2023 10:19:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1678126755; cv=pass; d=google.com; s=arc-20160816; b=k5RjbxqAbPORL7LtrdwJJxaBtmEUg0nOtuXHRXeS0e2sHbDXbDPOSVP341MC7hJfj3 qpMwmjTh39wGRSCTx0vjEcmr7LdQsdfVq0TSkb4643fLsxvLPBo11EmxZW+JacWP+4vn 4P9zTzefx2bt3mVqajbVCMrQf8fD1mw3CxMetquKuz5zLJATblTi8CTIFSh3HYUFYw4m OWqH8CJBnLcQ9QAyhoePgxcfJASjcxD3GM1cMttXVRZRmCfTzOoi31haLP4NE8kE1hOS ZcB9nUTpUunwwl1KyFPTLol92x+7y3nfrgEJKikfWvYO6C7JVs6hxI9jbvaVS0g3Yc+g lTrg== 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=pwFHmqjBVzoowkQPsGI32YFDgdwu2nct2hyJC2lNrWY=; b=ExzJQTdFdyVMemqyBYHrnasS2IBdd44uCVTLofZLRG5Mt7e424VElvuwJ/7fZKqZUD rh7LJRDrdGOHPxzf+cbp8ViOKZtw6lEv3LFau6OWozd2hZftgzpQI06dpASqm1HMPZU3 Yiqjp+OFO0a3yl/E8WzT/nRO0PbK8evN2oFdg7kbKz6KqJgZfERENZy0UoRNGwD+JY3i DO6PL+aD5c84+bJbJHWsrUOMzfMaDgn4DY503sxMoPMO9iGUya0rDEY+Gk4TVGW7kEFr qfsTLgBnhlr04rUxb6lizpDMqDpqujHUI0dKn+lvXccpjeQ79nyW+PNZT23wlOrDLy54 loyQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b="n/LPHOZe"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=IVZEuWme; 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 h14-20020a17090a130e00b0022bb4d6f7casi9413994pja.131.2023.03.06.10.19.03; Mon, 06 Mar 2023 10:19:15 -0800 (PST) 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-2022-7-12 header.b="n/LPHOZe"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=IVZEuWme; 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 S230217AbjCFSNz (ORCPT + 99 others); Mon, 6 Mar 2023 13:13:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230425AbjCFSNc (ORCPT ); Mon, 6 Mar 2023 13:13:32 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CE2F2707 for ; Mon, 6 Mar 2023 10:12:51 -0800 (PST) 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 326CxF3l013883; Mon, 6 Mar 2023 16:23:04 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-2022-7-12; bh=pwFHmqjBVzoowkQPsGI32YFDgdwu2nct2hyJC2lNrWY=; b=n/LPHOZey9T+RiyYvxpCES5sc9Cv4vaUTHlQ73eaUpC6KBNhWSjh7sM5WpRjbvPY4Bj3 Ju2uD40vZDam3WlKGNeN879cC41YFu9jojpWIxV4nS5cPfw/Nlu/IEzBzzWj2f4xr3NX plcSxdlad2Lsy3vyuHNRyxocmlh2lKn2pN+Y2sJuIIpUxoc+pNJgL8U6LHnc67PbuNsm kRR7KdXaxqFuPbqxfg1RCqsSWkHoDYqKV05eOQolc3cUPbUaHoEY4n9jupFT+4vkz1S5 z4TiXeDfli6ykZZlZyoASTW6LcZlQyAHC2baTghTPiZj3cpdhDIV8UNzcJs//FTFnU4s IA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p416wkaab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Mar 2023 16:23:04 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 326G0Fsc011448; Mon, 6 Mar 2023 16:23:02 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2106.outbound.protection.outlook.com [104.47.70.106]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p4u2gfbc4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Mar 2023 16:23:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mHFIKtQLU0Cq4IniI94sWI2qB4Wu+jM/QQfBkmqaMsWl3uO9fhUaqOs7gMFw1ksOCpKgyHzRWO/t62zXRnkoiH3Z+1BBAeshPzC1v++HWCpljbeXJo1Ssfep4cugo8ZO4U1zvFVkjY7uFPQSzaADe8UyvGWkjI54yW8g5227Lej8RDUgBRWqj9PR5Oz86ipnABMRV0ZYUHvfhsikafVQ42rapD1kt9TayXSklDFL4PzZRBCJbrZxOjctCKqHRH1AdhMQKYneOWyuNfwnT/I8WLAvDcdt0gIqnV5uDvpjUCFsGO/EohvRlceh8+fJbPlm5lqgmYvwQ28/KcORMniUyA== 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=pwFHmqjBVzoowkQPsGI32YFDgdwu2nct2hyJC2lNrWY=; b=ZeJkzaxm4WzTc1HMgRmS1MXVOG8IisIp++giOt+t3c46utlJnqD/QMVsC45tXBX/Os3Sp05nz7A5ATQGCSWUeqvepxAWoRiC5ByFJA1StpvOmVR3YWgFn5JYPiMR+ptVLxLRvWU7sZv5wYPDAanEBSTwluVs3e+YUit1TfFECMONCXvpcn+8mbWnRjK0Xf/poHSDNl+xDtStXIy5E+tORp+80WeaH1oLgSjOxSKX7uvTTBgfEDauWx1X7sMp+uaJ5PMwFwhPhg/VpMEeu1pUrgSc6FWzzoxgkDwT+DS1pYcogXi+8WdFVh1FI9YpjVwc+xfxRLgaCnUUKX/HHNnrvQ== 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=pwFHmqjBVzoowkQPsGI32YFDgdwu2nct2hyJC2lNrWY=; b=IVZEuWmeTa0PTwKa5eKPlBK+FnHCnvwz0qyBLPfH5NQubfO9tuwMeu+2wxefrcRVBOTjqoZOPtr4WQ6E2OMAZEdyhhrjrEc4nFm3f3uhn439USu/6eqHCqEWJJ9pVz77ktR6Otkx3Ouh7I64k1a9lAfxa4CGYx27WlZoFeTBuK4= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH7PR10MB6530.namprd10.prod.outlook.com (2603:10b6:510:201::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 16:23:00 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38%8]) with mapi id 15.20.6156.028; Mon, 6 Mar 2023 16:23:00 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v19 5/7] x86/crash: add x86 crash hotplug support Date: Mon, 6 Mar 2023 11:22:26 -0500 Message-Id: <20230306162228.8277-6-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230306162228.8277-1-eric.devolder@oracle.com> References: <20230306162228.8277-1-eric.devolder@oracle.com> X-ClientProxiedBy: LO2P123CA0073.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:138::6) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH7PR10MB6530:EE_ X-MS-Office365-Filtering-Correlation-Id: f44a9081-e8df-4f30-0bec-08db1e5f0db1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JmVLaYWPid2WFKPhGw30PuPEGIvLabrdGYFQ6n1IoXJ3qSw4ke1G6J2H8LhPbXEQCSyd9sSlLF9NQxkJAv8n+Bp02LxKB3k9Qb6d5+Drh47khsKjoaoSwNKsKhJxwdPKyCzOWHLtfWnxWIY9UOatGsmyDIZt+MfRo5+XtXwvIoi4scX+G4zixZCc1qFaOJYGR1X0RNcsb7WyvTtxc5eWqG1lRr82k7/Qsi7KUDXFfrzOjp9lbPvAbWsFz+4Rd4tBsb6aJOTEmgO3I+WFXYttBaPhx/0Sif7Pqh2/jMm+rQpfd76BvNX5FdjwfOgQEPrhzOtHpKYCpfujiIHTIMArzQyuc5ftNxXzie80WOg8X3PKWx9Kra4f8oFC5akbBVU8CKv4IxOY4JRW89BrvJXFVPCM8KOdlPX4RWSBNpJgTLJ8gYIVTWz0HaKEnxkf02kl9Ip+XBEqkpQ2+0fL/YbI4qwd+V5DHGgQVy5tS4LMOr5T2Jcl9pRLnjm7LlVLZ1jqgy6ltwVIYA6jonMsPEehwDwsAWG4U7DbCMQXvtKMKA+lZ+231Fbj6yGz1BjWChKj1kEzIV0hBaYFrG3pHWMIcPtJdbuKEtZcIbFdI5PaTvzih29Rqd4qHDm1dIF8aPirN/ypZM0Gbe8JUFrvrB0Czw== 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:(13230025)(346002)(396003)(136003)(376002)(39860400002)(366004)(451199018)(66946007)(66476007)(5660300002)(4326008)(66556008)(41300700001)(7416002)(8936002)(8676002)(86362001)(36756003)(6486002)(478600001)(1076003)(6512007)(186003)(26005)(107886003)(6506007)(6666004)(2616005)(2906002)(316002)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eZ/SypIwt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/fgogA1sGxJPacij3HcNE3hVOY2m6pioHJ0K9Az40enWtBYkeFLBWfFgNSs8rx36f8+S7Oaav7muGYl9LIyguRCE6KFHPYKwANb+ZmT9CpakMu0kLcPPAlAmiX7xLGRx4SWnSXqr2roevgfkSQ0qD0RGF1XyaMheT8tXJ3j6/HrWjx8n6rqtLmh5nfnJWevSVRwNsqTggQ10aKnxMK3GcLFcvGKk39S5Ly1At1Rh8MudlNIZFtQxbsBIyMccxTsco8dH6SNdeywZMwT16JyOzITFmtHq8B0DN5oCZZg1jkU66MUauvfElHTo9OFVjv8DvqltAbgwiL5Bg3qiVElBkvwbsId7MqrIxQiDPuHiueqwQgU2AZmUF0hplfqq1GzMujiOQskeN9+uyDqFXIt/HLOxDSSiAAUdSwQYPvH7l/9JZvQNH73eNl4gi0om4j/czmjiEPAHhJUc496hKTMYnAolvZThEC1TAZ3NwW9IY63i6VDzVZOja3VLGZgjQnLbgZRsTDMPNoQVRk9TU5sNwUhe3quDXMHJn7HQ/l1LAxhxE7tNn/6csPjARbtIOITOO4gXY1R8p4i9UMeea5pnlBpNWz9xB070LxudzlDxSG81zn+m8YRhAnaEBWnKIli52qghpITxjAJ0WwkeSHItWCJ2ofZwOZW2w1x7S3ynPRjWZcCkMRY4xSPpUjP1XMjhL8CMTDx/U0dl5W0sseAZM8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f44a9081-e8df-4f30-0bec-08db1e5f0db1 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 16:23:00.6927 (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: KMIo/bgoyNsTZ1lgo/43aPP8sfgaPpB+LbRV0FqIUGHFofgRqLPLGZ9URpb2VjKUGR/WcN4YSZ87XG/loYgZYAinxrTJCSr5uF0E30jutH8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6530 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-06_10,2023-03-06_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 bulkscore=0 phishscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303060145 X-Proofpoint-GUID: kMkOYiVsPQWLEPLy29RjK4JRFOxL9poZ X-Proofpoint-ORIG-GUID: kMkOYiVsPQWLEPLy29RjK4JRFOxL9poZ X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759643440824885064?= X-GMAIL-MSGID: =?utf-8?q?1759643440824885064?= 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. The segment containing the elfcorehdr is identified at run-time in crash_core:crash_handle_hotplug_event(), which works for both the kexec_load() and kexec_file_load() syscalls. A new elfcorehdr is generated from the available CPUs and memory into a buffer, and then installed over the top of the existing elfcorehdr. In the patch 'kexec: exclude elfcorehdr from the segment digest' the need to update purgatory due to the change in elfcorehdr was eliminated. As a result, no changes to purgatory or boot_params (as the elfcorehdr= kernel command line parameter pointer remains unchanged and correct) are needed, just elfcorehdr. To accommodate a growing number of resources via hotplug, the elfcorehdr segment must be sufficiently large enough to accommodate changes, see the CRASH_MAX_MEMORY_RANGES description. This is used only on the kexec_file_load() syscall; for kexec_load() userspace will need to size the segment similarly. To accommodate kexec_load() syscall in the absence of kexec_file_load() syscall support, and with CONFIG_CRASH_HOTPLUG enabled, it is necessary to move prepare_elf_headers() and dependents outside of CONFIG_KEXEC_FILE. Signed-off-by: Eric DeVolder --- arch/x86/Kconfig | 13 ++++ arch/x86/include/asm/kexec.h | 15 +++++ arch/x86/kernel/crash.c | 119 ++++++++++++++++++++++++++++++++--- 3 files changed, 140 insertions(+), 7 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 3604074a878b..2ca5e19b8f19 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2119,6 +2119,19 @@ config CRASH_DUMP (CONFIG_RELOCATABLE=y). For more details see Documentation/admin-guide/kdump/kdump.rst +config CRASH_HOTPLUG + bool "Update the crash elfcorehdr on system configuration changes" + default n + depends on CRASH_DUMP && (HOTPLUG_CPU || MEMORY_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 KEXEC_JUMP bool "kexec jump" depends on KEXEC && HIBERNATION diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index a3760ca796aa..1bc852ce347d 100644 --- a/arch/x86/include/asm/kexec.h +++ b/arch/x86/include/asm/kexec.h @@ -212,6 +212,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 305514431f26..c9aaec9de775 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -42,6 +42,21 @@ #include #include +/* + * 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. + */ +#define CRASH_MAX_MEMORY_RANGES 8192 + /* Used while preparing memory map entries for second kernel */ struct crash_memmap_data { struct boot_params *params; @@ -173,8 +188,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; @@ -246,7 +259,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; @@ -264,6 +277,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); @@ -272,6 +288,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; @@ -386,18 +403,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 + /* + * Ensure the elfcorehdr segment large enough for hotplug changes. + * Account for VMCOREINFO and kernel_map and maximum CPUs. + */ + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + pnum = 2 + CONFIG_NR_CPUS_DEFAULT + 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); @@ -410,3 +451,67 @@ 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: the active struct kimage + * + * The new elfcorehdr is prepared in a kernel buffer, and then it is + * written on top of the existing/old 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 prepare elfcore headers"); + 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("updating elfcorehdr 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 Mon Mar 6 16:22:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 64924 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1942004wrd; Mon, 6 Mar 2023 08:37:09 -0800 (PST) X-Google-Smtp-Source: AK7set9IVa1iHoYbAXd8mHaH1rY6o9jEt65P8PNqK6iQ2LTHmpfN0w+J3Li1JekO7yGFTZL0Sjoi X-Received: by 2002:a17:902:f693:b0:19d:e11:32de with SMTP id l19-20020a170902f69300b0019d0e1132demr14334193plg.34.1678120629633; Mon, 06 Mar 2023 08:37:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1678120629; cv=pass; d=google.com; s=arc-20160816; b=sDr8yqjAQaRbkdQ61LNeGTcH9hYUEDcyR/xhtYWmNhClAUssLAM6fVmmfzXCPkNXC0 rD98RnuWZG3k+LcyAqHD+4hwAmk7WT4+WCSIkq2JUlbntX8Z4E+yp4+1asjirdwjrlb3 +z/rYb/0oDwupT7erokNyJ/vXsopSqBGsttlY+TPlqu8Kn16xpyP33p14RygldTeoebm Gfai2iLJ8ahF4Is05x7ExJhJoKzNS1JDF1crxAOc42EfaRzZGrz70w9vIIKqUJLskTTR xuyM5o3m3UDiwNdZNYH8nUfrsF9nrdzINNZaTY3AbE8/iZpEdcEsjMMI3RL1rwSUkVzW fkJA== 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=y9RXT6YQI6qfXYeSiTIBV2erHTqpwWSMOfMIqjcVYfA=; b=oQyd3mJ0o/mYgHbs9eyTCN8iaVYjqL82kfcWRcdzqCW/GhmP2Y7J2tSh62ehMhHZHB GEhNlOLsBERzsb9n7l/za4wC4vE6m/F2xyUTYCHN49rnYzKyMVsuQd6Y8YGjNw67evxA XuVYMX94OB2EOtEL7I4CDiznkNHZCKKssgw7S0iqhOxffmLwaIWQ1iSg1Ojre2st4IL2 azXEPPfkuWxVLGH2+bQXV9BIAfdSCAyllsvaERRGqfDD2BtYTr/g91sYHZu0z0saeEYp 0b79KIeV/xW0+kiBi3XgYqJ/OSTFJkSmrb12pp5Z41sEwrXcOmPmBSs8MwR4bpQNbUAS +bJw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=A2w241el; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=z+uEfA0x; 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 e7-20020a656487000000b00502f0d858e9si7880325pgv.174.2023.03.06.08.36.56; Mon, 06 Mar 2023 08:37:09 -0800 (PST) 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-2022-7-12 header.b=A2w241el; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=z+uEfA0x; 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 S230194AbjCFQ0R (ORCPT + 99 others); Mon, 6 Mar 2023 11:26:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbjCFQZ5 (ORCPT ); Mon, 6 Mar 2023 11:25:57 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18438CA09 for ; Mon, 6 Mar 2023 08:24:46 -0800 (PST) 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 326CwrCj002568; Mon, 6 Mar 2023 16:23:10 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-2022-7-12; bh=y9RXT6YQI6qfXYeSiTIBV2erHTqpwWSMOfMIqjcVYfA=; b=A2w241elpR2eE5PFGau6bpO0ip1nbu4qcAU6VYXwk783Dhwjt3DeS8cWnbqOvwayiUr7 HIDl+RrWNo/IbqzZz2b57E7w3VOUCtUEWCwx0xxnmpDky+9cajfdC0XQIbgsi6Vsh+L4 B11RWuBj3e1RCAz3Pz0OJxC/CV/gyrEvEDyn8vFSLpV40AFEcTIvv99sHLsXZmXGXNkG fcMfVb/8LP9RjCDqpInGXSA5qhH36XHBXJ85hR7XPZgiq0U6QIUlS1ahGOHpYLrT00wO Attc69jdvnhQzINAa8MLC923qnmEIFxZ01YknxsV55mnizND1IKi3EZEw0QxZEmW95P/ kA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p417cbavx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Mar 2023 16:23:10 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 326G3Xj8012362; Mon, 6 Mar 2023 16:23:10 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p4u2gfbhm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Mar 2023 16:23:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eps/GSjvs6r9YUQmmhKHfJhdP7ZfNPcv6DmIZuW7UufnOyI0erGBKNudG2dSH+WSuDpdnvVPB4e3zCQKTYfjwQqp2uJwYG09hkVFKMx7cdFreLxz7s01TwsBr8yM8dIufKWgfWVfOvT9z2kxYispkWmFxc3n0rQM/O03XoZt1OSZWadLoPNKdlnp7POOO2D5HuWV9aybaXUS+Nl5sgjTHXufjXrNf7epFiIGFitxKMqUa3vEEnCIOu37OHel6cPAcG19oQcHE0rrbbfuwNOs/nrmKydQqblYrzvxVjO7BGoAqTo7TjCLCI3QWDYvtkBYRUKojgUKhJ4+VBDyKZSsIQ== 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=y9RXT6YQI6qfXYeSiTIBV2erHTqpwWSMOfMIqjcVYfA=; b=Hd7UJmQY1Mgt6iO3919Nn7iiWP5wsks5H6+/kjIFTDP/OioHJv5LL9A6OYGkn8VIshNbNwEfMRpmqVkpIpsAw+Iurqa+1xghDyKDK7mdCsoodqcV7Lu+uJLcP+oZkT0CxfY93VKhUNqv9WbRmZ3syv6YnxlmjGNv/NgbjkfeO6yIkzMk/f1QqZF4g86X/INmkBr6w1bKueE5jYyu4tivMEtodYMyceXtFrl/iMSezwC/4xQ5Xm+8Y8U7KCCwlJc9VBhumSYWSpLI94f4rPK8d3PJV6v0MA7DU0qZN2UKtKh2c5iQpFsWa9wyLZF/phYVWe49Ze4izqD0/JDM7Id2Xg== 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=y9RXT6YQI6qfXYeSiTIBV2erHTqpwWSMOfMIqjcVYfA=; b=z+uEfA0xqqKV9SMomjnU4DE3slae7v96B3RooJEk4qxCxxN9VJysax9VibcQOOFoa4Dk78+okKqVbsTCp1XpbxBqS7WA/OrFsZdkIQA/m9Ro2WtOTrIasKLyzJSR4dHvcqtZ+wQSI4fy/tzm6UkruHBFzXkaFUiAdDplZha0qPs= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH7PR10MB6530.namprd10.prod.outlook.com (2603:10b6:510:201::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 16:23:07 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38%8]) with mapi id 15.20.6156.028; Mon, 6 Mar 2023 16:23:07 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v19 6/7] crash: change crash_prepare_elf64_headers() to for_each_possible_cpu() Date: Mon, 6 Mar 2023 11:22:27 -0500 Message-Id: <20230306162228.8277-7-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230306162228.8277-1-eric.devolder@oracle.com> References: <20230306162228.8277-1-eric.devolder@oracle.com> X-ClientProxiedBy: LO4P265CA0162.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c7::20) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH7PR10MB6530:EE_ X-MS-Office365-Filtering-Correlation-Id: be4bee16-8bc0-4d7b-403a-08db1e5f119d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I/CIBurnTVBm16WDeY6kMnPIf4P78GiZZfnRwW86Kp8Sd/eDtZVCJVqjePpycUn/tOeMGSrUR6teBjWoEvojOjTX5DIQ4KIzAJbOHtc1Dbi+EiOaF/G6pwARhVcE3qcLXDKcjP0T1EJVhAP4oIp97FMtBR4vqtYpl+BDucN3JjIMQmBJ2trJeggfzN6Rv8CJmEZLqMyH/DJMnNnBQ6jpzh+HwGgg501IAaR869o+K1IWmuCaPQuZBT1oF6dN1aFZRr5xy4bzV4Yqv0hETfRd81Y46LmmGtdHzLGzSlkIkWRSl/BVhezLRoMSL375yQkZNMqOK1MBv05D4AnllpTfQU9u0yHCxEkWtjwJJCCw4alGRYOx4vXqq5TMSh7uZN+G3v72B8lpCqUNMHK6EoT6W7XUPIoMssFnPSwwoSMRqP2ZnTflxXNjoi/SM6lj+oeSomqHwcsDXu03L8FBUYzgydxLwIbR6Kv9YvSP7t3CB8sx4Ecy7ZOQY1zNRZGcub6efCyj6ILeAasMl5QcI7Lkrdf/XnSvmD/5DYb4h5tSoJc9mfr+rJSzUuWobMOCZyEksrKpDLwvTquXk41D69cdvlrK01SgllPYis3QeVCIhqeAASUX6Vkol2kJpFcdElZke+Zoe3hZRo9IWQDulLhbDw== 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:(13230025)(346002)(396003)(136003)(376002)(39860400002)(366004)(451199018)(66946007)(66476007)(5660300002)(4326008)(66556008)(41300700001)(7416002)(8936002)(8676002)(86362001)(36756003)(6486002)(478600001)(1076003)(6512007)(186003)(26005)(107886003)(6506007)(6666004)(2616005)(2906002)(316002)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nTCNfA8ukLpcaviO4FVWpZspORCf6G1YzfTDf2xhMaDlzyL6jVbhl2/L7LZ10atIjiAkcnITK1+dMM9b/JInI4SxmgtSg8kx5PWIaifp8reKNiIk/hcPfPjNaexj7i1bwnQNQiyHJQp6jStgRb0gBCIbRx4vaAApBuKA4nE9xP9tW8CioOCWz3BliQONXUaMoK3ZHDSHy7lP49t86mh97qNVTCVA4E5dKPzO0gjSOTRj2qmnoRi82hrDORZc205Z3YMOCYi3Um1p+/aC4zY+JPUjTrGn4nfGqqvH4rH3lxb/hibWHFPg2evYW5SbnVW5OYVY151CM/TCrjHmCMEBaoRB988vMwiuDnSzEqljrmqvBipyw3TuyvKbJtlSy6HKrG75/NRmBKXOCMOZFZ9+KmUq0kMYYhCEeLOAyX+Y6vY63hvsnhx7mxPiOnOoP0/zth1sfWG5OKth6Pf3rRbEX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GKD081X9bMoljEUYk0bk8GyVOr+uqyH3uTH3lktFTjKJjsdgz21rG5Sb8FeL6o++LFKlYtqxvPfIk7NLVKL/XW26Jw4dHeXwuoyrUz8i0L4pCHf6e+ZGAhe1oLdkIPIOF+uQa0kyu6fC3yuY33Nrz/mGDg7OJJUJ/2VkeOotk/G5WFjF09N2UMou4khLgDpq1bn2FiT98pIub0oMnYEWheFn6tDN831ICmgg+Q7npiL+Lfd3tfPkRsxaw/3qyqaBMjaiVIK9oY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: be4bee16-8bc0-4d7b-403a-08db1e5f119d X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 16:23:07.2270 (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: UZIGccj6M/chIdIANF/Py6H6koa9Vb2oU5ypbH3zgG62sdWKtuuVol6/IzRj7cjJai/Qf/73EJxNmcgEj+uFs6W+YEp+nLTDvoILvi88APk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6530 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-06_10,2023-03-06_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 bulkscore=0 phishscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303060145 X-Proofpoint-GUID: ewlG8ZhyAzFce90EDH26uJe3U8OS8hNV X-Proofpoint-ORIG-GUID: ewlG8ZhyAzFce90EDH26uJe3U8OS8hNV X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759637017420256285?= X-GMAIL-MSGID: =?utf-8?q?1759637017420256285?= 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 change 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 change 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 in 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 --- kernel/crash_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index dba4b75f7541..537b199a8774 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -365,7 +365,7 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, ehdr->e_phentsize = sizeof(Elf64_Phdr); /* Prepare one phdr of type PT_NOTE for each present CPU */ - for_each_present_cpu(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 Mon Mar 6 16:22:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 64918 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1941470wrd; Mon, 6 Mar 2023 08:36:05 -0800 (PST) X-Google-Smtp-Source: AK7set+1SyXKoPiGf1rxH05FV43rOd6lRC9Q9wIJ9TNo6ERWQylsIHGM9xRU1sQ44JAUKpbQWdXl X-Received: by 2002:a05:6a21:6da0:b0:cc:50cd:e2e1 with SMTP id wl32-20020a056a216da000b000cc50cde2e1mr12766142pzb.0.1678120564813; Mon, 06 Mar 2023 08:36:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1678120564; cv=pass; d=google.com; s=arc-20160816; b=QGdXjC/vEo/7Le5q2Isy8Vg1vC46HCS66LeDRpe0Ius8+fIu068Ww9f6GbZ0H7cdK1 bnZ/3wrpEbj9i2IixeAfckcUdS6D3WN411oBGd6vefL7oLp9kYknp5t61TY/4HV2J6YL kARjNuoFoY7uBFmZz8c3Z0AP/NFjt+Cqv7X7k69mf63U9N3DA8TA+Xn9kgN5jDw4KIay I3ndvZLDmRRVysmFjTakDNpRCtU1tMmBErS5dlP9W+CZb2rqRqrH1+KcfWiEq6cDT1cK /jXQBE76XH8xgQPYGoT2T1kuMJadb6TgvHKTTfUWmTAEvBpP0DYqm1pIDi5JI7L+IafN 0ahA== 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=TMa2NJx33yIc4VOtYE8TqZmk60QFOgD8Z7Kqzm24ldY=; b=asyQ/BiKqc8vHjVv9PjPbfcF5wSyOaySVC65nXMhCwdlJQNXjSKGRE7SQ+wh1Ke8Y4 FMLOGlSKvwB3wsneL0rVwxjH0tYEe0Iy4O5RmJWhxb7PpJ7Q7nyGM1Cfcq0ctQSnf+7/ d4Mi9Fsga3ighpBytcfFWYMi5K0xqhJ05BXFfWjsaSxp7H1X8nTDAybVb2n7BcgxczvB 1wyUTw3Yc6Jmmwti4BBt3bIr3ehMjvtkJi3rM4BTlM5pMu+F/Z73Z2tkoC/o1zLaQB2f R4SYOrMOGA13ch2KUUzrocFgM3ZlV+KdVLYiL54P80XVEQ6xzc9WDWaFyfDqPJjvUBwY uizw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=G5pi+9Wn; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=gTEI+Yag; 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 n6-20020a634006000000b004fbb641a508si9518194pga.337.2023.03.06.08.35.52; Mon, 06 Mar 2023 08:36:04 -0800 (PST) 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-2022-7-12 header.b=G5pi+9Wn; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=gTEI+Yag; 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 S230312AbjCFQ0M (ORCPT + 99 others); Mon, 6 Mar 2023 11:26:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230124AbjCFQZk (ORCPT ); Mon, 6 Mar 2023 11:25:40 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5EEA38B7C for ; Mon, 6 Mar 2023 08:24:42 -0800 (PST) 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 326CxFvT031462; Mon, 6 Mar 2023 16:23:16 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-2022-7-12; bh=TMa2NJx33yIc4VOtYE8TqZmk60QFOgD8Z7Kqzm24ldY=; b=G5pi+9WnJnqHD6ZXpdoEf+pOOASWbl3NiQN2REyDkkOmXytYmB6EupjxmTRlSOtYZChq Fe/g/PjuhG7H4u+5e5iZaZqNai8TbtW/g/BHhrF9N6PiGPnXc8EG/OmZ1NxHthFKK0+P qwpNayO1e1qgDi5yHVHZWutv5Z6Q7Gfq9hfLkqiWRAVzcIX/CkDkBGmErGLcO30XYoCx +Q71FY/sQJeU1zXUHGQZhG5MmJeMSRZPVRCcyUGkdKQbp+FKXq0avPCqUEjM9wz0RfmY Nbu38m8gmwkApPH9ypXkYppishW4ea4aL0sxfRxJ939WviK6dZLLAp+2rB9g+fCGuWWi iw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p4180ua5j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Mar 2023 16:23:16 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 326G50X7026894; Mon, 6 Mar 2023 16:23:16 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p4u1dq6n9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Mar 2023 16:23:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=coLXWh+jLpuGw5ayQws+70TLdatPujd5jvb+yEboChoz6KqtJt+8Xd1zFp1Lxk/FxRmUoKaFi/E0T8YnUSVrCI7jHAWZyWcch8FvFGIrbZjrLBtrWc60DTJ/zca0qZXZ6OaLKURjwu4saGTHtEAmXxp8gcLIhBGc13/UWC0q4aJiZJtzA7X+eYVE/nuD8+/edtUgNUB/6HK6dNs9502OKXZzFfvNFjIm9n3ClfHsFDuzq7R2W3g58eA3vdZeclEAFPBW71goPaEXgu35c2IIZH0oK3/l2GXNOeiZpolnpP3CZUGfO64WCH2M5PMoVMQJh+bB2pMtBGxdf81l4S4uTg== 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=TMa2NJx33yIc4VOtYE8TqZmk60QFOgD8Z7Kqzm24ldY=; b=BW6WSJ0k0Uzqbiq8VOwdSpQmHiy9Dk0HL39VjSZKTG2/bYk4uvN/Pn1YlbSAMCLYNmjXwd8+S9plciYQZEIZXaBoVPN6crnkbVAKiwcQNr86aCVKUEZT+rf3u+JFGlXVK4YLj3eVWLx9fZ9Tv7GrPAYb2PJijdwkpXDH4w8I4395TxFob2ZZq0dBup/dM4KchrB4lGSwQ7jXZal0GDg8I2Y5F8KFT/4Kh7+S/KRKFS7OES0ILNdr6q/aE1mUrgxA0Q71wlT9Pd1pZwyK8sEq9YB+i/CF58WdU4y50q6Zy+s0hWthuOYNOsloy9CG/iGfU4KA7N+/+FcZYqlncTNnsA== 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=TMa2NJx33yIc4VOtYE8TqZmk60QFOgD8Z7Kqzm24ldY=; b=gTEI+YagtEL2JaITbebpn9YvNlrPmPl2wyew9m4hCyuw0kPolBny90twPuj6GgS37qj5GfvaKmJFfdCnEGrIuMqciytZfDB2xluSWja7FtZrRTl0xdza3gPzF3EBtqMxarlj9L+Z8L9/D2b3vBLN6CWVhnx7O1xsBfLjY8Umo3U= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH7PR10MB6530.namprd10.prod.outlook.com (2603:10b6:510:201::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 16:23:13 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38%8]) with mapi id 15.20.6156.028; Mon, 6 Mar 2023 16:23:13 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v19 7/7] x86/crash: optimize cpu changes Date: Mon, 6 Mar 2023 11:22:28 -0500 Message-Id: <20230306162228.8277-8-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230306162228.8277-1-eric.devolder@oracle.com> References: <20230306162228.8277-1-eric.devolder@oracle.com> X-ClientProxiedBy: LO4P123CA0076.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:190::9) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH7PR10MB6530:EE_ X-MS-Office365-Filtering-Correlation-Id: f3d214e3-49c5-4c58-dfe9-08db1e5f1530 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9lW092tEuXsdOVAH5tctvxC6JfCADRJXCuuRAU0HGJGjgiuu6uhit6NsN7IpHz5mrCA9kYjRPL+R4hoav35k/drvUmW7EaoAMdYqJOiZfS/uFiA9+YOlFh+zFu9kHufchbfUYnyNenEeIqz0e7Rtq8S8cu6etgZbly0/opMOgNFQtHLftxncPlIwbWdZDxYjoOTOU2u7CU28pl/HXADhsuXgnknUoqOHyOeq1236J7YOzg5tdid8Z4HNenz8Ustv6o1aJVxPGcWe83qj9IDWvQcvPJsBMTqDC0mfH5RZNne55jvy7s5yaqW2YzRzzfeS1dnRIqzP9EO/KtioCbU6z2uLS8kCZkcNBaXNANctAv0YGFQKX+WtXWsqZzAVcCyq3AZOE5WflnpxpJxZYzsgiB4xWe6fZjtOVnHRf3a/hGZnTtZIf4kcAxmNL8G4uPMU9cQLCL2RFvO/hh5mwwTQvwK0Kqha701/7nZqIRUAiCMjHE0czNJGO4ozUOl6okNy6ArxU8NfsFneDiLeeZKukDpqiFuE3xUYmHqjsB1x5PgFryNW4gYc2bF8EO931PbeaUSRlhHSapO7zHEgDV9YjNEES7yjPmfgxjhnd9lqRTNn0Jr+oxP8PEKicGWHF2Kavp8Vd9pZVoUhiIvEkj1uug== 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:(13230025)(346002)(396003)(136003)(376002)(39860400002)(366004)(451199018)(66946007)(66476007)(5660300002)(4326008)(66556008)(41300700001)(7416002)(8936002)(8676002)(86362001)(36756003)(6486002)(478600001)(1076003)(6512007)(186003)(26005)(107886003)(6506007)(6666004)(2616005)(2906002)(316002)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iXuTQr0+5Uw/Ms1EjhBNOYjAeNSYvHaZmA2jaTiUsfENsqaunp/1iVD6+kQJyWSA91sX2qHYZTprP69kfr3V28J6bu4qVhlWG1I1xURTy41KMDAwrFlv0bVUTh/lUT+DG8S+LGXC3sId+amYNbEC1zG8aNa23ePeTFWqybvSzBcOC90XoE+rzJaldCgoLQCcRo+/oymKAJX0Tvp/w41hWclcwfwi+7JKPSupCGEbWvNsLXswwKPQuCSoua5wVUohEoudPtediHcrQFKGSPm5nLSfSEP8InXSmLWYkGf5Jge5Tv4d2EHdYHcpVuU5UeuODIlvUySI/BTjuj3+aCVvbezkLz824ooiyFRyqh+BuTP/FPwydChPrO5d790ywQqUMcikyygnIcC4F26JVIykV6EsIR/nr15nF2VQBtSpN1NH6tcoMe9fL9BPFnIJxc2Da+V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OsAL3IFHebCGP69GJTeHw7deO3MN7rKn7wwEKX5k4wFz2DbAjrqcg+qH6VZjqdax0z+JSgho/9FJ39wwFzzwn5dy4kKCd9Kzl+6MCVhcqZ/AzC3DcB8QdOQNTZqqguN1yjFmSq2K+8tBfe+Uc5m5B/WQdT2Zv3MqpmbOJOzQ8rNR9SA47PlFB0QcZDze7hHS4heyQ+7C7PUXZ3g4jZjOZjnEijXRSG6y35ingZV0zOOrcg0xwtwFTriZEXKKvtWDEaFvWyrNAO0hrDcFuQQV4cOs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3d214e3-49c5-4c58-dfe9-08db1e5f1530 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 16:23:13.2276 (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: fol9016Zr57xA03kCyhP8Prbljwit4J1TILAcMNHfZlqGh099HEs/vJeIZP2++ceaxDZd9v5pP7dRvKtz2YgdaRgcmbgcLy7fBO7dHLnpG8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB6530 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-06_10,2023-03-06_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303060145 X-Proofpoint-ORIG-GUID: 5ieTIlNYOlekrNhT-pNfW7FgT5wQo6KA X-Proofpoint-GUID: 5ieTIlNYOlekrNhT-pNfW7FgT5wQo6KA X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759636949610816584?= X-GMAIL-MSGID: =?utf-8?q?1759636949610816584?= This patch is dependent upon the patch 'crash: change crash_prepare_elf64_headers() to for_each_possible_cpu()'. With that patch, crash_prepare_elf64_headers() writes out an ELF cpu PT_NOTE for all possible cpus, thus further cpu changes to the elfcorehdr are not needed. This change works for kexec_file_load() and kexec_load() syscalls. For kexec_file_load(), crash_prepare_elf64_headers() is utilized directly and thus all ELF cpu PT_NOTEs are in the elfcorehdr already. This is the kimage->file_mode term. For kexec_load() syscall, one cpu or memory change will cause the elfcorehdr to be updated via crash_prepare_elf64_headers() and at that point all ELF cpu PT_NOTEs are in the elfcorehdr. This is the kimage->elfcorehdr_updated term. 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 --- 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 c9aaec9de775..82ea2b1bdc61 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -471,6 +471,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. This works for both kexec_load() + * and kexec_file_load() syscalls. + */ + 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.