From patchwork Tue Jan 31 22:42:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 51074 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp77930wrn; Tue, 31 Jan 2023 14:57:30 -0800 (PST) X-Google-Smtp-Source: AK7set/kqSDJqt3TLQsEIVt/YYUFTwQuHs324GJiCkQ/my4tX5EFVHKzYqAvwV4Vgwkrx7lWgyAJ X-Received: by 2002:a17:907:1607:b0:87b:6aa1:c87f with SMTP id hb7-20020a170907160700b0087b6aa1c87fmr129330ejc.26.1675205849990; Tue, 31 Jan 2023 14:57:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675205849; cv=pass; d=google.com; s=arc-20160816; b=a9ICQznxXNj44bcnZj2dXfqnkl+Ds0TUX49ZHL3ATtkovLuZwLxrSSrm9ckiMZ+7UA g5l/Q13MbIX1kyw2kEq58RDzxFj5uNdWLVtxf6pOHS6HzaOr4vPiEj6RBPEkpsTUJ0it rN9yTwpg3LasO1pnsxI6vYfHl9kHM4LR9YSWL2C39DfemC16FxCz0Spd2yhtgpMXfvbT sRxND3e5Hj7qkNtzMfPOTg287dNapDfyKSPaeMPo7BUr+TLaM4ZoHSR9yX4WGVqI+ntS LRQGvnzdeKyOTgmn9DgbBTiGWt50q9AhUyQwuh+cK0rx85mE85AcsOjD+HunUdP3d19Q P6XQ== 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=lZHxvhJxu3EgYdDyb+xldPTjoyTFBCi3+bZNLUK7LNA=; b=jnyE/KF5TKcPLQz7rNGhYArR4H7Vk7DdWEeHJt2RNwX9uT+EjNaTT5ce1kQhxb+hZW HdxPfzMZoTegbi785CaTf8ReZUzhIKBId/fGAzp2hFcl9cgF6jaPnIxlssNoLMx+FxxZ XL33RJrhKNEFSwmsXVWNE871/1sFYL5VOXCzDH69zyRkC54/OnH4Q0mBIPvK+lyTToTd 2SPtL2QAIah01rsZCLJUWFyUPk4BsSoyNotH0wfD9vgb5EBvdWZTZ8kf5uAh4qZ0mgN5 SgQHBSNwjUcFYCNyfgCSQYzKiaz+CYWF76BJWMwWaMnp6h08eP4hziphvnzOqj4CD8fk LVhQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=0zpCtsue; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="lp+VvhD/"; 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 fe19-20020a1709072a5300b0088d11b71f97si1986622ejc.324.2023.01.31.14.56.59; Tue, 31 Jan 2023 14:57:29 -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=0zpCtsue; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="lp+VvhD/"; 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 S232017AbjAaWoH (ORCPT + 99 others); Tue, 31 Jan 2023 17:44:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231888AbjAaWnv (ORCPT ); Tue, 31 Jan 2023 17:43:51 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CF44474CE for ; Tue, 31 Jan 2023 14:43:48 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30VIiLdE014801; Tue, 31 Jan 2023 22:43:15 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=lZHxvhJxu3EgYdDyb+xldPTjoyTFBCi3+bZNLUK7LNA=; b=0zpCtsueWJ5WoB3hmThtxn0dOHLep77/bC7ehxOLucMnV7dbDw8B/BUEvJ18ty8CfTFV Yz3XLXjqpimyci4lmEA7Rlt56QdLLFlOOUUJ1HbUIsY/2Pz5fX98qpvdFiA60FMrD4bf zTXW0icKSuZU9/bsE8wLTi5kTWte/8m4HN76Kjl0/LjX9UjSF9FowZ+W2d49TBmFKsb5 SKdSvLtBq/A/zEzYWx31uXia5hh/KT8if3tBdd8j2RjWetqwdjnXNeGq+YjRgUCI0QYW y6p3O1anZxLzZ7M0alkK3v/nCIPvASv/7Qk6/Cbmnmd05pifwuKKWHUdy61hFY5H+jmM 8Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvn9xxcw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Jan 2023 22:43:15 +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 30VLD9MU031581; Tue, 31 Jan 2023 22:43:14 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2108.outbound.protection.outlook.com [104.47.55.108]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nct5d6xqy-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Jan 2023 22:43:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AN/E5uwIgXnWJgUQDMStibs7DdbWjeWkMjD9xJsfrK40S3jOmqLpEPZpAAW9aPd1ssX9Npqu2iss2OIHkRSRqpUSuap1mFKwTNbvo+Q0AjcN06jzE+88V6OKfhmof80cyd2hEK6n2ziYr84Wag+hSuzLOLOTrbl/ygtd4O1nHX7v6K0jxsMiX15YO/RQrca+oDFZ99v64vIROsT/hcVcvHdtxaQGqoNC5N8x/CJQJo9mvxCd4t1ad9vS1SrI4Tej+TnsPFSbOVWsTXX0GzGdoZLnLWo+RThL5PnK25n81qLxze9/OCLktjYUAg4DFJq/aL37HD8Gz2BGaqZkm2CwoA== 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=lZHxvhJxu3EgYdDyb+xldPTjoyTFBCi3+bZNLUK7LNA=; b=ACHZUaNcFuLWwnxBbBJrpa0VlmWuR+vo25h5Ni9ftUntS1m7/TuQ0o5e9URJV/tvcprx5CdSlumzObmzOEq1SXxLmv1vgIJnh2fkRrAgj7B9tHW/Xm9ERF3zkOuVT/dWTwgsir8d3HUKa4tcXFh2Bgu5KhovnZtDJ6cIzOYyf23wl80LcxMFUItKeIt6NZiW+od4Gr0lEuZHIoCR2RrkVCrU4iO3a8Qs8aeSwt3w6cUIz1YQTBpnMYcq4VtKt/UPdM3vWFkUiaXxX4tVcpQ9QcmGY5w7HaXxDnQ+YYRQbqIWYdQFSFCMwFSdOgi0oi9AFzUVODMF/LJUlhzUB0Vjrg== 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=lZHxvhJxu3EgYdDyb+xldPTjoyTFBCi3+bZNLUK7LNA=; b=lp+VvhD/MOWZNDru5cjSaTNS5XQNxH6I2bHoToBT2+BZ12iChNy1HeugTen9jRXlCamTPcLfRkPPUTcugxkOnhe73/O8VTOVYVcn2LjSg8ysagOxGCy8FTmUKUoDCfPhgIrGoKLKIgXcLqY29dP4wOcciVJPjkVwPRZYowGzcj0= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by CY8PR10MB7241.namprd10.prod.outlook.com (2603:10b6:930:72::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22; Tue, 31 Jan 2023 22:42:48 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::2101:3ed8:9765:370f]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::2101:3ed8:9765:370f%6]) with mapi id 15.20.6064.022; Tue, 31 Jan 2023 22:42:48 +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 v18 1/7] crash: move a few code bits to setup support of crash hotplug Date: Tue, 31 Jan 2023 17:42:30 -0500 Message-Id: <20230131224236.122805-2-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230131224236.122805-1-eric.devolder@oracle.com> References: <20230131224236.122805-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR11CA0005.namprd11.prod.outlook.com (2603:10b6:5:190::18) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|CY8PR10MB7241:EE_ X-MS-Office365-Filtering-Correlation-Id: 15736b29-312c-402c-3d98-08db03dc7a39 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iVQUwPpFhJcM2Jl7si1n08/c9pMH8W2vgSJeKPkRs/THrD+Lx38UNraWgKN4r/UoBXIaIgGKiUpwfnhICypW+G1V+7DhjsRLyJzev25pyh4IRisXvBvCiO3N4MeN3gFAKH01qS7pZ8c898t9qd3Wh8eOR7rMqkOHZ0pFd0Ez+Dsbfp4Y55MYkQeaB7xFNEj9AzIO2+SK05uQHqWvxuu3UygQjZfCmxWIN0OvCuFOfMJRjrZfrRZ3VmyBF+ptZO/AvNJuIXCreKOf9OqW22rNJ08hHYHdgAF8tZHqmXceGN25HgN/WLAQicVGnEuAC2hMKRhhSb2j9cIkCy6SsjmbND6e42r86iHoomcMuXOov+NZJNBmyxhXiZvi3UfDvG13F6hPZ863ygey1ro0MYdPGeTBzjLesEKgmXtd6yYZCfdYZPf4S3J0xQcUT20/6Yz4YVeIzs9dTJigV+tMAx9IaXo/+tbcQ2BASuvMlCLF/2AJnKSACvxkmSHWjMxmekSoxuiExKFE2oNDrMPdbFSG4dkxM/Fu2PdN/8alZ1Rimxqh3PCaJoxibgBG2S9PO5otWjj9YU0EY5+Mnn0Ocj/iZSQsR2f78eccjfNrEGbHUZODY6TkGuMWena1f6iYakdbQawniQ3YCdLVCmM/yT0Xww== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(136003)(346002)(396003)(451199018)(83380400001)(41300700001)(316002)(8936002)(4326008)(66556008)(6506007)(8676002)(1076003)(66476007)(107886003)(6666004)(66946007)(6512007)(26005)(478600001)(6486002)(2616005)(86362001)(186003)(5660300002)(36756003)(7416002)(30864003)(2906002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JUmbsYSbl8Si7gB1EV8715mmGEaUDL8oBE+xrrSeiew13kw9KIbdlA6hkCQcZrixRTkfq/Nt71NbptgE6u9yfsYET3CSjS0AvHiE4H7SrZSmwL27TnXX+IfLtX78Qs/NW6UYZWRcQnNpa2YanRNe2KZvbKOr3T38V6fKeJg+3CgeJBwIKCQmD9fNiZuW1kIVWteechaEe+NrUE33zalBff+Apt7sQO7/BKLZZSj79DOfPjWpiw9BteQalp81WwX3Wy3OR5Q80oA7hnPisa0Uwcp6r26bUbG3ZTopjZwBW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4X4N2bu6h6Xx3fpoppJCaJy/Aejd7dnq/YV2MuORQmO+w5O4GJu2py8BxIOZBmevCyngRco/q0ketb/M+SWtEaEoS3zG2I8qpUdc6/BOyVVkPA6HthGILCUXvNBC40Ou/+g2UECeRU/e5JAYr8SqifRVg8GR+jGJ998Zjc7Buvy9eISRD/hAO8DQXIF5io0AVls3VOdomxaBIPu/5V+7C9lT8CQ5I6zYRuizppALI0zovLZYIjzcwvGANKUvVpvDDfG1VLJuJpqvAGKHaCOL//lJr8PDensa5B5AqzUone5zzG/T+Qe+AReTIYLDv5pUez2zJFRakb8xaAsBM5XyLBCdQaq8SEh10Ns2VN82ERYfQsgr+CTyukyBDQibTGuCUbcytOG4sox3pY/C/ii20rd0TVxIj/IkxMKKvymh2BOabiyony0grShg7RPoRSq0N99Dhcr/+aZg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15736b29-312c-402c-3d98-08db03dc7a39 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 22:42:48.3816 (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: BSC9oQ7AiZb2pq1b3VjYvw6vWYzkulo4YnDxVFWga9MWmIlR8frgoOiG/JEmay8P3p74H6uXvWpCIKreXrAX9GfXBuVSIW8ztViO2E6Zbbo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB7241 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-31_08,2023-01-31_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301310196 X-Proofpoint-GUID: K-3s-bYv-cmZBf-Jx02Hn4cZv2Z16zhk X-Proofpoint-ORIG-GUID: K-3s-bYv-cmZBf-Jx02Hn4cZv2Z16zhk 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?1756580649304968888?= X-GMAIL-MSGID: =?utf-8?q?1756580649304968888?= The crash hotplug support leans on the work for the kexec_file_load() syscall. To also support the kexec_load() syscall, a few bits of code need to be move outside of CONFIG_KEXEC_FILE. As such, these bits are moved out of kexec_file.c and into a common location crash_core.c. No functionality change. 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 Tue Jan 31 22:42:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 51078 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp89953wrn; Tue, 31 Jan 2023 15:22:59 -0800 (PST) X-Google-Smtp-Source: AK7set8pG9sr4CSwhCBS9EPp1S7is+vPDP+XNiz3TNeyMpZ329RxoNMplEVakGq5NJvJu7aa6AeS X-Received: by 2002:a17:90a:be08:b0:22c:926c:bd0e with SMTP id a8-20020a17090abe0800b0022c926cbd0emr10611347pjs.24.1675207379264; Tue, 31 Jan 2023 15:22:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675207379; cv=pass; d=google.com; s=arc-20160816; b=f6GhB3UxsZmMiCIOfso0edFayt7pB4afMASX7Bp2JWRJtXUUhxDLD9c5imDlrqPCvD OSCf1gDzPF6bxt17oQlfJ4/N1yWEa0AXuK1/I05sCQT4xLz8VEY/36AW7KHqbQChhfLV VmdMp6G5daedJAyrLSrNZNIvIZcPy8jTnCj+uigqV638Wic/ogzhD+KT8ilvZJzQAIrt YJcLXI4qT/LkSiYRPOOORn9ZPvUz3UfLz7bU+uBl9AkToznOq0e1d6e6RK4G7dIsptu9 6fNdpb/yYZfA05TiYcFzUEKAiimqHPXCbFNuOVGAVV+SOgHvj/wXqlDdmhiJDD73oWvU Uk5A== 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=sQ2+0k1amV2jdSprO+MK0XZanXAzgdwhDPNvATY/vOVNieyAthUBUOFrtcTjoFrIhk SNheSOOifV/G6EPnFisMBcC+mpYT87BcTo4I066AL4sp7g5kiDQrLUWbzC7SyL7gOKEF Jvo1FWDyw+d/+oQa6d7aXL/MjJF/y4tmrSIlKoyQTrvnpT9+sx/EqjRbUHlMEq86r4HO XF2O3IRA5nL7ZhvlwtREODpnn7/ykAL4IAoGNmhliMmIMifRX3cYmaCY8J+CnWYrSNiB gMHnbFav/5dW/NLXPS+WpAN+SVKt1P27Ew68Gx6YT3CcJBC1L/RfrFyZdqXJkePlPc1f q6tQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=E79c0NT+; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=K6uWZqwY; 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 c1-20020a17090a8d0100b002196cd830e6si25836pjo.11.2023.01.31.15.22.44; Tue, 31 Jan 2023 15:22:59 -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=E79c0NT+; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=K6uWZqwY; 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 S231938AbjAaWnx (ORCPT + 99 others); Tue, 31 Jan 2023 17:43:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229961AbjAaWnu (ORCPT ); Tue, 31 Jan 2023 17:43:50 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9C2F3EC4D for ; Tue, 31 Jan 2023 14:43:47 -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 30VIi8vF006400; Tue, 31 Jan 2023 22:43:18 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=E79c0NT+e/VIs7NTydr4SVnl4JLlDPNtHVwH/qoNRf3Z5W8bosmSPAFd8FkpkqSfG0vL kN5lL7Jc+OcdvKzL6H+k8c5IivWEEDXIqCiq7SxeD2x4Oah5H6+64RcVB6wbWgCaJMia SbJOcdIdFtUPwlsw2qjoDOGnGOENAqjpYHqa1BOm8X8+v1VDi3nCcfzwS7JJKbRdLYUM OaqOocdWAVtEIDc/sew+vR5ip+Kqz2p59bEtrI2pKW9RXRJ1msZw2LU1ssLydBTvd/0L AtepDZxLOO3oR1VMaMW2RoYLSbpAkSZzqSttsbqm/zpWl24kmZGaXuA1JvoLKWKJanKX lg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvp16yh4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Jan 2023 22:43:17 +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 30VLD9Me031581; Tue, 31 Jan 2023 22:43:16 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2108.outbound.protection.outlook.com [104.47.55.108]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nct5d6xqy-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Jan 2023 22:43:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kPDQXn4ROfF0FG7h/znWVLCxUOuq9EUaBIVNMABTLdmlvXxwgxeQxFaGVMj62KUBuPm4MtTEJs3lr7rNj7mBNEKr26OCJ0OjO7pH/GJnA66AnfoQG2eF9ly6A9z0ZSv+lP7urk7Lh+zU9KIEMBPxRzLrf3Lxk4Qu6ldhf6sJW4AP5JrhyD832425KWyrYQEPtjV4r/JfYDr9pYRQcAUJWvUSgL+4gpdAu1rMwqA7E2DNQ7HtJXmGgNntW6vkqQ91BgJaHffbAEXfLbQUV2B0B8/jKald+XY1R14Ntb2l4YdY+1KEtRDtdhbOFg3uYZ6migvtS+u+H643wvDH402faw== 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=SQoXNIPc4XD7Q+iw9Cns2ItTaCw4oHFBeqmmE+9Rv0leZfC5OuLSM5ghR7dPSjokih+bJATskFbOjLnAT9eXsLVObXTYLEsBKkEcyNf/jnc8Lzaocceod4Vc8I07EV8vJOByPaNbqroUn5AZWW4chfe8aYGq6uARtWoRI5SX9VHmJMUli9TcRVPe7KozpZiFK6E0WEJcgF13kgF13D/rCYX8864NWqotlAPXi1CxR89lTO5oRMqhoFp9AJ9dTrAi0qIxQ29+rUN1IOcfoGvPHF3nt0rKLHMLbk7KtCi9iowUFof0y8TqPjAsopxBvKIKEp8I/sGlgsQAPKMcAJP6AA== 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=K6uWZqwYoWZKQ1ek/GHNgaMH6cfsRQECbsQycfTdCR+ZPU7u0vXUa1g7CtJIrJnNvU2xkJCvcff9of3qohSxebhvseR2t0DjZJU8SRi18dZvcvljijOU2G4NAEOPc5vctMgR2YI6Cl3rJmQe60AqEJgP55zMgxbSbu6Wmc5Nz0g= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by CY8PR10MB7241.namprd10.prod.outlook.com (2603:10b6:930:72::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22; Tue, 31 Jan 2023 22:42:51 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::2101:3ed8:9765:370f]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::2101:3ed8:9765:370f%6]) with mapi id 15.20.6064.022; Tue, 31 Jan 2023 22:42:51 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v18 2/7] crash: prototype change for crash_prepare_elf64_headers() Date: Tue, 31 Jan 2023 17:42:31 -0500 Message-Id: <20230131224236.122805-3-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230131224236.122805-1-eric.devolder@oracle.com> References: <20230131224236.122805-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR02CA0148.namprd02.prod.outlook.com (2603:10b6:5:332::15) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|CY8PR10MB7241:EE_ X-MS-Office365-Filtering-Correlation-Id: ee4bc8a9-e643-4f0e-a8aa-08db03dc7bed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KhGoDG+LFeriNb0/dStEZrlyqicfqNynnjpjdQ9JPnIK1KpAzm0aYkIQrOwWqxIeeFMLvc7JF3SCyX3EIS9Oi1XjdodkyTDD/CnMF4MLYlxNEMM2VIKad8fUNV2LdTGOLyDqu+ma3pGuHLv3XJLS9wErGqx6Ewye1TSNDa12u2RZKJVv+IduGwvcqgNLmd49SOpece3XKHtJw//t8Dwodv02rdvrq7+y9LnYjSZQFuFr9OKtovsPu2pyMPUxS4+IbPwXThmHQFmx5P4jve96URu7MIuQvBtDtPdRUlcX5PPlLXLN4CkRgMB3Yv22/wreDXbqnX0j5l1rkTJC25O50m1QqxQSAu+UqRIrrYaLYKf44vYJGgqAXyha51o10IaAaiuBzPeJn0/Op3CvkTeuZBdMiJJjIM9Hs1Des7P2c/hXH0fhLaLCIKmNTIDw+IyvnKW0Rwir3YcaOsm+VqBmpAydqb9rcgs22aJ4osUisSH8Lzz/8WznteTyGKyLZV90VgcbInRZ9mgmfmyhqeFmMNSDHufuHUtAy1ABEYRGlmNQ/I0ruhEqqrmBb7ISZbo9plJX0d+h2VQnLnaEkMG9sRejyGKPKf7JXLaBL8FINI18sV37YO6RuHTxKwqehnqjrKQ8b2oVKpSezdpTjJVpsw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(136003)(346002)(396003)(451199018)(83380400001)(41300700001)(316002)(8936002)(4326008)(66556008)(6506007)(8676002)(1076003)(66476007)(107886003)(6666004)(66946007)(6512007)(26005)(478600001)(6486002)(2616005)(86362001)(186003)(5660300002)(36756003)(7416002)(2906002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uPKpSU7H2rVOo1uvlpkgLtpjDfbSiIt/coQtMZ3XhYpy+JZJSUWvSsmD5Z815VQrXQJ87ScF/PAbhammcWGBxODGkVtY5ifwByboM6zGx7iPaa0hrMOiseYr/LMVaZly3cYVzB/verVCngkacAHM+3C9LfSvCWp9GcebCnxH81zk7+dVYS8buqj60YCkC7EiuyXjQFK4nbddzbG8Hdbf86WBCQMr43h4Un9g1zRFt0VDCxtl4/ogC9gpxrRHY3KMd2j9PO0mW65UwMnk+bGhdtYofhpm1ieRgbQXdutptE8l1/ltQyUnQFX+2VV/TaX6/RJvx+YyC+tde+gDyc8VFaoR2/xYNxn6vII6XSx5SU35ZWucuS3Z2MmZGVS/BsvfHqlGEd2YJssvAcy/avHuQicJz6CecoAA4b4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+B2F8ZXsv3PQoADY6BSI0k/VzmHl11enIi9eK6Z9r77Cwde8BmgBmCWNw9Pcfpf3pNxr/7HHm+qq/FER4WcQmkX192/PLVdONmKMqAu6C0KyrXhIEGvaSG+i/GGXkvTYDZAI3YPaFtjJWD7pmwhCbzrQRAJGIK8jkuG4cNPfJq3Xm0XpcLYHf09zsSuju6kivOfWbomD+ID+N4z37ccurB3Uxw1dWc10Q4fCtoNwA6FVJ1RREorokSBfyoRdFyeEEHWiPEzoUnJySprrUFB6c4HGVGJmEkhUhC2HxewsAEkUI7lxgGzKY0GUWgs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee4bc8a9-e643-4f0e-a8aa-08db03dc7bed X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 22:42:51.2275 (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: 1ODkCwZPsBTnjne39WNOzvwSEDBnHF8Eg3Ls/lpzKRMBaM61aasE+TzbaGw2Dg8S4q1c1k6Xf1mWlUI5rco3+gGsxxZsNQz839UbDr/joC0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB7241 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-31_08,2023-01-31_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301310196 X-Proofpoint-GUID: Q7UOU-skQM5SXjozUqOdBgWuImjq6zoT X-Proofpoint-ORIG-GUID: Q7UOU-skQM5SXjozUqOdBgWuImjq6zoT 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?1756582253109118863?= X-GMAIL-MSGID: =?utf-8?q?1756582253109118863?= 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 Tue Jan 31 22:42:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 51077 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp89528wrn; Tue, 31 Jan 2023 15:21:36 -0800 (PST) X-Google-Smtp-Source: AK7set8DdgNNv6n9JCKf5Jzmt+fYomJIlNR2s93JTalzwtZ6TQHV1TlyMZrFFsfLD6gsUelUqM8R X-Received: by 2002:a05:6a20:7da1:b0:a9:e225:6f7b with SMTP id v33-20020a056a207da100b000a9e2256f7bmr295821pzj.0.1675207296359; Tue, 31 Jan 2023 15:21:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675207296; cv=pass; d=google.com; s=arc-20160816; b=AJKm2ZlqkRnJ/qpyE2xo/8Gw0I+Rs6oBVlKHOazrh2a3hp3DrMVqMVjDtD0CV2u54f nHgFHOvdasTqOjnX2QPGaP+wP49Usf6DkNQvHwG70OY4wxGE4H9wCS14rO/ejCQ9swP6 YOAjkKln4nW7atxI+zIPiMYv0RGv8jFae4EmlnOIWc8XSpCwgtMh4lXe0lKCSy7OBNb6 mGIOCpcY0h20znHUJXOeA4ALy2eus2r3DuL/lvFdO0ycu2dhTZcjmyabZOtiSHhX1M6d /YAoCIUkP1Eb0v/NuoBQdkO++auqUCRa6XP2O+O6Lb0sLyfFGFoliKZLiHMZZjkQXR3Q Ff2g== 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=08ihQdBGWvRilR/2uujMfBbxUyEOPxzlfkXGugWjcW0=; b=BPZi1A9+uO4mA6wKenCyCKsHKLOtNmUOAfCHOu142O7Jw9CcQ33+6UQtPwe2pdf4JK uh645u3YzKXMSb3cFFbfqHmPhLCCc4zoKPVL0i0uuLq+/VvYncxwLkKpqmYVtiGULu89 kZNXoXliDEZTpuZ87zP6Se2vTzbDuH9V7+sthLUtRuhri8DmI5rv9UyQcvTTtHc+Fr/F 9RajJ445JMICvTGZUk2lWzfE5yVB4H4VqiqjOcn/WU+Bb16LOHdpW9w/3l7ECZPn8kLA 95jZxut140fV7LFKyjflNlJ13D2HQ9EoiuZO1eXMROUdQmSGMhn+nnHvb10qumf9BnMb lANw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=ZAczgWqy; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=JoX6xCZa; 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 j7-20020a170902758700b00192a3e13b52si14279216pll.140.2023.01.31.15.21.24; Tue, 31 Jan 2023 15:21:36 -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=ZAczgWqy; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=JoX6xCZa; 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 S232024AbjAaWoL (ORCPT + 99 others); Tue, 31 Jan 2023 17:44:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231915AbjAaWnv (ORCPT ); Tue, 31 Jan 2023 17:43:51 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 257AB4614C for ; Tue, 31 Jan 2023 14:43:50 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30VIiH3a021418; Tue, 31 Jan 2023 22:43:20 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=08ihQdBGWvRilR/2uujMfBbxUyEOPxzlfkXGugWjcW0=; b=ZAczgWqyZRMUOxpPVvFCYF0wpJT+MHhryqyeUCqrNtavMend4x36xEohDzlmEjlsqKPh /SBMsZ3qFCuj7uiIdoTjVBTXU9A9b+nXjabGbfC7NqOD7L0eM7DjHHPaFNtxyWKNT7Hh z74qzLlD0WirI4CgruM00mcrrSci1ZKgCsKTyHEOTgbqz9tL8PNocoO5mvOl2XWLC84E mg9j4RBnxe0/rfsST1NK6yLQ3vJWNjUD3MSporjSFCohSg76/Dlmky97b9HveYboFizg ZDhMMHeJLb6BLaVgvrrkYvt84657jC3pT7I235gYbuFt7E5LyGeCiLXL2g+uw7SWEyXD Ow== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvr8q03d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Jan 2023 22:43:19 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30VLCm8k012912; Tue, 31 Jan 2023 22:43:18 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2101.outbound.protection.outlook.com [104.47.55.101]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nct5d7qg7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Jan 2023 22:43:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gABU0SDt7YMpm/qDjk0zuyGga8MtWN3uXtvWya0cl0vO8ymHLz1keZPDn/dtW+OsrcDOPa/c5qmj6vHQr5jBeQnRpo+Thoa9qKw56DSFMkXPk2ANNr0vshV2QBRvi8v9h80pNLn9d//pNnPvzesfDcru1N7OGuNzflBTSWFsoMrcdLH3usruzvaHOFY1QbWYbyFQhHMfMZgTXs7qeX8+kft4OOpX65nOeD+S6M+ayZcX78/1Sr/tf/Wu4qi2+4zxNIC5LQsCHORekVuWkkJJLR5Q35nZuYHZRGJMuayyjMCL73ZLHy3OZr2igI5/Ih7Zed6KNdE+u0GMXBRUz9V8BQ== 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=08ihQdBGWvRilR/2uujMfBbxUyEOPxzlfkXGugWjcW0=; b=Hklmq3oW0AhNmsk7fdYTUjtFG7XOZzx7HJfFppT9a7bvxwgq5FfV7T4So4oVUcCqDU5ulo/nNg04gNp7swrpUoE253ILetwkD3dyjBjH5CYekM9q9ZhFoye7hv0zSBKREl37I90G6p0jQ2/pqf9uyIEjKYDtvgJHk4CINRQOISHOI6pDGgFtECxkQ0uAdIYs6KfS8vdKIZen3OGzQdtLpWp8/GCzVkcNV5DXcz9KJTMXzNuWfPANsI5+6BNOVtSET/tCK8vAdpMsDpJkZl1ShLaDUcccqihQnoDlrJyzQLnfvithnCXGahNcZeA+ZeaR55DOTFEwQj9mQ4b+kt14GQ== 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=08ihQdBGWvRilR/2uujMfBbxUyEOPxzlfkXGugWjcW0=; b=JoX6xCZam5BL6Ofe0E5uaf3ZwFcKhTD3eqUSIuvYz44S+pT2PuuOXbD9q0lDJYc9vYwaOKedUOD9WmiizYT5Q+zv0lxv0/WdqdbAE34Utdmn5JZvfKgaULM9ETde2RsCOvIhYlseKADKsWo8maEKEGOrQIYT/0+YWQXaouChqXE= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by CY8PR10MB7241.namprd10.prod.outlook.com (2603:10b6:930:72::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22; Tue, 31 Jan 2023 22:42:54 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::2101:3ed8:9765:370f]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::2101:3ed8:9765:370f%6]) with mapi id 15.20.6064.022; Tue, 31 Jan 2023 22:42:54 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v18 3/7] crash: add generic infrastructure for crash hotplug support Date: Tue, 31 Jan 2023 17:42:32 -0500 Message-Id: <20230131224236.122805-4-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230131224236.122805-1-eric.devolder@oracle.com> References: <20230131224236.122805-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR11CA0024.namprd11.prod.outlook.com (2603:10b6:5:190::37) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|CY8PR10MB7241:EE_ X-MS-Office365-Filtering-Correlation-Id: 38fe14bc-0f9e-4b52-23be-08db03dc7da9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TOyIB7cVMir4naFJ1ufqkVHz9nwEhkEAFQ9s0SPAORa9BW8p2lF1XsOq44gRb4oUFkCGU9PL/IqIBuW4lJnWI6Gq8jd86F0aNdi9cVM+EKK+hbduahq/QibdKI7EYqvO8VoYMzDEWN8kz6CH3uCmYXIA7vll2MJ+NdEQ0XIN+kLl/YPOfQaiAu2aorEKQjIH8JKE3XimrZgXyfGPWnaCcmzpFExvAE9ifaKBFkugdzKb+sK60c4zM8d07tUS9BTZJZ2n75gb4dKTXIFFqagcBEHIBLuwyGZm5NCthc15ibFtseLgPu/MJuySAMW59j3z576Y8mWdboi2R1VUmV8kkgswpzvKxKNn71mnrrmr/LRTzUMXWlrUYA+RCk7Rt17dtFdM9MXxjrPMus5eDSObfKZ6qGnx89Oq8FLRfXa6weHPzBafwwuSRBD9enchgdxpj0imdJFt0RYoC96cIaFrFBViLPkuhwtoaNzBnmaENaFp+4R607ltd8LZyMygyCqMtPpQ/H5ui7wlDtJelHKdXRy6oD92uUDYZNV4qQkC6/iasJyn4mgo2FnzduJtuLy+OWPpPIzLbwpRdZcjxherJl30sksDTS1pbWqGW6H25jTLq56fEET1AZZTp1L/gIrvFysk+PmBr21X8imJtUgrbRMhV1TNP1SAympBWePi8gUdiSxzBM6QzmDq6H/hVLHm X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(376002)(39860400002)(366004)(136003)(346002)(396003)(451199018)(83380400001)(41300700001)(316002)(8936002)(4326008)(66556008)(6506007)(8676002)(1076003)(66476007)(107886003)(6666004)(66946007)(6512007)(26005)(478600001)(6486002)(2616005)(86362001)(186003)(5660300002)(36756003)(7416002)(2906002)(38100700002)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Kdj/6KlWL/SPp+7+5RSmJ2Y9Gy0wEZo4zkzMncaNc+EnqQVSV/z7rul/E5tWrz/cyC982swefn/yTnNbkWhEFCPmU/7ArQiOFEJ1qJVwgvAhwaxdsU1yuM8cYAP4GVi036RairRq614e5fd6xMbbiuCqVygI1n0s1KcQ5NwqLF382VgZaXsPMxUieMCytNZMxCdb5UQ+zkkPtrdWx9gF6qjKqtkafCvSSlVcaB/nTbhoB2LDhgfhkmXWCUv6iOFYDFhWe2krHIz8Isi/xDsXcI1r78mqxJeSsfPdVWaGY8FAOIKAtgTb1mw9BPHLaGaXYC98BkQciCHeyky7gVFP2T6csNdOCfB2qFVNsUYcrvZoO/141kknkUgPHG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GNobr/ubPeha1rLeyCVTZfQL/pWCbWRPW4xsjtXSsOxmjun7m+PZsojDNnPFveKLF06G3ZZPtWDrSvcv3WaKOcBJtKp+28VNe88u/T1JEfEEyDhoDg94LVg9hYmHlCclyy8RcIk1gt1z83oBuJdBx83D6/H86umFTvdP0J7Rg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ef4yHhTJF9qcuhnP5u4uXAu7ObvvwAFzTsvb8j6YFxkUWzLisjHPHrg2/HPW+aORWW0QGGZ+d47DIr0BhavOjubAuZCom1PvYfd3LN6EIRnScREhGcrLuTXSj32tGBJsYExNCOgYYNpwUCzdylgvxtGN8uMhzLya8Y3oF3TiWxtqVc9yhko5wsXRd7MZyEbvwklYux+5EdA82V9O1pZY5+wrJZWpXvER21mPHTAVuQaN6ZoNE7beUTnXK9EqYVz4MOR/cIMajoaH4nDfkrCo6/5xG4lcg4ztmwvnMeTLprjYmDyKYVmuiVk919yKhD5HQiZHOZVAAbDWvmS+dTqrUmjFUzcy1hkoGVCYlhINhI6KajHGUtKkpz3EwHUuiClwu5wY9A0lsnZeQOf8nMeBwuhNO8AyPaEIILSRZbsH3VRJxoIOcCfhRaZKb/iek1sPJ6AQDHTh/jqGZmyn4aICd4zOSg3qFFouVdIxihQ1rB+drshesVKEbZIvcQxXIIHHwrS685R48O4vegDVvrggunZpWZ/pEAwB7NtPNUSAvhMyq9UyyC/9zXg6l6UT5clv2GTcgfYDYHt74jDZpYStbxgB1J/QIYxJIV0whpET8poX4+bCxTrPIRD8bI7nwjzlCIxFO3CWM+1gi758ERnJrzNJUFrDKawBP35gq6ruvD4jvOmui0zuVhG2muYlFUhOIPD+KNKGSo/bcUFiXCjketD3iSeAcmaPaX27C32FVnyfrcox9p9vPSTSyxXjiOu+wV9yNpv6jxTELwmTKPEq31OOVjVHU59xCqPhs+NCSC2kgZNy/n7pktuzGWXFh2v0W3nDFmZu/a7clGOsWsD2Yye84bzvEYveY87PEoDvbJ1SMgYVj5MgLMUd+c2LqW/l7FLYDlZiBjtL849Gl5lHFM+yeXlKTbceAfMGlpVOTTwPX5czyNvhEzCLW7GJJTUlZ9QR7qEIBHWhGfF5bqBKbYk40u90NKRD9MIfXbl2DKrXxBJrN4BRfLL5YEfAuXa+nK5k8IzoraAl5vLHjjdFPvFqjrCo0e4iCS6hulK8Y+WhDQATWXitnm2bn8V1sStu0luCTtlSHAvgmFHSFv5WMuIkuQ349Rltjg4zR0l83gyG6LVXQ0BObX1hvNZCNrewTZC/Vh8DBCSfjR1Hvns0tER7kkVIuWcjp5b1B4QT4sY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 38fe14bc-0f9e-4b52-23be-08db03dc7da9 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 22:42:54.1325 (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: kO2mSWlbuO8OFLhAYEEfqCYiH0UkkqWFus7W1XK58LbWEOJehIjZ70RM8dEek7HiEFDM44CcKkbRoczH4Dg5D0QDUFIlE2Z89OtT8VPRPtw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB7241 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-31_08,2023-01-31_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301310196 X-Proofpoint-GUID: Nr-jP7sDdrpDEwBOdqyS3--SDFINFZiR X-Proofpoint-ORIG-GUID: Nr-jP7sDdrpDEwBOdqyS3--SDFINFZiR 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?1756582165688672665?= X-GMAIL-MSGID: =?utf-8?q?1756582165688672665?= To support crash hotplug, a mechanism is needed to update the crash elfcorehdr upon CPU or memory changes (eg. hot un/plug or off/ onlining). To track CPU changes, callbacks are registered with the cpuhp mechanism via cpuhp_setup_state_nocalls(CPUHP_BP_PREPARE_DYN). The crash hotplug elfcorehdr update has no explicit ordering requirement (relative to other cpuhp states), so meets the criteria for utilizing CPUHP_BP_PREPARE_DYN. CPUHP_BP_PREPARE_DYN is a dynamic state and avoids the need to introduce a new state for crash hotplug. Also, this is the last state in the PREPARE group, just prior to the STARTING group, which is very close to the CPU starting up in an plug/online situation, or stopping in a unplug/ offline situation. This minimizes the window of time during an actual plug/online or unplug/offline situation in which the elfcorehdr would be inaccurate. Note, that when a CPU is being unplugged/offlined, the CPU is still in the foreach_present_cpu() during the regeneration of the elfcorehdr. Thus there is a need to explicitly check and exclude the soon-to-be offlined CPU. See patch 'kexec: exclude hot remove cpu from elfcorehdr notes'. To track memory changes, a notifier is registered to capture the memblock MEM_ONLINE and MEM_OFFLINE events via register_memory_notifier(). The cpu callbacks and memory notifiers invoke handle_hotplug_event() which performs needed tasks and then dispatches the event to the architecture specific arch_crash_handle_hotplug_event() to update the elfcorehdr with the current state of CPUs and memory. During the process, the kexec_lock is held. Signed-off-by: Eric DeVolder Acked-by: Baoquan He --- include/linux/crash_core.h | 9 +++ include/linux/kexec.h | 12 ++++ kernel/crash_core.c | 139 +++++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+) diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h index de62a722431e..ed868d237c07 100644 --- a/include/linux/crash_core.h +++ b/include/linux/crash_core.h @@ -84,4 +84,13 @@ int parse_crashkernel_high(char *cmdline, unsigned long long system_ram, int parse_crashkernel_low(char *cmdline, unsigned long long system_ram, unsigned long long *crash_size, unsigned long long *crash_base); +#define KEXEC_CRASH_HP_NONE 0 +#define KEXEC_CRASH_HP_REMOVE_CPU 1 +#define KEXEC_CRASH_HP_ADD_CPU 2 +#define KEXEC_CRASH_HP_REMOVE_MEMORY 3 +#define KEXEC_CRASH_HP_ADD_MEMORY 4 +#define KEXEC_CRASH_HP_INVALID_CPU -1U + +struct kimage; + #endif /* LINUX_CRASH_CORE_H */ diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 27ef420c7a45..a52624ae4452 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 + int hp_action; + 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..5545de4597d0 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,139 @@ static int __init crash_save_vmcoreinfo_init(void) } subsys_initcall(crash_save_vmcoreinfo_init); + +#ifdef CONFIG_CRASH_HOTPLUG +#undef pr_fmt +#define pr_fmt(fmt) "crash hp: " fmt +/* + * To accurately reflect hot un/plug changes of cpu and memory resources + * (including onling and offlining of those resources), the elfcorehdr + * (which is passed to the crash kernel via the elfcorehdr= parameter) + * must be updated with the new list of CPUs and memories. + * + * In order to make changes to elfcorehdr, two conditions are needed: + * First, the segment containing the elfcorehdr must be large enough + * to permit a growing number of resources; the elfcorehdr memory size + * is based on NR_CPUS_DEFAULT and CRASH_MAX_MEMORY_RANGES. + * Second, purgatory must explicitly exclude the elfcorehdr from the + * list of segments it checks (since the elfcorehdr changes and thus + * would require an update to purgatory itself to update the digest). + */ +static void 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(); + + /* Differentiate between normal load and hotplug update */ + image->hp_action = hp_action; + + /* Now invoke arch-specific update handler */ + arch_crash_handle_hotplug_event(image); + + /* No longer handling a hotplug event */ + image->hp_action = KEXEC_CRASH_HP_NONE; + + /* 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_BP_PREPARE_DYN, + "crash/cpuhp", + crash_cpuhp_online, + crash_cpuhp_offline); + + return result; +} + +subsys_initcall(crash_hotplug_init); +#endif From patchwork Tue Jan 31 22:42:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 51071 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp74611wrn; Tue, 31 Jan 2023 14:48:30 -0800 (PST) X-Google-Smtp-Source: AK7set8JwUApA7qPjATcwsdSTF0HNZJQU4xDi/RB6SQUodqyp0LBQy3AelQsq8DMzRkgODzsHOVf X-Received: by 2002:a17:906:b7d7:b0:88d:fe1:1aca with SMTP id fy23-20020a170906b7d700b0088d0fe11acamr46676ejb.34.1675205310788; Tue, 31 Jan 2023 14:48:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675205310; cv=pass; d=google.com; s=arc-20160816; b=obWjSzjyHyqE8PMAYYydJQph3lE0h4XcIgUnA2/aVDTw2jtxWHaoOETmCj0T/tlSiu Wiux8nBhfHSniDahcFUHDXgaVF0/FthfcM2/j11/c0bFt0vU1LrtiU9pPZyH04zA04gn mIF+y55NUDqDuzsdh/pvPLRL9rUFwGiC6rcGB45eLFyXTV4Sr4eJqoEGQOWJnPzJSyv5 Itj0nzRW/J/sqsB5Nt2vr0as8+FQ6J3l/pvOO7waU12LUj2kFqyj+7FpaqqtX1VkwIIR Qw8sFQKNhKyeYUf+21pRnNZ2dVF5ii7Gdyj5aRLkE/EfeY9bguTh8F49EeErtTHzunzS HhQQ== 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=rdmUDSyMhz2W/a+vkSrakisRhiXl4iqAlBAA0WrriH0=; b=BWWKFwj+j9nkJWPb0PPuJugCAbWFOe66h88ckVWv69qiFKrCs9RQWDw7eKUklYLnDF hpQjGIkolR7VkyGyuAF2OiLe7qzowIqkW+H6LEd01y2UxKSarxtziBFf3mvSpcYQ1IZV obUHp9Hf5GFzUowyqdIOI+4puXtr0GIEq9W+z1TZj46k3FUZuwj4rowJwasjFSUbCS/O rdICB4qyOnU/Y4Jv8ho0PP0+e959FeRTbt7blNWfA3MVQr/aeFapToYgrxnOR6iQQsH/ hWGd9uQ6DySMrA4Bv0s6wX4x+FwuFeVZnzq1INa35ekRotisMML4M0nJmVA73Mq8wX2F dbmQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=SKga3Yh3; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=SLyAFcwi; 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 26-20020a170906011a00b0086f05817f39si23586852eje.39.2023.01.31.14.48.03; Tue, 31 Jan 2023 14:48:30 -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=SKga3Yh3; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=SLyAFcwi; 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 S232001AbjAaWoA (ORCPT + 99 others); Tue, 31 Jan 2023 17:44:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231791AbjAaWnu (ORCPT ); Tue, 31 Jan 2023 17:43:50 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9108A47080 for ; Tue, 31 Jan 2023 14:43:49 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30VIiIW5021443; Tue, 31 Jan 2023 22:43:20 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=rdmUDSyMhz2W/a+vkSrakisRhiXl4iqAlBAA0WrriH0=; b=SKga3Yh3Wq4foOr2igtEnp8FHe0uOTssQ+uq5ZUX2pWqFT2DlUj7W7IdWla2uB17Jmzy iaKZ7k505c+D1H+5uVCz9g9Y3doNihV0pzUrvjctxstYgK012CevaOungMmt6VtLQuaH TMPBxTIHX16ftZXhx1s2ndGXLBGPmJ1rstxyNCl0Vc9ImCWZeSggRg7oqOsMPmP/BQgT JrNnGuhIJ/QaEjufdmTZ/z8QQQPskXHiVyYj+i3NA9cVZfn0P/InVfOrXMcyOAzM1fxz wUINtk7Ga9WzeSmWQldYowP9TJEeUre7bEnpWSikwiABdqZgcsocEc7Ht0d0W4l+zlvC NQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvr8q03e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Jan 2023 22:43:20 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30VLG1Ot012963; Tue, 31 Jan 2023 22:43:19 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nct5d7q9v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Jan 2023 22:43:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WyCwaF/5D710PMzrORiD4eFamw6LAMSdGucDc9BOWEXmQc78DaaHzVF6ACyslzwm02mkZoPx3KrZ6/42Vx2sGmfYU0wQ/huHBb7XD1Eo09ur7coE0cGYmieW5L5c9QlS6RWfy8l/IqCTJEynEU7SR9ktkRdiYNCS9cUQGTzH+wXhZe/6EXBDpYZHM9mCPjVw5udRpAxUnFKUy7Sz1H/jMTGndp7x8iE1HWwoRpPr3KfHtwKuGJutkxTvyQgdEqP2op1mcXzrgsxRmcE61QDqLJN6WY6V/MD+989UGUeJmhYCgY/uczPV9vOcVYmizWVLjioHdrkPY1Vp4v8yZ9NLyg== 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=rdmUDSyMhz2W/a+vkSrakisRhiXl4iqAlBAA0WrriH0=; b=JA6EoU9LBEU0C7nAVdPzZb4t79J7XWTuDyhmmFYYs5SvIiedBFuAYJIL4Q5xOA0MLrA9IYJyTfvpmouxQWwT1E90A9JvEeZvtz0+9PrbeVkrTWp5h+kB3jwo8tam4wW46V5z5t8YCqwD4IIzk7/BTHwYAhAvrIAD36ZZX+LMPsC4QAiMZdYhTTCs88nGGum4LDBZIaDsbEDx23YwXR/3k4bwg3mNWboEOH4lxL1zYdFxNZoOoh4OZ1dml5ubPAKfmXiJZw0DQXfiVg061IMYiz1bdfrty8nBlg6DBdhXvG2G4FRTAOGUglQYKBhwV0iawya8GSEH7AIpjro4y8op0Q== 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=rdmUDSyMhz2W/a+vkSrakisRhiXl4iqAlBAA0WrriH0=; b=SLyAFcwibB8blGsoN0KzlQxskOhwhYVodMUTmx3e9S6IreT3ZionG09Zi9ZIaPWmzbelOzXuT5iSHCovhFvdjneOBCDORjQRWy6JtfDAJ3b8M5OQeDa48yw6vMmb3ISQnu3rRdH/ES4HSkDVyGnjR7rOXGYPWrE+xWRqvLCkBYk= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH0PR10MB4647.namprd10.prod.outlook.com (2603:10b6:510:43::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22; Tue, 31 Jan 2023 22:42:57 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::2101:3ed8:9765:370f]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::2101:3ed8:9765:370f%6]) with mapi id 15.20.6064.022; Tue, 31 Jan 2023 22:42:57 +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 v18 4/7] kexec: exclude elfcorehdr from the segment digest Date: Tue, 31 Jan 2023 17:42:33 -0500 Message-Id: <20230131224236.122805-5-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230131224236.122805-1-eric.devolder@oracle.com> References: <20230131224236.122805-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR03CA0053.namprd03.prod.outlook.com (2603:10b6:5:100::30) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH0PR10MB4647:EE_ X-MS-Office365-Filtering-Correlation-Id: 65c18717-4ed4-430d-e3ef-08db03dc7f51 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jepb5nJJJJ//msmgyjg6Hid1+NO+3uft/C6Nf6gvUDmdFgcCGMaO4Lo9QDWW4zS1lxz3yzSvzWD6vfv4+Sz7vejUq6Xg8Wz+RNUeePgYHvkFvd9nyr5AXDoxYXnLirqak9gCRJSbPyo+2HnCseCY7VOCzsbcIOmaZCUnYcl73bhoGadolVEoeAFI34oGfGSnocVI5sjPWjAjYEt6U4WnYb8P2rTc1TaV+Sj5GpR7ZaDxetVQ13BTy/oQ4e42DWUGI2ZcZ6Csabki+gGS0tkp28dllNeSNmgi/WKWzxodGLyALYxlRkPuop9tkhkmpGeWuFXOuLB6OzRJ+CEpdABJ1jyyk7ke64rQbgiHD1SsdA0N4FVG4IO7+/vp5QK2dEMq8MSLHIO2mTdf7zxnnHGkYNq3jMiZ/t60ZDDHYnhcTvxmIWzttuF8AdV5O8TTNqWIXIUXqvS9qrUsks0eQGfExBFq2zRwysBGQEu4ctEiJf2WGW18SELMUopOmGJmwqp3jU89q72EeGnbbf/90v31ojmDX2pcIQBjV/xaGGrFu5yJ+afbnQM9AXpxzGrdB2yq8GhNhq/6Do13UhRQkQgUsjC74zlYoqREIT1LeAB3e8j72rERMY20m4/e45O2OopjJR2YK9F6xhsMbSxPlyOyZA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(136003)(366004)(396003)(376002)(39860400002)(346002)(451199018)(2616005)(316002)(83380400001)(66556008)(41300700001)(8936002)(8676002)(66476007)(4326008)(66946007)(107886003)(6666004)(1076003)(186003)(6506007)(26005)(478600001)(6486002)(86362001)(6512007)(36756003)(2906002)(7416002)(5660300002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eaYNtiSmc1vbEtzt/qZGHbBvQsrkVx9xciVX3CY5xFmgjaYySMciUGDKsP95cGjvKqhwYtEgoGjCHq9aKKm0d1KvuiA6vr3bKFvCZWaCsxk5HrrP9Gp9Qi/IXmhS6h7c5PWWUZARCfI8DWIDBl5FBhKlBN+J7l7HQH9c41lzqy4szz9socYRSvyrttea/vEVoPplaNk/5xrlDwdp9S2Kf66Yq3ISF2IPm/zaBefHuQmpqpXchIWGDvrNzCSyffue3fNPlizI6D/oSLoaB1wEmwe4B5YfmV7vJElK2Jt9XdIa6MzLzpjx4pnD5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ZfUt5Y0ACEAevTT4mwxmiK0rl2UqnJugojZpi+LicnIRH7onLiSjo1l8hRRdJPHV4WWXsx2RWOlbW4btbIQZSoBenAgO2/w80q2lEnAaSIw62k1vxCadV3a0T7aocDKTiYJeRPMgo+f8cmfaR/tXDsRZdBNVIsMPCANZscFf4doZLgcpYgZFgR+g+3XTazQ3Lnc/MGF5ELz6bi0ft5B7MXwQncMzIA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ky1ShiU6YHTBnI6furvJ9miVslXC9XgW5xUviPPPSlqghlGUU9ggdZehDU+biDbEqGdy/HaMgL9xJk4jjiOdqr0CTL++5J00DKpkxeLDdeH5jTujZBHAlMvQ7FNL+8yDHXXdZLqEZDerjUb0kggbiy+2H4fJL84nRQsVwNL6iz2HstNslqK4SFpO2C/3TCQIYpJMVgYAufAHAoKvLKPBJdWc+GCCCLote7/HSyPJuQvhe6fc3i727tWZ1WyVwNp1DRCEISrWfzcEqdTm21koW04eRI6vF3Zzx2mzJblRPZfRYdwafg801d+6hp1+ydu1DAVMyZhcse4lw1R1UyzwZcOP6HbTz7dErojWEbKe5XVYl1ba2/crE87VuvPIg4/39Y/A2Gpr/woX8dhqzgWwg0zQs8VUMH9YCZChz5JvKNcepwXgI3PIykmVLuQeDGp0yTyQR6NB7gjsOgBDS6okqoKA7qI6xFvWxPdMSCPOLQIjF/kYVlFr0GdOzaD9HxtIxyH6YuMFYDw1Q/+NK9Qkcn4FGNPO4qleceF0MzCPajWjQpNBQGCSCDr8lb21d3hQAhURLru7QZRUJYw69Gi10KQKOeIYQOh0LHAGtXjm1HfkBgExCkSk76ekJSQ+KvDbPlhCJzS7whpRzR0u3IcZKMNqCCdXDLn6DUcmyFvxFQL0wNBFdIdvFEJwlzVxnu8cft6VlFBA2DxXvIsb8/yQviFpSh63td4DCBbZBp7B4v75eKTvFRzKXzBSrWhdFIkcD3poPSkzWusv194x5D+P7MmvQ3DCgm+FpZivNyKyckt931MYKxSKGfI2lteNG8pgoWs75sIhQYucfTSqx+JGBQdAvfLUwuFteyEQCnJXKqDRrYxE3gywwGlMy05pLULFIseayxjXPwwSpBeTjQ+FSF+4xsMEICNaQX10rv/gOBFguLwTPxKMm8oqcCCtip0WKk1876WgsrlQIkSko/zx1+gT0gqOt/k+J1lgOQj/tjlZruejnRqw5xER3fSwCmoFnSfyGkxrZ1aPPyr+VoVI4Sc9jkx87Ec6VEoiuQTlcfk/ZpNzjXEhhIOiLLn0dMtvpTeaDSRyT6nC461hi1w28H/ACmKfpzgJfG8Fe1g6iv+5NJLuhvoAyF+saUDPHWznTnw1jcHUuHN3O1wih6hfS37brOYQHlmhUv8UOBYsHsU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65c18717-4ed4-430d-e3ef-08db03dc7f51 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 22:42:56.9162 (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: J+cq4pzgVAqjFWK6wGV+Hp23H3xfIvfPgX41d+8TgL9qof3+5otfc/D8rG90qtLqqZqwLynquCz/dsatjwgOmBQ+RoR/ZSQLE9F7h3XGhGE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4647 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-31_08,2023-01-31_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301310196 X-Proofpoint-GUID: KUBSU5FZOglZrqNta8C2HSXJlObsRoLf X-Proofpoint-ORIG-GUID: KUBSU5FZOglZrqNta8C2HSXJlObsRoLf 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?1756580083636941541?= X-GMAIL-MSGID: =?utf-8?q?1756580083636941541?= When a crash kernel is loaded via the kexec_file_load() syscall, the kernel places the various segments (ie crash kernel, crash initrd, boot_params, elfcorehdr, purgatory, etc) in memory. For those architectures that utilize purgatory, a hash digest of the segments is calculated for integrity checking. This digest is embedded into the purgatory image prior to placing purgatory in memory. This patchset updates the elfcorehdr on CPU or memory changes. However, changes to the elfcorehdr in turn cause purgatory integrity checking to fail (at crash time, and no vmcore created). Therefore, this patch explicitly excludes the elfcorehdr segment from the list of segments used to create the digest. By doing so, this permits updates to the elfcorehdr in response to CPU or memory changes, and avoids the need to also recompute the hash digest and reload purgatory. Signed-off-by: Eric DeVolder Acked-by: Baoquan He --- kernel/kexec_file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index ead3443e7f9d..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 Tue Jan 31 22:42:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 51082 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp90267wrn; Tue, 31 Jan 2023 15:23:55 -0800 (PST) X-Google-Smtp-Source: AK7set+YB6PFdXmCy2ivjS4+aPJf0da2yeZ6qCQnwZNwEL5QxmDomreEP9pHceY0We3rF/FI11eO X-Received: by 2002:a17:902:c94c:b0:196:58ac:6593 with SMTP id i12-20020a170902c94c00b0019658ac6593mr712973pla.61.1675207435123; Tue, 31 Jan 2023 15:23:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675207435; cv=pass; d=google.com; s=arc-20160816; b=MLddTmm/Cr+0HDsgntQ7GL/7UbjuAKM/VgltD+XSCik7rOHxlpyB6w7PFZcr3gD2rV VkdHrW6HyjTqgYWVeMttdjjBbygNF32nhKxTvpna5jYafGOtQbLOlAGysUZ7yzEXAbo4 c+Duj6Q3Q6JISjXIgiaWRGzVSFWFb24+/YzIC+I76fo6DHS+0MFapV58XWrcVqt0qZeD A/cdmmoIipCwrtZSUqJhIPOAGma1O4aYE2TmP+j8XGk7YS1nmTr1RnsI+ScQnaASxWUm 7TCyxc4B+IOmkEqixJN2ERwAah8/CDGAD5N213/QE9jKDZr9/3NbnpLzHx9oPaUY98tK iE4A== 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=8tUD23MLKHSi2Mcl5JhPnpLAKNKqOrZZxS+XQHu8fgY=; b=cL9NJ5X/kh11QgVPd1TYx+k4iUMrEMXCO6v9CZaTTwXbNO3jUs3ObWVlMUfTAJTlPD CCkn8UUn/uCtJKfVUovGo5rT5YnF+TzARnAXTce/n+UyG5BUelgevJVziOjVCwchOrHG F2xfdLH1kUMtqms/uxERoo/+nISaBdTCMrSqqtCK5z+XfOmQy4b5dWz+0edYEU/0dhTE OZdNgoNII3Vyn02wySLt2a2mnIR+aOhyQGVXJI/LKXVh6dcoEwsydEsPR5WhXzZuqZLs raCEgRD0+xpdNZDIK19pK0iLI8N2jqGwxVYOUEkAwH7k+t1l04caSEKsZGBx42+gN0Cz fSyA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b="hyEHuU/2"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=MPBtYCyO; 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 s21-20020a170902b19500b0019609a3a4c6si16594502plr.89.2023.01.31.15.23.41; Tue, 31 Jan 2023 15:23:55 -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="hyEHuU/2"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=MPBtYCyO; 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 S232007AbjAaWoF (ORCPT + 99 others); Tue, 31 Jan 2023 17:44:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231886AbjAaWnv (ORCPT ); Tue, 31 Jan 2023 17:43:51 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BBBF46157 for ; Tue, 31 Jan 2023 14:43:50 -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 30VIiM6a032618; Tue, 31 Jan 2023 22:43:20 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=8tUD23MLKHSi2Mcl5JhPnpLAKNKqOrZZxS+XQHu8fgY=; b=hyEHuU/2uCiZlRbKzwJRSpx9EMB5bRKYHpQLYV1pYdC2iXg8WMJx0l4HlCZOcKfE/VM2 J/fAva5LBn7+oQt6vn74oY8EXZUbaN7VvEBYDU0iZqSE18WveQBhLf7USYN87U3f504S b0GswIwmjO2WbYH7awoxg1YwNLPPhpnq1wKPQ03/uZKn7oveE13KbYnkW4A9Sw8NHCvK 6Ea4TDGPL1Z9UZe+4i9JZ8uTv6+GaKgsdrwfADrQcwXG959vl4q7kzMitDQGIoMWEF0z jPmdAq0wn5eq5oX8cUFOCwXFvhSZdetj5lorEN52V4XhdXsXCidpJ4S572xttTl+dYSW Yw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvrjxx38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Jan 2023 22:43:20 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 30VLG1Ou012963; Tue, 31 Jan 2023 22:43:19 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nct5d7q9v-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Jan 2023 22:43:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gfPrhwrnI6M/nAwD9kgqEZBDFKno842UOSV0zKg1Pf70kMGGHyEG+S/Pm0x/Gwp4QIoiVGGF/8DMRaLW+tAssDcWvFxPyJZ1/sTtrAdJXcSgwBVXWhIKcta4g0HS1X9amIhsTEVb2W97S3T9jL1PWP98F8nHQBa1uu3nzV1Vlz6NiANlpSrfiFiT58GyQyzFaxCKswzsaXAu3H+ruuG9TcCS5Rp6JLSZVfECJYfotVc06+zgCOUwASDIhZ7WbQLSOMUIvAWCq2J4N9IpJ6XxtvuPk4c2JI6N74dpaJS/FbM16sR5Ils7zhWFtiORabV5hEaxiq+IYxyOdNuk1v/bQA== 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=8tUD23MLKHSi2Mcl5JhPnpLAKNKqOrZZxS+XQHu8fgY=; b=lKnJgQ1Sih9xSTC27x2FtMg7AxR96oLMgyybD6pCNHm0JVvjZ7YuGZJw0S0fR1wqJZTVYnR99KgVcYoR9PSScY4AHXBD/cGjA75lKHhgXco2Am2kwAzmiypjcTRMnWacsyO+5S++ygFDI23U152hHoObYpBfI687wKLWJkISf4EogOpLkbUsi5DEuc0N+bER4kI9/HwDWudL3hOB7zuWaHr5P0CpsO8HA4nbXzveGxPmb7G/qK1BdqSgmaDacb9evkgUCzkzClKCs346Lbn3azBcdDcr0SwwNdxds3Aw6x4qms2jUCzD/kvqeONsgf0Z0/PGLl6efvWCL8yusBoD/A== 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=8tUD23MLKHSi2Mcl5JhPnpLAKNKqOrZZxS+XQHu8fgY=; b=MPBtYCyO6DDlqDdcDSPoaUtNF9c9lYpsV3iEyOzYP7s1k4HXY0HTtwCOsM63F/oBzdnJPgLRtIo2tQTowaUTsl6ORs8ot1FOKawtOU8ZNfc4aTtEiH9/Eua/EwM0SJBNSkNMTVd5rJ/tYEBsvyWvhly6YE1LYifDvEQsg+DPPOQ= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH0PR10MB4647.namprd10.prod.outlook.com (2603:10b6:510:43::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22; Tue, 31 Jan 2023 22:43:01 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::2101:3ed8:9765:370f]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::2101:3ed8:9765:370f%6]) with mapi id 15.20.6064.022; Tue, 31 Jan 2023 22:42:59 +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 v18 5/7] kexec: exclude hot remove cpu from elfcorehdr notes Date: Tue, 31 Jan 2023 17:42:34 -0500 Message-Id: <20230131224236.122805-6-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230131224236.122805-1-eric.devolder@oracle.com> References: <20230131224236.122805-1-eric.devolder@oracle.com> X-ClientProxiedBy: SN4PR0501CA0062.namprd05.prod.outlook.com (2603:10b6:803:41::39) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH0PR10MB4647:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f991337-5e24-494d-14d8-08db03dc80e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bvKTyM9HQhSJMcTGJYMmD/NK/fmuxEK+/JS7YEw16/hRIzE3SsVMHi58imggausEmKB6ORlUMaPFlqZB3ViKBbnPGE+TNBwRTqtJIPWMsQPpg/h62ylWjmn5hiMXIkw6qGHmgfst8OZ/nGenPFjiALqdYDW8Hw8elNXETwEPtkb70RB8ZpI9bKZUCrgY1AagzH80NMswn33dWQqY4zOonvtihrZQ3c7NGULQ91A908SC5ZuM+Zrm1DhhBW/52fZC0ZE1bG/bcKqt/1vpezIfySrUxFONi7jXgztILxp6abXPJyW3wWITP27asMYLM5/RMU8nRdXJwtn3V+f+BmCb1tGvKV2ksmwErHcIIApkAkctpR2xdNXYt9V6QSZRtWHDs/BkFHP4bTO2BFtwlTYKtd08GP5AqlQJlb+7CG48Y5M79v4mCm9eub3HOEIZxnSu6KmZXDVugSUcelLZhOyc9rJeER86VM+Jh0t8bqwUO/3zs4ToZE0zCHh85y+GLZq/Hlf0cvjHDRvH7L3obmDsI4QLnl3WQVlnd/XuAHNGWqGMTCm0zvSyi9Ub8ORnSB4aHlnNxhxKwqmeuUiwMyrrxmVSfAuEwWPUPJKtvdAxi7Xm+i9/fkYiwajk/OYg3mVK8ifXSlhYW7KR0Bde96Cptw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(136003)(366004)(396003)(376002)(39860400002)(346002)(451199018)(2616005)(316002)(83380400001)(66556008)(41300700001)(8936002)(8676002)(66476007)(4326008)(66946007)(107886003)(6666004)(1076003)(186003)(6506007)(26005)(478600001)(6486002)(86362001)(6512007)(36756003)(2906002)(7416002)(5660300002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BNgbG0UjLR4kZd+V+Sd34XjBC3IKDy4ZwuXdydwZQ7occPZqZS6TzQxS7yLYki5BxcWFfGzYqeAWfOKEfV0fcasC1saLbLI4vNh/MC8PkECRIRNAnij+XvrOJpyR4LqA+2Ip80wiJoKjePpljR9ThZMykax6uVlCeVHpIa7KpZUxxC+U/tRO2YG2R2E0Va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v5b5Pcx4Sk+69vtN7sSEYGllN6wiJg9Z6Gj8z0iqmZxT4/jawV0rQ1aI1s20xGQqpyVfA8w91DnBnjLbhoxuxr9jakvAP5PDwmovuwJmD1vpU9R9sjuI11bLAccYwywty7y3c+8Ka8VwhEOjg0e4FuWqF2IckH+U6B74UHou2lRnLuFh5zC7crXmhwq42R0NcmuH5DR+t0u5FjaObM1qpQKsdR/iSTI9OCGzqgBHYCIV+VTvfCTQmJLTXZFnYjL823QPkgUAfwrdfybhzD9r0DKazE7FQNq2HhSV6/fBIVobjaQXKofQDjElsRjo92XmyjI6NzkTrW1MaDaqJIFFd05M7JWP8G4YXz9f/bNpRcp07HTk/h5iap9nxz41qcQ/7IL9caBY7vo20bxUF1Oocnva02tsjtSaXlnT9sLovYbvfsEqxzG+vaBlBR4Cy+RbGX3l9EdPfVL8rve0YwUa1h4TCGbG2DVAv9rChr78t40tOtwCL13bD5iNAycVkyC783Yvx0c0C+QurlM71UaaHh+m5+h7g= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2f991337-5e24-494d-14d8-08db03dc80e0 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 22:42:59.5414 (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: rWTVtWbz8nATry76R49poY/69evAK9ByoXSimH+INJ1eFftdzJLmXV4UCxqdca6UJHWqVZXwpvFFEAKc42klAazAffsySCsYz16L42u3izo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4647 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-31_08,2023-01-31_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301310196 X-Proofpoint-GUID: eGlfM_w9TWFUqJXfI1uoDEDOJ9gdLrit X-Proofpoint-ORIG-GUID: eGlfM_w9TWFUqJXfI1uoDEDOJ9gdLrit 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?1756582311385401220?= X-GMAIL-MSGID: =?utf-8?q?1756582311385401220?= In crash_prepare_elf64_headers(), the for_each_present_cpu() is utilized to create the new elfcorehdr. When handling CPU hot unplug/offline events, the CPU is still on the for_each_present_cpu() list (not until the cpuhp state processing reaches CPUHP_OFFLINE does the CPU exit the list). 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 Signed-off-by: Eric DeVolder --- kernel/crash_core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 5545de4597d0..d985d334fae4 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -366,6 +366,14 @@ 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->hp_action == KEXEC_CRASH_HP_REMOVE_CPU) && + (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; @@ -769,6 +777,14 @@ static void handle_hotplug_event(unsigned int hp_action, unsigned int cpu) /* Differentiate between normal load and hotplug update */ image->hp_action = hp_action; + /* + * Record which CPU is being unplugged/offlined, so that it + * is explicitly excluded in crash_prepare_elf64_headers(). + */ + 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 Tue Jan 31 22:42:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 51076 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp85449wrn; Tue, 31 Jan 2023 15:11:37 -0800 (PST) X-Google-Smtp-Source: AK7set8OeVQlFqxPqsehZFR/oZsyMGZuMlyvAXUN5FO0ug1CBR0iIyTPYRoLBI3iyPN0FylJIZLC X-Received: by 2002:a17:903:24d:b0:193:38ce:7bb8 with SMTP id j13-20020a170903024d00b0019338ce7bb8mr14024585plh.37.1675206697235; Tue, 31 Jan 2023 15:11:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675206697; cv=pass; d=google.com; s=arc-20160816; b=zIDXNhDe77zycIgIhH7YaS/9Km/lBJuYvnFTbUoj57IpTm4PS8JzzhtSXlIqWVEICZ xbGSG81TIQVgODOomrkbR+n+00ZpCZDlp/lVGcstajWku8BzlUaoaEWYnXCWP9hnbLOR DOyjQ6xtEeLx97CQ1vZ5CaDI6v8m0EoMe/51TaniU3cOEcxAHDwyu9UJOAWaY0Bu1H7J R8MSLyo/gCfAXtl8gqU90ppgEierHiaXq6PDrKc1OjBV/vb1VinEMUREQKWQRMfMFlCV jMYtJya+d1iIMF2wnZIXxFfD744f6pRa0/3eCYLYVjczCUiqb5jDRV6rPNGhErdEjy6t /ktg== 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=nN3aFpo0np67yBPrfAKy3et0sb4QX9dxrzTYCtzr4eU=; b=tPFOYAqHzlYbF4aApZdu6mKaqcUAD4tzU2X5+WDBFR+7KcsSuczQ8uVHr1yKlnam/w xk1IS9MpCcOpQEQsGukc8N27X5aZDrQXpVjHGbV7Qms0E6Hvvs2FZg5R4OpzLb/o4lhn I0fSNbsPvtz05P2qJWjdnNWfUM2bPK8iKNf9tVwwOkXvk47EHk4fk2HfYk3/13fYgzWl /nywsNwoI7RI/06EEVwN6a5n71lajKhc+HdingcdUgigV05Zxoo4nEPSJpthZa5Iyf3Z CA6CWxvbesgHB8lS7OIkOne3vwbPyxCk0w0+NnQKtuNIZ1C0Y2IHuFDAdJ1BrSsXGzVV gT9w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=vJRo1c3g; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=bYDbG2eN; 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 s3-20020a170902b18300b001944785f248si16184497plr.84.2023.01.31.15.11.23; Tue, 31 Jan 2023 15:11:37 -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=vJRo1c3g; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=bYDbG2eN; 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 S232033AbjAaWoO (ORCPT + 99 others); Tue, 31 Jan 2023 17:44:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231754AbjAaWnx (ORCPT ); Tue, 31 Jan 2023 17:43:53 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6F444221 for ; Tue, 31 Jan 2023 14:43:51 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30VIhr2W025726; Tue, 31 Jan 2023 22:43:22 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=nN3aFpo0np67yBPrfAKy3et0sb4QX9dxrzTYCtzr4eU=; b=vJRo1c3gLmOvTCIr7asCka879yfzQiCq1x1R0BaXUDeuLCRIRWQxRK46T6R/IXS12EGe 83/9kcY4/TWntWJ52uoByWxE43F7IgOUb1j4nyNRKQJ5qAQkCf2Hxf4bjZAiSYMFRWGl SfaG7hE1zbQoOkAVnPmCT9HUgFZFp4+fWA0ZWPAZvJsPpenybalP5dnqyb/Bw60ULC7M LjDQjEkTPs1aj7pqGbY6Tl77sutTFcPJhbvkbdBsSVDTqogRCtIHkX/9RwnzqAELsZZm 87iK7TQ24POTAmOllXXqCXyghlBBiHJ0ErjcWm08gxW9ZV7C4L4DQQV176SMbPgOpT8g xQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvqwy0ps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Jan 2023 22:43:22 +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 30VLKJdb031557; Tue, 31 Jan 2023 22:43:21 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nct5d6y3p-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Jan 2023 22:43:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d0LGOLlpr150+YgHjTGqFf9cG3cCHQWZe07NHMhLSKaP6YYghALlBKbxOki4u2OZnMRnW1NQroTs6x5P2PMHV4mlXnxJOXvJJzWgYF6LUs/aJ7yQ9BBr49Ha1pupyCYtGNgYPLMDYZ3N+XKW1JoAXY01UKwTNRiXiaa+GjcxLbk/kZnS00kn+qpEMbcPtYCJqjYz0xtcDhPs2maB/kJjBHT9CrXM1L45dD5mb6uvFjwq71XnZ4VqNlpIsIjBbS+cewgADoVHDJjvP0HTJvtrOF8vpo58cK/Kx/Aiw+jTBeQtPwhb+8a6sCBj2T5FIxFdrV/ztaUBGnDq19PdrEbXVQ== 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=nN3aFpo0np67yBPrfAKy3et0sb4QX9dxrzTYCtzr4eU=; b=YUO+AlpMW1q7HWvaJ+mbyEr90Wl+P95vqi9BR5caGqv7/i1bfTgg4XdfXSrPCpZ0OYNZPs1icN8L5UjxSxUZWkb759X7uYXG06YobQmuONA8o21c0Gu78HzZPA0y9TBiWByHWKYygKui4aVM9HjlOuWG5Jjf7dt2l59TA8hQBJjLnw2c/6P4a2CJOieLNWbaqOT4X8XE6OaxcLjugOkCmOh+dAItpzrEjZF4klTud5NKC40FV7HV2K35l19w9Awuc0VtmjbVdk8ECpwWCHsaTaRXaW5nM5hIuDu/2rwnYn7B1X0JnT7ENSWY5+usecoWgRKt9VVgEmW56aGkq0WePQ== 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=nN3aFpo0np67yBPrfAKy3et0sb4QX9dxrzTYCtzr4eU=; b=bYDbG2eNOKt8wwqj8n5p57mNZ1mZYZkMVpahAYjtTGceScDk17yGx1wbp7NhePLbt8u7aUNAxeymmKKatNL6TqARzk3KNdMMwuPmhAsqIY09DT9g3GpmO/8l4fduTjna8Q6lgAKl13h2XskWEc3nDj5bOFq6fN2zKCHkRg7AA4Q= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH0PR10MB4647.namprd10.prod.outlook.com (2603:10b6:510:43::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22; Tue, 31 Jan 2023 22:43:03 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::2101:3ed8:9765:370f]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::2101:3ed8:9765:370f%6]) with mapi id 15.20.6064.022; Tue, 31 Jan 2023 22:43: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 v18 6/7] crash: memory and cpu hotplug sysfs attributes Date: Tue, 31 Jan 2023 17:42:35 -0500 Message-Id: <20230131224236.122805-7-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230131224236.122805-1-eric.devolder@oracle.com> References: <20230131224236.122805-1-eric.devolder@oracle.com> X-ClientProxiedBy: SJ0PR03CA0287.namprd03.prod.outlook.com (2603:10b6:a03:39e::22) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH0PR10MB4647:EE_ X-MS-Office365-Filtering-Correlation-Id: 26b4f817-11f5-4eb8-f3fa-08db03dc82d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8clh703IkwXNApQGqAZN08nnufgzYS1gfKZj7z4HNufFTBQ9TrLGP5b0JbiXtuZkcmVmDq5XJblHirfRsm3pi5sPEzfPZT24WLyZTT1vPOsrNmSwQq0aMMczfF8aT2YHHCC9dXzQ9dLSNGLo1/vg1C3NdWn9FCEGC2TLOoS3QUwabRr3SgtkL5AVJgWO0z5XF1aMDCGo/dgOOAx70o/JIbv1bBNweLD033/owDpcUA6NXT7Yo6fTeVnvcKgePJGnIX1fPYLOFkLTOnJtVMR6d7nbp3uxZzU5XwC8/Tykij+7eQ0zqaqiPWtzXxKZlkQVxmTXaiLxsvhjnDL92mxwiTQYuY4auNCCavV31A47+1w8JL78MtH2uXQBfvTGFNvY3vJMnXLgWHMyW/nq/mOgjAe41iyBbtihi7gHXr5X8CzWGUsQN4dBSECjgkLG8S1KFfQmddSRhk2UduR1J6fmv/cm4uWW7xRQ0mp7gi6OJw/BYs6IX0BSCUJmttqfl8uPEtz8p8hANdc2T7TpCnjaJkCE9lydoUFwMHVcdC0LKCskMs9qCCZXrqJ1uTmVaQi82dvN3H5uu1q7YZYkaX7En7Rmz+Pmt18Ons65Zl2gkEXgz7hKdNPwKrOSeqFkO5BBCyJocdIP65/cPp6Co2kV+A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(136003)(366004)(396003)(376002)(39860400002)(346002)(451199018)(2616005)(316002)(83380400001)(66556008)(41300700001)(8936002)(8676002)(66476007)(4326008)(66946007)(107886003)(6666004)(1076003)(186003)(6506007)(26005)(478600001)(6486002)(86362001)(6512007)(36756003)(2906002)(7416002)(5660300002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tQqP8s2fQrjokXWSE6bPLYWJ29icHVgZ9O4k2PI0XU3aqQagyxUTTY3nHfjmVmzKhg0W/E3Qcz+OKNMzVeFSYSJDAS3vem2zYEKYpTmNVrSHAcaWyvoITMRPyzfmxErkcqiuKWNC8yXfgVCCU+0kEFGU0vXUa7E94spQN7GvoJn3Zkuv8NVnmGGN2dwyLGeDp39rVndVVwj39GdyJdRb7xGFOVzIkT4jIk1D0X4g7MEfkHZMJ2RjKf0NJKf86bIprWKqT10j0Zdn39HGw6XU/nTMbe134C1HCV4g56QHyOXOt/rBDkXNLzCU3wmri4YRX6hCb3tNbG37OJkgJX0jyd1JcrSdC9/RQWZVqdH/6OElEWu4l5gU3b9fv1sa1zQZn686MyaRjFxf0pSUWz+ZqJlrRvSbQEJn5EpS1czYS4zIv+SvY1ispi2BZQjsFvTt8UbkXhNvO4tqnyYrcSN4RoNXLOV25kE8Ipe6PgBFDFUAfwgoipdnC6UfCBaNW1NfCFT+UvlumzPMuioCj64Y68/SQc7LKsrFsxVzfVLauY22mU3zSZVIRXK8J0AxOWgz4+6L62I7tjxuByWq7hoFZodLkFmiAv2A109sgxEtROlNGwVycgY3bMKokSMDTAK+m1wZTYvWF1mECicy3pk4s/mEEMgTHeOm/NDfiYLGCsJLwF+U3CPduM/bN15lAQsbhxeMO6KzHmVsJhvVpp4Dx3wBhsQV56aP3VgS8g/A5E/vJ2mv0PGlpn55EwPJ56mM47oXPgVA48BD03fvOVFnkYVbKFg02/mcSjSANbx6k1lZC1lfFzq/prLl5XE8kcYVYaFi2PabVCP+2Nb7hmIUSTFHbbyiESn1qqOwhuZ7H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nQkXXCTDqeFxLIRnV09d2wMEEmQmBRyxVKve1vSi1WrA3O2nfog3TwGUYW7J2g0APW9WvlD2+jps40Hziszh8XUKRsG/Jxe/jS3+qcgoonCtGWtC17lG19eFAEDIC4aaeX9xby/HMNMi9aEuCe/xC7QYntdPHSwTI/DfxexknZ+w1oPTLmkzuEFDwoYm4DjhsZx9Oa7N2jA4aZy7R0iqdvKVHe6gUp1ZbQx6+Xxx5oEWTiklWpsBaO14itrP+Mcqpk81cFqPstt6joBP6HcK2OPo+WPc9iEa2XUmC/SwdZn3YO5EnBy/HSUAHEAOq5cfnifNNOG2+1JsOHYkKBRHiN9zlkgERKCAp0K901Hw41xC5x8XH9z55TUcOccZ2vs5EwMiRJ/Ms5NlLk++KMz56Etx6xPAIKWbip3+5gBbo8l8BPmjj/SdRqdecL2KJNkAPBbMVeawS5wV/pYi4CZ4446pmNQ8Lcd1YATGrzrVGYOV7h25cpV//POqU9qFKCuoArlzlcV4y5hyz5hWix3N20OOSmiQyajLizk9tPMkrmnW/bz4gvIcBWevLAHaxtKRZxJmSbzZAfa4bYS/KEKHsda0yoUBSMkp/k7JYNcrcbjaq3jX0b435T41Lj3+hAKpfwliIW/sRjtAIHgan1V62vA5XOIHO68l35k5J/MyT32JsOh5R1CFVjSMTPKz3hyGAhRfjalVbRVYU9x+rae92XrBZwAmof9+TYgwIXMA/1CKKW67uwazKD7oowrkJ/3MXbZdqQFb9/JHrDuS3t0mlpUDugs88cqLZ1juPDQNTixo1uIRwWsm7JBrsrDvUBVj0FEY5QhrqvTCDfD+yHvjDTaqMJ0G5Hp8oe/VqiXOfJQ8H2nnzD6cI8xDexoVjz3b2ZfKivwYEYBGuD7cYN0w2MXvyL0jzTUO98cSnd4dSPZOvDI0xQhuJ3uw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26b4f817-11f5-4eb8-f3fa-08db03dc82d6 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 22:43:02.7901 (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: Ma7mKWL9KJNF84xcJVZRdxt0xjhtzmM7WSMdxPqOgx1w3zzbvd0KHR3ZstzcW4le+pd7QYuWfCawUnKZ4IR68+eOTySnn86kUoVe87AJy+c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4647 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-31_08,2023-01-31_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301310196 X-Proofpoint-ORIG-GUID: w-IDA8lxt6N8WJIyAm9AMYVzfEXJE2m_ X-Proofpoint-GUID: w-IDA8lxt6N8WJIyAm9AMYVzfEXJE2m_ 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?1756581537800656180?= X-GMAIL-MSGID: =?utf-8?q?1756581537800656180?= This introduces the crash_hotplug attribute for memory and CPUs for use by userspace. This change directly facilitates the udev rule for managing userspace re-loading of the crash kernel upon hot un/plug changes. For memory, this changeset introduces the crash_hotplug attribute to the /sys/devices/system/memory directory. For example: # udevadm info --attribute-walk /sys/devices/system/memory/memory81 looking at device '/devices/system/memory/memory81': KERNEL=="memory81" SUBSYSTEM=="memory" DRIVER=="" ATTR{online}=="1" ATTR{phys_device}=="0" ATTR{phys_index}=="00000051" ATTR{removable}=="1" ATTR{state}=="online" ATTR{valid_zones}=="Movable" looking at parent device '/devices/system/memory': KERNELS=="memory" SUBSYSTEMS=="" DRIVERS=="" ATTRS{auto_online_blocks}=="offline" ATTRS{block_size_bytes}=="8000000" ATTRS{crash_hotplug}=="1" For CPUs, this changeset introduces the crash_hotplug attribute to the /sys/devices/system/cpu directory. For example: # udevadm info --attribute-walk /sys/devices/system/cpu/cpu0 looking at device '/devices/system/cpu/cpu0': KERNEL=="cpu0" SUBSYSTEM=="cpu" DRIVER=="processor" ATTR{crash_notes}=="277c38600" ATTR{crash_notes_size}=="368" ATTR{online}=="1" looking at parent device '/devices/system/cpu': KERNELS=="cpu" SUBSYSTEMS=="" DRIVERS=="" ATTRS{crash_hotplug}=="1" ATTRS{isolated}=="" ATTRS{kernel_max}=="8191" ATTRS{nohz_full}==" (null)" ATTRS{offline}=="4-7" ATTRS{online}=="0-3" ATTRS{possible}=="0-7" ATTRS{present}=="0-3" With these sysfs attributes in place, it is possible to efficiently instruct the udev rule to skip crash kernel reloading. For example, the following is the proposed udev rule change for RHEL system 98-kexec.rules (as the first lines of the rule file): # The kernel handles updates to crash elfcorehdr for cpu and memory changes SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" SUBSYSTEM=="memory", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" When examined in the context of 98-kexec.rules, the above change tests if crash_hotplug is set, and if so, it skips the userspace initiated unload-then-reload of the crash kernel. Cpu and memory checks are separated in accordance with CONFIG_HOTPLUG_CPU and CONFIG_MEMORY_HOTPLUG kernel config options. If an architecture supports, for example, memory hotplug but not CPU hotplug, then the /sys/devices/system/memory/crash_hotplug attribute file is present, but the /sys/devices/system/cpu/crash_hotplug attribute file will NOT be present. Thus the udev rule will skip userspace processing of memory hot un/plug events, but the udev rule will evaluate false for CPU events, thus allowing userspace to process cpu hot un/plug events (ie the unload-then-reload of the kdump capture kernel). Signed-off-by: Eric DeVolder Acked-by: Baoquan He --- .../admin-guide/mm/memory-hotplug.rst | 8 ++++++++ Documentation/core-api/cpu_hotplug.rst | 18 ++++++++++++++++++ drivers/base/cpu.c | 14 ++++++++++++++ drivers/base/memory.c | 13 +++++++++++++ include/linux/kexec.h | 8 ++++++++ 5 files changed, 61 insertions(+) diff --git a/Documentation/admin-guide/mm/memory-hotplug.rst b/Documentation/admin-guide/mm/memory-hotplug.rst index a3c9e8ad8fa0..15fd1751a63c 100644 --- a/Documentation/admin-guide/mm/memory-hotplug.rst +++ b/Documentation/admin-guide/mm/memory-hotplug.rst @@ -293,6 +293,14 @@ The following files are currently defined: Availability depends on the CONFIG_ARCH_MEMORY_PROBE kernel configuration option. ``uevent`` read-write: generic udev file for device subsystems. +``crash_hotplug`` read-only: when changes to the system memory map + occur due to hot un/plug of memory, this file contains + '1' if the kernel updates the kdump capture kernel memory + map itself (via elfcorehdr), or '0' if userspace must update + the kdump capture kernel memory map. + + Availability depends on the CONFIG_MEMORY_HOTPLUG kernel + configuration option. ====================== ========================================================= .. note:: diff --git a/Documentation/core-api/cpu_hotplug.rst b/Documentation/core-api/cpu_hotplug.rst index f75778d37488..0c8dc3fe5f94 100644 --- a/Documentation/core-api/cpu_hotplug.rst +++ b/Documentation/core-api/cpu_hotplug.rst @@ -750,6 +750,24 @@ will receive all events. A script like:: can process the event further. +When changes to the CPUs in the system occur, the sysfs file +/sys/devices/system/cpu/crash_hotplug contains '1' if the kernel +updates the kdump capture kernel list of CPUs itself (via elfcorehdr), +or '0' if userspace must update the kdump capture kernel list of CPUs. + +The availability depends on the CONFIG_HOTPLUG_CPU kernel configuration +option. + +To skip userspace processing of CPU hot un/plug events for kdump +(ie the unload-then-reload to obtain a current list of CPUs), this sysfs +file can be used in a udev rule as follows: + + SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" + +For a cpu hot un/plug event, if the architecture supports kernel updates +of the elfcorehdr (which contains the list of CPUs), then the rule skips +the unload-then-reload of the kdump capture kernel. + Kernel Inline Documentations Reference ====================================== diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 4c98849577d4..fedbf87f9d13 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -293,6 +293,17 @@ static ssize_t print_cpus_nohz_full(struct device *dev, static DEVICE_ATTR(nohz_full, 0444, print_cpus_nohz_full, NULL); #endif +#ifdef CONFIG_HOTPLUG_CPU +#include +static ssize_t crash_hotplug_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return sprintf(buf, "%d\n", crash_hotplug_cpu_support()); +} +static DEVICE_ATTR_ADMIN_RO(crash_hotplug); +#endif + static void cpu_device_release(struct device *dev) { /* @@ -469,6 +480,9 @@ static struct attribute *cpu_root_attrs[] = { #ifdef CONFIG_NO_HZ_FULL &dev_attr_nohz_full.attr, #endif +#ifdef CONFIG_HOTPLUG_CPU + &dev_attr_crash_hotplug.attr, +#endif #ifdef CONFIG_GENERIC_CPU_AUTOPROBE &dev_attr_modalias.attr, #endif diff --git a/drivers/base/memory.c b/drivers/base/memory.c index fe98fb8d94e5..a3f37cb57d79 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -495,6 +495,16 @@ static ssize_t auto_online_blocks_store(struct device *dev, static DEVICE_ATTR_RW(auto_online_blocks); +#ifdef CONFIG_MEMORY_HOTPLUG +#include +static ssize_t crash_hotplug_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%d\n", crash_hotplug_memory_support()); +} +static DEVICE_ATTR_RO(crash_hotplug); +#endif + /* * Some architectures will have custom drivers to do this, and * will not need to do it from userspace. The fake hot-add code @@ -894,6 +904,9 @@ static struct attribute *memory_root_attrs[] = { &dev_attr_block_size_bytes.attr, &dev_attr_auto_online_blocks.attr, +#ifdef CONFIG_MEMORY_HOTPLUG + &dev_attr_crash_hotplug.attr, +#endif NULL }; diff --git a/include/linux/kexec.h b/include/linux/kexec.h index a52624ae4452..ef2b607fa105 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -512,6 +512,14 @@ static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } #endif +#ifndef crash_hotplug_cpu_support +static inline int crash_hotplug_cpu_support(void) { return 0; } +#endif + +#ifndef crash_hotplug_memory_support +static inline int crash_hotplug_memory_support(void) { return 0; } +#endif + #else /* !CONFIG_KEXEC_CORE */ struct pt_regs; struct task_struct; From patchwork Tue Jan 31 22:42:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 51081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp90184wrn; Tue, 31 Jan 2023 15:23:42 -0800 (PST) X-Google-Smtp-Source: AK7set/xG+ZDyIKwxS4RYbr0+9Oq5o61jHgZGkvMsdGphdreKoTkIhiTM+/UN4rY7H8qWI3ZzEDc X-Received: by 2002:aa7:8427:0:b0:590:7623:9c6f with SMTP id q7-20020aa78427000000b0059076239c6fmr56251pfn.34.1675207421726; Tue, 31 Jan 2023 15:23:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1675207421; cv=pass; d=google.com; s=arc-20160816; b=XIJ9CoLKvzlQ5POeJ/JkNa6c/DIWhE1c7Q6TySe5WLAy6fdsjj0R58ZCE0dmLfE8Mp dCv4e5dWPcRNI7I50EIg2O7sSIypDBmlmNmcX4rkHsGc/m1mrrdpHuzZNop2xMY+lPlv dhReyyfQEBUqWO/+aOt2gZKKHysbGL3g2MXVDGDA7rlGhecuvUBRnM/gGVJb96errnIU m55q6RtageAG+3VhavzcaEz0QZgGXoSAr66G+3tWekBeSOckhwhGh0VgNaDOuYnBc7is oyf0TztQu8WGIpPtaYCx4Ctf+oWUqzOlqWsaePmQmoxXCFpiO6SHWgQJxysZgBbaGPZF CVHA== 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=lIasJHV5RY2DlOlVGMTyiteQsaaXBEqgFZ/3hOF+230=; b=mmCBD6zwavvRV387ItiK1Vh4K5JOEUWbx6fYQ8NSDbciI07kyiKxsaJ6L4AANAgy20 Q4ura2rZF5MPD0ofBXeDjfWPWhzrLYYoaxtc0Hxzdi0z5ODjNwwPAg4ZUOjxFmoyI45b kWhMxtuKOmNGgf1fs17XZxvJ83SdNUs1/08i6aAoo+k7tphwT98g5LMkDl1/W2uVGZmH xl08MsTadqAS0XER8SywG1OjQrHtxwvF6chzM3FaoxzQdyzG3GqR/l/hYtRmczQXJ5fN jDkV7hX7O0wQ43ubQJm0k74KXmgA9gdfX+uHz+jaFOYCFTg0Z3bkTFGLnzn+gqa7lPj7 YPDg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=Brf2dCW0; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YWsfejsT; 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 j4-20020aa79284000000b0058e16d32d35si16665791pfa.378.2023.01.31.15.23.28; Tue, 31 Jan 2023 15:23:41 -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=Brf2dCW0; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YWsfejsT; 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 S231989AbjAaWn5 (ORCPT + 99 others); Tue, 31 Jan 2023 17:43:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231781AbjAaWnu (ORCPT ); Tue, 31 Jan 2023 17:43:50 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2593B4741D for ; Tue, 31 Jan 2023 14:43:48 -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 30VIi744004116; Tue, 31 Jan 2023 22:43:21 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=lIasJHV5RY2DlOlVGMTyiteQsaaXBEqgFZ/3hOF+230=; b=Brf2dCW0SFch/6vV+hP4wl7ZaLfStjEPqRmKLcy4DOMzXHXv+xZVeUDa7Z00iUaRrT7R vui029Y7wpKtGFB6Zw6PrN7Xr8SOYg/YGVeOrHt2pMYiajwY3IAP6vSKPxkCuUx8TkpB zfnkZf9smA1dz396m8952kGykMfH/q2pEnQdtLMzE40Zv6q5GbnB2oGseDo4IONWkZjY N+jQXuyExesV98jKrhU5pYQNlM/JyK9Xq1q7P6dSike+Ztw+M3maUm9ZEHy41BlOAhlh 7RZMlfgSCVRSQ9pcgdodeg5O2wGF2WA4o6DehG1RkIvFGLu9ybaeKSdbG2D62tmuf5ku HA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ncvmhpxrg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Jan 2023 22:43:21 +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 30VLKJda031557; Tue, 31 Jan 2023 22:43:21 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3nct5d6y3p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 31 Jan 2023 22:43:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ez42PTiF9xw06UDdrRIjp9+ASkhbSbuNtTFgC7kPJ1oj+E3CjoFlGaPezxDy9q3G1ymI0DmsqY3xGuDdwflmrmHkfsr1x+Bl9ygXO2qv088ptAxaO84pO+nFcfOzwATC49wys/qtQbqEQdSqHL/2j9Np4GxRwuPDB7uDIZgp8XMp71zMcldJBpNL3KNFBCPidpgOoXqb89oeaIvcTUHaxIAj909+Zb3Ra/N9uXGDzCALbDSjyqfMrLh260rBuHTxWATa1njeVpkj5ycAq4wCcUDgtOZwzGKAKeLAQFefS9rnCTscqeJEJH35hS8/0/FiYA6c2/JbgDMVFWfiWgpfoQ== 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=lIasJHV5RY2DlOlVGMTyiteQsaaXBEqgFZ/3hOF+230=; b=gn12ZdvLN1JhayQmdwC9n1KjuxNYiuCHIKuHSfODCVpUT0CdSiUQcbJblwm2HCcOsQyRjyKxpVE2o/NXMydFvetOkHpUZdnFEWe303Hf9ViZY8gs7XHqj/LNTeyCvfMP9vWKv4KgWD9qx6gLObqQ6DhhBpCkkbKJpemTkO4GhGdKWuFucJAh1h6T59f01pyjSes2QUGr58ZJOCydr+hZJq4JO5dE7e84XPlMZhZpkfMzgqqaHa8A9kOFAu1DVkRWF3JUwOxY39q88lCwWNI6i46ScYQ6wSfQ6QLr/ZVKD7Mwm5f3zdGpIlknnf6z5EyKsB9Arc+SequvSO73KKkruQ== 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=lIasJHV5RY2DlOlVGMTyiteQsaaXBEqgFZ/3hOF+230=; b=YWsfejsTGy49MW6uOvPeT7HmtixZCRrUDb5UhaikXlKUAH43NAAZviUhccfMekOLoo6bJOPv34vJJIVbSHB/JaTy5VLJJI+odzg9NIA6V22E2fCT1DKcxVUBQeB00aeB8EJes6rZabvXOka1nXyTsqb53LrmM62naJS9EDFNhVo= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH0PR10MB4647.namprd10.prod.outlook.com (2603:10b6:510:43::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.22; Tue, 31 Jan 2023 22:43:06 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::2101:3ed8:9765:370f]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::2101:3ed8:9765:370f%6]) with mapi id 15.20.6064.022; Tue, 31 Jan 2023 22:43: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 v18 7/7] x86/crash: add x86 crash hotplug support Date: Tue, 31 Jan 2023 17:42:36 -0500 Message-Id: <20230131224236.122805-8-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230131224236.122805-1-eric.devolder@oracle.com> References: <20230131224236.122805-1-eric.devolder@oracle.com> X-ClientProxiedBy: SJ0PR13CA0225.namprd13.prod.outlook.com (2603:10b6:a03:2c1::20) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH0PR10MB4647:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a4add91-6223-493f-27c8-08db03dc8495 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1zCvOtv/xQ0nUyUoutKqHXnGEsJQ9oVySVNwZiOYcehOnrKY02uXL32J59O6RAZwM3XozM/eDMXP0gtqhVnebUSE6XM04pqn5OqqxTkM83ADASKlff1soD+Hl9rZTD74V5tJnzk6MqW90s5QIhcHfUlUahQUE+GfCIqGemJzIzNHxH808yxk4nsDUK7GqLnObfaTm4QfdZhYfDV+/4eIWKW0uQ/rvreB0M6DR5UWTCi+CeKOKBkRGMMeD5wKmsfIPob4o6Wh17Z2OcKfasrVPajkv87Rp3/ZPsFZKUAKLtCSynnhQO9iWfEpmCdnrzpm6TMBOofzEwrX0+9QF54rh5yVYJVdtc8bja6gWUuWTHszAca/GyhlAV3kw5B9x+qSdqEaW0cLRNtnr/5hBq7MDLo6B9KViFRD/jp8PEnVwPC4z094GLUFG8sIYEy+ntynwlPJZ7QF8Zz1ASUlxxX8zQtlHYXkofOPpv+TMZTD0hJH7hX/31hftqJtC0zqGnkUoVx0W1MdbdzS9c46FolSCNkGG4M0bNWjhe01EFA1U/KEhWc4Nep0yO9EzC6aMd5n+gwEUc8g49EP/tf+AoOhmswUFT7LIml54qJZVDCvJVdB4bSBFb6+H8Y6uHxcQewbg40Wubadjaw8pjffkD4lhg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(136003)(366004)(396003)(376002)(39860400002)(346002)(451199018)(2616005)(316002)(83380400001)(66556008)(41300700001)(8936002)(8676002)(66476007)(4326008)(66946007)(107886003)(6666004)(1076003)(186003)(6506007)(26005)(478600001)(6486002)(86362001)(6512007)(36756003)(2906002)(7416002)(5660300002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BcfyleJgJj3ngckVCF5HYfY3BoIWUGoCSMU4S8F8aBI4avhgo48kHqbAfO0Hnq+1WOMBINlh16aaqtvp4BwICXUNdQoiw76/2iDn18EeekX1SWmXN04OdfBXgd1BDmoy7H5Z27vswDC7HKjF6ASWz+FUVkmbKqSfnU1P9Jn+hJ7B03j24KhVxNqm8JrkK9wRt0ZgTDhviAL8PiGIhZUiftO7EzeSaHlb/11n3P2swD10lqEHAjhrb+KTOTm1vip+NWr0tEKV7wtZC6FcHR2EBqU1QcvnZyUPJ06aOTcebHQZsUObnw3E/if0//IEDpSFaGZsZpcLvZfEBatGsXvSLEivEQnXP0ZC+GtfKqady4RXUqFnMClhjO/JiV6D3O8zjocMi/EQDDehkfMGwHo+JoFKeBAOq++ktd3OkQbLpgwnNVyUovaPMsprW9U+zizJNSp3Rq/FOIN91/mHUR7FnDX2UFMHVI2Wkz3QViSVStkCbfVkxxnkVVL/W+7rPHstfdvnEmB+csY/kSSCRLa0LiCtsuTgeY7XsKbrFvxOUqNb12X8jArTBMEFP1tAoRes/FvV1yT768vigVM2QB2Kn4+7m9MQiFLM2AEchn5PTOWGFs+zt0aeTDOt+KAIsSo93r1n3Z7ec4mun2Z9u4LPtg8V0DsDRl0hR0dwPtW4Y9uyI6DjvpwBWBAgnjCcBveqciuZnbO/J3hRTam53WMcM25Fq8g+MVPINXlM0RON25Ri7wj6HyU7wCs9vzkLt0TscyU71V2NLasHNkgkSqIWaJZcQMSNN89TNtrr/CazfPi+i1N0pNLhKMMDYejwe0KKO0UeO4+A+G6xmouzJhGflyBR1xWdiy+YkqevNqAZkhbuzpavs+qHgJqkhsF2SQ/DDru7zcIiOwHu6llSfcRoWAvyRjPMcqoavvWwkAPs3k5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i+xegR2b7hAVh1y+NKzy8dFsc/Q/l4BbGIq9O8nTVfN+uAXihtBIVWy4vs2eA3B1/uoQ1yZV0gNrsS/yB74T+9YscYH4Vm0mONsEzkfZ5a/ZKPTwvPtfpGvb2smAGzztnn57MjrakVF5F6CDhEJM/O7pjcdRGqcpn28sAG3q2RVMjWSDSRVLcEDi5ko76TFjln/VWfGsR8/gcbY1Byclby1G/Io4Q0TNi60BKcTsMGRu7TlMv72fvdH/cVMs2T/Py9hAxp+2VvIqizTojy6ietnUKIHrTRvQCFbJs0nFaT0zCEjtLRWNO1vDUJ0Z+QHCLN5bwYRhYV3VQxkpskcOOHMysy3lDFU6FjQaIERMWpSLTWY7nWPNaIT0BtIGzmmyu8HTFKTmM8a+S/F4wxCh1Td6o1lOUNlX0cyvz4RVIJq9rNnhkMV4ST4s/MJxXrbsKSTiEDjfF7C2ZbMJSAn5urKkSsY/Ksa3NuQIJ2WzryDEAaD+f3U396xEVDtboLO8P4/gkNwjxSzgXmoamgH2W/G4LV1VhNSmKsIFmZoVTi0WcRH90kgQKsTEURmZPzZcpPdet0biS8TgRtBr1bHDuFQRDtM/YEt2csOQPn8qnDwq4CdgRy6EV9V3VmZ+dXTCxMhL2IsSs2tpaac/gggQxTS7qgzZSPsABg46ySfUiYP+DL1x1iNCfI5NkbJhLhAjgDZNqkOmobr/N/ujBi+U1zBSxI21o0Bnvid+lRpDKvFbu/TowhwzzUgo1aNbC+FgpGM9a5XVdMqG4RPJ2IgtSf9RZ4BF04ub9vn5SuG5kQKlhENBU4FQFUMODTBCxE6+aoaaNN++XcdTT2Y3PH7/Q2rnJiIZDJ19rw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a4add91-6223-493f-27c8-08db03dc8495 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2023 22:43:05.9174 (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: waAUjZsrsrbp6/G9fFhIJ8thYR26Wj9yY6KyAYUhd45mze/3zYtFlXGdXozQXjJ9Q5y5LQWHVQwJWXqHVOzUbcgFZNMvQGhy5RtaYBaddAA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB4647 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-31_08,2023-01-31_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301310196 X-Proofpoint-ORIG-GUID: EZx_VPE23EtWISVe23gXYqq27SAYFdwX X-Proofpoint-GUID: EZx_VPE23EtWISVe23gXYqq27SAYFdwX 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?1756582297241665880?= X-GMAIL-MSGID: =?utf-8?q?1756582297241665880?= When CPU or memory is hot un/plugged, or off/onlined, the crash elfcorehdr, which describes the CPUs and memory in the system, must also be updated. The segment containing the elfcorehdr is identified at run-time in crash_core:handle_hotplug_event(), which works for both the kexec_load() and kexec_file_load() syscalls. A new elfcorehdr is generated from the available CPUs and memory into a buffer, and then installed over the top of the existing elfcorehdr. In the patch 'kexec: exclude elfcorehdr from the segment digest' the need to update purgatory due to the change in elfcorehdr was eliminated. As a result, no changes to purgatory or boot_params (as the elfcorehdr= kernel command line parameter pointer remains unchanged and correct) are needed, just elfcorehdr. To accommodate a growing number of resources via hotplug, the elfcorehdr segment must be sufficiently large enough to accommodate changes, see the CRASH_MAX_MEMORY_RANGES description. This is used only on the kexec_file_load() syscall; for kexec_load() userspace will need to size the segment similarly. To accommodate kexec_load() syscall in the absence of kexec_file_load() syscall support, and with CONFIG_CRASH_HOTPLUG enabled, it is necessary to move prepare_elf_headers() and dependents outside of CONFIG_KEXEC_FILE. Signed-off-by: Eric DeVolder --- arch/x86/Kconfig | 13 ++++ arch/x86/include/asm/kexec.h | 15 +++++ arch/x86/kernel/crash.c | 122 +++++++++++++++++++++++++++++++++-- 3 files changed, 143 insertions(+), 7 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 3604074a878b..2ca5e19b8f19 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2119,6 +2119,19 @@ config CRASH_DUMP (CONFIG_RELOCATABLE=y). For more details see Documentation/admin-guide/kdump/kdump.rst +config CRASH_HOTPLUG + bool "Update the crash elfcorehdr on system configuration changes" + default n + depends on CRASH_DUMP && (HOTPLUG_CPU || MEMORY_HOTPLUG) + help + Enable direct update to the crash elfcorehdr (which contains + the list of CPUs and memory regions to be dumped upon a crash) + in response to hot plug/unplug or online/offline of CPUs or + memory. This is a much more advanced approach than userspace + attempting that. + + If unsure, say Y. + config KEXEC_JUMP bool "kexec jump" depends on KEXEC && HIBERNATION diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index a3760ca796aa..1bc852ce347d 100644 --- a/arch/x86/include/asm/kexec.h +++ b/arch/x86/include/asm/kexec.h @@ -212,6 +212,21 @@ typedef void crash_vmclear_fn(void); extern crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss; extern void kdump_nmi_shootdown_cpus(void); +#ifdef CONFIG_CRASH_HOTPLUG +void arch_crash_handle_hotplug_event(struct kimage *image); +#define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event + +#ifdef CONFIG_HOTPLUG_CPU +static inline int crash_hotplug_cpu_support(void) { return 1; } +#define crash_hotplug_cpu_support crash_hotplug_cpu_support +#endif + +#ifdef CONFIG_MEMORY_HOTPLUG +static inline int crash_hotplug_memory_support(void) { return 1; } +#define crash_hotplug_memory_support crash_hotplug_memory_support +#endif +#endif + #endif /* __ASSEMBLY__ */ #endif /* _ASM_X86_KEXEC_H */ diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 8a9bc9807813..5c9e01fe27f5 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,67 @@ int crash_load_segments(struct kimage *image) return ret; } #endif /* CONFIG_KEXEC_FILE */ + +#ifdef CONFIG_CRASH_HOTPLUG + +#undef pr_fmt +#define pr_fmt(fmt) "crash hp: " fmt + +/** + * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes + * @image: the active struct kimage + * + * The new elfcorehdr is prepared in a kernel buffer, and then it is + * written on top of the existing/old elfcorehdr. + */ +void arch_crash_handle_hotplug_event(struct kimage *image) +{ + void *elfbuf = NULL, *old_elfcorehdr; + unsigned long nr_mem_ranges; + unsigned long mem, memsz; + unsigned long elfsz = 0; + + /* + * Create the new elfcorehdr reflecting the changes to CPU and/or + * memory resources. + */ + if (prepare_elf_headers(image, &elfbuf, &elfsz, &nr_mem_ranges)) { + pr_err("unable to prepare elfcore headers"); + goto out; + } + + /* + * Obtain address and size of the elfcorehdr segment, and + * check it against the new elfcorehdr buffer. + */ + mem = image->segment[image->elfcorehdr_index].mem; + memsz = image->segment[image->elfcorehdr_index].memsz; + if (elfsz > memsz) { + pr_err("update elfcorehdr elfsz %lu > memsz %lu", + elfsz, memsz); + goto out; + } + + /* + * Copy new elfcorehdr over the old elfcorehdr at destination. + */ + old_elfcorehdr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT)); + if (!old_elfcorehdr) { + pr_err("updating elfcorehdr failed\n"); + goto out; + } + + /* + * Temporarily invalidate the crash image while the + * elfcorehdr is updated. + */ + xchg(&kexec_crash_image, NULL); + memcpy_flushcache(old_elfcorehdr, elfbuf, elfsz); + xchg(&kexec_crash_image, image); + kunmap_local(old_elfcorehdr); + pr_debug("updated elfcorehdr\n"); + +out: + vfree(elfbuf); +} +#endif