From patchwork Wed Jan 18 21:35:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 45513 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2576390wrn; Wed, 18 Jan 2023 13:40:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXtqiQyOjyaZMOJwyRZq00BczXkBivTATGsXAevHOjtY7SrS5ByA4S+4VPV/ePZaw9+526Pm X-Received: by 2002:a17:907:6746:b0:871:b898:92fd with SMTP id qm6-20020a170907674600b00871b89892fdmr9212042ejc.6.1674078056708; Wed, 18 Jan 2023 13:40:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674078056; cv=pass; d=google.com; s=arc-20160816; b=MfehYroLTPUNwED1xYXwmawHc3fXSoTaeuYT4UBiBEN+rqTgBJz2EnXIEKZTQ3QyTW JIs0nkRfEUcEBm+DBcZPw4rFYMm4f+pv+/RpErJxDE5sPLwc2/f1NNjeCNfNUyhwRz5j FnOhb47/p5Q23fR/A+20EOcemPuEReqQPD5t7JYN+Otc2y6SpKMjbrQZDKWXd4z7nxxl YuHOABP0zhUtY5lsvqxOhaA+XAbVysVSiCG5f04bYGitVjpDBuGb0UXd2TzrThqPBLEc G12DC2fvPUUsWfZLa70wmanu6v8LgRjDi9wXn/kF8sL6Uf65ANxtHv3zuy3WQw2M6+hm dsMw== 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=9/bVpuk+uMb1Bj437tZwCfjxm5pp41gQevBuBX5gnVU=; b=oIUmAxqckddgDPZJcmdIsFUbaHqwkx5qWriMR5M9r+YJIDQOVJ5eGN0uY/EeODTTGZ Ga7qJXm5EqXHYNsPdwvaNPRwtlSH185nzvoeVwalbyG9pmAuv/TWmNHYm2K35Ld5lSxN mzW2WerE+dRTSU3Hnb3D+BtABj/x9ktnY2rr7LA8y8BrLraAnymyZ7SE64C690Qh9d6n F5bMMesPgkssqzZYnrRzBUNctzufAjULMG9mIyS0y8nRcCnk2XSGl+KOkv4FrXIBoylu qdeLenmBGHsx37MfsTN/4RBMiQIlfc7dpOa/Hde+yoSHGZK8EpLWCdf6fNHYtJNcEp86 WLzg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=tFjtHm4F; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZfEYPzOu; 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 dm3-20020a170907948300b007c16f74db39si16735803ejc.745.2023.01.18.13.40.26; Wed, 18 Jan 2023 13:40:56 -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=tFjtHm4F; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZfEYPzOu; 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 S229906AbjARVgj (ORCPT + 99 others); Wed, 18 Jan 2023 16:36:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbjARVgY (ORCPT ); Wed, 18 Jan 2023 16:36:24 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAE5D62D13 for ; Wed, 18 Jan 2023 13:36:22 -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 30IKnG7X008508; Wed, 18 Jan 2023 21:35: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=9/bVpuk+uMb1Bj437tZwCfjxm5pp41gQevBuBX5gnVU=; b=tFjtHm4Fh4ToI7ZKgMsKsMndeittouwmQpDu/Ks2Jd/BlSQ36xczYr67gnmGrcVgozv1 6waEqUz47ndBSbZBxVyNWi1I+3aGwrDsRAMPwVFZ1KBmE+2GUn+mQ20mOuG/V7YP2Kpc mi7lEM/AANpmVAF45jwdhSsLxbAdwcOcC9P9tY8EP+62cJC7mII2UeJ12jMzO/gCDsWs P+KaG8liovY1kECVxR78Wmie7rpQeVU3CxclxHfwtI56qM3dRyLFZP8a75pOLWANNOC3 XsBMh9bJjsiu44uBWYOmO5MNvsQ3mcMuFw2PKVdoaUHqsQ8RO0QYjakgPROuvu7vY+bY 2A== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n3mxt8r31-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jan 2023 21:35:58 +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 30IKSq4Z028461; Wed, 18 Jan 2023 21:35:57 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n6quftm68-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jan 2023 21:35:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fP5AkssXGR5Hw8qQ2IxUyJHmlAqRipHI+ohbCGRCt8gTU/4+/9ZUkeW8faJ7XZXUVoz0hs5Hvgn33UTfAgfxHtA5hbhkrEfhJzXNzC26gAN0ywuhyfAnQ+FsMPrbMZBhNwoy8Zub0O50SXnN3gIRvOyTpaLE8iHG/BATKNLzMSvOu/XsjeHwejP7YjnntCDaHjMGiKZQNm1UF02DYg36bIAVpkumtHPt8/JER/5FrTnyNrUUgwogndtRp48Eu+3TkNYqu0nKABJ3+lKbJbXj7lU9NzbBQ9aINOmDtRe+M+ZvvH/+ZMmlmBhuiVmwnboqqoGZ+OhyQ1IUMTO+0yowyg== 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=9/bVpuk+uMb1Bj437tZwCfjxm5pp41gQevBuBX5gnVU=; b=PNySnz0UTdY/LWqGhSx4QRtS/OZG/+7gWD82hNR2Oo36SR+kmr4VwWM9VRJXf7GMoVXx9faS8+pQ+2K8SQM+mtZjb/IwSWM9ny3sNqglNRgrM9hG+5AwUTp/XZEMMrkHSD77avdpoI8DIBMzAPc67OefCDm7/BkBfF+wkOIHCmTQZIYY66jgqrOJGxHvJYAPgu7C44KrmbHnWRsf1bLlFjK75taGzbgMdYErlJoz8yp516mtMzfIPjlmb5jh6L2l9G9bB74+GazLT9u12ItCuCbYGMerg3GjC7IPh7pQNJzrefIaXHlQtq9mIlLN3L3QtCE2xorcSnm67eIy4DEKeA== 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=9/bVpuk+uMb1Bj437tZwCfjxm5pp41gQevBuBX5gnVU=; b=ZfEYPzOuqKWvYg1V/IEGlHoeOeSN/VxiqgMhZJtkFcYZxEOPNN5QD7nCfq14c276gWkk1N9W3TWRo/ZyylHlVFBMFHkjRl97+tNZO4BpHFRIYxjCrODiTJMTsscOVqgpwPvXrZibkDlFjApDLV9njp2Q/BT1U44Mp4UWRCS0jlU= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by SA1PR10MB5710.namprd10.prod.outlook.com (2603:10b6:806:231::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.11; Wed, 18 Jan 2023 21:35:55 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a%4]) with mapi id 15.20.6002.024; Wed, 18 Jan 2023 21:35:55 +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 v17 1/6] crash: move a few code bits to setup support of crash hotplug Date: Wed, 18 Jan 2023 16:35:39 -0500 Message-Id: <20230118213544.2128-2-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230118213544.2128-1-eric.devolder@oracle.com> References: <20230118213544.2128-1-eric.devolder@oracle.com> X-ClientProxiedBy: BYAPR05CA0093.namprd05.prod.outlook.com (2603:10b6:a03:e0::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_|SA1PR10MB5710:EE_ X-MS-Office365-Filtering-Correlation-Id: e15d2aad-a547-4fcc-2fb5-08daf99bfacc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8T9ac6n8SG585o9dQmv81DWAuG4Z9ES1PJekU74m7NTrbquF8B+J9JKzJTLuqz3X/tBRdtfw7lAzP2XYCFArjUqR3L4UWxAPTBE4k05l7k5jizVrn1bbcxjNphdD0LcnE07NIFyaDEGGgTvPYfjdD63SI25JYyT1Chcaye2oqbvapFeDK0mPXXMfpYQQELwUJJTWPe8SC/De1ZG8KfBzFAUqp0MOKVxgjiqymkN/EaA+/FKkH3u6Qid4v9X3V94RQiIMebTcZzf0vwh8MStwIkJuxaPkV7Sw1dlsdwnMaoD4PFlFm0tqElDGfDaPqZ6OJ6arJUJFIcAHyjIBithx9Fv0NOVBBkZAYtR00CJd6L+zTWMxd4U9CmM0PStnFrIwi41h0kfgDkgc4B8gU8JUrLLXE/weYA4VC12iob6/sBH0G1aNhdYY6TOwyPlA4n/OEtx0bgUTpHDNnTrDKF0db86vYaJYfwl7VfcnDiN2HQDGC91FodWqK/L4rrxSw0avr77vwSMuZGoZvNDWGbrxBf8qH8rbKt1P0oPUfSXRpsqxk2Dc8ehcY/RQZciFF8sxXRXfGpMpReOetkmUJqQgYt0NtxgcXjn00DK8Ly3cXP7JMKXhNUXkByd75YpBpKvaALYEWrpd/QQesSEo/FKdrQ== 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)(136003)(366004)(396003)(346002)(39860400002)(376002)(451199015)(36756003)(86362001)(316002)(66946007)(4326008)(66556008)(66476007)(8676002)(6486002)(41300700001)(7416002)(8936002)(5660300002)(478600001)(30864003)(2906002)(83380400001)(38100700002)(186003)(26005)(6506007)(6512007)(6666004)(107886003)(2616005)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Xr0H6H+ovbcyh0SdiwDEMS7B0Eu8oqqW8QemvE6ls+eYeYxfVQy0uNbk4Zv4J2JZlX9k4Lc7cEznkohVhuNDMmpWmK6/ebzAnmhZgRFsDrD7choxPZmYRwqoBQripHB3LlHqWnxLdqclfodOE2iA6Ku4KCGhCSLvtwLckkZG5YDvW7zbwo/9w0aqrtSyxLAvymBl5y3gLceXYNVP0fch3rfHr+1jOUyW9QLWUQe3k92FvIH89etVy+Al50dJ4Hjl7OZVNixFzOEz/75Cfn9EssDKajCzUvjkb7yby1IEfFS1FAYPgTSMT+HHCfrZyHlyf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d43LmsMGwtU8T+BZxXoMwxkD93gQy1R4CXaUD117XYTUqBeNPwYT3T9W7VQw3D5cP+dQ1wz5QCsgnrc4LAQHAHQpvUucqrFGy8CpImmiOsO05/V+emfRfo5cr1XUCtUXYyKTG9WtqMTVA0S0Mc/2ZzyAvRgnbOA03tiGkdMXIPJJHWr6v21HFO7Q5Wn1ywuoWVXaJv011dYyukERGsaD8drTpP9zUP/j6M/auHAQj+PGfM6GbHYY8YceLDGg8vHVeJY0608n13PuO8d7tlTBeK7w6MG23mVtY5mz1Ff82UClh7A+HMM0S2e3jzYMfuKqROfVmD2wIK0OtnxFngGflOiY0DyK9ifKETJn5InFbJJIVpyVn2ZLNDs72RIC7o65LDd9m3ZGYC81khShE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e15d2aad-a547-4fcc-2fb5-08daf99bfacc X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 21:35:55.1778 (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: 5GzIDmFz9xkc5RqHd3ZHqCYGZMnb61edbIqLcyM8m2Uy4ntR65nuJmvx7Bf/yqcI0JlIwEdbTi7MyZ45CNqYZubpjGKnsH91VN5GFx8MwSk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR10MB5710 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-18_05,2023-01-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301180180 X-Proofpoint-GUID: mt64nRicdjY4YcNgftTJHCo4b5LDXYkt X-Proofpoint-ORIG-GUID: mt64nRicdjY4YcNgftTJHCo4b5LDXYkt 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?1755398072333253661?= X-GMAIL-MSGID: =?utf-8?q?1755398072333253661?= The crash hotplug support leans on the work for the kexec_file_load() syscall. To support crash hotplug for the kexec_load() syscall, a few bits of code need to be move outside of CONFIG_KEXEC_FILE. The crash_prepare_elf64_headers() and crash_exclude_mem_range() functions, as well as the struct crash_mem are needed for support of crash hotplug on the kexec_load() path, as well as kexec_file_load(). As such, need to move these bits out of kexec_file.c and into a common location crash_core.c. No functionality change. Signed-off-by: Eric DeVolder --- include/linux/kexec.h | 30 +++---- kernel/crash_core.c | 182 ++++++++++++++++++++++++++++++++++++++++++ kernel/kexec_file.c | 181 ----------------------------------------- 3 files changed, 197 insertions(+), 196 deletions(-) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 5dd4343c1bbe..582ea213467a 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -105,6 +105,21 @@ struct compat_kexec_segment { }; #endif +/* Alignment required for elf header segment */ +#define ELF_CORE_HEADER_ALIGN 4096 + +struct crash_mem { + unsigned int max_nr_ranges; + unsigned int nr_ranges; + struct range ranges[]; +}; + +extern int crash_exclude_mem_range(struct crash_mem *mem, + unsigned long long mstart, + unsigned long long mend); +extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, + void **addr, unsigned long *sz); + #ifdef CONFIG_KEXEC_FILE struct purgatory_info { /* @@ -238,21 +253,6 @@ static inline int arch_kexec_locate_mem_hole(struct kexec_buf *kbuf) } #endif -/* Alignment required for elf header segment */ -#define ELF_CORE_HEADER_ALIGN 4096 - -struct crash_mem { - unsigned int max_nr_ranges; - unsigned int nr_ranges; - struct range ranges[]; -}; - -extern int crash_exclude_mem_range(struct crash_mem *mem, - unsigned long long mstart, - unsigned long long mend); -extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, - void **addr, unsigned long *sz); - #ifndef arch_kexec_apply_relocations_add /* * arch_kexec_apply_relocations_add - apply relocations of type RELA diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 87ef6096823f..8a439b6d723b 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -314,6 +315,187 @@ static int __init parse_crashkernel_dummy(char *arg) } early_param("crashkernel", parse_crashkernel_dummy); +int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, + void **addr, unsigned long *sz) +{ + Elf64_Ehdr *ehdr; + Elf64_Phdr *phdr; + unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz; + unsigned char *buf; + unsigned int cpu, i; + unsigned long long notes_addr; + unsigned long mstart, mend; + + /* extra phdr for vmcoreinfo ELF note */ + nr_phdr = nr_cpus + 1; + nr_phdr += mem->nr_ranges; + + /* + * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping + * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64). + * I think this is required by tools like gdb. So same physical + * memory will be mapped in two ELF headers. One will contain kernel + * text virtual addresses and other will have __va(physical) addresses. + */ + + nr_phdr++; + elf_sz = sizeof(Elf64_Ehdr) + nr_phdr * sizeof(Elf64_Phdr); + elf_sz = ALIGN(elf_sz, ELF_CORE_HEADER_ALIGN); + + buf = vzalloc(elf_sz); + if (!buf) + return -ENOMEM; + + ehdr = (Elf64_Ehdr *)buf; + phdr = (Elf64_Phdr *)(ehdr + 1); + memcpy(ehdr->e_ident, ELFMAG, SELFMAG); + ehdr->e_ident[EI_CLASS] = ELFCLASS64; + ehdr->e_ident[EI_DATA] = ELFDATA2LSB; + ehdr->e_ident[EI_VERSION] = EV_CURRENT; + ehdr->e_ident[EI_OSABI] = ELF_OSABI; + memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD); + ehdr->e_type = ET_CORE; + ehdr->e_machine = ELF_ARCH; + ehdr->e_version = EV_CURRENT; + ehdr->e_phoff = sizeof(Elf64_Ehdr); + ehdr->e_ehsize = sizeof(Elf64_Ehdr); + ehdr->e_phentsize = sizeof(Elf64_Phdr); + + /* Prepare one phdr of type PT_NOTE for each present CPU */ + for_each_present_cpu(cpu) { + phdr->p_type = PT_NOTE; + notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); + phdr->p_offset = phdr->p_paddr = notes_addr; + phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); + (ehdr->e_phnum)++; + phdr++; + } + + /* Prepare one PT_NOTE header for vmcoreinfo */ + phdr->p_type = PT_NOTE; + phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note(); + phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; + (ehdr->e_phnum)++; + phdr++; + + /* Prepare PT_LOAD type program header for kernel text region */ + if (need_kernel_map) { + phdr->p_type = PT_LOAD; + phdr->p_flags = PF_R|PF_W|PF_X; + phdr->p_vaddr = (unsigned long) _text; + phdr->p_filesz = phdr->p_memsz = _end - _text; + phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); + ehdr->e_phnum++; + phdr++; + } + + /* Go through all the ranges in mem->ranges[] and prepare phdr */ + for (i = 0; i < mem->nr_ranges; i++) { + mstart = mem->ranges[i].start; + mend = mem->ranges[i].end; + + phdr->p_type = PT_LOAD; + phdr->p_flags = PF_R|PF_W|PF_X; + phdr->p_offset = mstart; + + phdr->p_paddr = mstart; + phdr->p_vaddr = (unsigned long) __va(mstart); + phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; + phdr->p_align = 0; + ehdr->e_phnum++; + pr_debug("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n", + phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, + ehdr->e_phnum, phdr->p_offset); + phdr++; + } + + *addr = buf; + *sz = elf_sz; + return 0; +} + +int crash_exclude_mem_range(struct crash_mem *mem, + unsigned long long mstart, unsigned long long mend) +{ + int i, j; + unsigned long long start, end, p_start, p_end; + struct range temp_range = {0, 0}; + + for (i = 0; i < mem->nr_ranges; i++) { + start = mem->ranges[i].start; + end = mem->ranges[i].end; + p_start = mstart; + p_end = mend; + + if (mstart > end || mend < start) + continue; + + /* Truncate any area outside of range */ + if (mstart < start) + p_start = start; + if (mend > end) + p_end = end; + + /* Found completely overlapping range */ + if (p_start == start && p_end == end) { + mem->ranges[i].start = 0; + mem->ranges[i].end = 0; + if (i < mem->nr_ranges - 1) { + /* Shift rest of the ranges to left */ + for (j = i; j < mem->nr_ranges - 1; j++) { + mem->ranges[j].start = + mem->ranges[j+1].start; + mem->ranges[j].end = + mem->ranges[j+1].end; + } + + /* + * Continue to check if there are another overlapping ranges + * from the current position because of shifting the above + * mem ranges. + */ + i--; + mem->nr_ranges--; + continue; + } + mem->nr_ranges--; + return 0; + } + + if (p_start > start && p_end < end) { + /* Split original range */ + mem->ranges[i].end = p_start - 1; + temp_range.start = p_end + 1; + temp_range.end = end; + } else if (p_start != start) + mem->ranges[i].end = p_start - 1; + else + mem->ranges[i].start = p_end + 1; + break; + } + + /* If a split happened, add the split to array */ + if (!temp_range.end) + return 0; + + /* Split happened */ + if (i == mem->max_nr_ranges - 1) + return -ENOMEM; + + /* Location where new range should go */ + j = i + 1; + if (j < mem->nr_ranges) { + /* Move over all ranges one slot towards the end */ + for (i = mem->nr_ranges - 1; i >= j; i--) + mem->ranges[i + 1] = mem->ranges[i]; + } + + mem->ranges[j].start = temp_range.start; + mem->ranges[j].end = temp_range.end; + mem->nr_ranges++; + return 0; +} + Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type, void *data, size_t data_len) { diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index dd5983010b7b..ead3443e7f9d 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -1135,184 +1135,3 @@ int kexec_purgatory_get_set_symbol(struct kimage *image, const char *name, return 0; } #endif /* CONFIG_ARCH_HAS_KEXEC_PURGATORY */ - -int crash_exclude_mem_range(struct crash_mem *mem, - unsigned long long mstart, unsigned long long mend) -{ - int i, j; - unsigned long long start, end, p_start, p_end; - struct range temp_range = {0, 0}; - - for (i = 0; i < mem->nr_ranges; i++) { - start = mem->ranges[i].start; - end = mem->ranges[i].end; - p_start = mstart; - p_end = mend; - - if (mstart > end || mend < start) - continue; - - /* Truncate any area outside of range */ - if (mstart < start) - p_start = start; - if (mend > end) - p_end = end; - - /* Found completely overlapping range */ - if (p_start == start && p_end == end) { - mem->ranges[i].start = 0; - mem->ranges[i].end = 0; - if (i < mem->nr_ranges - 1) { - /* Shift rest of the ranges to left */ - for (j = i; j < mem->nr_ranges - 1; j++) { - mem->ranges[j].start = - mem->ranges[j+1].start; - mem->ranges[j].end = - mem->ranges[j+1].end; - } - - /* - * Continue to check if there are another overlapping ranges - * from the current position because of shifting the above - * mem ranges. - */ - i--; - mem->nr_ranges--; - continue; - } - mem->nr_ranges--; - return 0; - } - - if (p_start > start && p_end < end) { - /* Split original range */ - mem->ranges[i].end = p_start - 1; - temp_range.start = p_end + 1; - temp_range.end = end; - } else if (p_start != start) - mem->ranges[i].end = p_start - 1; - else - mem->ranges[i].start = p_end + 1; - break; - } - - /* If a split happened, add the split to array */ - if (!temp_range.end) - return 0; - - /* Split happened */ - if (i == mem->max_nr_ranges - 1) - return -ENOMEM; - - /* Location where new range should go */ - j = i + 1; - if (j < mem->nr_ranges) { - /* Move over all ranges one slot towards the end */ - for (i = mem->nr_ranges - 1; i >= j; i--) - mem->ranges[i + 1] = mem->ranges[i]; - } - - mem->ranges[j].start = temp_range.start; - mem->ranges[j].end = temp_range.end; - mem->nr_ranges++; - return 0; -} - -int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, - void **addr, unsigned long *sz) -{ - Elf64_Ehdr *ehdr; - Elf64_Phdr *phdr; - unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz; - unsigned char *buf; - unsigned int cpu, i; - unsigned long long notes_addr; - unsigned long mstart, mend; - - /* extra phdr for vmcoreinfo ELF note */ - nr_phdr = nr_cpus + 1; - nr_phdr += mem->nr_ranges; - - /* - * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping - * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64). - * I think this is required by tools like gdb. So same physical - * memory will be mapped in two ELF headers. One will contain kernel - * text virtual addresses and other will have __va(physical) addresses. - */ - - nr_phdr++; - elf_sz = sizeof(Elf64_Ehdr) + nr_phdr * sizeof(Elf64_Phdr); - elf_sz = ALIGN(elf_sz, ELF_CORE_HEADER_ALIGN); - - buf = vzalloc(elf_sz); - if (!buf) - return -ENOMEM; - - ehdr = (Elf64_Ehdr *)buf; - phdr = (Elf64_Phdr *)(ehdr + 1); - memcpy(ehdr->e_ident, ELFMAG, SELFMAG); - ehdr->e_ident[EI_CLASS] = ELFCLASS64; - ehdr->e_ident[EI_DATA] = ELFDATA2LSB; - ehdr->e_ident[EI_VERSION] = EV_CURRENT; - ehdr->e_ident[EI_OSABI] = ELF_OSABI; - memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD); - ehdr->e_type = ET_CORE; - ehdr->e_machine = ELF_ARCH; - ehdr->e_version = EV_CURRENT; - ehdr->e_phoff = sizeof(Elf64_Ehdr); - ehdr->e_ehsize = sizeof(Elf64_Ehdr); - ehdr->e_phentsize = sizeof(Elf64_Phdr); - - /* Prepare one phdr of type PT_NOTE for each present CPU */ - for_each_present_cpu(cpu) { - phdr->p_type = PT_NOTE; - notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); - phdr->p_offset = phdr->p_paddr = notes_addr; - phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); - (ehdr->e_phnum)++; - phdr++; - } - - /* Prepare one PT_NOTE header for vmcoreinfo */ - phdr->p_type = PT_NOTE; - phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note(); - phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; - (ehdr->e_phnum)++; - phdr++; - - /* Prepare PT_LOAD type program header for kernel text region */ - if (need_kernel_map) { - phdr->p_type = PT_LOAD; - phdr->p_flags = PF_R|PF_W|PF_X; - phdr->p_vaddr = (unsigned long) _text; - phdr->p_filesz = phdr->p_memsz = _end - _text; - phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); - ehdr->e_phnum++; - phdr++; - } - - /* Go through all the ranges in mem->ranges[] and prepare phdr */ - for (i = 0; i < mem->nr_ranges; i++) { - mstart = mem->ranges[i].start; - mend = mem->ranges[i].end; - - phdr->p_type = PT_LOAD; - phdr->p_flags = PF_R|PF_W|PF_X; - phdr->p_offset = mstart; - - phdr->p_paddr = mstart; - phdr->p_vaddr = (unsigned long) __va(mstart); - phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; - phdr->p_align = 0; - ehdr->e_phnum++; - pr_debug("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n", - phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, - ehdr->e_phnum, phdr->p_offset); - phdr++; - } - - *addr = buf; - *sz = elf_sz; - return 0; -} From patchwork Wed Jan 18 21:35:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 45514 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2576935wrn; Wed, 18 Jan 2023 13:42:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXvoKIs7F1PhOfGWnU3bq9NN+Ha50J12JA5jPw/Nzosg8gPilNK/R3z54P6kTF0bU9YFtxFV X-Received: by 2002:a17:907:7da0:b0:86d:67b0:6292 with SMTP id oz32-20020a1709077da000b0086d67b06292mr12640589ejc.73.1674078155006; Wed, 18 Jan 2023 13:42:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674078154; cv=pass; d=google.com; s=arc-20160816; b=dY6afN2bEJifWVRo3peshpZGt/UPt8oLw873gwggE20lv/okgD9jM6T7PKpzlMcWdN 7YZgRjeogmyKmCxI4MKxPTB4ET372BD5lfq1m8pcxT3qVIII4MtmkMs2n/xbNzJ7a0kl HaoeYradUJrY/+Dg7CjI1WGug608awY1xJDGLzBr506ugdoV1QDB68rGwzncgm/CUnCC VPo+MhYWmQ5Qb+64ipfPdL3NFJhgB+uge9hX8h6o1EG2CWTn3ScZYV6lcXBDxiFyMnnn pq8Efc6T7LdGR107rcgQ3+aYQGp/QmBnL90O3J/v+3iC08NktHhE9cfmadMBIjgIqumC 03Jw== 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=DvuQcDsnckvmVGNILjIjL44xiJ7gNogghIQftN3NIJI=; b=gdVupRyMhBRmpGkqJdnDJj/KKA2MZcDdh0ZeCFhBTtPB1doPKDf8kzGODmiOHsmZ2+ NbWXx45DtAJUmcG2WwnU89HnRw2R7gAVXJfiJd90y/EmgJxT1vpA/3fHMDl2QNN79bOH GVx64zgWdujiMZGI+V9gJC17aABJ97AjSHMKTzR1weGwdTLooq4J+7f8DUc0PIZwbzm/ EBK6QrsF/+0FDYNnwvJAAoCKq+VF3N9A9q03qkX8AwjM9iRM+JRuJmmqaQ2BDovn+CXD ExRH7u9cGW9Z3R45W2PPNCgqqSdWawggOWa/sNo9sinQqR+GZrfH2VUQpn0gh6DgU696 0/cA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=wPvd7rgd; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=uHwU35Xw; 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 xi7-20020a170906dac700b007c0a9aca484si15467619ejb.755.2023.01.18.13.42.09; Wed, 18 Jan 2023 13:42:34 -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=wPvd7rgd; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=uHwU35Xw; 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 S230122AbjARVgr (ORCPT + 99 others); Wed, 18 Jan 2023 16:36:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229870AbjARVgd (ORCPT ); Wed, 18 Jan 2023 16:36:33 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAEA564D83 for ; Wed, 18 Jan 2023 13:36:31 -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 30IKmkKE029504; Wed, 18 Jan 2023 21:36:01 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=DvuQcDsnckvmVGNILjIjL44xiJ7gNogghIQftN3NIJI=; b=wPvd7rgd2CkG32i/iHGtaxg7bcz/HOGRE6PPcA9rw5xWnC2bToqUBekBtkMFyeHvKUwi qZPmYqCyY9UZsEB8xYJqYFUcVXgG4tyOePvrVtMOvViV/RVJhcg5gyIbfDvrCX1kj/HD uDB6dg85DMmiEKA8/BAaGIzgvJcdTnkVrF7D35niv9EsUOyh7K601EBXBS+KRcJXzaDi oR0MV5sM+yXJ66XPBT52rv1O39VRqS3wvmpOkQXxi0i+tcFY6FhcnGBK8LsNyFQZbDJo 01t8i/k0yVX8w/zTXaZ/naSsePpF8wp8hVZaBdEEGQwksBQuRIA1u1lNM/CNC99OfUtb ug== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n3m0trpuc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jan 2023 21:36: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 30ILVkZC009793; Wed, 18 Jan 2023 21:36:00 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2046.outbound.protection.outlook.com [104.47.73.46]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n6qmcu8p2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jan 2023 21:36:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EjPjfDB0rRaC2d+QLnyMVIxHk74F/TBBzSBVRZMt5AGIDFq0YEgQU8waZShrksa54MOao0+ZZ21Nqg/FKRdak19Iq710oOOm6KuFRi/tTTp0DMI6FnkOfdVYfcJK3BbFrxDax3n96Jd7oxOEl94eHHxvM03oBzbyuf7S/Xy26DXiqtlsORBr17PITXdehSMs08qPCrULwT+Cofu4rJ7KXkAjnjRi2tAp7HVu/i24H5Dczak0zmrlh6K6qs/q69kTYQWwB3OxxUNCAXbjuopPViXkpbZG0iiKYKfGrilWfhKf2NGqdJdWjbzN/otnH9NWczvQwOfuLQKdnaJzuKErYw== 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=DvuQcDsnckvmVGNILjIjL44xiJ7gNogghIQftN3NIJI=; b=JjwLB7ICGNrqOnnWXAyy1CFQNZjLvp9B0U7jzk2WBZe6zlASPHX8O6HoNUfwOqRFW2fvqRZBsA+Hfbrt+Vk+T4mWo7zJMrzGWHq0HuUKH+gghPs8Aq4n8h8GReKITW4M/ZhSuSkMron2NxI70gsX8nfgUbI86yMyayH3GMo8WEQHDCvAxoX0HhY4Ywr68qK2MhHBfpR/MForVeHNGiuYCuMznNv0QnsfO+o3aD+v/LHRCRuYPcxInFhMo707qKmnofPkIlbQ06V2aMxVQPGbJxEobsJJyH3nRpjPctAqSagcyxRPIiwEsRvQWDfgI/2SVlW6sshKAZEfONMJ/fh/oA== 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=DvuQcDsnckvmVGNILjIjL44xiJ7gNogghIQftN3NIJI=; b=uHwU35XwVj68si3cOUhL5JdAsUg4lGbdwpl4KOSC7JQX/OJls2UHhRWWNgKcGOhgclR2zF91x54HNdMxAyORYBxLQR+9fXfFXDCd+OVy9VxrDGIvIzduZMSys3WyxFtdVhBaeaVdbOIXwPDwOTZNy2/keYeNMDMn0hhvEaYgZto= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DS7PR10MB5214.namprd10.prod.outlook.com (2603:10b6:5:3a0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Wed, 18 Jan 2023 21:35:58 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a%4]) with mapi id 15.20.6002.024; Wed, 18 Jan 2023 21:35: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 v17 2/6] crash: prototype change for crash_prepare_elf64_headers() Date: Wed, 18 Jan 2023 16:35:40 -0500 Message-Id: <20230118213544.2128-3-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230118213544.2128-1-eric.devolder@oracle.com> References: <20230118213544.2128-1-eric.devolder@oracle.com> X-ClientProxiedBy: BYAPR05CA0103.namprd05.prod.outlook.com (2603:10b6:a03:e0::44) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|DS7PR10MB5214:EE_ X-MS-Office365-Filtering-Correlation-Id: a233ebe9-cf05-4106-ab34-08daf99bfc98 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oaIYwkmiYkXNCLlRzezxE7WXk7YvMeGG9GruZZnPS9In3LLmMeBzUL6Qae9sILryYP1x3pXPn7yxfDRaVCjHueauE5KEabjQzTc/BUv5jsharzXuS7o+2a38pqUk1ZFKQD09frLT8PsrxNIGVr8ZPO8rhL6xNDe/YaFveepqrJ4dhQhwVpKGlq37i6jrzAgewM8fDvB2rB58Hn/WVaio5MY5R4f3b3NqHy99l+FI0yvCVZC+ujDxSurvyB+WkqJYfa18SxYGANZqs+KHsKYCvdoZSRJ0yhDlTHJXj0sbN39IYL7OueRRtuyE1pDbWfqOvLEpomsgQ0PmF4YXDktyLF5+q3mDTwcSdyIdOxWf8Orcopb8N2BXTpcXwoUZYIVQD8xbbSfcbT9aowJ4hjowJAblIWj3kbAs7YZzfWcOoI/tItS3em3jXGKVDwtXdGmcWjuZYuReluvW0BucJp45MdSySz00Xw21br0cDst5PeO38FWmnM/jFEuA4GpdOqupPpmWmzx4QxcAlrlDIf9GHgxHsbkmE5/xe2ijYbI5Vxtlqc0ErodZvBQgqsP5csH1AYhrQeD9jW1nEIdP+l806wZfl+tsSZdfpC8mFrI9NtCZpOcDPO6ZONZk5Y6SMG7ryjnee9nxMfO3A+iF+f2srA== 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)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66476007)(66946007)(66556008)(4326008)(8676002)(36756003)(41300700001)(83380400001)(86362001)(316002)(1076003)(2616005)(2906002)(38100700002)(8936002)(7416002)(5660300002)(186003)(478600001)(6512007)(6486002)(26005)(107886003)(6666004)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BMzvsufwjwBgSAnF3rK5nf/H+M3EUIfbOfQUZdWHg9PYHQnqaQ8c5CDNuRJhsHNpe7Rj6VoYHTYrXxwnJO9lCmrMu018pQTDZp2RSDfVAZOujs/Ztu/bt0ITHK/yweZugnwRm57Cz9XzTh79BolIhyUyzdpDDN5k/3AYmkvlQVIkwFL3flCp5Pbp2INRqUBnGN327JUx1uUnSwjuuCaeyEorAs/uYKajFj/Pe3IIwgTDwui0p3lSs352ps5o/Lsq40pqZFSN6mKORwggM0b/b4vnh/ouRVhFIg5UzMcoapf1swy8nsMY4KVMMDzwaVDQg+xBJmlFheanYuwKyeOFYZffnNxh+YbEfi9l91PA0biNiQsWkV5pu4rtj9JLReQmcBnNHgT8KrAkD4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HjJ0suxUWEdcLWak6TJU/PeNpiOPDs0yKJX+NDptKCBFDKm7dGwGYRlJdWttlP4UGLXtO1H+Q+n4V/Q/h/SWqEIWf5xPrk91jlc9EShIfgbp67Xu8gTKAGKTbflCH8QZppP9AwDoVgCqZHCC/erQoeJ1lbPzPrXo58EVUIitsJ5nW1nZ8C4I5pNBNX7AEgq8Q7SK7+iUr4n6PCSDFmTPjHHaWvv7WIeDuTUdhZ+0vjpNaa00/IX9nMB1pJdGaLD4ILC2qmAT4rHsZq7L2CDq9qXEysX/7PFDklayqgEjW8hpQcJ789dGtYpUe0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a233ebe9-cf05-4106-ab34-08daf99bfc98 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 21:35:58.1331 (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: l0N9bo9Xf2UN/aGBnXJnbJcD4YmZ5zA3VZjTINH0PNKVkAUyiDtJodzeXRdnhzU2AR0jgpLkzyVaOcecsYFjVu2uPr0GasQkh4xDo2hxdIY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5214 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-18_05,2023-01-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301180180 X-Proofpoint-GUID: GIJgoJuvIb82DNaBuRyALJPnmxL-WiQS X-Proofpoint-ORIG-GUID: GIJgoJuvIb82DNaBuRyALJPnmxL-WiQS 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?1755398175297982508?= X-GMAIL-MSGID: =?utf-8?q?1755398175297982508?= 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 af8854f9eae3..e51d8059535b 100644 --- a/arch/powerpc/kexec/file_load_64.c +++ b/arch/powerpc/kexec/file_load_64.c @@ -799,7 +799,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 5372b708fae2..8bb2233bd5bb 100644 --- a/arch/riscv/kernel/elf_kexec.c +++ b/arch/riscv/kernel/elf_kexec.c @@ -130,7 +130,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; @@ -152,7 +153,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); @@ -224,7 +225,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 305514431f26..8a9bc9807813 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 582ea213467a..27ef420c7a45 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -117,8 +117,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); #ifdef CONFIG_KEXEC_FILE struct purgatory_info { diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 8a439b6d723b..a3b7b60b63f1 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 Jan 18 21:35:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 45511 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2576370wrn; Wed, 18 Jan 2023 13:40:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXvHyHVD20IPGsXEgJ8rzMg4MKF/KqzH0Ems+/WeSs8hpLm7zeJuDFCDAuv4XqRxUDcfAXeb X-Received: by 2002:a17:907:d68c:b0:812:d53e:1222 with SMTP id wf12-20020a170907d68c00b00812d53e1222mr8996051ejc.31.1674078053571; Wed, 18 Jan 2023 13:40:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674078053; cv=pass; d=google.com; s=arc-20160816; b=pue+hN9iuTA8xCAlqW99h+IWJw5b+8ilYXo92ceMwhbTyg382zYiMvdyWRE15Pv+Y7 e7WgUttQL42FgsHaukePu8K0kPn4aLFKY4RVGLDkaxn9I/LxfhhibgNtccuEhy+A6/bl oDm5AJdNEQPz2TnflHDeYC2o+lAJK2AhwmZmvg5M79I9E4ExBjGZcTfBgRq+2SpxUDIr Hze+D26BBYnwcQuMdXTpBXfDV5G6rkm7JDRmmiTKiEQBJ3v5iVLvtXOemdAiWRHg4Hfk bhMn/klWhQIwFJ3KnMzy2npCUg4amorR99gt+DPOrcqoFPfhMQvlcl1dCVUd1ZerzqoF nOig== 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=e0yADqJ81jLTv0pyZxCiQ3ni7M2ufBxAvQM4Z/Yavws=; b=1DdY4pvSsgd91hxPC/PL8I7/g0Md2k+VoAGTkmMCQGgH7YbXDqF+g+wqGKNmnn6qcs vXhG/8MEWy7DGO11TriCLsaxA4e+ufQ2G+sc17YD8P+ma9yTSwpHBMRVY10JQ5DKPMiL IHbBsHv+99AR6qjpcf1bkIOXojJyq6hQayUCQPJZ9MOq35/XNo9M3cMl4zwXzGEb+3Hx QEg7gJBIDfkvYLCoPiIJRLSFbR9Wp6UE+CTvUdu4x3zKiBDuvGe0UxiT5fpJwDE1rwkp nDDcaMGfXIjDPZ6YG3VBVPcx27yMCXItBBZzTdH/giRDcmWFRUffTz71AiJYe8Nk7gxm gIVg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=I2FQD5pg; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=p9EnabMG; 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 ds7-20020a170907724700b008775d59ce67si2865465ejc.217.2023.01.18.13.40.30; Wed, 18 Jan 2023 13:40:53 -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=I2FQD5pg; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=p9EnabMG; 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 S230363AbjARVgx (ORCPT + 99 others); Wed, 18 Jan 2023 16:36:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230136AbjARVge (ORCPT ); Wed, 18 Jan 2023 16:36:34 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 506E564D83 for ; Wed, 18 Jan 2023 13:36:33 -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 30IKmlEu018138; Wed, 18 Jan 2023 21:36: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=e0yADqJ81jLTv0pyZxCiQ3ni7M2ufBxAvQM4Z/Yavws=; b=I2FQD5pgOxjMdb6JwQ0dcWdun4A9n9AUxLR2FjR/JA7YsrQ8Osqqe/tBqAyU0/2Ai4rs 3A+o5A/+E40KdgT8vq+sCVvV+BpWa5+oFve28jDhSIJSgmvSgMZaXpcLQ+RLzBpUzFVO OL4m2O5Oigv1PBVz0CmNpSd1e6aOzizPh2VS1omunBZTpJ3Cg1bI3GraN59KopF+r4PN maheotfjmRh7Aq0YRTKwryS2P8fYmWpKCXvqbpYCINwYf3UbEmATYOUjiZn1++Zr0a4R jnVcEzY8EMElf881WvAe/MAL5EPfgLtwcIiV+5TU7DDyP+nRzVHIWSmmrX/sabC/j2D+ ZQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n3k6c8qts-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jan 2023 21:36:04 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30IKwdfE016614; Wed, 18 Jan 2023 21:36:03 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2043.outbound.protection.outlook.com [104.47.73.43]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n6r9e1f20-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jan 2023 21:36:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N0CmyXCfCbpc0H+Ahi2sZp/lt1E/29Rd0gVE4cUvXRwe1WImFjOrdJFcFUxu/hPrKuT1BgztroxQxhSOpPw4io/HfKwKyPJHcI/n7oGf4E36wt+Qz/LBlX/7hfUK83zoiserlFJejWuOP1NhUTVlRmPfV9uOUX7n4awjI/ZjWlBSfz7MejCTaB0QDzlg9vRBI3cLUMDVBrZTHbz8HmO/52ULj2EliuHasNVoCGfyOU0opXArEeodQivHN1Mmo365l1c5M3XN17ifAeMuV9SzhEN8Aqlk6S8MHWKNY4i7E7SyFn4CN8DeXgGwFsU2e4QsEcnJ9s3CE0o4lnN7BsIK8A== 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=e0yADqJ81jLTv0pyZxCiQ3ni7M2ufBxAvQM4Z/Yavws=; b=H3xLdgmbiQuBvLZ+zuXxy1kSCFtiBI5C+Ob0QgFGJg0QTVbafnAQAsZEyZmhNaa77S6dXTc+V2d5IgW8FZ+DJo92tCOjvqmhA98V8URCKRFI5chgCXCzLu8gaJaetJo1TWLU6b+G1Utzkcq4qnOi0GLtfJhtLpDr3tgY+hVIaZE+IWZ6aOdgpwjB9ebHf+3BVhXOVFPHZ3ttjTZuINgrXCxKaau/4EphatLALfM8ZyptgSeMtA8T/0c9bKCNUBAsl4ndbcD1V5MrgMsCYe4Y52dWSp+7kYPB/O5WsWdH9V4DqTYq85gCyxLOvF6HglW/GYOD8kPOmIIjJH/6c6anlA== 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=e0yADqJ81jLTv0pyZxCiQ3ni7M2ufBxAvQM4Z/Yavws=; b=p9EnabMG6iPoupDBBcPlNflsHyAjOtEUemU8Gq/qP9W58KdWzE3t/nZFq7dQrYCULzypbrqyK7nq4QtbC/gI5feZfcfqU2NnwXuTvSP8+Rb6wJ+PKQe1O+EAN+hkDz6lmLHoIbX5PIA0s5JhwujhueWSVRelyMxmWt8QFnbC1Q8= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DS7PR10MB5214.namprd10.prod.outlook.com (2603:10b6:5:3a0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Wed, 18 Jan 2023 21:36:01 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a%4]) with mapi id 15.20.6002.024; Wed, 18 Jan 2023 21:36: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 v17 3/6] crash: add generic infrastructure for crash hotplug support Date: Wed, 18 Jan 2023 16:35:41 -0500 Message-Id: <20230118213544.2128-4-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230118213544.2128-1-eric.devolder@oracle.com> References: <20230118213544.2128-1-eric.devolder@oracle.com> X-ClientProxiedBy: BYAPR05CA0100.namprd05.prod.outlook.com (2603:10b6:a03:e0::41) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|DS7PR10MB5214:EE_ X-MS-Office365-Filtering-Correlation-Id: a18ec4f6-0e0a-44ba-e044-08daf99bfe40 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A2xzfS6gqmZy5wKEs/+prZc5CWg3QCstRerBjiNzxbzGFqg4R6A/Dh0bEeLYjMuXEvzk0Dkz0YaY7NwAIP5tLtYk9pyfC9vazV5w8Rna5KpEIf1bZ2rREIxNUiC5PGB0XzfUGTStSkseEI2RP7TIiR2juqVnUX0NsW9x9+HrgBZcGf7etStTuq5Zf0u0dwP/qhph9Y/h1olhIk3t1L7K6KGABbtkNiiedxpSakZqBxRlDX1T+qicpRxvS7F1JtDAKZPi5E3jT13KaSg7e7AebrdXfFCegCYgOCfJJvh8/giJm2/1gMqVkeytP+OnKhKaOuXUSsgw8PjzqMyTks1JB4zUoZeQMvdlhrftgeZlYVviRZpel0UbGo1lr96dK6vuUDsgecE6bGo9t/Q+hmZjuxLc7wvOIDfkqcD7Qn1XzmsJM3QHaodk3p7gp4FktRLoOKF/ayt4qGKL00QkY9NifB0DL6TC9R+s/Xd/ihEo/PkenGm4RYYweBpd9AlYejff0W3R+vTXkiCMa8lWUFLkVw9817CELmlbpYd+uywgidQUVzrntUcf/0eCsUh/pnC7L8w/dqbrSYIENWFIWlVDu+DV6+J3KZgKYTE4fA1glNLK3C/7fu6CY0u3x83XYterRxjNcvZFu7OT/C0NWxVdx2QXIUEc8Xe/XUbMs4l4HnZNqRakwHapxy+CzK/W5WII 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)(396003)(376002)(136003)(346002)(366004)(39860400002)(451199015)(66476007)(66946007)(66556008)(4326008)(8676002)(36756003)(41300700001)(83380400001)(86362001)(316002)(1076003)(2616005)(2906002)(38100700002)(8936002)(7416002)(5660300002)(186003)(478600001)(6512007)(6486002)(26005)(107886003)(6666004)(6506007)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: w8pHIs/YzT+IGXnZVMg8Ic2ZrsjnLo5gAeY5Mgm2vlCFYPQXEIkIZ9ZzU2Ix+e0ECJ+cjxD1xmOPicnEHLQNPOvv9WTd9mAyziDryqdobmD/yHEKN8sFeRwcT4iRBqBld58HbS259gqAosAsToIXa7pVWKDF5FWJN9iReBETlPoOQS8XVrZBWTzDoHP2jB9iGo0PVcxJa3u0dmC4wovF1suEIAYvBykXMOFc0irEkvuRe8DmvM3Qqzb9rMti3iEFmrdyhq5qmSyagITiP08JvBx+ZgmuxyJwTGHoOiqjA9wZtRINYmHTM+amout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iktbvqAFGfwG7mBqvMclWObx0XpWn8EG0q8OuSg99fPO2RvDOW17AA4LkqB1KGuMyzZXbrgok5nOH2beDlHaX3iIpDRHNdt0krepHrAku5GRTJFmsY76KgA/qhZX7roTtP677MBklJpZRTU45Wp2YeGB9whylCndoYfYIgzqiCxPHxSQzOxBxEQsqLhNwgz3jlZE5djxXpB7QpBBeh0hrVOKu1V4A2Ulsw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: daOEC8p7K9+Sq7NY0s2K3yyzSlfCU+yjBCnslOOK/YaliLx+zDtBVI2IspyvjD+2V3sy68w/b0ldck/6ROtL+p9LwtFteEgEv/yNpoazA5SHAraUdPHbYVOiXXNhgloBTRGMAHA2lCfe8165Z38I144jobum7nIFR7N/mN2kti2DNBmAZHiLYV7hW/IFVncJhr5LXuf/u0AyS9xrtly7HJHDCRxIsIb4Mr4BnXk+8ypguHeQJWhMIteywLibLaOGfajmdJQsShGuu1LUWgatsz3vVIMQHJqzB+X8Utzq6dIQE2yI584zp9Nl08hlTK5L75gvfj/WEmPolTAf849UyYzrM742zalO7YCwZr8cjrEzjiDOGvZ/zx4onYwggQhi5mascSPUEoDc2RE8FO7qafac2bJ7w0bcUR11SnmmNWiELTPhQalX6TeFhluwRuCveHi0+9F1efJynsPz89RoU/oF60I8LFBRalsbILQTtTyYt4OrsW/2phC9jZ3n2MicQI28yjY8C8sGUCAAvX4rOEQCoVmb7C1j4LJdGySfF9N90aE90CI5LM3W4MBxpW3LG8v1546OkxUlIgtQB0m8+7rpWrPjqoy/uz9ziM9ApnTX3LN+H0EMqzkZgKaV0/ams2ODhlavxH5VaAOb/WHs2xnN30xB6p1FIzDH8KMvwmxgYvE5ShDjvvAiHsT3KQLTHqObH3epylad5/RlTGZ52Ni4xUVZCBvYO/Q8pha2hOcc4XDm0ypKoMJSzkWagLu5NZdaqhrGoxYlG5Mp9m/E1DSGPkSgaoVZrIb5aEIP1VuJAynGD/W0JqdtnvtqrR9VvsjcLJvkXRMjU0pRq8oLyenqr8DL3xIQpag2wVK3c47MHNuHIQlZRn4K4slZzw2FNzl/mPnTVJxUYeZipSfFQdMUkXn5I7qn+j9EQcNn3b21b3l8UzOlhVdaoaOzOW/KyRBBXC7goZ4gP69lB4rDtdtPixD9mWg5VLa0alGZTC+PrszxVLmsO+Iu4OeouWZ5vhlTAIKlXQLTAwwG91YEdIGiDD3Kh/72baitdndh91+Es4uuHLZIQLjiYwrqHOe9uSTM6ZKBeC7a0OHchPgVjkVu/mndrNcy5xwrYk+WzOlfI8hSfiyyTuJ4XrD/hvRzVU87awurdYkX2DEulwN1k92OP5A12snrK17oRrsYMqE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a18ec4f6-0e0a-44ba-e044-08daf99bfe40 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 21:36:00.9913 (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: IAmYmtxwxUUnwriVOuFEEOJBBSioHyR+/aR7OVLavP7kqtPwCgwvXtTymfc9P/EyJxOymoi1zQ9XcNVg33tgig/7rtqugXQnmH2eLuI7sMM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5214 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-18_05,2023-01-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301180180 X-Proofpoint-GUID: hLgdDf8pfsyBGpYSSTNcGOPCBoDONCLP X-Proofpoint-ORIG-GUID: hLgdDf8pfsyBGpYSSTNcGOPCBoDONCLP 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?1755398069313929058?= X-GMAIL-MSGID: =?utf-8?q?1755398069313929058?= 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 Acked-by: Baoquan He --- include/linux/crash_core.h | 8 +++ include/linux/kexec.h | 12 ++++ kernel/crash_core.c | 138 +++++++++++++++++++++++++++++++++++++ 3 files changed, 158 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 27ef420c7a45..881e8a43db89 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -33,6 +33,7 @@ extern note_buf_t __percpu *crash_notes; #include #include #include +#include #include /* Verify architecture specific macros are defined */ @@ -371,6 +372,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; @@ -500,6 +508,10 @@ static inline int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, g static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { } #endif +#ifndef arch_crash_handle_hotplug_event +static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } +#endif + #else /* !CONFIG_KEXEC_CORE */ struct pt_regs; struct task_struct; diff --git a/kernel/crash_core.c b/kernel/crash_core.c index a3b7b60b63f1..ab074a706e55 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include @@ -18,6 +20,7 @@ #include #include "kallsyms_internal.h" +#include "kexec_internal.h" /* vmcoreinfo stuff */ unsigned char *vmcoreinfo_data; @@ -697,3 +700,138 @@ static int __init crash_save_vmcoreinfo_init(void) } subsys_initcall(crash_save_vmcoreinfo_init); + +#ifdef CONFIG_CRASH_HOTPLUG +#undef pr_fmt +#define pr_fmt(fmt) "crash hp: " fmt +/* + * To accurately reflect hot un/plug changes, 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; + unsigned char *ptr; + unsigned int n; + + for (n = 0; n < image->nr_segments; n++) { + mem = image->segment[n].mem; + ptr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT)); + if (ptr) { + /* The segment containing elfcorehdr */ + if (memcmp(ptr, ELFMAG, SELFMAG) == 0) { + image->elfcorehdr_index = (int)n; + image->elfcorehdr_index_valid = true; + } + kunmap_local(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 Jan 18 21:35:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 45509 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2576359wrn; Wed, 18 Jan 2023 13:40:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXsJTkPpz9WcwAovfXugd7FRddZcbv24u6pFl5UY5KXjoW0p4kSYL6DkM9EKQzICPBjkONhR X-Received: by 2002:a17:906:314a:b0:870:2cc7:e8e2 with SMTP id e10-20020a170906314a00b008702cc7e8e2mr11867286eje.54.1674078050752; Wed, 18 Jan 2023 13:40:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674078050; cv=pass; d=google.com; s=arc-20160816; b=nGXRWng++0DsaI8F/OPoNgrqPRAGEG7sgFpNRaCn0RBPn8c5IQHufNzlBfbyKAWEAb QkPUvv+hBE5TEIngIRfnpkcEEe/8CbxtCIH+C0UHy8ZvjZtkaM8x9l3bwphuIZr/Zs3/ AtGTIOX9WWdKkQ8cQyjW2tg/2Z9wNpXUNuTh+4XzkSCVFX6xLTHU3yQnz/h6O6Jx3XUB WXpRfQvbhL6LxjP27Moddr1nmG8Ru2v9wRNmoe4C5Pq8Hl9VMIfPu9TF9vaISYUiUDVl jBp5jULfoWWhC1/fCQyd8d2ehN42u55u1ou3QP/KCnFtbFzbqmidv2gYfF6GNFvr60q/ /06g== 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=hjA8LtzxdRdzjixqkYOUgiBezHcVOhJoacVpmeuNeag=; b=icH1A4KcNKo31QiEYTkSNSjZxsRpCMXJw29psnwJxC7jXPFbYvMbFpKtE+EhyHNHXG +1RxXr65wR8v4NDrk35ywmEruTsh9yTct9ItJ6o/lKwpKY+jL6wCRGdWios49lR3lyFR 10AlPTn7if2mj2ZidBWN2dWj7g7IsyGqB/4cMWXVk7P5e9uZkf0psIcp1TYbLbvtVgYb uboZyBXMXAjjfFvj3bFlWYdU50KjYdH50CGLInGcCqY58parGhtMgJGsGN38r4s4HV3W MIH6EyXE6L8tbZqF0y90N5UfSNu2BDVCoMYHP4BxdfAkoFa8/qp4FpQK0Er5Y8t96y67 YslA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=FA13uOTO; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=a547fEAn; 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 g16-20020a1709065d1000b0082517442ad3si14482824ejt.682.2023.01.18.13.40.26; Wed, 18 Jan 2023 13:40:50 -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=FA13uOTO; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=a547fEAn; 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 S229651AbjARVgd (ORCPT + 99 others); Wed, 18 Jan 2023 16:36:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229593AbjARVgY (ORCPT ); Wed, 18 Jan 2023 16:36:24 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74DAD630B1 for ; Wed, 18 Jan 2023 13:36:23 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30IKnKJL001433; Wed, 18 Jan 2023 21:36:07 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=hjA8LtzxdRdzjixqkYOUgiBezHcVOhJoacVpmeuNeag=; b=FA13uOTOm2ykaE/cPVYfAom5AH+zwMei0POo5xmpNYEe8lXY595mV+EMUTINcTW5g0bW CEOSnLWgoUnDJICKXceHRi9MmehgapsbKvzknuJKCH+u0HzekM61HTw1IMC9FOsHI0qd nx6ScwkYejgvG37d6eCz2qnY0Ypq4fiHNBDACgZ4NPlpHohHNoQH9djNLxxaRjsp/T/1 uVfQUBkIf7w2pYmPq2Q4m67X1OTmgi59O/YxqJWatMWZvZYbolDsPQDl1pKTjGHLxRAt GZOfgC1dpgMQMKvN/l7It6JzcgC3jDFA8Ekx33nRC/lmYKTZT93vV+EXCXFn7olshWxQ fg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n3kaagsnf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jan 2023 21:36:06 +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 30IKDhFi009445; Wed, 18 Jan 2023 21:36:05 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2042.outbound.protection.outlook.com [104.47.51.42]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n6qmcu8s1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jan 2023 21:36:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d7nuj8LvVqJ0TP0QMHBE5l6wUKIJ5E5+gU1NkGJKBl5bYLyiVQpGkwhlJItonNggjx4pusE/vlk4AWPfDw2WNihc3aQxSOK810b2ko/riUfP3JI+608UCoMzbgK5XUkL5ls+/NHU8BQP7CZxVhBNLkbD2tVAHfKOMJJ1Z0TYQ8ntuQf6Kt+YDmz7L+RlAy/DZnhk2eQQV9+yxxEtWMmK8+y5UXkUlydSeYpVaDaV/AXC0YmbO05YaJJb+xEIAqcyOtpwGxlv0cEsvfly/UhlZ4CZABxJirSQznh6AJFuiUCsi8m8SbFFEAkgc4zNeyIl4Y0/rx9soGD4TL1J3dje5A== 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=hjA8LtzxdRdzjixqkYOUgiBezHcVOhJoacVpmeuNeag=; b=b+4CCqkveX9md9rY0XTnF4+wEuZpKmcyr0A87dPlRTKgHCwb8UttHVYDbXpN06nmlmjqO7pdQtBWoOoPJp/zTE9F3WjGXZuOBU73o78w84ikg09mXZ3TJIT/7XEN1cj2s0CvoAb3qp9ZTjUIJso2cJ/7P8IXTRBqsKqfNWI/k8B2n0tHPukklGzs/2jWdQzu/mAg8dX1eVb3dfrXHcINc8zNVmACPYu/tBdxfxTnA/9qDSiwM/B2H5lcR5wBbVUqgMacsIbHpzN512xL4kzBbls/qkfdDs3FA3QbunQXs3T2I5QfvD8iNIXjzROLvhFhObR2UJh88eGRVNh8wW8R8g== 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=hjA8LtzxdRdzjixqkYOUgiBezHcVOhJoacVpmeuNeag=; b=a547fEAn/0ae2gFySTSxHWWEGlL3W1/OFXCS+hZTbf9RTD/ceaCzMJ5XK4zJEfMSuXUj/NaxQQc0R3OglghWPyN60o/LRzUwBKb+woE6RNLMNFtlllUWGK1wWJjE1q+uadxT7x2iOYP/xHCYzPG/9AJnr/AA5yWP6XR+LXGaiBE= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DS7PR10MB5056.namprd10.prod.outlook.com (2603:10b6:5:3aa::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Wed, 18 Jan 2023 21:36:03 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a%4]) with mapi id 15.20.6002.024; Wed, 18 Jan 2023 21:36: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 v17 4/6] kexec: exclude elfcorehdr from the segment digest Date: Wed, 18 Jan 2023 16:35:42 -0500 Message-Id: <20230118213544.2128-5-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230118213544.2128-1-eric.devolder@oracle.com> References: <20230118213544.2128-1-eric.devolder@oracle.com> X-ClientProxiedBy: BYAPR06CA0057.namprd06.prod.outlook.com (2603:10b6:a03:14b::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_|DS7PR10MB5056:EE_ X-MS-Office365-Filtering-Correlation-Id: 7dc41809-2555-4574-05f9-08daf99bffe5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b/Dz5woe2EIOIZwGvL3jieVJOVtjcKNl7WqiuZF+sf3UeeKZe8Cws6snj2DTxUIP4isaubIQ0L6yaGOK9ANvjWcb3KzA4k9gnycaxzTgbz0RjyojqyLMChPfb5rSyQmFLySsh/e36yPLx0IrY69Wu/f/JXLwBfIID2fUaB4wLL5QxjKyR5FTtyqYPQF2MXeFiqqa6jyHMkDLbVCxQP4e5EUaQzTV54zGDVW9bMmLt9TlAkAFvTDjgQIplb1IdNZ0YoyWJmueyVbSdgvjEMC31CF+bib/QNVfqNmV2L6jsdWzvIW6wMXavdXAEPdOY3AeWkFroLimen8nSiX/u/s3UCRr8Hegw2kRUeNu7xElSzVPk9hEVrIIX+QlumBPtXrkh1Y4eMLsrJHFhU0WDmF5rwxifwslq9zswpedfv/Biz7JlpXograx96Ve7LqgJuBKIKwotMjtCWDz3GzWFIdnsFHntOYw5Rlgb5tkWynYhbxT2z6WQydyNCAtt7palD9MWlGtft9BvL69MacZf4KrfcAS3e2HE/5hBpGM9G/t6sjb43VsXdjgA9wG/XciNThckANCjVeQlY8oN4miDMH0LGYSkyCS8HHzK2e2uAedVu7kv1PtpdmIyK9zeOUZVvNK5nR+YRD9X4Jgg2fca6TTIg== 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)(346002)(136003)(396003)(376002)(366004)(39860400002)(451199015)(38100700002)(36756003)(86362001)(316002)(66476007)(66946007)(186003)(26005)(4326008)(66556008)(8676002)(6486002)(6512007)(478600001)(2616005)(1076003)(2906002)(6506007)(8936002)(41300700001)(107886003)(6666004)(7416002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: otsTjMd3UOp/U+dSCcPlIIPAkSHzMBnCxD6MEEKaK35U5vgeP5PFoKedG2XeKMPtqrylyaatG1KkGHIRji+6Eu0O5YW7UFiIvNyQDzjsbg1+LKWxMg8NDOUV85wkvTq6MFXutbl+q6BhkYDcmKPtEJFuCu3f1/EpXqOsGpmqAZFtUWh+p2+SARcpnvikaU/XzYrXluEeuiWZJV1pETIgCBLg8NL3IIHvOKns9JNk8JEuY6Ki+72M/gemGbtYsDpIxq7wHQvXZ+BXgFn5xj96K5ovq6QuKzhuzsffgA9eOnp0Rl/IK1NAQ6xKsK33d4THqe+J70NtMT/13qgL2o+a1XD1bXA0q9EcXVFNd9NMGWfPk+1LaW7VaYylyr7TV6sGgAQOtTESQQcHbwq1D1ynOPi33nDjSh20gc3JPIVl0W6OJYm5wnOtRB9x90GrAeWoUHJc8GsYz+SueBluSKv5tNPftmBFdBsjBZaqaUsQ8ILS/tVC8dOVKFHtVNARJQN7onC5zrVHB7V7VnebEo+zaJ88DZWuHRPQye/kxRWavVN32igYdSgCS/hB9PTwclbKnTQLtFC2beovOHYGYf4f2CYFAPzp0xZOA2XhlTJwCtlQ7dhCx/e+vbJKqnTU6WjORbCQyYrrQcpyrPLQnGxhBZcUX+oK2gwva8sXCmNgWkFMExGxhKB111L0F2KM8p0iLdnSJTqBVjOCfeoSvbFDf4qyetrwME06NQXrsuaGwWPjjgwtPi7Hvby/YSuZRj7F/r2k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Tenant-Network-Message-Id: 7dc41809-2555-4574-05f9-08daf99bffe5 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 21:36:03.6668 (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: rrEeb/YpJsv4Q87rWJbMjIJYtQcF9yVs0Z2skIu6vNEiJOGLTzUZ76nsnrz8Ye3mLCqfEsrwluGmMvX6RSrSOcMuO2GquQe1Z4g0bSNQxIA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5056 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-18_05,2023-01-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301180180 X-Proofpoint-GUID: Xgalic_tRCTEpC57pixzS6nw4i7w10Qk X-Proofpoint-ORIG-GUID: Xgalic_tRCTEpC57pixzS6nw4i7w10Qk 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?1755398065885478113?= X-GMAIL-MSGID: =?utf-8?q?1755398065885478113?= 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 ead3443e7f9d..2f3b20b52e5d 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 Jan 18 21:35:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 45512 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2576386wrn; Wed, 18 Jan 2023 13:40:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXsVIYg4LJ2gBL3sVOyqKOK4B1ZR2sVjAvjKQeOSZhDAsyk0M3ShRHU7491I815XF9Ohbixr X-Received: by 2002:aa7:cfd6:0:b0:461:b8bf:ce1b with SMTP id r22-20020aa7cfd6000000b00461b8bfce1bmr23250251edy.34.1674078056334; Wed, 18 Jan 2023 13:40:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674078056; cv=pass; d=google.com; s=arc-20160816; b=xp0qsFO1U/Ntg9vZJQuoeWPs/eP8/EiTAs+0ZbDDGcug5Fc/u/2gpLO7DCmefgfxHs vcxXz8h8M6zfApf1opjbgxH6aQhdM713ErYiw3SC66x4vzFiLLWD94xxM+UZE9hyAt3Q HVBNDtZfXrGVP2jfFqDrPW0BwY9F/i2Tmxc5+zhJ7QwINqLvfqBlJ1pO0c/+3RTdSdKb OjQd0pAz5Mbyg0akF7ltOd0OKFxKo1mJat5KkIJUe+uZ+Zso/QOJ+wc+Ormk+x5fQGkQ lPoO148DtyCcJqYK6QYpH15rU+UNLofgQpr8DH3ztiQ3oJV96zn5lLUS0HTAY57cB99X Ctgw== 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=fd5q0t4KYkyFNurH7Nydv5I9kT0Rxu2wQStQGSToUBc=; b=gcFto7sOeZDiyc43QSfraSk9xM2I5URaqfQxlZ6ISjEWImOlRrXxUFd9Rdl4H89QqN bejehouT/bJeIRVMss4mMbM2CqyW58rmKjeVzEvF7S4fpmUc4O+Kr4vKlnc1YRmzRDKt gMldeeZALUcUiFFq1BHGf4eKjE5XYf/MoSakdXA6tuvdEW1W//KEmMciYIwtOsK6gfLy OHrAjYkq3UGQ3zQ1cw9GMSkrQanSf+SjFNfSTtg0tnO1EQs+yrIegf5mntz3by5kWiS7 0gEMNv0lQPzbqx7iZxPjPwrkhN1aZcHuZLk7yokn3GQH+vu/tCv8bVd8q1sI3YeXv5GX iDsQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=UR63z7Hi; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=SoGMaWaG; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a056402520b00b0048d42f6970bsi16173906edd.252.2023.01.18.13.40.32; Wed, 18 Jan 2023 13:40:56 -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=UR63z7Hi; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=SoGMaWaG; 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 S229618AbjARVg7 (ORCPT + 99 others); Wed, 18 Jan 2023 16:36:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230156AbjARVge (ORCPT ); Wed, 18 Jan 2023 16:36:34 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5163646BB for ; Wed, 18 Jan 2023 13:36:33 -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 30IKmmRC018177; Wed, 18 Jan 2023 21:36:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=fd5q0t4KYkyFNurH7Nydv5I9kT0Rxu2wQStQGSToUBc=; b=UR63z7HiAlp18rljmU+6+JWa+K+RkYUrleehjegcYfomwSiDBLSMT1S+mOBBzShRVE5g XfvFgvaDB2lRPxENYG0TseDwX1+pm8JvazIjyZQbbLP6VUNoaz7eCUcGWnfik02T8oOK I5v7RT+PkUaODjlUzJwObP9BZuWO32r3yxv8zOz2pMYlvjWB+71VH4+HdU7Weopre8At 1S2bZImOkva/mJynK/vcPmdr1qDV9VvPMYnc/qrUbx+q+HUIcmSkQ2o9mge+pXw+qiHw hIkaYez1XS+mYa2FuqYu94ETYeBqBWAdt5njYtzGoqpRgYtpqMJkUby1KDDaWTCDz1n7 2A== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n3k6c8qu0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jan 2023 21:36:09 +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 30IKDhFl009445; Wed, 18 Jan 2023 21:36:08 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2041.outbound.protection.outlook.com [104.47.51.41]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3n6qmcu8tc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jan 2023 21:36:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ayiCosJ5v47O/JS/8Hiz98TaH3uE/OCjiX+1tNZnJSzJdx9GNUaK+Qli2yGf0ZHyes8p/mxh4FW6usYS+7acMYirNbthdbLONE4RXXSz58VQ6KEQHZBmjxWjGw7vbjej6ufs0MjPVTvPa2RQtQmimoIc1utohRHZ9z2GnCjCZDA1fQwRGg59ScpENVqXwAOzIg9Xm7kZxlTyFjDqwr2mof/zXh4UxX6g6kfFjlI7CY3MvdfDNWfGLz3OfvivV0EDXUtu0JoP11vQv11GMKybZX8socLrAJsM+yjLcFuP0wnjMEZ8dsDZUswW7+fza2t62AZ3PkYc9AxbfkMOAY6GZw== 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=fd5q0t4KYkyFNurH7Nydv5I9kT0Rxu2wQStQGSToUBc=; b=fajSb91kMQ/955YvEBTWSTFXoMpJOk8Hah/alSsBeHyMszFxP8j+liDN3aOco0scPNYLKqPuhC/k3zx+ixBC6h6LG7i24fzcww2bPAYeYpli3YqzXrIu/qdYPc1x05WKbWeZec88FgGfc5xlfH7QLys4cTD6HTWgy8Dm4d4HJozo+G8z9I6reor2d135c6oiN7adtSbnqe97cvrRZycpOx9xg8ODRrXPr7s8yIvXoyL90gXmkm2cLuUjFwKOUK7QdO2YNx1it++WMrKOICGn6q9/VUEm551nGCumRcI7gzyCfX89ba1Xl/HEhRri/d53Z9Y0JVAuzVKvv0GNYLxWjQ== 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=fd5q0t4KYkyFNurH7Nydv5I9kT0Rxu2wQStQGSToUBc=; b=SoGMaWaG2XSYJuzCKRSmQUSOfrGiRdmGqK8eVAZx9icwrCIfkVLOF4wlkx43EtNQGC4R034jLse3AsSg4ZFz2eVds0a+L+AuYgQq9/J6NjzyMXwoMsqOgT83oSYIfh/YKz3NtjvQ9p5uXkX+3wArt67ZxCb2tI4mt0AEo29Qse0= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DS7PR10MB5056.namprd10.prod.outlook.com (2603:10b6:5:3aa::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Wed, 18 Jan 2023 21:36:06 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a%4]) with mapi id 15.20.6002.024; Wed, 18 Jan 2023 21:36: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 v17 5/6] kexec: exclude hot remove cpu from elfcorehdr notes Date: Wed, 18 Jan 2023 16:35:43 -0500 Message-Id: <20230118213544.2128-6-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230118213544.2128-1-eric.devolder@oracle.com> References: <20230118213544.2128-1-eric.devolder@oracle.com> X-ClientProxiedBy: BY3PR04CA0002.namprd04.prod.outlook.com (2603:10b6:a03:217::7) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|DS7PR10MB5056:EE_ X-MS-Office365-Filtering-Correlation-Id: fac02528-9590-4682-0457-08daf99c0192 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Eqen7a9zYC0xnwKwoPESgDBZkT4pCkXO3E56DrXQ/hyOWYsMQoEhyykVbG24LOnRYKqRzFRvqEW8sv2n9Pf0TH8KH8ckim/eFJ/PIho5ejA/e0svf7XV8iF42BQyMtsjNS2Tj6kFNjp7RanR4EwxsPk5CAhnsYCQxBXky4EX99VqVoU/RsG99YCIFn4gEBypoXFkWV/1l1MTYATw6SQqZm+lZ64GwErek6WMYzmTmKPcx1KTVlgk+4sNhAA0RykwlFbOQGpoqZ2HyvpdbUeNvwOnZzwl7l8uoXwWlVLDWldUjk8HeUmpvpGQYWsVPMZW22PfRuE4Lw4S9MuCc2YNW5jqiWuH6GCF/92IBSwU/D/XpipNjPRVcrqnVNDrKOyv6W2pbpai00JhFFUtRoYu5eyv5hwY84lvjQLxuJQ7QoFYviZAmfhzLTFpfx8aNOJwXXUUZicyhSVTp0lzBQBwTBMtxJvz+pVx3y5HD8aWDT8fD6UdKSsWoRAaHa0d9lyrM+2fVfES865eI55PzKXAc8qszzc187yG6gwxjkbBeqVDZVrx7DxUCC6zBp275jv6/8b22e/YzJLN3ghwN3xV34e2MzudFzgtXjc79LRrRLaqR2T6bXFNulpa1XlL6Dzb 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)(346002)(136003)(396003)(376002)(366004)(39860400002)(451199015)(38100700002)(36756003)(86362001)(316002)(66476007)(66946007)(186003)(26005)(4326008)(66556008)(8676002)(6486002)(6512007)(478600001)(2616005)(1076003)(2906002)(6506007)(8936002)(83380400001)(41300700001)(107886003)(6666004)(7416002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dv3ScGxDiteuYpIpldIH8luAJM6Di2CvSEMAoGsp8he3muuJaEC6yKXtvSdqf2I240vcfYl6QEkLqCydRJgZUA1PwtWY7FGJBICTEUCSN0GS6Njb/JzAfD08LlEQaES5HI3STWyZ1P9V+fUa5i9uCE7QgY3wUUY+Sb+jDf1fuJwym+sqZC4JN8LgpTiBxuF4oIhbN5dS1RunBgayhGKr1cXH78dd+VBsQOdhsJp/0wS81V7VMt+2dxxBgNH5Xh0VA0tLQIVo4ZrzUAxlCcJoj6ekY55x1nn5SKyBjSM0NbH3L7hRvTW70+SXrGggLF6huxACvwTJyZ42b7y+8k7uaODGsIz2346JvBMmomJ5csPr7ySwQ6Alg74HHMrWpJMXgAaHUrdbH3eihOpKUsoMuezdca+wTQFYdRhMkHeNN7ytVPlcRRNYQogV0yP2k/CJCk3/76IqYW+IwwmoiPnQ+oc2S3FU5Wd4ibDJV0uP7ihS8nM3lK4vz9iX8GQecvaeXv3YmBoCFwCqftc1LeMVhKjBSIyHfEQgBoCfqWoEyNllh9ylcYbiPcuovk0MfrDitC4vmN1zP5WQsXJxGbVgxGN15dEwrRFOt3rY8wKiim14eesSu33IVXHdWCp7APZ0C1kHguKpS4bBOnXLK4GLWR+59QksviOtfDYUhP2ucXCkaXvmGRBUenc9/VUl698FiH3COUO2RGUQBiP3BCJ4XgX9tjBqaFm/3HpcXw81m+645lw6ZVhgOZlb9+G12VomLmwzTCKM7KLfAicfDNDR8k3YsMxqvMSn75s1ST9KvwEzm6BUPUwUDheSYLnoWCIyblGlUTfn0kUd0CS5/yEIwZCETA7EOYBllWmux6GNILTjMCP6tK8+V2y5whh2Ykarxnl8ZTFvBC6xMAB2f8faX41SbXehLn6yrmf2h/8WhsWkkhSSF4hBslpbFI1/N5PSxWDGB6mkamZUMvZt5Gqh3TUOz5JDKH2Fpl+f12QzkymdaQpe6UFjHEdxuakSSBq2i9rmUWHw52vs3gDk3HdjIoc3tWYNmkNN36Vksip2ava1mjCx+s9/wkT2yy5m/YH1z5tprlL0HDN97XY3KyecwajnjfT282iNChLdMXGtf66dK4H8P71PV2MkuZvlYoNf77sKndVt1rPqE5yDQhu21WJtZ1PDY4yncoc3onmvubL/bUplfKJOyCqtInSgGidxiLlmnwVy0HXb6UMsZktQo7ZrZ6/Oc4DN8ZX5UYD+3T7k8hBNHbaYF31LOWMXWD3130u0c+vur1P3Csx8J7P1J9/zKCLEgSzgR2gWvjfJRz/tBpnk3CEKKFLahPZB78uhXWSbEkgWVtF0fAy9fdhbGBrK5ECxbuvlWdmFBChs6j2LgKPU5ZyndzLiEqFT+sVml8Q5wRE3qPB2tUa+bzSHXTp50y+TgjHbh98LMwNcuZPo90rmQ0gL++qLhBfF7Cwc6Q0IR761pGtLaWOuu019gwPP9auolKm+OfBbKyrYCMSnHHqMHMJSfZmST92I5hvO6jnUGVTrNmUbmVWchHKGZAvoI0COvoAju6dajNt9SvDkJOmiUYVijkqBmaVVar2V0b+6ejUAGCVXe5uAUrR1FQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: QEg1E6vGJea0wA42l0cR8FjdVKekv6cIIx0vI0yhjPH2vEWICRDDPIVxBbJ+TyXfobhPl6T0DieXY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rum5TBXFRcDj5qovs/F22DjwFOBxRtJmpv/n4s2hgfMuccEEq/HR0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fac02528-9590-4682-0457-08daf99c0192 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 21:36:06.4938 (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: 9Pd9BTN9WnR5eJwCd/IeMcSDSGcgzuKSptpwETWnJZ/7WHSmBV1MMW2N+fI34OGykB2u9U46Lj14rgDDdlPaoiJScwQlJEmTRJBiN+c49QQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5056 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-18_05,2023-01-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301180180 X-Proofpoint-GUID: zkT2FgEHtUfxLfNAygIL3DFC4TqMkM5n X-Proofpoint-ORIG-GUID: zkT2FgEHtUfxLfNAygIL3DFC4TqMkM5n 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?1755398071741812735?= X-GMAIL-MSGID: =?utf-8?q?1755398071741812735?= 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 ab074a706e55..37c594858fd5 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; @@ -768,6 +775,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 Jan 18 21:35:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 45510 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2576367wrn; Wed, 18 Jan 2023 13:40:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXuYAjGTZ68QjuZVIXLbaV39y3kSA7CDCAK0hs6Ux8uD8d9Kpud3lfspc4+bOTc7Fp7/V3ty X-Received: by 2002:a17:907:d089:b0:7ad:aed7:a5da with SMTP id vc9-20020a170907d08900b007adaed7a5damr9170002ejc.28.1674078052777; Wed, 18 Jan 2023 13:40:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674078052; cv=pass; d=google.com; s=arc-20160816; b=MdROaubTIq4KHQ9h0HUHeUMdxNsHP0/or7NEKxOj7G2ZbHCjmn2O4UKOhixT17u0mL TPbDSP1GPgUAYNd9Yf7Uqo9vBHW18eYjODNI9/xM1h/elmxEHTdUmEHtcpfEgbY56zm+ 4vgBxKEf9aNiHN/zSL0BDgYczMcTcKrXfNULsVcoOq5l71R00yT8x6T8Sl/7FrZqnq4C smzE0ar3oyrZ/A9CC97lgG0zZH27vaZ+D7BXRqxNQ23Yzp+RRX7DxtZMTJCNGx4PBbvm Dl7/n02kGd9cmVQUxlHyYmr1nIi+Kt6QC/iXt3/El/sE7chu69nMMY0tBYPO/4br9+Vf GHcw== 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=f6UdExf1TKM8GUOVAAnj9buuvcJy94WdoCzKS2kMVAo=; b=AjYa5+wOrUeIOMeKRnl5vZP+FBbN/fQepMiAZrxUnP5lZt7opIXFyN5aPJDhlmp9TF EhQHqAEUGrmTOLrBt1seLJ1B/FEgBZIzb+FMhUbPUPw4W2crL4QCRsgzEm/HrbhAHgJf EmBkIAWXHpZ7+1A4q58AZ4yxyh+TJ6MCbTOksGJ78hY/EtTXma42q4Nm7D6cQ94neETu dIjPATVZHM9gT+L+TiPRXIryE/BOzMuk0b3xrfyGps5HD/QCxoTbQAR2oOtdIzKtyMkz P2Ha//FTKMQpRGD/7DZqvkGST2XUy02C4atLwoSPQzpa0Ny5zrSa9mKVuHpvTQv/F9Du YupQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=rGAnPudw; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="moy/RY3R"; 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 be7-20020a1709070a4700b007c11e5ad98csi15915110ejc.352.2023.01.18.13.40.29; Wed, 18 Jan 2023 13:40:52 -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=rGAnPudw; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="moy/RY3R"; 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 S230217AbjARVgn (ORCPT + 99 others); Wed, 18 Jan 2023 16:36:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229932AbjARVgc (ORCPT ); Wed, 18 Jan 2023 16:36:32 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A03AF63E17 for ; Wed, 18 Jan 2023 13:36: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 30IKnDFa002415; Wed, 18 Jan 2023 21:36:13 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=f6UdExf1TKM8GUOVAAnj9buuvcJy94WdoCzKS2kMVAo=; b=rGAnPudw36n0GN0wiWEHkCR96+OXh2ZzsW6fNX0dWHfa4M06Y4pSBVU23lcUelF9JHII 3O2Yl7fe8gptAxndVwO9etOA0hON9Kt8ZI85kv6wS+/mqSkyb99GuGMAULkXtMY2Rev7 DNrAI9THNtLVgcUCHPj+XM/UM3Wtrh9V5Tj6PGkOt31GQsEI0Dj/sfJlTjNfPymvgGBQ dYAdRc/2eLA6Nqb7ce3wc1SYEi6NuIFa54AlzktQF8RtZgTHWhLkT++CTV0LX7r/eCF3 PAD7BBDVem5gEHgHBUcVLGtUlu+2rgfkdQO3r9muVeZUhkByxt2V5MYO6pN5owbnHEHM Qw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3n3k010t89-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jan 2023 21:36:12 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30ILDROl033460; Wed, 18 Jan 2023 21:36:12 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2045.outbound.protection.outlook.com [104.47.51.45]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3n6rgc8tb7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jan 2023 21:36:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k1MODJtXnMXH7aHVTcjqpq/pmu9y5wyDQ/sADLmpyMdstL2gDVrgI7OkrLV/ewBWTRcmDVGhLaN3n7a2I0hjm4qgdjkSp+14qEqm1RChMTv0RleHOsetqMP4XoAIfV/LW2FafO76eEZTz1+KLQW8cI+aN0hfHKWHbz7RMu10n153YFkzB7Vi1/MG/Fa2Pa2m9Yp8h1l41gQcZdEoSYEIBft+pHr21ljuUBlgNuYpPu2pDmvLqvGikET6H325cb0a1dVbyjyWKQIjXWYYF+JCNWSnmvcI32Eip54QPnPRcTgQ+BYfvYDvFgwBs/5o/30V74ULdUelLvA9I9MgKIICfA== 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=f6UdExf1TKM8GUOVAAnj9buuvcJy94WdoCzKS2kMVAo=; b=gy9pNNUqwQN+Xru7V8UE1MLRwTXI4Z9xnzTwk/d3qXAJ8i3CI+iWQA93rdGPSTEggg92i3MFtu0oN989dyFOYQvGo29jNSYj330PiUl8XdERoKZRPYPDgBGKvtQw3816AoFZ1AcVmwzFLFEu1lk2qrFO1VMvg1dKoeDgUbtod7UnOfJ+BYVgkA3T1Ehq6d3rc00O5Gjy6gVc5Mc5BQANxBIdYOrsicTsPomhEGTTr3CBsgFzCNB7vH/wVwib7ktlebdwtwFFE7JP5UldYsEQITm3CktM9jl8TJOS8aTRb01PFSvrRpyUdLlewgjQUEtvvyhlrymmu1MzAv7XZ8OTVw== 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=f6UdExf1TKM8GUOVAAnj9buuvcJy94WdoCzKS2kMVAo=; b=moy/RY3RF1ZN1B7xol6Y2gsRwsAD2kzoDgx/OLtD9MOj36Q2+/Bk9jSeQ4KMnxPwbS0L4z4PSgXLfj+7ojUz+1FxUFM7NG8J5PVGBudhafgclCNsGFQ6B3HJYjISGG5Ug0VSwWB14+yNpX2p+SgeVBxj0htdykZ7VSaq1CmNQZw= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DS7PR10MB5056.namprd10.prod.outlook.com (2603:10b6:5:3aa::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.24; Wed, 18 Jan 2023 21:36:09 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a%4]) with mapi id 15.20.6002.024; Wed, 18 Jan 2023 21:36:09 +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 v17 6/6] x86/crash: add x86 crash hotplug support Date: Wed, 18 Jan 2023 16:35:44 -0500 Message-Id: <20230118213544.2128-7-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230118213544.2128-1-eric.devolder@oracle.com> References: <20230118213544.2128-1-eric.devolder@oracle.com> X-ClientProxiedBy: BY3PR04CA0030.namprd04.prod.outlook.com (2603:10b6:a03:217::35) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|DS7PR10MB5056:EE_ X-MS-Office365-Filtering-Correlation-Id: a477b4c6-a27d-49bd-998b-08daf99c030f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Qn5KgznBrTdchz6IpNuNBVJiv/466ys0F4bs0YAtfmgEXdi4VUUc6zp6ieBfw9ePFfIU4vubjTJflXSfdD8JmjSwwsONOfMtN78A1AVinkIC73M7HGM2EtLU1eE7sUmJlgIS2esPnNHk4Arf71Q9PEiB/2dDX3KAjSjT/rOqqsUrZoScHA9a7Uz4gDF6SnMib7MNuEoEdj3bv8QlQdPEp7NNqZ54X0xLy7PPd/0LVCvv2FTXfJOKmgI+0st+BQCgwSpT22BLio1mW38QBDv3sYNkcpRK+5PaqqIkhThS5z+/lEXd62EWzHUB8AiL43vqSlmdOXLY2yDhJyb/OH2DrALX3zHTMBHljhoo1i9mDsGfthqNwcfjCvKhsHavdRsizKYEWlTCa1SRKUE0HRpDER/62Hj2VoWtkbouQATRi8opCE2SbfACB61wMpzWy1UMPJCqrlYzA8N2bBUkizJMXNvpeBIeZbbLJ5R+FYsJ6GygMAsHXFgKkpose6WArQUNdr4ebraGpjUXBtAG0nF6tC576JNMRcAQ0uT2W675hqlslPl9633xml/EKjs4Yw8uhcm7yF7tscuUJG3MrizrX0kvgbL6vWYH63BVKsEYYd94kq2XgPWpD/Jh0NYR75Crqb9YjW/K0oePpKXsA+PLUw== 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)(346002)(136003)(396003)(376002)(366004)(39860400002)(451199015)(38100700002)(36756003)(86362001)(316002)(66476007)(66946007)(186003)(26005)(4326008)(66556008)(8676002)(6486002)(6512007)(478600001)(2616005)(1076003)(2906002)(6506007)(8936002)(83380400001)(41300700001)(107886003)(6666004)(7416002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /to+1Kk5oc8DtTn0xl0gQO35O3GQPdv+JyzWe9rRFUoxvevkoihxcW6VGFpUuZAAREzyI/b3/l9qrCtVPc4eRql3yvy7srlfeyBuot+LUElJN6wEf2Y19STatnuuDJ4DbTyugTL5Z6hij5dgD1PRs4gUOcZNlnDAJugOIxojrBfe8EUxw+wT2FfdSOQ6otXXdJfRoNYdsREQSyJTqtQV0kiOV4WYYkh9GcYwLmYEcyx5F4VCDB4JjtCBoo6/1BM6MIjzLa1/9FaMxu0fBer7trEFPR5nP4NzjBMbOPybh6UacPYlSX/UzyJYjaX/aKg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hYWm9uxl4Z+keUhf+F1jWT4HdYq93KINvvK/BBEbJiX9wzT/RirPr6Qu5o+Lk/1EsIBqZbk221T8OdaL+IsTpZsPsc5o37nwUoFlMCtQvzaMY18/hmmNtESsp4wOk/ynFHo9VAnagkP6nRQTl0hnxkG0E7MLsxz/pQiY3rhRpYuGONUH/S8aki4iM3U3MHg0ozmsAksz4fL/WyZltz9mEsRL2O+W6W0eOd09WZI4XNeMCkye8sqJfu2CJDXQ6EtflN1/EelvX0vvwNOB8Acmo378uddNUMmGNEXNFyav03tt9KwQSu5btA98sLATmBS+MUmTxLbez7VzQDvroU11mFBCWzPoJRUsgVhkwR+aGobOvT2y8kpB3YXfDnPu6wwef5EPdpMzzrsnnPaIcAwfN0ghgJ/Wej3iwXVlM436gecI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a477b4c6-a27d-49bd-998b-08daf99c030f X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2023 21:36:09.1114 (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: S8nyeIOTH6hHAd+LTwEacU7qXmdX6D8KRbxIYEw1Ls0IQigSGjsQf3UmsxbvzIfIHxaC+UV45qhp8fhqPDWoxhCCBveBqM2bEYJQTOOvBuY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5056 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-18_05,2023-01-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301180180 X-Proofpoint-GUID: Dys_SDOHcN9352GpjbvQwddgzo8jdTl- X-Proofpoint-ORIG-GUID: Dys_SDOHcN9352GpjbvQwddgzo8jdTl- 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?1755398067940091817?= X-GMAIL-MSGID: =?utf-8?q?1755398067940091817?= 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 | 12 ++++ arch/x86/include/asm/kexec.h | 15 +++++ arch/x86/kernel/crash.c | 123 +++++++++++++++++++++++++++++++++-- 3 files changed, 143 insertions(+), 7 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 3604074a878b..09e9b7a091ed 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2119,6 +2119,18 @@ config CRASH_DUMP (CONFIG_RELOCATABLE=y). For more details see Documentation/admin-guide/kdump/kdump.rst +config CRASH_HOTPLUG + bool "Update the crash elfcorehdr on system configuration changes" + default n + depends on CRASH_DUMP && (HOTPLUG_CPU || MEMORY_HOTPLUG) + help + Enable direct update to the crash elfcorehdr (which contains + the list of CPUs and memory regions to be dumped upon a crash) + in response to hot plug/unplug of CPUs or memory. This is a much + more advanced approach than userspace attempting that. + + If unsure, say Y. + config KEXEC_JUMP bool "kexec jump" depends on KEXEC && HIBERNATION diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index a3760ca796aa..1bc852ce347d 100644 --- a/arch/x86/include/asm/kexec.h +++ b/arch/x86/include/asm/kexec.h @@ -212,6 +212,21 @@ typedef void crash_vmclear_fn(void); extern crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss; extern void kdump_nmi_shootdown_cpus(void); +#ifdef CONFIG_CRASH_HOTPLUG +void arch_crash_handle_hotplug_event(struct kimage *image); +#define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event + +#ifdef CONFIG_HOTPLUG_CPU +static inline int crash_hotplug_cpu_support(void) { return 1; } +#define crash_hotplug_cpu_support crash_hotplug_cpu_support +#endif + +#ifdef CONFIG_MEMORY_HOTPLUG +static inline int crash_hotplug_memory_support(void) { return 1; } +#define crash_hotplug_memory_support crash_hotplug_memory_support +#endif +#endif + #endif /* __ASSEMBLY__ */ #endif /* _ASM_X86_KEXEC_H */ diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 8a9bc9807813..ba11c7e70edb 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -42,6 +42,21 @@ #include #include +/* + * For the kexec_file_load() syscall path, specify the maximum number of + * memory regions that the elfcorehdr buffer/segment can accommodate. + * These regions are obtained via walk_system_ram_res(); eg. the + * 'System RAM' entries in /proc/iomem. + * This value is combined with NR_CPUS_DEFAULT and multiplied by + * sizeof(Elf64_Phdr) to determine the final elfcorehdr memory buffer/ + * segment size. + * The value 8192, for example, covers a (sparsely populated) 1TiB system + * consisting of 128MiB memblocks, while resulting in an elfcorehdr + * memory buffer/segment size under 1MiB. This represents a sane choice + * to accommodate both baremetal and virtual machine configurations. + */ +#define CRASH_MAX_MEMORY_RANGES 8192 + /* Used while preparing memory map entries for second kernel */ struct crash_memmap_data { struct boot_params *params; @@ -173,8 +188,6 @@ void native_machine_crash_shutdown(struct pt_regs *regs) crash_save_cpu(regs, safe_smp_processor_id()); } -#ifdef CONFIG_KEXEC_FILE - static int get_nr_ram_ranges_callback(struct resource *res, void *arg) { unsigned int *nr_ranges = arg; @@ -246,7 +259,7 @@ static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg) /* Prepare elf headers. Return addr and size */ static int prepare_elf_headers(struct kimage *image, void **addr, - unsigned long *sz) + unsigned long *sz, unsigned long *nr_mem_ranges) { struct crash_mem *cmem; int ret; @@ -264,6 +277,9 @@ static int prepare_elf_headers(struct kimage *image, void **addr, if (ret) goto out; + /* Return the computed number of memory ranges, for hotplug usage */ + *nr_mem_ranges = cmem->nr_ranges; + /* By default prepare 64bit headers */ ret = crash_prepare_elf64_headers(image, cmem, IS_ENABLED(CONFIG_X86_64), addr, sz); @@ -272,6 +288,7 @@ static int prepare_elf_headers(struct kimage *image, void **addr, return ret; } +#ifdef CONFIG_KEXEC_FILE static int add_e820_entry(struct boot_params *params, struct e820_entry *entry) { unsigned int nr_e820_entries; @@ -386,18 +403,45 @@ int crash_setup_memmap_entries(struct kimage *image, struct boot_params *params) int crash_load_segments(struct kimage *image) { int ret; + unsigned long nr_mem_ranges; struct kexec_buf kbuf = { .image = image, .buf_min = 0, .buf_max = ULONG_MAX, .top_down = false }; /* Prepare elf headers and add a segment */ - ret = prepare_elf_headers(image, &kbuf.buffer, &kbuf.bufsz); + ret = prepare_elf_headers(image, &kbuf.buffer, &kbuf.bufsz, &nr_mem_ranges); 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; + + if (IS_ENABLED(CONFIG_CRASH_HOTPLUG)) { + /* + * Ensure the elfcorehdr segment large enough for hotplug changes. + * Start with VMCOREINFO and kernel_map and maximum CPUs. + */ + unsigned long pnum = 2 + CONFIG_NR_CPUS_DEFAULT; + + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + pnum += CRASH_MAX_MEMORY_RANGES; + else + pnum += nr_mem_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); + } + } - kbuf.memsz = kbuf.bufsz; kbuf.buf_align = ELF_CORE_HEADER_ALIGN; kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; ret = kexec_add_buffer(&kbuf); @@ -410,3 +454,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) +{ + void *elfbuf = NULL, *old_elfcorehdr; + unsigned long nr_mem_ranges; + unsigned long mem, memsz; + unsigned long elfsz = 0; + + /* + * Create the new elfcorehdr reflecting the changes to CPU and/or + * memory resources. + */ + if (prepare_elf_headers(image, &elfbuf, &elfsz, &nr_mem_ranges)) { + pr_err("unable to prepare elfcore headers"); + goto out; + } + + /* + * Obtain address and size of the elfcorehdr segment, and + * check it against the new elfcorehdr buffer. + */ + mem = image->segment[image->elfcorehdr_index].mem; + memsz = image->segment[image->elfcorehdr_index].memsz; + if (elfsz > memsz) { + pr_err("update elfcorehdr elfsz %lu > memsz %lu", + elfsz, memsz); + goto out; + } + + /* + * Copy new elfcorehdr over the old elfcorehdr at destination. + */ + old_elfcorehdr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT)); + if (!old_elfcorehdr) { + pr_err("updating elfcorehdr failed\n"); + goto out; + } + + /* + * Temporarily invalidate the crash image while the + * elfcorehdr is updated. + */ + xchg(&kexec_crash_image, NULL); + memcpy_flushcache(old_elfcorehdr, elfbuf, elfsz); + xchg(&kexec_crash_image, image); + kunmap_local(old_elfcorehdr); + pr_debug("updated elfcorehdr\n"); + +out: + vfree(elfbuf); +} +#endif