From patchwork Wed Nov 16 21:46:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 21296 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp77938wrr; Wed, 16 Nov 2022 13:50:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf687B/Pyv+SRObLcXguvTq6ZlVgJauw8+HkGQZnvqMAeAbqxP/JoD+5ltuH1s9CBE4q+xq+ X-Received: by 2002:a63:224b:0:b0:45c:562f:b2b9 with SMTP id t11-20020a63224b000000b0045c562fb2b9mr22013915pgm.245.1668635407370; Wed, 16 Nov 2022 13:50:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668635407; cv=pass; d=google.com; s=arc-20160816; b=spTB/NXvV7TwLSY96RXnLfNXnALRHZO0ExS8nSBUhNBozQh4Vy7vA7dzNBrCYgl3DL B1Emk/LuKGr3/QCSNV8K3knjSo1URIN3kmoM+NWCCQlrHuYdUxtvzMHWzPNkOvrgU2bd oDm3w995JAp86d35cMM4AD8kiqst6WetRFItWLd62KIGt/9YTDVL6u3hoScNTtjLn25x n2Z7ufEBo0VH7l/H6PWovA4v+YIBrelgVHcXLrBD22iIHBaTcw2GVvpIBfKfmuNkQZ/B My3rMPBtCJz073imGBrvPx6et5CybYoM0u1uox2kYaaniPkYNoB+NkDDkUgse0OZntqY smBw== 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=yMEg29W3sMLUXgMiy8fBRbgWQt1x97oMT+MMk1QNbdw=; b=HACt9HPmb+JXdQOWyx2Ph6JzQmC+fvw55nBmsvs8twaxeZA+RNR+yAt9HqnigK1gJC JsXsG4k44TBh1+Ot3kv5+t8s2hJaR/trGTXP4sVwhTVAqx5+oQrJ5G3DEm0m9ujVc7PU 2oXredG6nVdE4eBLISb8FlfnNMqMRPuBKyQmWaZePilveipOL8VqRnlCiiDg4sHGXNvR g60vplOW3jTRWtMg0WwMZPs7Kv95UG7gW9M6YJCnuZZUX/XPP5k38/f1B82vFYuCxONB +ApScMccjWLb8IeQlu5f0zHd8xfn0sxnZZzt0mFDM5URSH8OqISLlv4V3LMiOJAYUaI4 xbaQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=o8d6jDEj; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=EUQWIZW9; 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 i9-20020a17090332c900b00176b7b8cf2esi18265106plr.586.2022.11.16.13.49.54; Wed, 16 Nov 2022 13:50:07 -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=o8d6jDEj; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=EUQWIZW9; 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 S234438AbiKPVrx (ORCPT + 99 others); Wed, 16 Nov 2022 16:47:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234161AbiKPVrf (ORCPT ); Wed, 16 Nov 2022 16:47:35 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A62A165A8 for ; Wed, 16 Nov 2022 13:47:31 -0800 (PST) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AGLhWOH024213; Wed, 16 Nov 2022 21:46:56 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=yMEg29W3sMLUXgMiy8fBRbgWQt1x97oMT+MMk1QNbdw=; b=o8d6jDEjSmxxjhAH2r4zR1penVClzaIsc4eAraeAiFF83MllxgUeQ7UoPZfdZmHCIxjW KgOwWW0i9R1SDnDX7HWS3R2cGLffripwJZ4qCHQ7x44LICumjJ38+LMnlMvNm+gKVasE YGHnNhJb/K0oXk2Ow4xVyqjj/IuTZNr4Y6a6g1z7XYAHgyIR0to86utcLn6U53qpNf3m QJuOGSryZvLcjGOEHKALs7bC6gclFbSa4ktbrXrpmT8+K2C5JVuV/Bxjj1WMgwjjzIZW QiidC09HP2rRtq3iloCy5ZYHHUYRCCVhyuQEajg9g3BBQpJRlRpuuwg2+nMXurp+0SRB sw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kv3n16t5g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 21:46:56 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2AGL7Dm0040913; Wed, 16 Nov 2022 21:46:55 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2171.outbound.protection.outlook.com [104.47.59.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ku3k8y3kb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 21:46:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UN5tkUl0l5RYA96yu5IG2VKRIB9FCLLnhYT+gE6z7LZWjLRrj0jtmHWcEYI9lBrIQzSQ7k78kkGgtCsELioQ+g5pRgF8+jTyhU3z8+G46FTo07Iz1pItftl3lLfZBEMiWGc7x8JNJ16qctP0SIpP9E7pS+7zfrHTO2FoZi207NCAXxYOhw8HAXx50VFp5yhEZKnKt85XDZ2gE5V8lhcwu99k7AtnfwDIVMcpHxfw30KGmNFyRPLCWQY3m0JC/xZ/GuxJ1qRhS67fyyIphXq0dTLoDpR1vNLNDYmF5lN15z6LFMcmwd8yaf8MZpQlvbD2anWrp4MXEyQ4H/HNPnMC2g== 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=yMEg29W3sMLUXgMiy8fBRbgWQt1x97oMT+MMk1QNbdw=; b=ULBhyYGStk16ZmZf1bBvsvyCK3IDPP3PV9qGQYiYPBJ1GQMgAA8al6L8micljNNYtDLW1Ep21C33kqbdN+HcAr0LbIGeoxc0DDMOUCwCMYi4nX+JMqT2vHsQ+E7oQTGxNaDuGYJq7MINFN9TkEkK3Dim6GXE/dTQKnK2bXLT4qP5lfwnaRJ3cDGYSy+ZOJUgTlXQfaYEcpKrCcNQ4AyLHt4iHLEcW+UiK7Nk6caq5hZcx+wIEcqT0rfUEYrf5vQZ1d9ekmaYgyMC6sqWIHMXzYazFHO4aKtbAzue7ZLJXxiAiKSUUvX8ZjDMwdLOY5mZTcubWirQm92f3Ba7O3RJVg== 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=yMEg29W3sMLUXgMiy8fBRbgWQt1x97oMT+MMk1QNbdw=; b=EUQWIZW9MtyiluJb3Atexp2u6/almX60yftMTuuiEFrO6rduXVyIcXkxLyuYjdrClNTkOur8veA1EmDmvC7adcet+9mIk7bRf+jdeQyzXeknpEiJf89x+YR+2UyFLLnFCrXu01mPVF54XFe9AoJFs095UI5XOVvkIyqv5yiUumk= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ0PR10MB4637.namprd10.prod.outlook.com (2603:10b6:a03:2d6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.18; Wed, 16 Nov 2022 21:46:53 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::f7b2:af85:fe37:31a7]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::f7b2:af85:fe37:31a7%9]) with mapi id 15.20.5813.019; Wed, 16 Nov 2022 21:46:53 +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 v14 1/7] crash: move crash_prepare_elf64_headers() Date: Wed, 16 Nov 2022 16:46:37 -0500 Message-Id: <20221116214643.6384-2-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221116214643.6384-1-eric.devolder@oracle.com> References: <20221116214643.6384-1-eric.devolder@oracle.com> X-ClientProxiedBy: SN6PR04CA0091.namprd04.prod.outlook.com (2603:10b6:805:f2::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_|SJ0PR10MB4637:EE_ X-MS-Office365-Filtering-Correlation-Id: 57ec44e6-ee9a-4a2d-c3e3-08dac81c1322 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NNAiHKzSLyVhoLW/eK56U+FhYZReRWU79aXyI/9XxZ7AZHrsu9zLvFS2obeeRAY9gyVSZq98BXYbab89uJWgUzzOmJjxWsxEv+92Wmp9GpA8fNdA8muSV4LAzl8cSJXqStWW3x8x7W9Lmj6mZwwSxcTL8K1p90RUIdW+PnN1Xfozwp0XYhdoHIO9ZjfqKFT4QaJLBEbdDpn0aMBwYt/+lP5ydrXtrhB+9w1todIxBt1mmu2/U77H+RBA0DX1jAWxsBBuyFt9ksAbRsBVIn+n9J9zzxIjsocMZPnHh3ocyFL0tkl9si8rNRbEo3dVJ5qwdDzPRE8IJyDgrMXOFLsrD7obAT66xfuQa3++LorhSW1xt8MD/Lw9iTnlAWhG6q3FaMvZHGp+lFOHO+874IMS3FoHzWWnQUtwZqqLYjklTtu8SBll6f8Y6OyqfAKvCVzFyP1YICl0W69hJ5Wdt8mDKdXKIkpCZhW/PBtJkQ6Oxg5l1j9GI70qLKLiDVs3Cp1NEQiU5seESFhk5DvGHc5BcCu1dQFuUxVuMY1ouAWJzTukzdrW7V/jiAfdt5QIyW9WXmHEZnKjC9zN7Cvg/PbHhYEVhYCsgXd6yMad5jadqqGrWll8OEy4jdaMA3E37QZpF6sqsWeu2zD6BFVR8Ly2Gu84k+NCX3AgXqcAtJgsr+jzQamFx2mOKKsF3T2r1pm2KN2k4GZ5W7ObNNi8Mg3tWQ== 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:(13230022)(39860400002)(376002)(136003)(346002)(396003)(366004)(451199015)(83380400001)(26005)(478600001)(1076003)(6512007)(186003)(2616005)(6666004)(107886003)(86362001)(6506007)(38100700002)(36756003)(8936002)(41300700001)(2906002)(5660300002)(7416002)(4326008)(66476007)(6486002)(66946007)(8676002)(316002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8JK246N5oRIX9EXJDlF6UPF0FlFyHrwKu3HQjQ0PxX3X7zyq9O/j5ZetWI+49uTQ28InpODBHwJY2Ud29kyBliBwe3CyUwiRrCVKsMsez30rR0Yx9XABLxmXvcmunZ8V6++lmSreWced/P0u6wO2a18+pjm0VV0/fk3K50lVDBbVVNotCD/L3UbAG8wXQY854OEh8uC5ZYdUbkjMjtOJsq2Imdm9w6RMinAlW5p5IZUh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4IlVJzeg94XDOg70G548BGbjy7hkegVym41u0Ed4jBfXxhxwuCgLzjOyY0YDcKMHqFp28Y24Z3p/ygnZ2mDS1NVPWJSouJU7NvAlH4ZWxFwHsS3Wb/CiUhculwZWO37m/ZYsXMfMg7P6Zc9ueReFsiI/Y/299m2ZyEFHBbuJgO5nvC5HQtcRZQRo5APpiBpwF7qZq76BTRx2621DWDb2OC9OkRZB5kbQnzt8svwvmTvXRaBCEAsE0iT9RofGCZpcq1FcT/XBi4NIWRyvuVJz7yuz/E4XAtPnybhKfdBmecTL4hFgud12NGk1rrUW4ip0SzdTALu3KFzte/dxPSAsaPswg9qQhQ0osBKB7DqPmGcpWTlAd3ysEZRtYWR4m5ADTvwiXiQZnb7YZwdCkm8Z2Oo3slz5KQ4eyDj2rn0BuyfcRDFjxFKW92EeTV6dOb/TMuL/h+OlFvfifeqfRY9I9/XtNhHIZ1hN0PDOMuzgvsxH9cNUJxj8EPUS90a2CZLAaoKmXj1Jvbl8YtVT9Iz/d6tm2o6aVzIzxaH+1vwksOmLIBXQbVlPQt14kaTVKSb/INpsuR6QwjKfW/MPIyEaYYpkvb6g0OScJnHZ52w7F03yl89ty/v8KcID28VxcsXbnYx90WY2RwACeGVeeLfIk1acX/YscLmIO5SKr15Hl2XjSLdfrg9jA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57ec44e6-ee9a-4a2d-c3e3-08dac81c1322 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2022 21:46:53.3593 (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: NVgXW2l1/WJmCROTe+gIlUDhOFto6yGWNXxKRP8D4cxvTXndJlufI5z2AJ8Qe+eF2FBHjyAW0SHnxOpNcPfEaxWFcCG9G58QtDOzerCSD5I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4637 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-16_03,2022-11-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211160148 X-Proofpoint-GUID: gS0q9uj4B05ey9rxSbcdA_7-402_e7OK X-Proofpoint-ORIG-GUID: gS0q9uj4B05ey9rxSbcdA_7-402_e7OK 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?1749691040665572858?= X-GMAIL-MSGID: =?utf-8?q?1749691040665572858?= At the outcome of this patch set, the crash_prepare_elf64_headers() is utilized on both the kexec_file_load() and kexec_load() paths. As such, need to move this function out of kexec_file.c and into a common location crash_core.c. No functionality change. Signed-off-by: Eric DeVolder Acked-by: Baoquan He --- kernel/crash_core.c | 100 ++++++++++++++++++++++++++++++++++++++++++++ kernel/kexec_file.c | 99 ------------------------------------------- 2 files changed, 100 insertions(+), 99 deletions(-) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index a0eb4d5cf557..46c160d14045 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -314,6 +315,105 @@ 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; +} + 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 45637511e0de..f98d1742872b 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -1217,102 +1217,3 @@ int crash_exclude_mem_range(struct crash_mem *mem, 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 Wed Nov 16 21:46:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 21300 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp78025wrr; Wed, 16 Nov 2022 13:50:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf52ZQJ3k8fNf3J1vrX6OUKefpoDx76h+XyC8jlvXOY6TroezdZHSiIRhaYVloWBzPYH8SST X-Received: by 2002:aa7:9518:0:b0:56c:8c13:24fd with SMTP id b24-20020aa79518000000b0056c8c1324fdmr73774pfp.2.1668635420507; Wed, 16 Nov 2022 13:50:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668635420; cv=pass; d=google.com; s=arc-20160816; b=HIMKO8ze+pNsR3+iu9GkJn4ZEEvLEc/zVQdLyCRnpzr3O7F2tg66PCqmzmVHmw1fLq a8uQDOuuHCtuJTFwqHTE6GU8YrstJlxklCSAGK0JaSR6Nzetv/zjf0dZ3Za8Hh2OOeM/ sOAZd9bTBZHeWH0gQWwDuslZHEuOC5NoLx/yWwtXjdAhZcXa18yHtep2y7zYIkjumdhl /QcAls6KmL+2t2UnSVjpiRi0Pl9BrRtVQPS1ZmsV+jkzwd4vvS7e9TmVCVxV8luN22Jz Fm64bMPyChkf0EA3S59K+tSoBLAnpZ4wlSHkyfsQuvzUCfcWjW3QucVu/F4UQTUmG967 20uQ== 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=yO1Bb8EkmaYNrUwXwWRdRFTo+nQ8wWUK08fUE02PIV8=; b=x9JDaU5VvTJgmCOokjriyB1WUnF2Hm0ZB9uH1UvfuslR2rQZoMPSq3+j0HHancWCku gPmsIl8LOrZo28TygrwG18ZlCiIp6VD8hKIfEw+rKtKoVqMRLPcrerWwjySPK2zp/wjR Ydz3Umpk1ttXmepui6wKs3z167PlEX7ojNHvZ1HtCg3TCsZtNCyxWusNuJttWVuwboLh i/Bura/wJUcUyXyxGJ9w4RGLpEvVkLEaxSQzVQYwPv9ShtrjP9wtK0x91N6ehyCpbjIG j/MjKu7HFi3IMeK+R9aINvu+PJGuwqtUg3lBAsUhjQ6UR1uEMBPWtP/UlcHu9EGf2RAG WH1A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b="1LAO/gPb"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="JqXV/Fu6"; 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 nl3-20020a17090b384300b00217ec4647afsi3288646pjb.14.2022.11.16.13.50.07; Wed, 16 Nov 2022 13:50:20 -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="1LAO/gPb"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="JqXV/Fu6"; 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 S234464AbiKPVr5 (ORCPT + 99 others); Wed, 16 Nov 2022 16:47:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234167AbiKPVrf (ORCPT ); Wed, 16 Nov 2022 16:47:35 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CFA017078 for ; Wed, 16 Nov 2022 13:47:31 -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 2AGLUo4G016367; Wed, 16 Nov 2022 21:46:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=yO1Bb8EkmaYNrUwXwWRdRFTo+nQ8wWUK08fUE02PIV8=; b=1LAO/gPbRuMXMGELSqf1JLfGoxwDeSccC4iE+Yt1aKiOxAcAHruNF0U9ty5Skdr88xeF Kb9ftl8lSibTU0F9jSuLlxA/TdMQ852xCxEgwV/lvTWZzct3TCS02O53EgfyK2uiK4bO WQZszkAG+hbV7L/lOsZQ8hVVWxRfwhXdXYS5ryoBWJt+1aANVerP4UlZN9Pw3B7Tuw2w 8DN6g481VXEz4ac3NzAL/FtdhcyKVpn8lr2mwGW17/swVdQWgGDu6tZgG2pGJPiq91DX xLf9SuigLCqbQLxkFmaZREzaFORFGj+JTp6C9x9DWYHJaYadVeQqsf1fpGSEtW6RZDV4 dw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kv8ykp6k3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 21:46:59 +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 2AGKmaSe009421; Wed, 16 Nov 2022 21:46:58 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2173.outbound.protection.outlook.com [104.47.59.173]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kt1x847ek-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 21:46:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f+uWAFLX0zNeM6WsjnqgVPj4KvU2j7OxOyDXlM3WYTRfYlp90AqckinbHHKaK2Doejs5GHj7HLnO05kaCkFnGxYcOW7hq3h9/oYLDYifsC1ICNochdT4joWWzwadXaeogvpBRRPiqaug5ZElBIje4okU8CNDiz5osvsFsiNs0hcez6f2qupMfA1oaS82g29yuEwbpp63QjT4ve4gLoMygIsyH+r/LWmB9xz9WqAF/+RLJYuqzljI9/8P/4FdUGm5DlHfBmPILWKssYcCeFHhd0KF1g8ZuxNc4O0BEEO9HDfvo7oayCOCyplFZm3TsrUbbz/w4Ssu/kGOtDm7Ba4xDg== 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=yO1Bb8EkmaYNrUwXwWRdRFTo+nQ8wWUK08fUE02PIV8=; b=lcPVuGTGoQqsVBpk4v8VmefMlruzVms1A4tgKNflTmVnFkawZVrMKAkdSqkuq8K3G8ShrUDnDU4/aV2u/qX3tMyu4PDlCpXCkI525896c1DaTsfDBjefH0OcXldgBdLBY0UAPUIm4NPcskLrottqywLjsnHpQeQV3p2rgmJsFLl7WB3WGAmETuBMHUohttXKtFSy3ArIr95L14RI/yWx3E2h32ZZ5q+gjdboiHwQLW8sFgzA6RrxI70TjbeNsAzrLh8lqkufCavBszsYGIF00JCUxYHwkisbHgfSfVdox2W9ueRqqsuJokoKRyzDuhHrcHF68XQQOlvblhVWPnqbZw== 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=yO1Bb8EkmaYNrUwXwWRdRFTo+nQ8wWUK08fUE02PIV8=; b=JqXV/Fu6W5wBC1QjBhxpQIut4L/6wv9/EOSy4U0tWEBjj+O2866dGsTHrn8ts1Zj7wutixEewQO4u41J+HpWXA16VgxIBzsLeg3rFx4Cb0Ww1JZ2IrCiyyv4vBe0y9JmG+qD4QrKzXw/ytwAXMdY0U1pqcmva0cNiQKiDrwzjKY= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ0PR10MB4637.namprd10.prod.outlook.com (2603:10b6:a03:2d6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.18; Wed, 16 Nov 2022 21:46:56 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::f7b2:af85:fe37:31a7]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::f7b2:af85:fe37:31a7%9]) with mapi id 15.20.5813.019; Wed, 16 Nov 2022 21:46:56 +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 v14 2/7] crash: prototype change for crash_prepare_elf64_headers() Date: Wed, 16 Nov 2022 16:46:38 -0500 Message-Id: <20221116214643.6384-3-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221116214643.6384-1-eric.devolder@oracle.com> References: <20221116214643.6384-1-eric.devolder@oracle.com> X-ClientProxiedBy: SA0PR11CA0181.namprd11.prod.outlook.com (2603:10b6:806:1bc::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_|SJ0PR10MB4637:EE_ X-MS-Office365-Filtering-Correlation-Id: 3603d84e-5795-4046-1969-08dac81c14aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3zx7RSawR/a7q8BaEeLYBQhAyqnPwIi7lcfyua8A+XfqIa7SyGy627DLmYVNEcVzBT1E/FCZy+nKRjds5UKmuKlAdrmC/Ho45Y+5PettZlAFYbzuxuLTrlUvNgfE25x4AQMVGb/5e+CcfMvFq1pfFtolCDUDIvkCf2mgC+nx9ntqeyrFv0DTPZPFyLHJUWYkFMZdJo+Y1XslJh6Y9m7f9qVik3ISC1Nr4W5baj3IcIzP+EOqlO+Vx0XB6L4WvU29LJZUEOI0N5/xT46fGuDMVApdnC8YY7ogQyWg85L6+5lRqsZygTxLWmARuqtVIs4FpX8TNhdXKJ874w2msKWqe4mVHCgG/epSEKZKTACzoFaWyJJ6M9PAX7jvw59eAnt0qlfyammPqvWYwGqZZwHftOJqtnXKshw7rUZeHp9jlUFgb4i7dYODxhGzlEOFsHMzd2i+BBdNWxCTU9mbGISCFuTEnIcBIIMH16aAoXG8YqGmBCj7odNm8O9fAgp7EA+1HDYVcW7gfLbhGVem3G+Hu94PXme2ZMmCuxrWbByeY7h52dIySQ9uexghHLbblwOsuNzCSzGO5E/0VdJD2mnFEmj24p/8rOGypcG2hsct59L+ShD3hPc9NpJtxFLXFEEzaInW84ct7ZsSY75/Y5wxLa13gmh6dCml9TnXdxSbpfPQ8dLWdK7Qaz25KAHk2G/B8j6/INDlSKyqyRxYjYo1Sg== 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:(13230022)(39860400002)(376002)(136003)(346002)(396003)(366004)(451199015)(83380400001)(26005)(478600001)(1076003)(6512007)(186003)(2616005)(6666004)(107886003)(86362001)(6506007)(38100700002)(36756003)(8936002)(41300700001)(2906002)(5660300002)(7416002)(4326008)(66476007)(6486002)(66946007)(8676002)(316002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZhCgyWWCeRCNqrhzzmpeBxyjoMGp5OdZDfLFugpCLbfkj+KK8dHdLxQjjG3DUa8Wcn5WmQ0KlYJOMVCRbBMVuqyJIUJXn0AHcxIkwfl6R3viYwCtZ/3lqxbuzgUyl19uNrfHxNtgTtAEprSaRoqdw398T8DI0+rIDJcntYabizGNGuoZu8dT8AzHSYAwhXebqYBsrBj8a0YfbSk6gr5UuUS9s8vyf9fiAbNzTyGrGzzbFDuag1P0yAT+StkfsJUJe0Pwa7IfRA74wL3mUKpX6ZGcSQnI9w7lRtUMqcTyuWTAyh5TQ8cHAHQ+auenmnlPrAztNHfZS9jKOey2MeNUhfojRxa5Qtd27opohcCcLbjq0pOOcPRtVvHcal1sfqmk5/q+I+Uo1nWcBdvcmPiqdm0rdmrfyNYT8VLxzDZ7Z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LNytj6tCqn1hiICifcdAY1tiLBT4TIUoEW4ZhiuyNCmkrxIbP2Lxu5G8N8ydPUSXBnaiQEnwFgocFI5WsmR5Ckz2PsmzhSOFZJHVZEwKuf8RC7BuRjeU2n8ratipAt0BcVoIyqSEmn6s4nTdTM4BJBVczUfDCzj41IIg2/RkE7N68xgMUgP2jUDyaw2vysv2jZYLQWId7+KpJOj3kCH2MbJ+DStBjTZvo90XdOui4eLF+V48aL4xufth4T039h1RvdUrRfhs7I/NvE8VxkO0MTLEotHZCa2DWT9VULHuBYAZtLRlZ9E3hmszKBJgwvEt0LCOgAHg4qBtvTKmqBOgvGYwmwpPsPnGcWGf2NU1oDFgUa+pJeGEuorp3cBlZawfpG7uvV3EeYs30QBzRS5Jr+u0oXHqACNBVGOgujJuzScDNeBuaw2CI2z+xT47BO32I9ItJzdEuGeOlCa9EenaIteGVIoVTop2S4DWYIvxLXFg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3603d84e-5795-4046-1969-08dac81c14aa X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2022 21:46:56.0334 (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: RkLbUXZEpqZbbjj+hX3S+ROQYYR9SHdIs2NQG+TOM9ZkAyIG0q3v4SeDX1g1rci0G5bYXtJWz44dClhPwkHcVH6coZ86dxN2TYjqq3WMKWI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4637 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-16_03,2022-11-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 phishscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211160148 X-Proofpoint-GUID: BxADNTa__yZ5CxHTZipuWt_SclFTyNhk X-Proofpoint-ORIG-GUID: BxADNTa__yZ5CxHTZipuWt_SclFTyNhk 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?1749691054374678233?= X-GMAIL-MSGID: =?utf-8?q?1749691054374678233?= From within crash_prepare_elf64_headers() there is a need to reference the struct kimage hotplug members. As such, this change passes the struct kimage as a parameter to the crash_prepare_elf64_headers(). The hotplug members are added in "crash: add generic infrastructure for crash hotplug support". This is preparation for later patch, no functionality change. Signed-off-by: Eric DeVolder Acked-by: Baoquan He Acked-by: David Hildenbrand --- arch/arm64/kernel/machine_kexec_file.c | 6 +++--- arch/powerpc/kexec/file_load_64.c | 2 +- arch/riscv/kernel/elf_kexec.c | 7 ++++--- arch/x86/kernel/crash.c | 2 +- include/linux/kexec.h | 7 +++++-- kernel/crash_core.c | 4 ++-- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c index a11a6e14ba89..2f7b773a83bb 100644 --- a/arch/arm64/kernel/machine_kexec_file.c +++ b/arch/arm64/kernel/machine_kexec_file.c @@ -39,7 +39,7 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image) return kexec_image_post_load_cleanup_default(image); } -static int prepare_elf_headers(void **addr, unsigned long *sz) +static int prepare_elf_headers(struct kimage *image, void **addr, unsigned long *sz) { struct crash_mem *cmem; unsigned int nr_ranges; @@ -64,7 +64,7 @@ static int prepare_elf_headers(void **addr, unsigned long *sz) } /* Exclude crashkernel region */ - ret = crash_exclude_mem_range(cmem, crashk_res.start, crashk_res.end); + ret = crash_exclude_mem_range(image, cmem, crashk_res.start, crashk_res.end); if (ret) goto out; @@ -74,7 +74,7 @@ static int prepare_elf_headers(void **addr, unsigned long *sz) goto out; } - ret = crash_prepare_elf64_headers(cmem, true, addr, sz); + ret = crash_prepare_elf64_headers(image, cmem, true, addr, sz); out: kfree(cmem); diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c index 349a781cea0b..a0af9966a8f0 100644 --- a/arch/powerpc/kexec/file_load_64.c +++ b/arch/powerpc/kexec/file_load_64.c @@ -798,7 +798,7 @@ static int load_elfcorehdr_segment(struct kimage *image, struct kexec_buf *kbuf) goto out; /* Setup elfcorehdr segment */ - ret = crash_prepare_elf64_headers(cmem, false, &headers, &headers_sz); + ret = crash_prepare_elf64_headers(image, cmem, false, &headers, &headers_sz); if (ret) { pr_err("Failed to prepare elf headers for the core\n"); goto out; diff --git a/arch/riscv/kernel/elf_kexec.c b/arch/riscv/kernel/elf_kexec.c index 0cb94992c15b..ffde73228108 100644 --- a/arch/riscv/kernel/elf_kexec.c +++ b/arch/riscv/kernel/elf_kexec.c @@ -118,7 +118,8 @@ static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg) return 0; } -static int prepare_elf_headers(void **addr, unsigned long *sz) +static int prepare_elf_headers(struct kimage *image, + void **addr, unsigned long *sz) { struct crash_mem *cmem; unsigned int nr_ranges; @@ -140,7 +141,7 @@ static int prepare_elf_headers(void **addr, unsigned long *sz) /* Exclude crashkernel region */ ret = crash_exclude_mem_range(cmem, crashk_res.start, crashk_res.end); if (!ret) - ret = crash_prepare_elf64_headers(cmem, true, addr, sz); + ret = crash_prepare_elf64_headers(image, cmem, true, addr, sz); out: kfree(cmem); @@ -212,7 +213,7 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf, /* Add elfcorehdr */ if (image->type == KEXEC_TYPE_CRASH) { - ret = prepare_elf_headers(&headers, &headers_sz); + ret = prepare_elf_headers(image, &headers, &headers_sz); if (ret) { pr_err("Preparing elf core header failed\n"); goto out; diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 9730c88530fc..9ceb93c176a6 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -265,7 +265,7 @@ static int prepare_elf_headers(struct kimage *image, void **addr, goto out; /* By default prepare 64bit headers */ - ret = crash_prepare_elf64_headers(cmem, IS_ENABLED(CONFIG_X86_64), addr, sz); + ret = crash_prepare_elf64_headers(image, cmem, IS_ENABLED(CONFIG_X86_64), addr, sz); out: vfree(cmem); diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 41a686996aaa..ebf46c3b8f8b 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -253,8 +253,11 @@ struct crash_mem { 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); +extern int crash_prepare_elf64_headers(struct kimage *image, + struct crash_mem *mem, + int need_kernel_map, + void **addr, + unsigned long *sz); #ifndef arch_kexec_apply_relocations_add /* diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 46c160d14045..8c648fd5897a 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -315,8 +315,8 @@ 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) +int crash_prepare_elf64_headers(struct kimage *image, struct crash_mem *mem, + int need_kernel_map, void **addr, unsigned long *sz) { Elf64_Ehdr *ehdr; Elf64_Phdr *phdr; From patchwork Wed Nov 16 21:46:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 21295 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp77926wrr; Wed, 16 Nov 2022 13:50:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Rht0nrWeEbgwiOYut8AQpYKnwdJvvOwjh4QM1gbL33+UyBlhRlSAIDujY7tVBmzfXjqBV X-Received: by 2002:a17:90a:7bc1:b0:20d:23ee:c041 with SMTP id d1-20020a17090a7bc100b0020d23eec041mr5564267pjl.140.1668635405679; Wed, 16 Nov 2022 13:50:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668635405; cv=pass; d=google.com; s=arc-20160816; b=JDWcWA56D0SgJtc7VRSzpbcAoIPqUZ8N3jTltWv72H1q+xlMWRby/G9QGWEoHxYRaa GnGUIajuSYfNKyI1p3nheH/i1DQ1HqMWdW80s8t7Pzz75Pa5YAE0txMKNJBgS+uRYLF/ koCua2Ti5pKzVmWSZ52o6kdOrtSKChj++xsC+gHsQQkc28RpTYv+w3ys0HVVHLmcl6uA CA9CfkdWEK4TfUlluK3lEBXzCHmrosACpEoo6Dw3x5dxjC0PfQN1PjpoXK8ZwA53HSM6 88tExnNEiZRCOBQ9pIxMvxqKQa0hhrBTtVJse21Vi/DyHA0b46XwmU0f07CeO0KJaS8R uSBw== 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=Hj6QP3AF4aXAFQOvMDiGMeqsass/ASyHJ9oGGdbl6H8=; b=kGf2doR20QEy4ZzuHNlLSTeiXv6SsHssDHsJ4lwUIgNGZ3F59V1q8D1Mjr/NINgKU6 lYA+CoWFG0ycOrvTowJqg0gXq8eTE9/znxeZbkNvzD57AFPJ7BDT84f27RQsboaNpKCj 82l4ztVj0VZbaLnItSHIutMfwQ3YQWneSzHvEDOIg0WwbHK8yj7EDnpywEeNmAeewVpB qT1Xkpl8UmMjiy/9KN9B+nPRWL1Wzd24rn42k6XHzWyLpBXwIbp55ar5RgfQOM7Ax+OV 5LXOlzShL9OGrQZPtC1eWVSbZogQQ6T62lifnmH6aB9kWkRAb9Taf93nPd7CLKaUV4kz +Izg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b="q/o6WyCg"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=RemdNfOx; 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 l2-20020a056a00140200b00572dc2ed220si1152613pfu.231.2022.11.16.13.49.51; Wed, 16 Nov 2022 13:50:05 -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="q/o6WyCg"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=RemdNfOx; 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 S234020AbiKPVrf (ORCPT + 99 others); Wed, 16 Nov 2022 16:47:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233262AbiKPVrc (ORCPT ); Wed, 16 Nov 2022 16:47:32 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80D1613DDD for ; Wed, 16 Nov 2022 13:47:29 -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 2AGLdKiQ016874; Wed, 16 Nov 2022 21:47:02 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=Hj6QP3AF4aXAFQOvMDiGMeqsass/ASyHJ9oGGdbl6H8=; b=q/o6WyCgmaz1Woru8KgqLCXFIXwpM4JeB3Ot2RiORKmhI+h9yPcqvxmD7qy5KEpJCXw8 Bi/rJDOOKL6tsP6PACOL0f6vjCBNe4RhOZ4+euSpvO8jf8R9GW8ZbL1sQHt6xEe1pdvQ jGSZUPkZFdC2A3xFptGJqfKA4Sgst4nvZkhLwCHPumx71OouJf587kuYW9N1Q72C/+R1 uy6bWOU3QWKVUaUcQkkzAw7yUEM7RInUzF8pm3st5Gjb8OOSoLIIAGkDCm1XBa/TixXi ro/3RZagpJW+nJOgatMI9a0VHUtZW5ncw6M96oTuTb5k8I65bSvSAjvxh+Uk7ia+qEwf hg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kv3htxthf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 21:47:01 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2AGL1Ye1000301; Wed, 16 Nov 2022 21:47:01 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ku3k8y3q5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 21:47:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N3rI4Or7TLDa4rgJ4qhYMnVX5Z9he8kuEzTAeu+mAPJ56Fs+bODVMDZfA1VzaL4IdXpnQPR4u5jr6v+WT5UgjiC7vjU8sLbAFrwbH6U0W1GqHcJi5wyfTvsMmX2d06AYLTKi1865+2zX3qE9PDxs38noLjFahbg4Qc214yjTO+PfnDEWb5+Q/aYUgUB7ZxGQGN1VC2J3uR5ymefDQGaUSwhBwVrDUHmJePCNliBKqTp1EvFK6rDW07GCN+uGTYhACQeH5O1b/JDi8m2p+aNOaQk2uKcu6AM67zypbqhsbl3vXycEhs+yC8oZDMD7k+KBD0QQSAF3ubrzUtJ7ZtoZBg== 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=Hj6QP3AF4aXAFQOvMDiGMeqsass/ASyHJ9oGGdbl6H8=; b=cKsujr4YlWzeLNel+5YvZGKVVC7kY0jHS0n6k+Kr38vmfSd8oIW2FrRqU1/duB6NqMcxg84Kbi+Z+E2naN0DNAzPSyOv7+ryJ3AZUGgZc4X2kh0Zjw9teAZPDf5izoGfTbvu8I69webQHg9iNwwNPZOk+RSv/o0lAP9QBYh7DWrpLFmjToc5YtEY8alwd+u5fFx2fA0wNT29xeJTAMRFhos8kW9ti+ep6dlIAVO+DjSGgkbuyIUZxKE8scENcFJqECV4RM9mcI8wnrMY0/ndYi2bz3+XXdoLsovfCVfCLz/Lk+Wgz/dyhcZT4mWTRAZVUc6oAxiMLa/8IBzfwUdBQg== 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=Hj6QP3AF4aXAFQOvMDiGMeqsass/ASyHJ9oGGdbl6H8=; b=RemdNfOxjzYZI/YtNq7T0lnR/qQHWb4HJ2zf9ci+4Sy/EM5MBpW6LGh9Efa2lbEP0SDNmW7VWlmE2ho4Tje0o2SNKXhG/Co1Sh4jrzsRBs6sharMoRY3np1ynchFGDaTWgKROHlsBJQEUYIebu0eXoCa8FzTbZyH/kWimPVSV9k= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ0PR10MB4637.namprd10.prod.outlook.com (2603:10b6:a03:2d6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.18; Wed, 16 Nov 2022 21:46:58 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::f7b2:af85:fe37:31a7]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::f7b2:af85:fe37:31a7%9]) with mapi id 15.20.5813.019; Wed, 16 Nov 2022 21:46:58 +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 v14 3/7] crash: add generic infrastructure for crash hotplug support Date: Wed, 16 Nov 2022 16:46:39 -0500 Message-Id: <20221116214643.6384-4-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221116214643.6384-1-eric.devolder@oracle.com> References: <20221116214643.6384-1-eric.devolder@oracle.com> X-ClientProxiedBy: SA0PR11CA0206.namprd11.prod.outlook.com (2603:10b6:806:1bc::31) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|SJ0PR10MB4637:EE_ X-MS-Office365-Filtering-Correlation-Id: 41b885ac-0fdd-466c-0b3f-08dac81c1638 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NZ6hMcNovM5RjaW4AR2rAuCGjHUG5P6nk1pUw43Mhj6PwHj5Gp+kUHz62l5NR3unxMMbErD60nHD5oDKofBLcZFYIsuJQQBHsY9rdCvQUhlOtAQyWPRN82fU443Spwpvq1Sku5yGVLIXP7mcN3BnOdiEMmYOIrB9ZcrPuJbdtQf4Eq/68Ot0egge2drf9N20v/diVapV5HjG/Gtj0wNKs8ayVrU2XebquUVWg9SkAzURk1UnLqezCt6wLCRv8JtKzjKCmiLl6XGh8AbDqHQZjeREztUFnY5mCMDyCtaIqmgZb8cZ3kpUcYlrkRY8bCqR9FDX1Y1fdJ4xQ3DQY21BX5WMUOe5skWa/PwrhocZn+XEIJadok/nheELur0lXoZKAiz2IO6WAebS5jHu9ypddXTF0sTVcStZ9k4rqcHFZudSpx2tTPN9e9IlivFwJZlt4IBW3YHnot9QOrucEOl9MIcukfUMC/W6bGbn6oAWF6n8FDyWJq7nUakQiLBxyeyi8uQTCmbPSVSXPO+xJiVDK7mI9omT/5XEjpCt2pkAuA6O7CSg+SdxStAkb4WIyDRFF6EamhR+fMFhQVbGh3YDEaM5K7k+EPWf5T9HTVxb/x2FraPt61uCBMnv+2MVlv+APpbX4iJoswoJncvsOvvgHs+TeFvjYH4B48GC0vBClSEtyhascm/LKf1nEw2rLmMdPk1obj1LXs4u6fQmUXftkij6NvqnaLV8pXA1ceK+kXE3eF6ieDzBMretxPJysjEl 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:(13230022)(39860400002)(376002)(136003)(346002)(396003)(366004)(451199015)(83380400001)(26005)(478600001)(1076003)(6512007)(186003)(2616005)(6666004)(107886003)(86362001)(6506007)(38100700002)(36756003)(8936002)(41300700001)(2906002)(5660300002)(7416002)(4326008)(66476007)(6486002)(66946007)(8676002)(316002)(66556008)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EpCiMizW8oUP3Tjc87UfSxqdpd7mvvzEAXpIrSkbT6odY9Qv7hlALNvGKhZTKJP880F47ahQZC59cOHDcyO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FrshNYxp94IUinhF9adm7KEsjHabip30mUqFBaHWbt15hvWyiyC4UdLHkB/+wIMUyGBa2nhfOM7JvQLxaylD9ewrxmhuwFCXd4S0/zoEX9sQELvSz8M3hOyVj+LB6vFE3DIUTQGc0zX/S5XVAkOykgExyvqMmGKtGpmesom0JaLEUXqEqJMok1E2N3ponFgILWfCp2Zkvzpq5FtjIlOrtC4SNFbAi7jJ2HlBscm99dPMjmYw2jDL14e8bsJKqj0OtGVX/5Bw3aMP0OgXO5rjfoAkeioFOUHB1fES6u6Bcwfh/8DOK7spm1cTkcPW/U8mbYAFVRLNWChOwzo0VFcdLMxGR4mQs0NpeHrtxT/Hl8VaEP3amecm9O+wyzmC/uBRYTkRhRKA06gQwNQzXkFeIzkJKgPEH0LQzPebtL11pbmV554lrRXkfMbasr/SNbjBDfvc5iMkp/Bq29Vjr8QbmnOf0jrKViTwR0DDwvVf8llpH4/6XUXLeWl4YiqQSy45fLm2af5xiAm5S586RL2CkKwKuzznWYYgqAdmkSTLhTuPc7b83DiX0uzYZ+6/15xiUTGdIo0qGDK4BDPMiSChrGwegCtTeuBJcOXLtVbx1hdZhybjTFkByKE4u0u8pTGKL+BvX2me00m4JkBC8g0Rtx6jop8EgItxwIUjdGKCpZZOYlksjDZNtr68UvjV/BL0H/xO4yt6DsKo7QtMZwVFGxhQweHlytkrnlSKS00Wp+apnbMTxhqcjRmrxcM2dtBe8FoFWo4IMzNPhAO/B5DzY+ohNRHO7Q5mzB6b9viCYPKnSglDr+3W73oajLiIIt3HA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41b885ac-0fdd-466c-0b3f-08dac81c1638 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2022 21:46:58.5944 (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: shp8Bh7bySZQc1M8plGPnUADZbl6MRTHjgjSz+SgsPSd8dmO5lH/FhjHp46pzd//wFitGlymzCuDjzmbj7k/GxOJ7wwddSUO0ewwbJGhrBU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4637 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-16_03,2022-11-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211160148 X-Proofpoint-GUID: RAA66WreBW7AneB-7fbPsZNVP48XsRbH X-Proofpoint-ORIG-GUID: RAA66WreBW7AneB-7fbPsZNVP48XsRbH 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?1749691038883296911?= X-GMAIL-MSGID: =?utf-8?q?1749691038883296911?= CPU and memory change notifications are received in order to regenerate the elfcorehdr. To support cpu hotplug, a callback is registered to capture the CPUHP_AP_ONLINE_DYN online and offline events via cpuhp_setup_state_nocalls(). To support memory hotplug, a notifier is registered to capture the MEM_ONLINE and MEM_OFFLINE events via register_memory_notifier(). The cpu callback and memory notifiers call handle_hotplug_event() which performs needed tasks and then dispatches the event to the architecture specific arch_crash_handle_hotplug_event(). During the process, the kexec_lock is held. Signed-off-by: Eric DeVolder --- include/linux/crash_core.h | 8 +++ include/linux/kexec.h | 36 ++++++++++ kernel/crash_core.c | 139 +++++++++++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+) diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h index de62a722431e..a270f8660538 100644 --- a/include/linux/crash_core.h +++ b/include/linux/crash_core.h @@ -84,4 +84,12 @@ 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_REMOVE_CPU 0 +#define KEXEC_CRASH_HP_ADD_CPU 1 +#define KEXEC_CRASH_HP_REMOVE_MEMORY 2 +#define KEXEC_CRASH_HP_ADD_MEMORY 3 +#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 ebf46c3b8f8b..b4dbc21f9081 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -32,6 +32,7 @@ extern note_buf_t __percpu *crash_notes; #include #include #include +#include #include /* Verify architecture specific macros are defined */ @@ -374,6 +375,13 @@ struct kimage { struct purgatory_info purgatory_info; #endif +#ifdef CONFIG_CRASH_HOTPLUG + bool hotplug_event; + unsigned int offlinecpu; + bool elfcorehdr_index_valid; + int elfcorehdr_index; +#endif + #ifdef CONFIG_IMA_KEXEC /* Virtual address of IMA measurement buffer for kexec syscall */ void *ima_buffer; @@ -503,6 +511,34 @@ 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_map_crash_pages +/* + * NOTE: The addresses and sizes passed to this routine have + * already been fully aligned on page boundaries. There is no + * need for massaging the address or size. + */ +static inline void *arch_map_crash_pages(unsigned long paddr, + unsigned long size) +{ + if (size > 0) + return kmap_local_page(pfn_to_page(paddr >> PAGE_SHIFT)); + else + return NULL; +} +#endif + +#ifndef arch_unmap_crash_pages +static inline void arch_unmap_crash_pages(void *ptr) +{ + if (ptr) + kunmap_local(ptr); +} +#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 8c648fd5897a..4e7221226976 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; @@ -612,3 +615,139 @@ 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, 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 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, it is wiped to zero, so + * the elfcorehdr_index_valid defaults to false. 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_valid) { + unsigned long mem, memsz; + unsigned char *ptr; + unsigned int n; + + for (n = 0; n < image->nr_segments; n++) { + mem = image->segment[n].mem; + memsz = image->segment[n].memsz; + ptr = arch_map_crash_pages(mem, memsz); + if (ptr) { + /* The segment containing elfcorehdr */ + if (memcmp(ptr, ELFMAG, SELFMAG) == 0) { + image->elfcorehdr_index = (int)n; + image->elfcorehdr_index_valid = true; + } + } + arch_unmap_crash_pages((void *)ptr); + } + } + + if (!image->elfcorehdr_index_valid) { + pr_err("unable to locate elfcorehdr segment"); + goto out; + } + + /* Needed in order for the segments to be updated */ + arch_kexec_unprotect_crashkres(); + + /* Flag to differentiate between normal load and hotplug */ + image->hotplug_event = true; + + /* Now invoke arch-specific update handler */ + arch_crash_handle_hotplug_event(image); + + /* No longer handling a hotplug event */ + image->hotplug_event = false; + + /* 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: + handle_hotplug_event(KEXEC_CRASH_HP_ADD_MEMORY, + KEXEC_CRASH_HP_INVALID_CPU); + break; + + case MEM_OFFLINE: + 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) +{ + handle_hotplug_event(KEXEC_CRASH_HP_ADD_CPU, cpu); + return 0; +} + +static int crash_cpuhp_offline(unsigned int cpu) +{ + 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_AP_ONLINE_DYN, + "crash/cpuhp", + crash_cpuhp_online, + crash_cpuhp_offline); + + return result; +} + +subsys_initcall(crash_hotplug_init); +#endif From patchwork Wed Nov 16 21:46:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 21294 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp77929wrr; Wed, 16 Nov 2022 13:50:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf5TNFJqfgIz6ArrQ1mLLTH+grtQxn9sWUHHJPky7qODQ63S6Lirf7XqYHjFjsLkEN+zvaI2 X-Received: by 2002:a63:4a21:0:b0:46f:d9f:476 with SMTP id x33-20020a634a21000000b0046f0d9f0476mr21807452pga.468.1668635405876; Wed, 16 Nov 2022 13:50:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668635405; cv=pass; d=google.com; s=arc-20160816; b=p8Uxos8MxUWzwbNcnVaEJYy4K3lfncx8RiNOQW+J3XBdJo3IlwBzwlBBLyVd/zAITt jc4TPb10EJs3P8aGdkTVBUkZYCBSNr8sPvhxu0C5fs0haCc2fliOHpIlWvYW58Azysjq PAcxZcVj2sMJRO6uGyjP6dwUoRTgRhhhHZPwa0AIL6SwCglqcE0DyD0AivsSlBtTmo5G NKhmBWUFyOaxMb6OMbdaIK8vDzybyUv2OUhh/mlB1/GoIgUr+eWXoy87yTOxq71BmTnN PHVt8SmQz+ctP0aLB3OBjIM7OrDv7ggzKOfvO8b7ojYnI+gzvGglib5n/4R40mi8t+5U jLXA== 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=mijXuv7oHiRF5lvBg0NKfhfXlOiOtyS505PIT5Fw+o8=; b=NbKt8R8W+S9763wEr23OPUiK2lBTAmL6yi/TCqoo5YGbY3hBzY/pYq+naSzqfB1bMp 8zYNtJTGIC8a+IZXWmG0MrvjnHDzwNUsUM+5c6MR/WlomJ9c5Q5ogNoS0vWc2xfZJs9L PHXtnIIniRF0ZCVOp/lZh5b3yvi4IANl1qYU4bXiOZ6vDbsg9o21JvQmiqWZYSjLKzjq qh4kio2qvQqkwjJouWVAHQbDz9Cv2RgFlXRUCDtg6X232SgRvTPfsuXH0brWUXxz7Mx1 StDJZ0gnNa5EiCfiTX3oYlU3VBHkBpTrP6FOV8mNUv2Ab0c5OOnS1TQ/lXOYLmwLt1Bi 2oyQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=Yvdz0I47; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="gZc/KgwW"; 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 b8-20020a17090ae38800b002036f0a953esi2683058pjz.88.2022.11.16.13.49.53; Wed, 16 Nov 2022 13:50:05 -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=Yvdz0I47; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="gZc/KgwW"; 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 S234045AbiKPVro (ORCPT + 99 others); Wed, 16 Nov 2022 16:47:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234156AbiKPVrf (ORCPT ); Wed, 16 Nov 2022 16:47:35 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12E4815A1E for ; Wed, 16 Nov 2022 13:47:31 -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 2AGJJhj3021463; Wed, 16 Nov 2022 21:47:05 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=mijXuv7oHiRF5lvBg0NKfhfXlOiOtyS505PIT5Fw+o8=; b=Yvdz0I47/YGbqMABBU7L2ICF6fcix7LjzadxRJCCrf7rAl/MrZbuQ3pHegJHnr6JZdNy EPGQOlk3A6vzWE9a6wE4GiZ14XHsMz2WlNyMSy69ONvufVjqJh8kelkxgInGnjoxEjAI IJr3Ko9Q9G+jAW+CA/Ta5fXEYvPpzTbmYpVcOpo3rD66yGpFtIT6pO35Nk+0XClgCbAR o3mHmQEjrZAf5ee4SlMUtPnTe/I1ttZiRjxUksJW69wdLBym63wZRSP1B1o/xq5p6viZ 3t1ztHib6NjOQrirqeHE9Uvl7XYlS+B6RjxPq5f/MW09lJkiyGoT0GvsGQXxWqwODmEn XQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kv3hdx9r4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 21:47:04 +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 2AGLdJrx009418; Wed, 16 Nov 2022 21:47:03 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2101.outbound.protection.outlook.com [104.47.55.101]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kt1x847ka-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 21:47:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WH8wo6tcmCMPqMLxgzp/xoS+WuzhBHFi8PKQgXjqdtx+4bMm3EPhRLWqjNXsAA17MSlQHJgCJc2yOo7Iacf4AspMYwTAJkQ7ztztgfcXKTVSwMZtpo8h63TPqXFsY0hfahD0m/R4NHLIXUaU7iSyNi278RFg+pzSHJI9gdTxezP3GsTFghAxQfnFBaSoe0mpg7zqQhU9dUojxO3wmFZ/0ywpyddrB1S2B80wFKj0IqCSHK7ynfCBpBW3YYjBOtiw4z79kR05vSwOhH0GETVO4/3HTJm5wh95E77RVgkPepJPArYSPQ7gOT2m/gges0OGDsDlukh8jytS1NecVZClJg== 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=mijXuv7oHiRF5lvBg0NKfhfXlOiOtyS505PIT5Fw+o8=; b=IUQo1pCahFeAWARt5TtL+4C3HeU/qIqJF3jSVdcNDVUKxW+TwmC8IfFmISV+UMmCIirtJ7KG4bnQz1sKKUZBULDYMLAd91rqdNMa8APO7I+l8WNiG5mgkxucNwvIhu5acqemwgg8QQtOkZ1W28VZltSa6uXDRYyGL8QNb3trZvn9cSsqnCSjPdsXP8htPJz7S1Z9T3y3KjQP8u6Uizx1aX5uHcsW6SkT8fx8tSheVGQ9QuIOq5lALxksIHeiG2NvQ8030/USl3G3GmB1Xb+dCxKcKv9N7svs3Fh+ZjkQDEfx4q/NDX9io6awYoJ8wzT3hv1LAvivVWrChYPqRJnpFw== 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=mijXuv7oHiRF5lvBg0NKfhfXlOiOtyS505PIT5Fw+o8=; b=gZc/KgwW8mQKkhm8IggT1rihjZATvg2JDSgf+kd8V4cEEGKB0F2q7dCivNmRBvhyt7BIL7toS94HFyN+3Wwz5m2A0QiBhFGTDJz+lIftVkbu41TvKjUr3jwpyAwmao0UsCEwmN5GP/Wh5BDp2f3dmVbmYTLCLuVhSl/2DmKMbD8= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ0PR10MB6376.namprd10.prod.outlook.com (2603:10b6:a03:485::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.19; Wed, 16 Nov 2022 21:47:01 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::f7b2:af85:fe37:31a7]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::f7b2:af85:fe37:31a7%9]) with mapi id 15.20.5813.019; Wed, 16 Nov 2022 21:47:01 +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 v14 4/7] kexec: exclude elfcorehdr from the segment digest Date: Wed, 16 Nov 2022 16:46:40 -0500 Message-Id: <20221116214643.6384-5-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221116214643.6384-1-eric.devolder@oracle.com> References: <20221116214643.6384-1-eric.devolder@oracle.com> X-ClientProxiedBy: SN6PR01CA0012.prod.exchangelabs.com (2603:10b6:805:b6::25) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|SJ0PR10MB6376:EE_ X-MS-Office365-Filtering-Correlation-Id: 3cd1fd56-4aa8-48ff-1320-08dac81c17b1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TWc4A4w96gjp/UdGt1D+/JQQVi2NSO8X/kSjjexxYPy9GyB5GEqc/oGt4jJogPa0sG+1++sUbgloXAd7SMrrbEO36oYxO0I2hUd7U3k8RfZ0bc5F4wfXpUzbFteCckc74QwKXz6JBLm8i7lsEjSDBNl36oo0iQmUIrWLxXt2E7dzMFfLt7EMA4rv8ANPMq9Rmwygb9KNzQRWS3YhoFKFtGB6rjcdWNz5VXoIl5UTN201DCSMGnrNhfRlB/Ua/1jH7i713wWQYZROVA3U7aCymOCeFc6CRg1eKHlHdMsP9krEev81UxeA4gZhkdVvgg6JWcL572X4LqkLLDZ3R/k/b5bTR58oQPDdphRpgwG9dh4oVYKaFoGzzm+UgnpUEakYRtdqxair0In/xYlDrga7zoQ0Av5THBF2p/c0iB/eH+9mnBJS2M7ZbBU3W3D27+1nPcLUrh1lP1gh6q+PVxBpjSrL0YHBUU5B9IDln7ZoJBx3QvywOQceeJKLAP6mM1dyWedbCko4ckGI4RWdve+wna0IHjrX/xvA2iU8naJyCkRdOE1tb7KxXqvtnl+euSygFSOoQ3AhHP2WrR3FjFOl6niyHdf02g0yysVGawJdR1uMLME5zlx20Lj5vPwED39OL8I/TKrydMpkgruU6D9m1Vz1Fgyv63RhkNK3/eEf/q8YuJ/Wo0QyrTUVcVwcmYKBnnfxtIuvbPT66Abi2X+Z7Q== 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:(13230022)(39860400002)(396003)(346002)(136003)(366004)(376002)(451199015)(38100700002)(186003)(86362001)(6666004)(5660300002)(6486002)(478600001)(2616005)(8936002)(7416002)(107886003)(6506007)(8676002)(4326008)(316002)(66556008)(66476007)(66946007)(41300700001)(1076003)(6512007)(2906002)(26005)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-Chun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7m4POO2wbBwE32sDAzGqlNmNcnoUacI/axAGCZIqVOW/JF7g/CPm2XisrWutcD7itjoIB5qE9Z6cPG0V+zmizJz48+akbThhVTfbTTrTRLaOXhjiK/8FO6xlID3QrpDxMJtQO3EnUkOgDK6ZVf/JnttGSHWu8Ks8zL+bJbbYAj22ocYErdVBKqSsVLN4mw6Oa2qHCo64hxqdW4Qm5wqGyt6+IfJyE8XKNXw4QuJOVyB2RDQYHHMmW0cRJbrrs312TQNcvRKy55yT6fqT4/+9nTI2rEi8dhghy8QX7NHzXYsnDcWGqu50HGWwOczOsrof+FY/7+chH6KJ93Y+gNACh9XRcqGmm6gOkNQOMtUOoTBt9L43lzzMV+3ZwfDrjD7/Xfkhu9rM/V7lGq61zkAAuJsu6Ak/DMknwjC3zvnF0rckViR1EVyWGFgUdMqlkTeEt4G4lJQgmr+MFr1ytHzhzVWyTKYRYMFeS6i2JCOVTnueOYlfEuDTLBnVYiezBu6oaUA4bzz4X4wGB/ke7oBIDGpnXw1P3HfAYIvMdrtpb194rg5PGBG3bRQD2y9eEn7wJUUxQT8oG8IkZXF6tUwy9ulGhah7jsP3A5FrGSpgnxFxBNDhdy/WdUj0KnDsTAcl1WSmiCckFQPztfUtsF8KXqr5QhvlftmyET4x0s3s/IQnCTGbXKjZ3WsExDZXzwBlyxxBKBUBnP63GI9LwlcMOyIThp9eg+5KUJfzs8ct1N+Dl17FztoZu0DTJK55/Qxc5ZXLvm1i9psy7n8D4yX5GawVbZFdU3e0ESogGRngJ/8SLVC9328PeddBMHk1U8J5uF164rayZdpaIYfJeIbEe5ktUAFEDKRasVc49MHa5NmlWpc24i8Y2sBJmTIS/cXtP5z23VPn14OmJ8+tH5RSQlfWopvU7Qp4Cq5w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3cd1fd56-4aa8-48ff-1320-08dac81c17b1 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2022 21:47:01.0966 (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: E2dcazXdWXEevwFt185bb0V9exblpmJH2AAqf51DolsvNKrjN4sHbpJzd6ttkUeH8AFkxjSlsfZDECnU/uNxVq+eTzsEzpy79pdrJpF8vWE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB6376 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-16_03,2022-11-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 phishscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211160148 X-Proofpoint-ORIG-GUID: Y2K25I0AE3drzgdur1lWU2uif_NbwUGP X-Proofpoint-GUID: Y2K25I0AE3drzgdur1lWU2uif_NbwUGP 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?1749691039436900908?= X-GMAIL-MSGID: =?utf-8?q?1749691039436900908?= 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. Since hotplug events cause changes to the elfcorehdr, purgatory integrity checking fails (at crash time, and no kdump created). As a result, this change explicitly excludes the elfcorehdr segment from the list of segments used to create the digest. By doing so, this permits changes to the elfcorehdr in response to hotplug events, without having to also reload purgatory due to the change to the digest. 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 f98d1742872b..cc976948f17e 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 (image->elfcorehdr_index_valid && (j == image->elfcorehdr_index)) + continue; +#endif + ksegment = &image->segment[i]; /* * Skip purgatory as it will be modified once we put digest From patchwork Wed Nov 16 21:46:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 21297 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp77940wrr; Wed, 16 Nov 2022 13:50:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf5WP/lkA2JItSmOV4bo7iREXD0JdXzy5jFiXx9L9zjv3+4k/yKfbQuA4TGgnbbM5B+YCfUL X-Received: by 2002:a17:902:e946:b0:17f:66ae:b84 with SMTP id b6-20020a170902e94600b0017f66ae0b84mr10763311pll.32.1668635407875; Wed, 16 Nov 2022 13:50:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668635407; cv=pass; d=google.com; s=arc-20160816; b=AEDRW153LRn+M/LPyd2JuV4LjCU2bGwsJt/24QfzfMGFuPKa40j5xR/9L8G9z/sGVX TgZgKsjznJRYhVC/0gS+41Rk5WYVTnuL1r4WqzLm+RV59WbFvi0rpA7sm3Awl/3at4H1 gYd1v1/tzneTnFfwAizfUjLxTdby6e9PVH4zx7ZQTSAuNcuIqQNNf0tsie9wCtI+x5q0 aDF41zqHtjHVxd54r/Hyo15bMbNf9CiVAXPvS4ycXfZMjSHlUKtVi17Cl0Oqpar45lnG ewJQ5awUCuMjEyBU+OZvAuw5w/jabooQGwSWaBPiSJvakH3U0Jv2VOEMjsJWdHcfuaJX p4pg== 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=FBOy/qrNE2LepDHPiTcH8lZ4QjwqMgdDISjHDIOKtDE=; b=0OEOYFuwtHFmsWQZ2Jgnd4XmJDkV8jAhIY6ndSYL/4tBBU+ruL0DIkRVkxb1UhBTME hmLyKogFcoRxt1/+ZIJP7/vOVhMtyeFEvctXNY9gbGXR33KjdxS76bTX+V6OAdtbELeM 12YgQY9KYZrB3NJA1LKTQ/mE6Vw4MhijjVqQ1r79EBWiVy4YKrUMXw726zVH71b5j5Aa 4WX0JQvQHmaLLp9L0s+eFPNC+PipKy8lfKL8zZHlWPcsQQoUGnXay0C26eJr3KMuEXfO Gjh89VbHCmelfJNiVR7BUi3Jx9jCgj/RucR5lknpSROzp00qCTzX89lll+t9Pt34wxP7 5NFw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=gphGceHa; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="UoaMOK/F"; 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 2-20020a631042000000b0045fb345cfedsi16019056pgq.640.2022.11.16.13.49.54; Wed, 16 Nov 2022 13:50:07 -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=gphGceHa; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="UoaMOK/F"; 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 S233687AbiKPVsB (ORCPT + 99 others); Wed, 16 Nov 2022 16:48:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234174AbiKPVrf (ORCPT ); Wed, 16 Nov 2022 16:47:35 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5AE018399 for ; Wed, 16 Nov 2022 13:47:32 -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 2AGJDxk7021268; Wed, 16 Nov 2022 21:47:08 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=FBOy/qrNE2LepDHPiTcH8lZ4QjwqMgdDISjHDIOKtDE=; b=gphGceHaIo0HnCNId2MQnPNld7Iw7kXHkmSvEoChcnWjTbVfW1js7c1OUQekNbKzvuqZ 5y8ma9qWNHXZ45/faNYeUeZTVU85SOUFc3CiBjYIKIaos3Al3p/Nf6k+FxzSWf1sWvdl /z19cfgTQNKkVa1yL5LtsjUCP2e6wpJb8qImi0dKCeerq1k6bHGus0suDX+EBkJ60igw K/8nB8PGFUiKmG+GASfxMMydkkyEo38qw9N2C06ExA/Nf1Wz2bSqqtYk55GnJcnNK+WP Q71XAaO2ilEgq/H4ylxGK/giZarnGwT2FChACowbKg2IMcA4pzV78k+GLq17fufJ422b 1Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kv3ns6pgv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 21:47:07 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2AGKiJtD000432; Wed, 16 Nov 2022 21:47:06 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2103.outbound.protection.outlook.com [104.47.55.103]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ku3k8y3u8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 21:47:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kv8GxNT8ASYluY1ZbH77d2A2cSfQ+V6NhYyBJNxZ0ugfgP95UfthE43PCfiVRLUS4JEvhi/EbIci0GvndVQG8L6emyUXrEhx7l1V3uKsyBumIAcPHascDlkYNsQSUCbNUnUaRAbR9bI30pIynlKcAamgfXr6M/couDWEr121O4uNpTb3Qou4nH9foP4ANv51HV3kWk6r4SzvBFGuJkIqWwPPUJ1TweY+VSnOn+dWdV/U/ldmEpF2/t8jiYZBwWDPmH0nHjnWJ8CIvyVTkyBf68jommqO1o6Gl8DbY2HbOYoyzOTWzrTpx2AZl5NIwKfFEGWKUNm0NyFEjC+vrGNGVQ== 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=FBOy/qrNE2LepDHPiTcH8lZ4QjwqMgdDISjHDIOKtDE=; b=T2I4Vs+u/6Cs8L1V6YYzZxd0lsKsO8Xv0F0nMRLyskI7/qqgCQ5WdBeszQK5deNj19n30vt/qinKu+CYAMP07e+BjxtPzJcLRxybF9TBgP9cfLeyYoLnBnSZYZUTfK1hV1bwbMHsaI1E7LVuUGT95DAL5k50nsLbfhvFqIsDlE89kZZpEQYqKp64sr5QHiK+UQNpZd1bq5pErKwYYm+JQyuSw7eYYgdWFLq8T6asTaxCfBv1PhEtM0lNWm5VnBj5t0mAnferffyMhKnWNYjv27YANraqYn/mck51XZxfpvQhgFxfncNLRDU7NoNdNTzx2m34y4p6uOaLaua820d5xw== 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=FBOy/qrNE2LepDHPiTcH8lZ4QjwqMgdDISjHDIOKtDE=; b=UoaMOK/F9oNYiHCthgCd9X1x0yrBWVYf4UF0M5idKiqgjr8rFgQyNtj4Vyi7woUfGrTHcMxj0dnesWylNPDXV8gMG3oQSS0xVH66JSouBWfCW+iuguEXY6UZbP99UeSENTp1ZR8vAdcFkvvP491wbKN8pV5nj9C9PKbxYp6GKP0= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ0PR10MB6376.namprd10.prod.outlook.com (2603:10b6:a03:485::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.19; Wed, 16 Nov 2022 21:47:03 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::f7b2:af85:fe37:31a7]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::f7b2:af85:fe37:31a7%9]) with mapi id 15.20.5813.019; Wed, 16 Nov 2022 21:47:03 +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 v14 5/7] kexec: exclude hot remove cpu from elfcorehdr notes Date: Wed, 16 Nov 2022 16:46:41 -0500 Message-Id: <20221116214643.6384-6-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221116214643.6384-1-eric.devolder@oracle.com> References: <20221116214643.6384-1-eric.devolder@oracle.com> X-ClientProxiedBy: SN1PR12CA0050.namprd12.prod.outlook.com (2603:10b6:802:20::21) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|SJ0PR10MB6376:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b30f633-edaa-4698-a496-08dac81c193c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OqHFaLbXyZRSAecE8TXYVxacT+9FCGG/6W0TGKYHoxYs8LYCw6UD/NUwiuwxwsQtPoHEXL7DugSwxznGDZu41cbN877A4yF+11eDbOYXPKbJLGYp2md9UhXcsgdCTGVr/N1cDR6MHtsIVagvk0k4Pi78fcrlYJ2JmeiwzEhVjQxuxOA7aD1HRgest+zvY4qcGFQdFJsFyOpm2G3T5ODLzJyGqBYJH43LY3/I8l1kLwLnmv/MmvQDDzPL3PK2H0fmwbcH7dxbvt9kAi6sQO7aA4PSTns4Pyhm8dgSqrOBzSTNJrKm3oE+8QcKma1VLanWRiDh1xPyU6J70go6DBtndLFoOnws3uy78PuY6BdH0EZtiouQUGYXNEdxlHGTCF37SrSGWJlsaUCOf+/VaGxlukqrAcLyhaUfdn0IaETcmMOFksjB8gGa8h90swDkMT3jAGGFaDVB85RtgRQT4cGcQ1yMJ3RgpX/dUtt3fvtLu/qd21YIt3cXW8MOd3m/RB2mY5K1kSfC3mcQ6U+ZJm/iMJXezwIfxbr5uPAQUS66G6d6+s9uc9hXSJMn0tLivr64ZRhEwfTSBMP/OKRVdeK/vI2O48gzxemxYMh9nA5ZoVHCQez8NHGylzZs7wFRS2byhbkDfxCTAt93RDzhXOMbzwgPHdKVPzGZITrMucPSv0vX+bVx9o0nqSYi6XBVTYyG1nw+cCZavl+y6g6IBqnDBA== 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:(13230022)(39860400002)(396003)(346002)(136003)(366004)(376002)(451199015)(38100700002)(186003)(86362001)(6666004)(5660300002)(6486002)(478600001)(2616005)(8936002)(7416002)(107886003)(6506007)(8676002)(4326008)(316002)(66556008)(66476007)(66946007)(41300700001)(1076003)(83380400001)(6512007)(2906002)(26005)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ao4Bb+FP03WmIB/3YbbHwhOjiL7LSABhrM8I6i5CfZV57rOPevJMsD2KqMiegBHFOSeYlOQbXVIu7EKruLk2Gq4I6lhvqJPq/UWjSD4U2KvG5jtVhWP6+enCysVDVDf2+TPgL1UvRwNDNE5T8/Ep07mTtxvqVHvL2PJw9YihRLUe51kmgbzFP108ZZJu6Yb8NC4dZTc/lCCXY5AR5+1vg8FkVBLvnPVPqYBQDvajlFzLpmm/c/yUaxvK8hp78MQJ4oslcwpX8bkFBSKReejGrR9EOmNxnfjVZHJGh2+41wocNHdv+jGn8gWgKrQRbUOMrPUcfAq6X3LikOZ3H4RaM2ntnSg9Mp4qGJapoilxQP5GqijLb7IxK562WROdG3q8UUC1Kg2rLUCAfmdF34H4vH9OKe1ZcLBF5/RtWZTO6Pgok3+1K1sitzGtQYEFckE+JBBublAzqMj0qlbIWlj+Qw3HeJ1fo2ffZyBInOwoj315lUc4GyxURB0KdJHxRufVyYsVAy/u9jfmC9QYjgJyE7cE1X32nGBknp+Pxt7WUDfVyTIvMXXgKnowA0CggXHALMmhiJRLvhW9GGDlRWPjKblhgRm6YZWwejaSGaUEYLcnuW4DxUBGcJ5UMBX/erwwNa6uZNijQ7fnIoELfCb8X9MD/FLJxT0gBPg/GgP1iS5LsUDqyFYzGLTxCf+fg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qszD1SWbQBJzKF7UFtOAG96cZmCDnhKed62fldgBZcnSgQoA1CHUuitdoDzVzcrtEB7b6FLnZw7vZiq/MvKTX20sHb6I9PHOTMVhONfSzzbGkDSxNcvUH0l2LzN1PDSsiCmytQXEDFD+Gn48pZxS6+oamYxiEpU+6B/3hM1gsALFHjQo9KidEPZwbjkTKUlxGNysZHmnrRI2oTb9LeZ8clFIawSM60ZgQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b30f633-edaa-4698-a496-08dac81c193c X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2022 21:47:03.5483 (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: F86+AcivgNO4yc4K3LNu0ejtr32yFw5eSsrW6n7A5GpgGuWrZ/k0fa9Xh3k9C0teZTH3lCTefs7Hc+6k2mvgmCO+zMRB+DLr/8r1+6RGLNw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB6376 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-16_03,2022-11-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211160148 X-Proofpoint-GUID: JiLGyF5UOqtVT6qOz8_Hx3_yE309Jf3a X-Proofpoint-ORIG-GUID: JiLGyF5UOqtVT6qOz8_Hx3_yE309Jf3a 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?1749691041051225449?= X-GMAIL-MSGID: =?utf-8?q?1749691041051225449?= Due to use of CPUHP_AP_ONLINE_DYN, upon CPU unplug, the CPU is still in the for_each_present_cpu() list when within the handle_hotplug_event(). Thus the CPU must be explicitly excluded when building the new list of CPUs. This change identifies in handle_hotplug_event() the CPU to be excluded, and the check for excluding the CPU in crash_prepare_elf64_headers(). Signed-off-by: Eric DeVolder Acked-by: Baoquan He --- kernel/crash_core.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 4e7221226976..5c90a90f3fe3 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -366,6 +366,13 @@ int crash_prepare_elf64_headers(struct kimage *image, struct crash_mem *mem, /* Prepare one phdr of type PT_NOTE for each present CPU */ for_each_present_cpu(cpu) { +#ifdef CONFIG_CRASH_HOTPLUG + if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) { + /* Skip the soon-to-be offlined cpu */ + if (image->hotplug_event && (cpu == image->offlinecpu)) + continue; + } +#endif 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; @@ -684,6 +691,16 @@ static void handle_hotplug_event(unsigned int hp_action, unsigned int cpu) /* Flag to differentiate between normal load and hotplug */ image->hotplug_event = true; + /* + * Due to use of CPUHP_AP_ONLINE_DYN, upon unplug and during + * this callback, the CPU is still in the for_each_present_cpu() + * list. Must explicitly look to exclude this CPU when building + * new list. + */ + image->offlinecpu = + (hp_action == KEXEC_CRASH_HP_REMOVE_CPU) ? + cpu : KEXEC_CRASH_HP_INVALID_CPU; + /* Now invoke arch-specific update handler */ arch_crash_handle_hotplug_event(image); From patchwork Wed Nov 16 21:46:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 21298 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp77960wrr; Wed, 16 Nov 2022 13:50:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf6svqIeLLijO1SKn9sxlN7FpI1I2F1dKxygkyLw4C9iz6L9mEfUj0xBc+n0RQunPLIlq77M X-Received: by 2002:a05:6a00:b84:b0:563:4643:db33 with SMTP id g4-20020a056a000b8400b005634643db33mr37632pfj.22.1668635410781; Wed, 16 Nov 2022 13:50:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668635410; cv=pass; d=google.com; s=arc-20160816; b=WUGWdEoVbs8n34E91/v/qaByuKZTo8A6h9pnRSO4WQhPdMKYRXjM8am2w9cE4tCII1 eLFqu3OoWNRnb9rLh1lW2tPhGSuBqYA/P5QAKPN8N/oVvSwal0OHR+VoscLMYQALFvd/ 5azFj2djsjhP8L9eo6UZA73/mlmTARSZ4PobRN7mUhFtVQobfo9LbWUTE//hhGBhqYsQ eVvw0uLAH3zGI8arVNyNmVCE/j0B/5uEWzjWE84emKKSfBAFekYTXCuJLK+G2yl89jbO +F7j4YC89BH013MmUHovs0OWUNKeuB/eBM2hGZ0WseHiKEy3Z9S74viCp/P7thuAnQE8 FtrQ== 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=k+S3US1QVOIXz9YPu9hytw8EChpDp957kx8ncyBFyss=; b=0+E/aWxSPVVPerte87dNEG3HyRbG1YAepQTgiLFXTbmcuH7CPoc8KQH3j/lVUXF5qi XtxE5rPu51B10+X9fgYE21vJdX24LDA96XTKJe9GM14i+3pOZKyX1IszbYc8a9wjM5cL HZu3D9qtP3Z6nVKoN/tpHg0ZkzmzKYxrGz4UUHVuj55xye+2ZJTiMkEoFc2ZHPUzQ0vB XI8ZW2H0mItAK9oJXxpzata70JlxQVPriEHD16k0Z0mPCRr8dg/RNKCpWe1v+HWdJ5hM hVZfMMWXhCC2Qasgd1INsLfX/bX7cZ9Spt4DKbq27n7PP6/FnD12DRGdb/J8dsKj5gWF eZ1w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=J+yN0iet; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=jFAABFQH; 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 h11-20020a056a001a4b00b0056be3109462si17762064pfv.163.2022.11.16.13.49.57; Wed, 16 Nov 2022 13:50:10 -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=J+yN0iet; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=jFAABFQH; 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 S234509AbiKPVsG (ORCPT + 99 others); Wed, 16 Nov 2022 16:48:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234181AbiKPVrf (ORCPT ); Wed, 16 Nov 2022 16:47:35 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE80A175B6 for ; Wed, 16 Nov 2022 13:47:31 -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 2AGJEUXS021257; Wed, 16 Nov 2022 21:47:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=k+S3US1QVOIXz9YPu9hytw8EChpDp957kx8ncyBFyss=; b=J+yN0ietf02Vyv79a5SnbHJB+trjZjkQO73hewUyh0eLETvcV2HQSzylhPz48Ezo6w+r Wej7KjkndBQTU2UJD/W0rJVKMRTYN7JOE0TTtX7mYTUJ3S8zMhAYmAYnBmJKKqjzc2+m +9urfB3PR8e7TY+VroKJtKuMgD6pMJkbnJxAkx+G2tAS91OrDYkgKao2LlmdDzIi1Tat 3Hk20K0oQmKv7xvnTl/9gIILw0egO4CRz0SmlwGihXVEhSThaISGYCOh3f2g4ZcWEeb4 aWSk0AGouAWmLBFfObIplQwzLSIfIsWJAm/Bz6TVQrYV1cbKIRqxJvupgEDApZfliFys Fg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kv3ns6pgy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 21:47:10 +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 2AGKsXkE012465; Wed, 16 Nov 2022 21:47:09 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kt1xeeetf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 21:47:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KWyuq+qXjI/OnROp59jd4v5MiQkL2GkzpTrPVBngIq+S0oIuz+DYNCAMD0NP0Rb9sTFWm1V1vCQuqg8qIpNwNIhfwSYsYYcqstz2bMlAFsa3LWHXFBNG26igZLK1+t1iG4zRrj5wAFGR6ptxMo+LAb5Y37bd5n8L/eRihZmnHL/DF6hMzviZ2ClYyTKyWmjZo0FK8WlbpBDteTQ1nnqB4UU21KTQ2KZIRd/JJFiXWhLRPm0UygM4Oy2iaMRQdR5B98UVIRQ9jZf6Bi6tEIb9i30wRnMBbSB7oiAG9NaKyiRE8odxKvNRcJ4BCz3d0uPWob6K0mehjhzMWxZWRYyUvg== 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=k+S3US1QVOIXz9YPu9hytw8EChpDp957kx8ncyBFyss=; b=Q+HCoZHmwBSS01mqywzSU2KePS/u7i73rofwpYm5+wKRqCa5qpT/4cWEuOtxOeefDzevElD7gfyH4S41Jv0+M7BP7jN+Pynh2obez/I5S2Jm2EA7dw4bpn8Elhk0EIPeGnAMV1HZ0MTF6xPJ+wEwTgLF43tws0V9sLnQQm6670PctDLDObKcNOhAK88i+jLsLOMP85b0vjBb+l2jRsFq0aKkfVbJn62S/7SvgsRNEoNtf6M1Wbj4vsKG7iRbM6HjnxI6Cj3Icnc5pBYRfKpQjeMpvgSA8wspWaD42CAWlyVfXlrJxJdgQp6etLHrgncDTlKqtT+rd6B2aC0p+qKjdg== 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=k+S3US1QVOIXz9YPu9hytw8EChpDp957kx8ncyBFyss=; b=jFAABFQHepYkOx9G8hg3nqSW0EltyWLjTrMl3FmtitJ5vqvCwl5rD5BjW8pogE1DTeUy+YQzp/KGKSY01GeHOS4uRqPfHlO34lntda9IS2T16+YRwUydtvWp1mzoBLFM67rkoEOo1vOY12InOw6BCoAA1II7ayRItyMfu2YhHtQ= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ0PR10MB6376.namprd10.prod.outlook.com (2603:10b6:a03:485::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.19; Wed, 16 Nov 2022 21:47:06 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::f7b2:af85:fe37:31a7]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::f7b2:af85:fe37:31a7%9]) with mapi id 15.20.5813.019; Wed, 16 Nov 2022 21:47:06 +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 v14 6/7] crash: memory and cpu hotplug sysfs attributes Date: Wed, 16 Nov 2022 16:46:42 -0500 Message-Id: <20221116214643.6384-7-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221116214643.6384-1-eric.devolder@oracle.com> References: <20221116214643.6384-1-eric.devolder@oracle.com> X-ClientProxiedBy: BY5PR04CA0024.namprd04.prod.outlook.com (2603:10b6:a03:1d0::34) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|SJ0PR10MB6376:EE_ X-MS-Office365-Filtering-Correlation-Id: cfe27495-a4ee-49b3-a820-08dac81c1aee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zenFeLhogTQXGqNPN8EzEzX4EwkbEmSIjCzsy4ucH5WVupGN3cxO0xjVIu5EYGj46r+5D1Xj6BE4SE6RMH/Auv4keUkh29uraAwVXLNZPtyvzCUXNEZTstZH803uHYWVBg60mH4b35P9r8IDzVWL2nSWbckj8UWJxVNF//MEgSRZ6/27sFYj1ONo0MSDBUmhZ0r+4u2kzIKXP8EFG9+EOyHQKAVa9LKsRiXZJz9dQ7COcpHiGuCcxlqG9EZ4wrNADNQddrAXJXG/gWPFJH/nN9nlFh+a53NnVHiIPR3LCTlNyZC++sF/0XWcC+T4q65W77/tNpfh8cnVx49SwShVoizeuv4BmH3UMkkRJfOplDqbsH5SNXigqJj/JkIzQBeQjqQuiDPxymQMEmJHdDpwOA4SCZTf8Dz7hUUXLP7si1IinGlJG2dJ7jECRGnALzd86r7A0kO8LvbdRCQNElfVERqWLtdIr0a+06MN/hrQCR7zMV589e4VQmbH6H1b0H6p4bqoEzoLW2hW9iZt69Taii+P2IS/YuLRxNF3PKR1Xlk4RYpZp58hVjZix7I9B9bTeYHn+u4hGAoLtm1rFflQHyGP6tv8sQgyP1NyZ920xvVKl3t7fYOASmsqQ+giOPV+qG6Esg0W7D9xtQgg6uv37ggi9fpyp2YqNWZiAQcwa0MyhsPscSP2Nq47IABVrGSxvwPtKzQfdtPDSCyL2LLgig== 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:(13230022)(39860400002)(396003)(346002)(136003)(366004)(376002)(451199015)(38100700002)(186003)(86362001)(6666004)(5660300002)(6486002)(478600001)(2616005)(8936002)(7416002)(107886003)(6506007)(8676002)(4326008)(316002)(66556008)(66476007)(66946007)(41300700001)(1076003)(83380400001)(6512007)(2906002)(26005)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1/SUjtfnEuWrcH6+jXEdDBm2eQvs9dKHHpUkKGQwZSMm+5PVuSVsBGrWY/MJcCOYrjUblG1SK/M3ApmbbceqG9ukbjeEIEO+HG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MFnxzMg22vUgePypA0XXOSp+QjDtRnKSpsWNmEWl12t13fqkzzE/yDwtEFscoCU1zBFs0idFfwW4XH3ksqxvk7ytssXRN2NRnlN9zYk328/1agDlr4uTig31R8r4GD+XCMb3bqtob6FPjnBme11+q/Ldo1aGEVZoTq3/IVbwLmYXy8s1t7JiYrnLFPwN5XvRG0WbGX9U65y9T/lXG4A1OLGb9SLUuRbW4VsuOSDGzBKyPH8g7pEfvQd9Qlrdd9zc4GdSezIEBDUSH9e3WwQ/F0WLGRolhpyd/Wn7/9KgX/HnRUN8VSzYJKODgXcwhzid0KszNvfJFqmTyK9kadAdNs2RuiwhtKxJPoLs5z9Bbl+V0u1T32ljUGhvFeevaZvXXfGflnkdkDX3qzIQMrXCdIZ/sXnXCMmFwkIKA8VN0NdYEMFBp5YxAgOAdylsb2lD3WRbj88Fe03vWDU00zHk/+rfW/2u/cPSNMK21lfz4pKYO5OGX88ElHvoiHCLDc14iQ26vHAKgp94+id6zx1FMU0E4p6eDvPtp7No1+GenuxpqPwGnzRO13FYS3RRw3lknQw4/x6C2o2phdcbqPUgzismt98QismPFcO9Otq/suECvwLENSus9a+dmCYuynQiqyR/5nhlA++b/4Hkv6Ex97hEmHatuP6r5LslE6kCX7oVqWlwrZYWi3jVAEY9O84WkxxoqcbnjA+NSO4d3zw0hXZQwEQkfZhqipEZ3i/dnvM+9QdhXeu2/NrgeC1Vb5uGSxhxEWP7N/Ixcrq8WzF5dPDqugR2czrvYSCnA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: cfe27495-a4ee-49b3-a820-08dac81c1aee X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2022 21:47:06.5646 (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: 2j9/R7npCL4Us1Ms1kP4sMU+5LUva42gUWAezpiVEEbRXcy62E9nvc+KX2pAKO6qQbiLk/pDiU/Ajob0Tgf8XB7C4wKp6Mwosqb3Qebt9VA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB6376 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-16_03,2022-11-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211160148 X-Proofpoint-GUID: 3BxvzJRdhYAVcElqdnq5uq7Oy337gKqm X-Proofpoint-ORIG-GUID: 3BxvzJRdhYAVcElqdnq5uq7Oy337gKqm 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?1749691044295072166?= X-GMAIL-MSGID: =?utf-8?q?1749691044295072166?= 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 fail 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 9aa0da991cfb..226be3134ffe 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -483,6 +483,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 @@ -881,6 +891,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 b4dbc21f9081..9bcb09dba41f 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -539,6 +539,14 @@ static inline void arch_unmap_crash_pages(void *ptr) 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 Wed Nov 16 21:46:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 21303 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp78408wrr; Wed, 16 Nov 2022 13:51:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf6WtbfyEpOq2ysTxEWazNIt+zWkRIPM0oxYk1dC4UgVylSqrh8ktIMec7Ylk2a+qgPYYebw X-Received: by 2002:a05:6a00:4186:b0:56b:d951:67d2 with SMTP id ca6-20020a056a00418600b0056bd95167d2mr24958029pfb.55.1668635483042; Wed, 16 Nov 2022 13:51:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668635483; cv=pass; d=google.com; s=arc-20160816; b=ra2C/bM20KXwveDzrV0CceTuYZ19I1rxo6H414615jI5fS5rbXLFVrc5Xq02iTFsrS V1l8a5mOUTUu+2nqe1xGl0lDe8NiqkFnDWN4PAHiSu1FewTQVhGDYgSQpySSEG4HkshF ztkRGi6XznMYzLImWayoD8pnCzSDs1rLwlS2fYZ8tzHYSP6rbbVwAtXoS5FbMDf2ht3b uGp9mp/CVAXVF42KdpwdXePTYJ4hEqEmS7JAl1ByXYQ693Tj9suoUurDHouqk+UR2HR4 +V90pkWw6SsVQBR8HjGDoAJavmRWsk806dulTv7q0W8TkqIHdD3kfRIgUFdTfv77x9lb NvxA== 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=sa+WccxhodFz7MWxPohazvPJBvn1/J4kEad4/zAvTms=; b=BBAsYX0gXXec5hLi+5ZmB+nzp2I5uwWiWSNOMcaWnGNZUxalYPZoPEkzHjIONhfNcS 8iS8Eq8Snd0Tv+gBSdYLBEAC33pcjE2K6wnMQFP065t6nkzaynnH9ceANDjwGcMtaO/9 q1xxBNqzB2RsSWDWmOSvDs8dC+kAtB02QUWt51yB3DH0T0iYZKxBRO/J+vlVb+wvHaKg xAUOIGdEVQ3C+qVSJcszYO0tm5Orh78H9CA6aOdeMns5Jf1jGtL61OzbFJYKhRWNc9RE l6K2LZqebQ8kqJt9EhZUMTMvlWAQgiKyp/0WK/7MxL7bTjc6ivULElism+bgbrg7PlTR LUog== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=acizyEDr; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=TSbRnpEs; 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 y22-20020a056a00191600b0056ce7a12b25si17489552pfi.137.2022.11.16.13.51.08; Wed, 16 Nov 2022 13:51:23 -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=acizyEDr; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=TSbRnpEs; 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 S233466AbiKPVsp (ORCPT + 99 others); Wed, 16 Nov 2022 16:48:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238294AbiKPVs1 (ORCPT ); Wed, 16 Nov 2022 16:48:27 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D2175654B for ; Wed, 16 Nov 2022 13:47:57 -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 2AGLX0gv016352; Wed, 16 Nov 2022 21:47:39 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=sa+WccxhodFz7MWxPohazvPJBvn1/J4kEad4/zAvTms=; b=acizyEDr78IgYtqzqqf5LAyPaYnupx5OaPjlfjvDEJ9eiEhMyoMYgkH8+pPB/jq+/+y/ KI2sOVqZjz54lME13yB9ZofJdjNj3D0keQgA4Lgp9JTfc7A44+voJEYjtUyqvRQZfClf blSLq962CWMBlyqdRIYebjOskK2J6qEi7tKlf5IBHxqZ6csmPecRBfRbbxlkUV2DjzhX gUqvmy+epgCGdE3H/7bBl8JaCFKVfLz0Ynt7jp1yQWo5Z5TrursSZYjW4w81KWIdu72t x110llh7gm6LAJIOH+Q5AmWvgas4MoOwhJK0tbnwURi94tNmGan4pWJqk7zwMxojJtBq 0Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kv8ykp6m6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 21:47:38 +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 2AGKoAKQ034766; Wed, 16 Nov 2022 21:47:37 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2102.outbound.protection.outlook.com [104.47.55.102]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kw2dcjunw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 21:47:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lIOi9O2i2/HPMAknATJdkbo3iuIph101FTnHGyoYTzB03Uf5IPWmqVlWGpz4GP9yiDxyofSpoHauB8x66bebKBdlpdaagODDULKCDPKtM94xN9tJHuv+FvIpGoqdsgXfmp5hy7BnUR87GkzcJpJc0mOqtf3hDNimdIjLI8HwJMMNQlHWXOV2IYD1mKUjnTgt2sCjbI4YofoxSl18U1eYG3Nn2r2EofmbD1bVmqdQ0o5iqjOzVdhQrfCf2pzBjlhqLhyNYBVEG5MWOM26eSNcKBaW8xyEE6yeI5lthEwXdSHFoZnZg8gkpWJCs0oUrJdbJKeZ8vRaYP8X8KKYf1kc1A== 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=sa+WccxhodFz7MWxPohazvPJBvn1/J4kEad4/zAvTms=; b=aevBOvZX33UvQq4951QsYa0ucf3GltT8T6ZDulSuHxbvbihlO6wWXaQ2LJfrSkl6aGyXSIzb/buze1hvszWIvofpLW/4UAFMlhVkj/tKH2ntxZ/sHCqUP5UYsnwnz3JO8HgS4LixqkmNce+rC+5tFWbXSuqckrma9eSp3cVU8JhEb8Tc50bMpVVGP3pvQVJoqyvUfNdckXke/LGn8LSffYECN1UZTxrrhrhDqDgQI/EE6OQrMkycOW9XAc+X7aOQNkmq6wHqSDi/2VBXGzs5cHdEYZBG5kFKVD7aGgOYzX57+QzEPpDOWs29K1rqmrxBPavWwwCGVS7o0KNwwkzxdQ== 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=sa+WccxhodFz7MWxPohazvPJBvn1/J4kEad4/zAvTms=; b=TSbRnpEswktLKGCbGH2uDzJC6aqqrs/tIlEJbJIhB0li1n28CDcU8Onjs8IFt7FflZt/MoVh43pVMYhbAp13Fj0gh5Avrxc9qUKcnhFw56UXwBb7/43OobcFmQcEslEg8UXfvbi1o6+zv2fG88ACprVnzfBqhhgS55LcPvZ5iUA= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SJ0PR10MB6376.namprd10.prod.outlook.com (2603:10b6:a03:485::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.19; Wed, 16 Nov 2022 21:47:34 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::f7b2:af85:fe37:31a7]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::f7b2:af85:fe37:31a7%9]) with mapi id 15.20.5813.019; Wed, 16 Nov 2022 21:47:34 +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 v14 7/7] x86/crash: add x86 crash hotplug support Date: Wed, 16 Nov 2022 16:46:43 -0500 Message-Id: <20221116214643.6384-8-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221116214643.6384-1-eric.devolder@oracle.com> References: <20221116214643.6384-1-eric.devolder@oracle.com> X-ClientProxiedBy: BY3PR05CA0029.namprd05.prod.outlook.com (2603:10b6:a03:254::34) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|SJ0PR10MB6376:EE_ X-MS-Office365-Filtering-Correlation-Id: 446dbee3-a5c0-47c0-5a36-08dac81c2bce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K3sa6w7uGy5u3gIUy7idiuaomor27W+eBtM1UjeoieJzA49fvHadOAbWf5LsjI6JAslZnVeOZAqu4fX5FPvcrGruV+9lymCZkGookBKQLG7fgMTaJYnYoiJgX+NVzh9ta8PljNdVfHL9oRuhdqjUwwE1R3oJy/VZTOYEs+6fUzOwx/zEP6BW4SEWzWpaJxtz4R98UfyCNFJtzxw0MF0QQCAfVBcOL3Zg8auLPO7qoVDklTkKKQQzXN+Xm8A/5E6ruSJxPpQ2Ha0QX2OhrmMwfJiw1CzBYqhsxtTU7YLVUIb2iRsVlxKoB1/tcLz1sEURXbXSiaefaoMdpkt1iRTHN5srvP314v6CPHnHGjq4ud8kSXoRvdofhiDxBccjuMRZqWDNZ4IerzMVsTlwAaUd+H6W14mOhyyKOLDlwJ9DCLpxk5lXfpN9ZjAonudrmgwKiO61gb0zz5fih0sbWkQ9P3dyn29n/8qymebEJKp1671o5iUOiHlodsVfTC5rtWvKF1h1t9lDdJBlkTwfNo/YWvcv9cp0H6ADAD0A+JhNvJOemPdVbHce/J+wL1rdvpdQjNbVv1pNQMSTgyj+jQ1LKacwjqWmuKV+/y670Dhczrp3q2/S5kTI/PF9+T2C7nzvfcy4K6ZKTTZuKz/qOsibOXs2RoabbT0Mfg/cCzlv/rvLbLjm9d798sqBNmYEs+7nRDzCNC9ExKfwTXMy70qe3w== 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:(13230022)(39860400002)(396003)(346002)(136003)(366004)(376002)(451199015)(38100700002)(186003)(86362001)(6666004)(5660300002)(6486002)(478600001)(2616005)(8936002)(7416002)(107886003)(6506007)(8676002)(4326008)(316002)(66556008)(66476007)(66946007)(41300700001)(1076003)(83380400001)(6512007)(2906002)(26005)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-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ervwvYHUVAN/THuzlJ6myURuZ0sDSuV39RKWh/2YFblVDgLcx0XX85iuumaQ2WZFWZD6kx/PUsY7TS36q2wF6ojvbFRdCJFUIfj8lZR/pEM53l81IuzjZTN53ddrVKd0ZXXyWtLK59sJPFPKjNUaOOOgs8sSQkaGpFfqkn+r9E5g823C6zUhPhG84isrFROlAGEeT1Z9eDiR3IdWWZZXpZbPgYBUpN9zt5yEljgZU/QoqIPoiB/BT/dknrcQypQqMFSDCZghamhgs/RvQt3sYG6x9FI2YPMV3TViLdSKVQnshBi5ZMgI771hrJroIFCsNgz3PHSMjfOU2axKy3DeuyAfyTichaNmCTJMJ4QNxlykigE/RMIkd20qy8D7DUlgwHI7Y6fX2R7SQzUlDNqSu8PIpfXLbSqBbVpGOqKd8a2vK5VF4SUoX4ltmDq8OQhOmU59IjbSQu3zk9eIa7mEIxReKJSGZTveWiGKByClf9wXIHn07QH7SWpTxhUmE/i5aLJ4ERV8D4DatSsxk1RmoftzeKlfyrmd5yZobFG+UkmjApf9siHxKZfkcqmH6x9ALUR1/xsMUlA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 5RFQukxWkh+uGQOWClV34M7hjcW8emgZJUfotnSFMi+KlVRae5DDxDnpiRK0BDQOWC2fywF32QTfhGJ0UDzMse1gLeY/tX2gk0FLl3EmyqErq1eq2nmLHhlfVDhoCBnSJsZuObb3lH6vvW7M56qhMvqAVDD4eTMSWeFpaenyNRiQWo9236/pqSruWfovOomk2Wrab+yKn5czdy2r6G0LvFeApHaVqmsRp9igpBSM5MAtLlrdjIpSX+e/WdHruuxJm3dI4Y2kOxMSPzBT/RiMsPfXqWdcCk98VXthrwLaxMIuQ0JyQT6tF1JxwetD+8ym+yG4zbn/K787Tk0zWr/+g3qOPA4H7NqIXAmNSEDjNLi51eIIp29pXwc9RuB9k0JK4ieVBM9wrsIhesQv/a+y50qettOxacvC8VGF+Eg46tmGjxA/nUv9mi0dZL54j7gmGZWVBzG1WKI0xVfvGrMKIuQYAaRj9youpzVd0Y6K+WxvmqI6GjUh4R3DUiJNKFcWdaJrsTTQ2Cy2u2hVgajNYKA5PNSWIgryH3U3NrtZpaoZt24hXFI3GdHrR3dAUGRQzpUHq/5RtwNqJK1sqxfj52PRO6zBHutzjOGkl3XfjsWunLYN+BmAUkhGg4nMp0EfJxMSM+oIyxEcCw3SAZynX7SKLIINlh0kn5GGkj50OqfkXDEs/lCv2HmKipcP4YNuslHkOLd6OLtJnRSDNMBxzSnOswDaNs2bIbLamxCdCab2HMR59hXh9L0a/l7Ve3oVQVhsZXJv7voBehm6BOlMKPb2OeM37Ys0+M2Lr5FmC3rA/hP3BSzeT7xpFCWYDCHABOB1lHCL6IcAJCeyHxO3jJnhUb+YsleTeU781ND9Dk5+GinXTv2sNEGupnqfJexsYXcKy946aMeoF69MqnDzbqpKLTUdfT6AOidAMTaozj5Ue1ROlBa4Ydhy+EXLlf+/OqXX6cZFdUrMpfVEcPj8xgkKO032ONJbF21pO0W4EjBib4WxndMSnnoNICgV/4rszT+VoDmG/1jPKruwaIvYuzNsZMBx7SEk+jkoHQjO7qv7uditxhOuvknIpKL+M9HrFQEb4aCkgSzX6BaFDHF0ccwV+/WIvPf/qd4mXDU4E3mg3xSzhm5nOJ1F8MokTibVOb9ajVEthf2fa971u3r86rMZiG4T1DKtSfOnbRAi5ShidiPNmuiMH2NWxjXbftorQNbo8ZmbWrKgzMuGqSJTV4FL7GfIVKu2Ar95jBS+CwLalKm2ry0CR3W3EeacxKOlP+6yKrlikdT2vNUsFlpFx4hyPMfYinnRQ+qLNefQS3MRyzWzhCqyeUCwiotZzHOkS7y5QPLgdXr2tKtDFLM8fg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 446dbee3-a5c0-47c0-5a36-08dac81c2bce X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2022 21:47:34.7960 (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: vW97f5tL8t/qBknw6ZhyQvrIbd0vTO+G+yPabnFYyKqnG/evMKp6S2wSF25vD9evnnZ7f+0O79xQumoRlNBtXW+Im4bKNwizpO30Xfgvd3Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB6376 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-16_03,2022-11-16_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 malwarescore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211160148 X-Proofpoint-GUID: W6TJk9z2GTHrm5hceuWARiOfRAceVXPo X-Proofpoint-ORIG-GUID: W6TJk9z2GTHrm5hceuWARiOfRAceVXPo 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?1749691120260310494?= X-GMAIL-MSGID: =?utf-8?q?1749691120260310494?= When CPU or memory is hot un/plugged, the crash elfcorehdr, which describes the CPUs and memory in the system, must also be updated. A new elfcorehdr is generated from the available CPUs and memory into a buffer, and then installed over the top of the existing elfcorehdr. The segment containing the elfcorehdr is identified at run time in crash_core:handle_hotplug_event(), which works for both the kexec_load() and kexec_file_load() syscalls. 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. Signed-off-by: Eric DeVolder --- arch/x86/Kconfig | 9 +++ arch/x86/include/asm/kexec.h | 15 +++++ arch/x86/kernel/crash.c | 106 ++++++++++++++++++++++++++++++++++- 3 files changed, 127 insertions(+), 3 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 67745ceab0db..fc7b6457a0b4 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2072,6 +2072,15 @@ config CRASH_DUMP (CONFIG_RELOCATABLE=y). For more details see Documentation/admin-guide/kdump/kdump.rst +config CRASH_HOTPLUG + bool "kernel updates of crash elfcorehdr" + default n + depends on CRASH_DUMP && (HOTPLUG_CPU || MEMORY_HOTPLUG) + help + Enable the kernel to directly update the crash elfcorehdr (which + contains the list of CPUs and memory regions to be dumped upon + a crash) in response to hot plug/unplug of CPUs or memory. + 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 9ceb93c176a6..d2238bcf8106 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; @@ -394,10 +409,30 @@ int crash_load_segments(struct kimage *image) 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 elfcorehdr segment large enough for hotplug changes */ + unsigned long pnum = 2; /* VMCOREINFO and kernel_map */ + + if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) + pnum += CONFIG_NR_CPUS_DEFAULT; + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + pnum += CRASH_MAX_MEMORY_RANGES; + if (pnum < (unsigned long)PN_XNUM) { + kbuf.memsz = pnum * sizeof(Elf64_Phdr); + kbuf.memsz += sizeof(Elf64_Ehdr); + image->elfcorehdr_index = image->nr_segments; + image->elfcorehdr_index_valid = true; + /* 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); @@ -412,3 +447,68 @@ 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 + * + * To accurately reflect hot un/plug changes, 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) +{ + unsigned long mem, memsz; + unsigned long elfsz = 0; + void *elfbuf = NULL; + void *ptr; + + /* + * Create the new elfcorehdr reflecting the changes to CPU and/or + * memory resources. + */ + if (prepare_elf_headers(image, &elfbuf, &elfsz)) { + 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. + */ + ptr = arch_map_crash_pages(mem, memsz); + if (ptr) { + /* + * Temporarily invalidate the crash image while the + * elfcorehdr is updated. + */ + xchg(&kexec_crash_image, NULL); + memcpy_flushcache(ptr, elfbuf, elfsz); + xchg(&kexec_crash_image, image); + arch_unmap_crash_pages(ptr); + pr_debug("updated elfcorehdr\n"); + } else { + pr_err("updating elfcorehdr failed\n"); + } + +out: + if (elfbuf) + vfree(elfbuf); +} +#endif