From patchwork Mon Jun 12 21:07:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 106902 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp141558vqr; Mon, 12 Jun 2023 14:25:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4dH5mFefbFVAz1U+tWGSPF2sOypH6PlU8yTnpgRSKLmF2DzE2PEQasXci7ZduH2GzTxFHu X-Received: by 2002:a17:90b:4b06:b0:255:cddf:a0c8 with SMTP id lx6-20020a17090b4b0600b00255cddfa0c8mr9026857pjb.41.1686605142457; Mon, 12 Jun 2023 14:25:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686605142; cv=pass; d=google.com; s=arc-20160816; b=biaw5hjzorNNHuoYn/K6YZcWKewnFULNbFRbAHkIHMf8sP3R1VOVwl9Bity040VTaj uP8JJPBK0wvUjM/sTYo5TFUQshbrAIED0Oa/SeBA+bw7HdyT0hIh5GVPbnir0lkgiRoF Fvs6ShAikgh/ySFOntaD3dE/tMjXttvkCCOTo1ncr+NGJtm/LZ8lkwLRxzS92+WzL7BX oH6TT4dL1uSEXLBdmCDiQeQKb65nhwB1pWOemJoo7wjtNGVuoOfXqPpjVh9uuCYPajRE vFHrvFP63YY30sJh6ZvMWrYRkR06PS74WkvtcOquPAxVI1TSCWEn5sJ+JC54mgpLRgZp 9d+g== 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=HSzcNdlJygzAbc0ZvnOKimbjFfFfH/fTWMiHEhLyWts=; b=Zb/vgzW2rAJ0o2LZSQhTWp/nXdzYLqq3ETxoCsCFX9XBffGk+O7g8CnGPs+f65jFME natdhwjfzr5oI7RSVh0yOXEaC8xK92Zx4R0Wf+Ipa9bf8sd7WbuyjvVQaAythbERX3hH UZWOo6ADleWGzfdBS5+qsqV2HVXtvVnxqHXqXTaptvg3/ydOjRYSMi82SmA/KdgKgAga 1Co/0mrrm6ao/n75bTg2rAnkQiitRdtetacd2pAkBFSbdzVnh6FOGOY7IwvxzsuwnUZc i5uAsnUz6QkhwiUUfwTVeQV2om3Jm7I5l1mW2IdXwcq3xHp21JCCX56KGjPceGEX0td1 LfAw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=bja8m4Is; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="vYd/qi19"; 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 f12-20020a170902ce8c00b001b382b2d2fdsi4201351plg.144.2023.06.12.14.25.28; Mon, 12 Jun 2023 14:25:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=bja8m4Is; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="vYd/qi19"; 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 S238724AbjFLVOV (ORCPT + 99 others); Mon, 12 Jun 2023 17:14:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237919AbjFLVNY (ORCPT ); Mon, 12 Jun 2023 17:13:24 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0BC1187; Mon, 12 Jun 2023 14:08:11 -0700 (PDT) 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 35CKO2s5029142; Mon, 12 Jun 2023 21:07:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=HSzcNdlJygzAbc0ZvnOKimbjFfFfH/fTWMiHEhLyWts=; b=bja8m4Is+ne9VGH97LRdVKlQjgle5SwdvCjpTaqX9RR2zmYOKXm6n6zmjbu+PLY4SxH1 6MwhyRF53Ot2imnEodBV09/gEqaWnlPIeAMHuRdbL8rw6cy4udNNDFUYcnlZvRgWV+Qb Ymy6tVst0Ug13Bb3NGpwN24PFVScCTvjkTxI/dsPRvDFFqqjCNoaApnlxZYRlniMM209 ggfGqZODDWUbs7ElFYkQ0ckrBHe0o7eAf19QLWqpJQHEwIKI9et5oITvCua5H+Axm8du bNV4recklW6sir3IXV9OLc09BmpTI6KSuMf5GngbB3WqjMA/5rNeWQTMpnpKH7XIVI3M mQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3r4g3bkytb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:34 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35CKTajR021673; Mon, 12 Jun 2023 21:07:34 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2101.outbound.protection.outlook.com [104.47.55.101]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r4fm3a84b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PE3qu9q3cdyUYZXAwlKPqdILXbRxa5xfiC7jYVcEzaOJxWQB7GwK/tE5GYhD4nKCHlJ+qP8zaCUP9UqCqPPdrCVc4Lfd3M94A7pexz7gEBBn9SirsjaMEiwX5FufqU4BdOqbUxdrRaT+ytRhI/XDcJKhEBcZsEU7dROw1J/UlcGt4aJx3MSJJEOH4aY+sf/jYEQn9wZOvwzSurVQDe00H+2yu5ApHd92c02tZlKObhkAFqKg5PXNCjY36BTEFUWZVV4mx5TNOMn9NyNomm2zcTMdnGthBqfNDhIbVRfBEjLbK+oXdX2CGMGiRBjJflJNPBYt2wuuOKsdLKgSRujIYQ== 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=HSzcNdlJygzAbc0ZvnOKimbjFfFfH/fTWMiHEhLyWts=; b=Wv3HQo0MevxC4qw+nH+J6rxl9fHt3dlvqABCe6a5YKEJGDNB4qRu+1glPeZDQoJ9GdGq8qL5d/EL2TlnHWMS1JDmbBP/ArNsNJfAEvtEBXCHVEFTW66ielIncAOOQtAD6zFHsFyL3GmeqMKufXuFUA2/3xqF5UDisR7qqL4pbOzrnJD9IaTh0hfKJW64awmnUyrHWFDYb7Lod7f6Vc4DA3tz8ufEpNe3HlKh/YYEqjs2KijGYiwcBe4Ihuij3i91O6N1ZUk9GmaHXQRcjwN0Cv70Sv/OXWFKIVVqnqFbiZiU83mtLjQsMGjaN+wRUYWMU5i8Le7BVCVMocp4WWGJqw== 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=HSzcNdlJygzAbc0ZvnOKimbjFfFfH/fTWMiHEhLyWts=; b=vYd/qi19o/fAp6n1FzfxzmkI19N1FRspIb9atdJsr7RzL9d719rz3EQNlXXEzrSHUHH9QfpCODu5iTtyq1irubbN5KCg9VnVOyJ0FjZpmoUk7uk2xzcv2HX+lO50GdLP2tQScixJrOcidgU6AgKb+yuxLnm1AnPPFSeiYFj6/Z0= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DM4PR10MB5966.namprd10.prod.outlook.com (2603:10b6:8:b2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.44; Mon, 12 Jun 2023 21:07:31 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6477.028; Mon, 12 Jun 2023 21:07:31 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v23 1/8] crash: move a few code bits to setup support of crash hotplug Date: Mon, 12 Jun 2023 17:07:05 -0400 Message-Id: <20230612210712.683175-2-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230612210712.683175-1-eric.devolder@oracle.com> References: <20230612210712.683175-1-eric.devolder@oracle.com> X-ClientProxiedBy: LO4P265CA0023.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ae::13) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|DM4PR10MB5966:EE_ X-MS-Office365-Filtering-Correlation-Id: d0b6259c-0c87-47bb-29a7-08db6b890918 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dU42Ufi1AmbhuRSfus8kFGgWIVZdnC5QVXRsCJI2Zmi6Bch2IeLEtrYitotJeJUXTmOm3NT7ynLGvl4G3ZLBVTM+QYcQD/blR+dUEtEIcvkVd+RF6x5lxcfpirTMHAiRUzKSgv84aQH6zZUUcs8nGBRgjoEhfodmepijkDzVx2a7QvCCHjvfXpmh6mx4IzOo0FDmBGOKxfHowkYR8QsqJTHfS5ZZjdcI1MWBqCsZbtjAQJ+8OKTfQI6IAi7SbECvrwofDE1xj3474usZOA0AwVI/gctrMkIm2DnFESm0nZtIYTAGL8EtUV5hUfZchM4Z6QN3D3I1kuJbJb1aQ4vinRIYyDLG1MrzAfvkNZwf/xqIgSmMj3xVgFcWGHbpfvSst5UrAjZIkp/2zOpppZMaKkrVcEaC08BGEVSkoqCYsub1Lld7Wqf5286V9lJ2pVHh/RBt7kimnl7FR8EbY2snfOSVdKpYy7AEmS0EPILVbQ9v7yBr6+xwb46KpnajN1dBR1igSRgeIGhU1TFcTH5RJIaEYwQjcey41gc0ORE18m9fSgzH//bQLXLdwpeApJAi1BlEQVYr4j0XaEAyvkUW4R0ajdGp0WaTejvxltVnqTc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(376002)(346002)(366004)(136003)(396003)(451199021)(86362001)(36756003)(30864003)(2906002)(26005)(6512007)(1076003)(6506007)(186003)(107886003)(7416002)(7406005)(41300700001)(83380400001)(478600001)(6666004)(8676002)(5660300002)(8936002)(4326008)(2616005)(66476007)(316002)(6486002)(66946007)(66556008)(38100700002)(921005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e/xX4H4a1oKa7oMWwheYsOmLHasEADguDUZjekPIslXTn391STksXWD1yV+bEha+olArPEtS8r2rcdO33DDOb2GFjEy1OLhkpYfbuGppDFhoAqMpgoEaG43/7DUm/iBuzITpFgrHO1IkFtW2/1IcY/qbKJe2Bg5ojtDqTqY++/nqJHaa0OHlt/I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ciKI+ZtkaO5IFuONnwZDjjs62DaVIy/eJiOjkDcsrYZA+BLrlYlwy0NVJh6oguBiPmuzaz7/SEbsbpqUIZl5UfKlejxBSQn76OXm4joRejY0eE8G1ehH6h2Wwx5ly0WLaQfi4g6MMUbMihKSQS0zwK+xTs+6+EtYrTlUtug4oqD2Hl1JbqXnhdvIhR8sSh2EWGjUo8+4JZV/9cXQiulPeqWmiQ+9UE+TeZRjEm6itlnb6D92FU3ECMNBCWMWknaa0/BWjdwEmMgbMkglceM9k+N1Si81/hiX36ASo4RZPC+i+jHC5zLRQrLoSojM9GlP9kvxzw7qXDOziRNXxQVN/DXH2fpxtOe20ccFxPxkEpdtKkKLQAum1GHvoNAqgzXJYUsZkxV/11Z73T02C5gHLnXNV14syQGlx+6qEfwRij4bQFYtTnmjxwJ6HstSNWP/q/++wBKtFGOCREsg+M84QC1/Df5UO66VauNHU3lhhWTRjHnquuMxg7F+LFjby1s3up5K30DEqcHYFFnqvtCCLQu6D6pksVzVDFJTT8n2R4iUM3utznCDgPA4G2/B/m7I7kbBG+ukVX7URX88bgAo6/lorLZldWOoZuwDPY6wonUAvg6iehihUU2/eGunxA8YC+esq9LTorKlCyuitBHYKTa+3VJORdR8nllXOrmoD9pQwQ1Zj5cfsjEW7j6BG+6nxJmIIaEVulUxvSEFtThBW6tCuu2Hwb6PEl+RcWthsLMvtoM4B2FQ81EjwdcOsre8XvpnpJ708nVD+pxBWfycPhQOCVDZtTY4C/Ll4OAzqbHI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0b6259c-0c87-47bb-29a7-08db6b890918 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 21:07:31.2084 (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: 1g/ueBZAMq7RmANweoNQYgbiwHAIRH6QlxgabEj3FAOa3H/tAKRgM2t+z344RJZDTM6Gs1/jTBl/yYvm+TLhlk0jXaPckC1rL3Ts8Y5BmFY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB5966 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-12_16,2023-06-12_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306120180 X-Proofpoint-ORIG-GUID: EVFxPqTm8TNvzGcDQai4qDUseDJhFpjY X-Proofpoint-GUID: EVFxPqTm8TNvzGcDQai4qDUseDJhFpjY 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_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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?1768533673427257097?= X-GMAIL-MSGID: =?utf-8?q?1768533673427257097?= The crash hotplug support leans on the work for the kexec_file_load() syscall. To also support the kexec_load() syscall, a few bits of code need to be move outside of CONFIG_KEXEC_FILE. As such, these bits are moved out of kexec_file.c and into a common location crash_core.c. No functionality change intended. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- include/linux/kexec.h | 30 +++---- kernel/crash_core.c | 182 ++++++++++++++++++++++++++++++++++++++++++ kernel/kexec_file.c | 181 ----------------------------------------- 3 files changed, 197 insertions(+), 196 deletions(-) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 22b5cd24f581..811a90e09698 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -105,6 +105,21 @@ struct compat_kexec_segment { }; #endif +/* Alignment required for elf header segment */ +#define ELF_CORE_HEADER_ALIGN 4096 + +struct crash_mem { + unsigned int max_nr_ranges; + unsigned int nr_ranges; + struct range ranges[]; +}; + +extern int crash_exclude_mem_range(struct crash_mem *mem, + unsigned long long mstart, + unsigned long long mend); +extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, + void **addr, unsigned long *sz); + #ifdef CONFIG_KEXEC_FILE struct purgatory_info { /* @@ -230,21 +245,6 @@ static inline int arch_kexec_locate_mem_hole(struct kexec_buf *kbuf) } #endif -/* Alignment required for elf header segment */ -#define ELF_CORE_HEADER_ALIGN 4096 - -struct crash_mem { - unsigned int max_nr_ranges; - unsigned int nr_ranges; - struct range ranges[]; -}; - -extern int crash_exclude_mem_range(struct crash_mem *mem, - unsigned long long mstart, - unsigned long long mend); -extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, - void **addr, unsigned long *sz); - #ifndef arch_kexec_apply_relocations_add /* * arch_kexec_apply_relocations_add - apply relocations of type RELA diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 90ce1dfd591c..b7c30b748a16 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -314,6 +315,187 @@ static int __init parse_crashkernel_dummy(char *arg) } early_param("crashkernel", parse_crashkernel_dummy); +int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, + void **addr, unsigned long *sz) +{ + Elf64_Ehdr *ehdr; + Elf64_Phdr *phdr; + unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz; + unsigned char *buf; + unsigned int cpu, i; + unsigned long long notes_addr; + unsigned long mstart, mend; + + /* extra phdr for vmcoreinfo ELF note */ + nr_phdr = nr_cpus + 1; + nr_phdr += mem->nr_ranges; + + /* + * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping + * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64). + * I think this is required by tools like gdb. So same physical + * memory will be mapped in two ELF headers. One will contain kernel + * text virtual addresses and other will have __va(physical) addresses. + */ + + nr_phdr++; + elf_sz = sizeof(Elf64_Ehdr) + nr_phdr * sizeof(Elf64_Phdr); + elf_sz = ALIGN(elf_sz, ELF_CORE_HEADER_ALIGN); + + buf = vzalloc(elf_sz); + if (!buf) + return -ENOMEM; + + ehdr = (Elf64_Ehdr *)buf; + phdr = (Elf64_Phdr *)(ehdr + 1); + memcpy(ehdr->e_ident, ELFMAG, SELFMAG); + ehdr->e_ident[EI_CLASS] = ELFCLASS64; + ehdr->e_ident[EI_DATA] = ELFDATA2LSB; + ehdr->e_ident[EI_VERSION] = EV_CURRENT; + ehdr->e_ident[EI_OSABI] = ELF_OSABI; + memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD); + ehdr->e_type = ET_CORE; + ehdr->e_machine = ELF_ARCH; + ehdr->e_version = EV_CURRENT; + ehdr->e_phoff = sizeof(Elf64_Ehdr); + ehdr->e_ehsize = sizeof(Elf64_Ehdr); + ehdr->e_phentsize = sizeof(Elf64_Phdr); + + /* Prepare one phdr of type PT_NOTE for each present CPU */ + for_each_present_cpu(cpu) { + phdr->p_type = PT_NOTE; + notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); + phdr->p_offset = phdr->p_paddr = notes_addr; + phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); + (ehdr->e_phnum)++; + phdr++; + } + + /* Prepare one PT_NOTE header for vmcoreinfo */ + phdr->p_type = PT_NOTE; + phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note(); + phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; + (ehdr->e_phnum)++; + phdr++; + + /* Prepare PT_LOAD type program header for kernel text region */ + if (need_kernel_map) { + phdr->p_type = PT_LOAD; + phdr->p_flags = PF_R|PF_W|PF_X; + phdr->p_vaddr = (unsigned long) _text; + phdr->p_filesz = phdr->p_memsz = _end - _text; + phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); + ehdr->e_phnum++; + phdr++; + } + + /* Go through all the ranges in mem->ranges[] and prepare phdr */ + for (i = 0; i < mem->nr_ranges; i++) { + mstart = mem->ranges[i].start; + mend = mem->ranges[i].end; + + phdr->p_type = PT_LOAD; + phdr->p_flags = PF_R|PF_W|PF_X; + phdr->p_offset = mstart; + + phdr->p_paddr = mstart; + phdr->p_vaddr = (unsigned long) __va(mstart); + phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; + phdr->p_align = 0; + ehdr->e_phnum++; + pr_debug("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n", + phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, + ehdr->e_phnum, phdr->p_offset); + phdr++; + } + + *addr = buf; + *sz = elf_sz; + return 0; +} + +int crash_exclude_mem_range(struct crash_mem *mem, + unsigned long long mstart, unsigned long long mend) +{ + int i, j; + unsigned long long start, end, p_start, p_end; + struct range temp_range = {0, 0}; + + for (i = 0; i < mem->nr_ranges; i++) { + start = mem->ranges[i].start; + end = mem->ranges[i].end; + p_start = mstart; + p_end = mend; + + if (mstart > end || mend < start) + continue; + + /* Truncate any area outside of range */ + if (mstart < start) + p_start = start; + if (mend > end) + p_end = end; + + /* Found completely overlapping range */ + if (p_start == start && p_end == end) { + mem->ranges[i].start = 0; + mem->ranges[i].end = 0; + if (i < mem->nr_ranges - 1) { + /* Shift rest of the ranges to left */ + for (j = i; j < mem->nr_ranges - 1; j++) { + mem->ranges[j].start = + mem->ranges[j+1].start; + mem->ranges[j].end = + mem->ranges[j+1].end; + } + + /* + * Continue to check if there are another overlapping ranges + * from the current position because of shifting the above + * mem ranges. + */ + i--; + mem->nr_ranges--; + continue; + } + mem->nr_ranges--; + return 0; + } + + if (p_start > start && p_end < end) { + /* Split original range */ + mem->ranges[i].end = p_start - 1; + temp_range.start = p_end + 1; + temp_range.end = end; + } else if (p_start != start) + mem->ranges[i].end = p_start - 1; + else + mem->ranges[i].start = p_end + 1; + break; + } + + /* If a split happened, add the split to array */ + if (!temp_range.end) + return 0; + + /* Split happened */ + if (i == mem->max_nr_ranges - 1) + return -ENOMEM; + + /* Location where new range should go */ + j = i + 1; + if (j < mem->nr_ranges) { + /* Move over all ranges one slot towards the end */ + for (i = mem->nr_ranges - 1; i >= j; i--) + mem->ranges[i + 1] = mem->ranges[i]; + } + + mem->ranges[j].start = temp_range.start; + mem->ranges[j].end = temp_range.end; + mem->nr_ranges++; + return 0; +} + Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type, void *data, size_t data_len) { diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index f989f5f1933b..f8b1797b3ec9 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -1138,184 +1138,3 @@ int kexec_purgatory_get_set_symbol(struct kimage *image, const char *name, return 0; } #endif /* CONFIG_ARCH_HAS_KEXEC_PURGATORY */ - -int crash_exclude_mem_range(struct crash_mem *mem, - unsigned long long mstart, unsigned long long mend) -{ - int i, j; - unsigned long long start, end, p_start, p_end; - struct range temp_range = {0, 0}; - - for (i = 0; i < mem->nr_ranges; i++) { - start = mem->ranges[i].start; - end = mem->ranges[i].end; - p_start = mstart; - p_end = mend; - - if (mstart > end || mend < start) - continue; - - /* Truncate any area outside of range */ - if (mstart < start) - p_start = start; - if (mend > end) - p_end = end; - - /* Found completely overlapping range */ - if (p_start == start && p_end == end) { - mem->ranges[i].start = 0; - mem->ranges[i].end = 0; - if (i < mem->nr_ranges - 1) { - /* Shift rest of the ranges to left */ - for (j = i; j < mem->nr_ranges - 1; j++) { - mem->ranges[j].start = - mem->ranges[j+1].start; - mem->ranges[j].end = - mem->ranges[j+1].end; - } - - /* - * Continue to check if there are another overlapping ranges - * from the current position because of shifting the above - * mem ranges. - */ - i--; - mem->nr_ranges--; - continue; - } - mem->nr_ranges--; - return 0; - } - - if (p_start > start && p_end < end) { - /* Split original range */ - mem->ranges[i].end = p_start - 1; - temp_range.start = p_end + 1; - temp_range.end = end; - } else if (p_start != start) - mem->ranges[i].end = p_start - 1; - else - mem->ranges[i].start = p_end + 1; - break; - } - - /* If a split happened, add the split to array */ - if (!temp_range.end) - return 0; - - /* Split happened */ - if (i == mem->max_nr_ranges - 1) - return -ENOMEM; - - /* Location where new range should go */ - j = i + 1; - if (j < mem->nr_ranges) { - /* Move over all ranges one slot towards the end */ - for (i = mem->nr_ranges - 1; i >= j; i--) - mem->ranges[i + 1] = mem->ranges[i]; - } - - mem->ranges[j].start = temp_range.start; - mem->ranges[j].end = temp_range.end; - mem->nr_ranges++; - return 0; -} - -int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, - void **addr, unsigned long *sz) -{ - Elf64_Ehdr *ehdr; - Elf64_Phdr *phdr; - unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz; - unsigned char *buf; - unsigned int cpu, i; - unsigned long long notes_addr; - unsigned long mstart, mend; - - /* extra phdr for vmcoreinfo ELF note */ - nr_phdr = nr_cpus + 1; - nr_phdr += mem->nr_ranges; - - /* - * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping - * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64). - * I think this is required by tools like gdb. So same physical - * memory will be mapped in two ELF headers. One will contain kernel - * text virtual addresses and other will have __va(physical) addresses. - */ - - nr_phdr++; - elf_sz = sizeof(Elf64_Ehdr) + nr_phdr * sizeof(Elf64_Phdr); - elf_sz = ALIGN(elf_sz, ELF_CORE_HEADER_ALIGN); - - buf = vzalloc(elf_sz); - if (!buf) - return -ENOMEM; - - ehdr = (Elf64_Ehdr *)buf; - phdr = (Elf64_Phdr *)(ehdr + 1); - memcpy(ehdr->e_ident, ELFMAG, SELFMAG); - ehdr->e_ident[EI_CLASS] = ELFCLASS64; - ehdr->e_ident[EI_DATA] = ELFDATA2LSB; - ehdr->e_ident[EI_VERSION] = EV_CURRENT; - ehdr->e_ident[EI_OSABI] = ELF_OSABI; - memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD); - ehdr->e_type = ET_CORE; - ehdr->e_machine = ELF_ARCH; - ehdr->e_version = EV_CURRENT; - ehdr->e_phoff = sizeof(Elf64_Ehdr); - ehdr->e_ehsize = sizeof(Elf64_Ehdr); - ehdr->e_phentsize = sizeof(Elf64_Phdr); - - /* Prepare one phdr of type PT_NOTE for each present CPU */ - for_each_present_cpu(cpu) { - phdr->p_type = PT_NOTE; - notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); - phdr->p_offset = phdr->p_paddr = notes_addr; - phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); - (ehdr->e_phnum)++; - phdr++; - } - - /* Prepare one PT_NOTE header for vmcoreinfo */ - phdr->p_type = PT_NOTE; - phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note(); - phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; - (ehdr->e_phnum)++; - phdr++; - - /* Prepare PT_LOAD type program header for kernel text region */ - if (need_kernel_map) { - phdr->p_type = PT_LOAD; - phdr->p_flags = PF_R|PF_W|PF_X; - phdr->p_vaddr = (unsigned long) _text; - phdr->p_filesz = phdr->p_memsz = _end - _text; - phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); - ehdr->e_phnum++; - phdr++; - } - - /* Go through all the ranges in mem->ranges[] and prepare phdr */ - for (i = 0; i < mem->nr_ranges; i++) { - mstart = mem->ranges[i].start; - mend = mem->ranges[i].end; - - phdr->p_type = PT_LOAD; - phdr->p_flags = PF_R|PF_W|PF_X; - phdr->p_offset = mstart; - - phdr->p_paddr = mstart; - phdr->p_vaddr = (unsigned long) __va(mstart); - phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; - phdr->p_align = 0; - ehdr->e_phnum++; - pr_debug("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n", - phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, - ehdr->e_phnum, phdr->p_offset); - phdr++; - } - - *addr = buf; - *sz = elf_sz; - return 0; -} From patchwork Mon Jun 12 21:07:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 106895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp139091vqr; Mon, 12 Jun 2023 14:19:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ607S3VaXXQyPqICZhsiy3Fj3DKNLpBis6x3HjZVzr6sRi5y7ssVp4RtHAyAWFUV9b7hk8h X-Received: by 2002:a50:fb94:0:b0:509:c6e6:c002 with SMTP id e20-20020a50fb94000000b00509c6e6c002mr5207240edq.39.1686604785303; Mon, 12 Jun 2023 14:19:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686604785; cv=pass; d=google.com; s=arc-20160816; b=QAeHUshgqRberCzbqNXcMseLzRBAS5bkBfpRo1eiV1NGowx1pfmDuCO8lA6yURe1hJ dHEvBIFf0Htw9BSaZsrFIeTq95wQum/iVZOrmdJCbeb7Z4C4CaLxTsq8Sq465TpSEc49 H68G/mnO08fq9NggJS+C1wFLssQ61CZ6Ak6ITzMXhGqFulE4dtnXM3C0ZEHltQdAX/aM ct2M4vTBRylQZMOXefvN3qwBzm0fJ6a0yR9sZRi+N5quUKjWEojLC+Pk+vBTHoXy/RuD iLOLIerV20M+/jOiZDU7lKIbq8wu6gqd6d/bWHC03MP+U/4XuAcghe+pHTWkdhQ6ld8i zgCA== 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=emdauTTQb/aXDwONd7tM3PBloeLeEdXW7mhte0QrtjQ=; b=yKiE05vgLxvbS5W1wOHRBLp5LnCEfWQRvxeTHEr8Xw7bO9LKfGh+GT4yaI7d1MhEY7 rYCrtpHDwCmxloIdDEa64qSWtsqf0J2Lv1gL8SIWKKbGBL0yUXRksl2UQE7A8W9OsGOd reK6SIF7/MILM3S9kN+7x8mB88vTUJ+7EQUENe+wMfrUcTPWewS8wwfJuAXtiHQQwFTp U7aypb0Q3yfaBBv3iThUqKUNYF6Cxelu8yDfB/mi2rqxRdMyCx5g/vekaE4qCekIYuDn RQmIvCXqJZCys7Fxix5ilj5uwAeTsB4IT7pBkb46Lccd7K7KVgzUD/wwAgtscy9eh1yG MdGg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b="2IMRK/+k"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=VGF6YV7E; 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 n23-20020aa7c457000000b0050bc6b7830fsi6000980edr.306.2023.06.12.14.19.19; Mon, 12 Jun 2023 14:19:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b="2IMRK/+k"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=VGF6YV7E; 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 S238446AbjFLVO0 (ORCPT + 99 others); Mon, 12 Jun 2023 17:14:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233111AbjFLVN6 (ORCPT ); Mon, 12 Jun 2023 17:13:58 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DB66211C; Mon, 12 Jun 2023 14:08:17 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35CKOQvm003977; Mon, 12 Jun 2023 21:07:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=emdauTTQb/aXDwONd7tM3PBloeLeEdXW7mhte0QrtjQ=; b=2IMRK/+kEeiVrQ4JEHuRwRZs5jMnkK0WgaYA0OxZnTHgxOVfghQG4L0GaEB2vPEu8w2+ HkoBmlt2UQRYvgNnkYmnNp19QBd7EH1ON7dp32+48dR50UIHHexZ9SYwBmGXB/7WdL6q tU8nA4bDtdDEz0Adc67XKiTbdty4W8F9oa3ZxBZEKwcGGjXTWnaLK8/s3iFkYRjSwjQg GCFV0BwfcKHoz5o1MsiDAFMJg/tWYk9IHjtVFtMxI3zluRR3TycqZVdiRvSpA3+V7BnF HzFKdGCCO2++GvQxtAnCvVuEu1RVCprLk2n5rRMCxFx15o7LMOl7LuRhRmZ1J7sh04yV eg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3r4fs1uyup-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:42 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35CKZN8s014146; Mon, 12 Jun 2023 21:07:41 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2109.outbound.protection.outlook.com [104.47.55.109]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r4fm321h5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GMnIDIJR6Wsu7XNJvZkv9efDVRYv+Z/8Q58TgElYg0ql93kYwMI17DguHsE62xIrE75yFHvJnUOVrpDUkHR+ZVPb6qQalx0PPjrhyj57SKagmr3IhaSdLgpQDjAarmwmrsnHwdDU24Vht8Jflz22yw5bi3pnDJpcDitqAFTuBlGdT/o5XpQLafRv9GSm/axzMz8DzXtwTcBj2+MWUH0thrdYiavz6Tb82PKNQVTkBQtmd74MlI0eoVxQ7eJS97Wk+kar8PGxJd+wg73feXB8Tk+FowJKZTQf/pB2Bev2wBUkY9rZprWH37+xb6BDlmFwJuHEq2hb0/qH5o3Gn1riwQ== 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=emdauTTQb/aXDwONd7tM3PBloeLeEdXW7mhte0QrtjQ=; b=csTo+yTJg4S6zW+pNvqp7dOTe3j4gfDUVJviZdmi+xTDd/d12n8r54kfySR1WlHExAVcOBmWKy1oVmgjsGhg5KzvsKMqkZzYv27T58zqp6RpoWi4AKFw/YJ4WWF5Cqbd8gD+SbYp3nVjZlutzYDfQp4FlX/nWtvpwP8SiPIfXmciWggiO8dcAwo7MgI8xvZBdJ5Z8rZ3rVpTTFFX+ic3QY/WKMni+aYn01K4/Pu/UqX9BWHHNiFwhS2gnME/VRfR/LE/5wiCWLNOCurd4HYnV3TRLj9sxIEunVEbzcrUScCva0FnlsgfESsiLGgahy2n8HohkyWiSvKEkR5YdTLGaQ== 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=emdauTTQb/aXDwONd7tM3PBloeLeEdXW7mhte0QrtjQ=; b=VGF6YV7ECbysJoZ2wvBE+MQy6Gh71iTPztCMcxNnpFD1T9y9R37eBhbjuX6aF1D2/JSvN+8ivBOjF4GTYzSXbZyIeDKxUAOgjbyb31NAfyMyQy3fkIYgjgiKtSKgjDudP98Ge81bOWYFR0XSqoLumgeJA28J6QFAR1qKcxOQtvE= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DM4PR10MB5966.namprd10.prod.outlook.com (2603:10b6:8:b2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.44; Mon, 12 Jun 2023 21:07:38 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6477.028; Mon, 12 Jun 2023 21:07:38 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v23 2/8] crash: add generic infrastructure for crash hotplug support Date: Mon, 12 Jun 2023 17:07:06 -0400 Message-Id: <20230612210712.683175-3-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230612210712.683175-1-eric.devolder@oracle.com> References: <20230612210712.683175-1-eric.devolder@oracle.com> X-ClientProxiedBy: LO4P123CA0347.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18d::10) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|DM4PR10MB5966:EE_ X-MS-Office365-Filtering-Correlation-Id: 09e4b938-6d00-4e6f-5180-08db6b890d20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gL/NpgSH/LUnUbUOTsqGdXEjz/1lR6t19uEntZa35XTtuwlkG4Bcp8se2n2fsbmKfm8Z0+/RbuMUK7OxPvtRVracCIARlJlfka9PhfTpkIA/b51u335uK04A1bWfS6DVvYuw7GH9X4DqmZqWCf7PLT7rDo3Z+hx8fydZ3Tmd/HxQ0BB3kZQV50/Ea1YpERyVtKXfRAOk0aqpwrOZl6QE7aehOjGjakSPazJJmxKrUknKpEE1khFvNLjLGTBg9vmaVFVEgZ6CLVqDZEWXvdjMOfm06J/T0SE9TZ6BxpnVWoidxTNZvMocJGrxXqBTo5vBPJHsfW+duXIuvDmcBIF5iUP/RcpiPR9+XiW8swgyJnlkMrDLR/6DRn8XHGXsdNvfKyMgxzS45lQ7CFOOUUkoXy0nWPszxvGiPIA3OIkIDdaYxM1w9Ib7Ziw2+4ExJ0rl2roxTQS66GezOS9XM4SsS38s3FWvlCtMgwFV/aH6qwXqImXzQcShzqxsyMn/mSzu430/oWGFIwNB5G4+NZZn5ivIeb0i3OXJaZmBVaXYvIYr1+DHoamRCAhQRSfqvcyLFQL3BOzsIgaPE82xEkdT9Pcb+378nKPScUzwu3TVRjBD76UC1L7os8Hqj5CywGCJ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(376002)(346002)(366004)(136003)(396003)(451199021)(86362001)(36756003)(30864003)(2906002)(26005)(6512007)(1076003)(6506007)(186003)(107886003)(7416002)(7406005)(41300700001)(83380400001)(478600001)(6666004)(8676002)(5660300002)(8936002)(4326008)(2616005)(66476007)(316002)(6486002)(66946007)(66556008)(38100700002)(921005)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hTQtZAhnPbNVzmCSqRv/BqlwLRi/UQJq7i/Alr49qZIymMhpHcV4JC3XsYnO5BfWas7CJSFUWJ17kAKIo2zSOY3z0C4gwze4Lu1vwp0crcjEyEsL4Gn10kL6hdJ/3e1CA5UhW8Y9WTprt+5yc4AvVU/69BXwkmzyHC6NLKqsLDcKHGiNp1ojxCYeYkyfjh2Rv7pv08OzvdlLHBb1TRRlMAKL/yZepVENztrWGRKL87jBM9akUSHxVsB6eeQqtFwg47ptLqdPavBGgQx3BkP0mO53dlKGA6VSVo9yAjZXsE6gtbuSkyKqi/q88j1OBw0nf7s6ulZmkA4C7FxzDK/wNKsaMy+EUgvWrDInOa/yxcx1cegBoBG7TwzdvJ4S/wFsIRnJJepWYzKoo6/EqDMZ0VqaDBVouqlpBNGkRal5p8RpzyOMjYTX7BfxH+4jbEBDFX18BS7eUz4FQIPFEBaiNoaY2EmqXPb7aKxklBpB/ltSaSpG5JS0c65EKZQ4pVKxgNtjGyIxT1dEtYbhuArumwPQWk7FIqlCdTaq5PdaGbfFZ5s//gkci4GrvL464zbwoTzKjiJ3lSmK/YLBxFtTWTuaoP6FMX5PT8ZRf4PoqeLDDqulcJrCoH5uIEZYaHRQldHvgrEjt06xSL+9vWBpQ3csuopb6fPqE9wexi5njI5utW38tENjQW7x3rPdmhEbSJ0HJk+RSahskMN0o3eSgnUstXBLudQkAjp/AJiPg1+kGaQxr4gFUqAQw/UWB8xbgiO85OHQYN06ncwq6aKMmWHNEkSLFJckJktWdXGl6P5pdp12WXtFPKh/yGTLvyVstcJe1EGT6v0Aum1IegnUDcLy+jsrSwc5e8sookEx9qKDuzGIwqsYjWGe030tQcaBv6SFt3GCd9lt3aYo9W2WirsqQ5xZcjjGJ/xskTylB352jJk7AqrHgW6IYKoEmyUaGqppYrmvd+84/efUi9fPPq8hz5RdPxrA/4ytP/+o6wzJXHJgIiMAMzD30HonK27xAMvQmASetx2+3sXlMmUc2UV0fatEucVKw4LxI5yRvkKpg/RB8iKe7GF3KehME69wrVjiIINnu9j5GN2Fitax7QkyRSBY7y8ulSARVoi4FZrxH1Sleni3+BtPc3/m8JnIAqkZjkeXnk+Gi9L/6fmtHdOQchr500dH0hY07Exp11MECsNJGMwG3PSaRivveNYw4Gf0OuEadnENoOm5WCjSig/HW9RMAfzqBmGEY5BfUISHAreMLwAJ1RXxGrNy6q4SHb1BcH4ihHuVfuleQpGYUgS6JEBMeU1ak0WnimisRQWilD6iiIzNsdyhrG3D/9xAkpxB82J6de3y3o/AjTiy2RmW3N50qvjYwVGoWFjZ2G7DB//pBpDLKRLiaFLz41GSPOD1RAyQ4i29mKk0E+/20wjvwhiAtsk66ORG/IUnIZ0gcFcLG0tKNlLQap3GOBog9TPVSGESOEFHrIEiWuZJ4MZU/+lv61a0RraVbjVSza2Z3jAuXn2lce2qYDwmRpMca8bgtoytq0AYrz+QOkR0QLBBh3UvY4L+1SuDd5lonwckFRoprLTUJgTYTCuiFtl0B8LVruox3eo+AQi0ZDc/Fg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: +FixyZDYtNgSPnygyQu0XzEUkgrc+PBkUxKj1z2fKBtNEYE5iD+guwQHrHbHMVXRH7ofPG27aGN1cCAK8/ghlEbQm0qI6cjEUDmrrnqbokYFbLvkroYtN1UckofrrPaBhfSkvWi3DkDLbiObDTjOZF4R8S4Eb9YW5VycNvc7ZotizhcWL/6lirFzMI1kmcielGrRXpmGfxGpKgkcozv4XdIFFeMQp72p+jxe73D0hZ+F+UsFQYjwqny9WpWxSdud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1NEJDONM+FQed+aTwqh/rLc62fOXo1FElsFtYdhfNKfklRYc5vWfO8wTQT3eNNR7KtUCdJ1K+q1+p0AQr4fInR8SGa8n4qTvAAYLelY0WA= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09e4b938-6d00-4e6f-5180-08db6b890d20 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 21:07:38.0010 (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: 9ERnhu7H1WgD6Wr3IB/OFfZBGlfkxpEFA7bDNFn2jOnexRtT8B/Yf2QrJzdZn0VgL/6WqBLqudoFQoKbQRUaOuNjlm+kbg2mIH9fSODC0lk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB5966 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-12_16,2023-06-12_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306120180 X-Proofpoint-GUID: 6Mq04LbYqxE0VXwLMrfEUPIQV5lTXpii X-Proofpoint-ORIG-GUID: 6Mq04LbYqxE0VXwLMrfEUPIQV5lTXpii 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_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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?1768533299381681789?= X-GMAIL-MSGID: =?utf-8?q?1768533299381681789?= To support crash hotplug, a mechanism is needed to update the crash elfcorehdr upon CPU or memory changes (eg. hot un/plug or off/ onlining). The crash elfcorehdr describes the CPUs and memory to be written into the vmcore. To track CPU changes, callbacks are registered with the cpuhp mechanism via cpuhp_setup_state_nocalls(CPUHP_BP_PREPARE_DYN). The crash hotplug elfcorehdr update has no explicit ordering requirement (relative to other cpuhp states), so meets the criteria for utilizing CPUHP_BP_PREPARE_DYN. CPUHP_BP_PREPARE_DYN is a dynamic state and avoids the need to introduce a new state for crash hotplug. Also, CPUHP_BP_PREPARE_DYN is the last state in the PREPARE group, just prior to the STARTING group, which is very close to the CPU starting up in a plug/online situation, or stopping in a unplug/ offline situation. This minimizes the window of time during an actual plug/online or unplug/offline situation in which the elfcorehdr would be inaccurate. Note that for a CPU being unplugged or offlined, the CPU will still be present in the list of CPUs generated by crash_prepare_elf64_headers(). However, there is no need to explicitly omit the CPU, see justification in 'crash: change crash_prepare_elf64_headers() to for_each_possible_cpu()'. To track memory changes, a notifier is registered to capture the memblock MEM_ONLINE and MEM_OFFLINE events via register_memory_notifier(). The CPU callbacks and memory notifiers invoke crash_handle_hotplug_event() which performs needed tasks and then dispatches the event to the architecture specific arch_crash_handle_hotplug_event() to update the elfcorehdr with the current state of CPUs and memory. During the process, the kexec_lock is held. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- include/linux/crash_core.h | 9 +++ include/linux/kexec.h | 11 +++ kernel/Kconfig.kexec | 31 ++++++++ kernel/crash_core.c | 142 +++++++++++++++++++++++++++++++++++++ kernel/kexec_core.c | 6 ++ 5 files changed, 199 insertions(+) diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h index de62a722431e..e14345cc7a22 100644 --- a/include/linux/crash_core.h +++ b/include/linux/crash_core.h @@ -84,4 +84,13 @@ int parse_crashkernel_high(char *cmdline, unsigned long long system_ram, int parse_crashkernel_low(char *cmdline, unsigned long long system_ram, unsigned long long *crash_size, unsigned long long *crash_base); +#define KEXEC_CRASH_HP_NONE 0 +#define KEXEC_CRASH_HP_ADD_CPU 1 +#define KEXEC_CRASH_HP_REMOVE_CPU 2 +#define KEXEC_CRASH_HP_ADD_MEMORY 3 +#define KEXEC_CRASH_HP_REMOVE_MEMORY 4 +#define KEXEC_CRASH_HP_INVALID_CPU -1U + +struct kimage; + #endif /* LINUX_CRASH_CORE_H */ diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 811a90e09698..b9903dd48e24 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -33,6 +33,7 @@ extern note_buf_t __percpu *crash_notes; #include #include #include +#include #include /* Verify architecture specific macros are defined */ @@ -360,6 +361,12 @@ struct kimage { struct purgatory_info purgatory_info; #endif +#ifdef CONFIG_CRASH_HOTPLUG + int hp_action; + int elfcorehdr_index; + bool elfcorehdr_updated; +#endif + #ifdef CONFIG_IMA_KEXEC /* Virtual address of IMA measurement buffer for kexec syscall */ void *ima_buffer; @@ -490,6 +497,10 @@ static inline int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, g static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { } #endif +#ifndef arch_crash_handle_hotplug_event +static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } +#endif + #else /* !CONFIG_KEXEC_CORE */ struct pt_regs; struct task_struct; diff --git a/kernel/Kconfig.kexec b/kernel/Kconfig.kexec index 660048099865..a117163fde45 100644 --- a/kernel/Kconfig.kexec +++ b/kernel/Kconfig.kexec @@ -100,4 +100,35 @@ config CRASH_DUMP For s390, this option also enables zfcpdump. See also +config CRASH_HOTPLUG + bool "Update the crash elfcorehdr on system configuration changes" + default y + depends on CRASH_DUMP && (HOTPLUG_CPU || MEMORY_HOTPLUG) + depends on ARCH_HAS_CRASH_HOTPLUG + help + Enable direct update to the crash elfcorehdr (which contains + the list of CPUs and memory regions to be dumped upon a crash) + in response to hot plug/unplug or online/offline of CPUs or + memory. This is a much more advanced approach than userspace + attempting that. + + If unsure, say Y. + +config CRASH_MAX_MEMORY_RANGES + int "Specify the maximum number of memory regions for the elfcorehdr" + default 8192 + depends on CRASH_HOTPLUG + help + For the kexec_file_load() syscall path, specify the maximum number of + memory regions that the elfcorehdr buffer/segment can accommodate. + These regions are obtained via walk_system_ram_res(); eg. the + 'System RAM' entries in /proc/iomem. + This value is combined with NR_CPUS_DEFAULT and multiplied by + sizeof(Elf64_Phdr) to determine the final elfcorehdr memory buffer/ + segment size. + The value 8192, for example, covers a (sparsely populated) 1TiB system + consisting of 128MiB memblocks, while resulting in an elfcorehdr + memory buffer/segment size under 1MiB. This represents a sane choice + to accommodate both baremetal and virtual machine configurations. + endmenu diff --git a/kernel/crash_core.c b/kernel/crash_core.c index b7c30b748a16..53d211c690a1 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include @@ -18,6 +20,7 @@ #include #include "kallsyms_internal.h" +#include "kexec_internal.h" /* vmcoreinfo stuff */ unsigned char *vmcoreinfo_data; @@ -697,3 +700,142 @@ static int __init crash_save_vmcoreinfo_init(void) } subsys_initcall(crash_save_vmcoreinfo_init); + +#ifdef CONFIG_CRASH_HOTPLUG +#undef pr_fmt +#define pr_fmt(fmt) "crash hp: " fmt +/* + * To accurately reflect hot un/plug changes of cpu and memory resources + * (including onling and offlining of those resources), the elfcorehdr + * (which is passed to the crash kernel via the elfcorehdr= parameter) + * must be updated with the new list of CPUs and memories. + * + * In order to make changes to elfcorehdr, two conditions are needed: + * First, the segment containing the elfcorehdr must be large enough + * to permit a growing number of resources; the elfcorehdr memory size + * is based on NR_CPUS_DEFAULT and CRASH_MAX_MEMORY_RANGES. + * Second, purgatory must explicitly exclude the elfcorehdr from the + * list of segments it checks (since the elfcorehdr changes and thus + * would require an update to purgatory itself to update the digest). + */ +static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu) +{ + struct kimage *image; + + /* Obtain lock while changing crash information */ + if (!kexec_trylock()) { + pr_info("kexec_trylock() failed, elfcorehdr may be inaccurate\n"); + return; + } + + /* Check kdump is not loaded */ + if (!kexec_crash_image) + goto out; + + image = kexec_crash_image; + + if (hp_action == KEXEC_CRASH_HP_ADD_CPU || + hp_action == KEXEC_CRASH_HP_REMOVE_CPU) + pr_debug("hp_action %u, cpu %u\n", hp_action, cpu); + else + pr_debug("hp_action %u\n", hp_action); + + /* + * The elfcorehdr_index is set to -1 when the struct kimage + * is allocated. Find the segment containing the elfcorehdr, + * if not already found. + */ + if (image->elfcorehdr_index < 0) { + unsigned long mem; + unsigned char *ptr; + unsigned int n; + + for (n = 0; n < image->nr_segments; n++) { + mem = image->segment[n].mem; + ptr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT)); + if (ptr) { + /* The segment containing elfcorehdr */ + if (memcmp(ptr, ELFMAG, SELFMAG) == 0) + image->elfcorehdr_index = (int)n; + kunmap_local(ptr); + } + } + } + + if (image->elfcorehdr_index < 0) { + pr_err("unable to locate elfcorehdr segment"); + goto out; + } + + /* Needed in order for the segments to be updated */ + arch_kexec_unprotect_crashkres(); + + /* Differentiate between normal load and hotplug update */ + image->hp_action = hp_action; + + /* Now invoke arch-specific update handler */ + arch_crash_handle_hotplug_event(image); + + /* No longer handling a hotplug event */ + image->hp_action = KEXEC_CRASH_HP_NONE; + image->elfcorehdr_updated = true; + + /* Change back to read-only */ + arch_kexec_protect_crashkres(); + + /* Errors in the callback is not a reason to rollback state */ +out: + /* Release lock now that update complete */ + kexec_unlock(); +} + +static int crash_memhp_notifier(struct notifier_block *nb, unsigned long val, void *v) +{ + switch (val) { + case MEM_ONLINE: + crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_MEMORY, + KEXEC_CRASH_HP_INVALID_CPU); + break; + + case MEM_OFFLINE: + crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_MEMORY, + KEXEC_CRASH_HP_INVALID_CPU); + break; + } + return NOTIFY_OK; +} + +static struct notifier_block crash_memhp_nb = { + .notifier_call = crash_memhp_notifier, + .priority = 0 +}; + +static int crash_cpuhp_online(unsigned int cpu) +{ + crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_CPU, cpu); + return 0; +} + +static int crash_cpuhp_offline(unsigned int cpu) +{ + crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_CPU, cpu); + return 0; +} + +static int __init crash_hotplug_init(void) +{ + int result = 0; + + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + register_memory_notifier(&crash_memhp_nb); + + if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) { + result = cpuhp_setup_state_nocalls(CPUHP_BP_PREPARE_DYN, + "crash/cpuhp", crash_cpuhp_online, crash_cpuhp_offline); + } + + return result; +} + +subsys_initcall(crash_hotplug_init); +#endif diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 3d578c6fefee..8296d019737c 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -277,6 +277,12 @@ struct kimage *do_kimage_alloc_init(void) /* Initialize the list of unusable pages */ INIT_LIST_HEAD(&image->unusable_pages); +#ifdef CONFIG_CRASH_HOTPLUG + image->hp_action = KEXEC_CRASH_HP_NONE; + image->elfcorehdr_index = -1; + image->elfcorehdr_updated = false; +#endif + return image; } From patchwork Mon Jun 12 21:07:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 106896 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp139150vqr; Mon, 12 Jun 2023 14:19:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4VfyVzCdHx/k4w9jd8DaUJ8aYqpsNa2WYayoPYP9dXZecbi9uVNfcbr0IeNzBG/Oupv/B0 X-Received: by 2002:a17:907:3603:b0:965:6a32:7de6 with SMTP id bk3-20020a170907360300b009656a327de6mr10750560ejc.30.1686604796099; Mon, 12 Jun 2023 14:19:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686604796; cv=pass; d=google.com; s=arc-20160816; b=CEkchG+8ZGXXoCsWy2HzWrip59PcQJqU+ruxf2wmlWIlAgCUNNGueMPvZLqtSBTO7F 4rycKgt30Pmo3xLFOEJtO4CuAnvLpSHBCJpI9dDsRQZan00pNGcK4lbM7ZAQ/0mGWPdS Fz6BQ9my4/nJts5epZf1GtqJD8FEgz6jfNZS64DcsYzuirJ60tNnVRhYaPONswFCT7xi ig1DI6EUoThmFOP8SYamyC5UEyimILvfRDzlZcj+ERtYyGbs6T1jt91XhW7/IxNXpWkl y2EbxnTPv6tiD1Eu5M6N04jKyxK1FoiMHgFdmy1T4GdttC7jXXQG8OMkhzvHXCmc2ZZq GguA== 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=q9yPQDWoY3RWIM9fWPlBbfnDA8cyQY7I5wErjxCIeok=; b=aXEx4IBUG8QBjtNhNzlh8mLSvgj7ITPZpEum7jYGlmW/36WZp4EdkbRsKN31ACdjD/ DB+gN9jAjEO1ahARzVSM92I32uJZXrEnSisg43om55q5VOrVs1bjTccQH+AecykYlboA o52CJA0hPGWGnHFMhPNIHciEqK2QEZIG/up/xExzQaUPcxXE0/YMWlXT6dY5LfS/xlVU np3qSxdUX2rGeE9LtqfvrQwglrUzAZ6c7IAP7Url2mjD6jz9zQwEn0pBqZnxXXuUVz+h L1RpL1tOtNvc6fNKBNZJoxP4EzA8Ofv+dRqjhEdnn6vAU2TECES24P884zrDZ17Udbfe reyA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=FUzXfIqD; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=dDmse79R; 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 rl26-20020a170907217a00b0094f7bc61a0esi5744354ejb.969.2023.06.12.14.19.31; Mon, 12 Jun 2023 14:19:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=FUzXfIqD; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=dDmse79R; 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 S238442AbjFLVOR (ORCPT + 99 others); Mon, 12 Jun 2023 17:14:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238233AbjFLVNY (ORCPT ); Mon, 12 Jun 2023 17:13:24 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 725791BE8; Mon, 12 Jun 2023 14:08:13 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35CKO6sr029783; Mon, 12 Jun 2023 21:07:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=q9yPQDWoY3RWIM9fWPlBbfnDA8cyQY7I5wErjxCIeok=; b=FUzXfIqD19TzUYnsowVNea4NvRMk40/wYGiWmXFbjN0XomtYBORFnolVuBXOeTfddkEf b42BtiIZmXxDlYpvXzT2QzWvSYOqwtp8VmQeNLpYYPPZEJUs5xDfR5pmBXTYXD2qdYNP C1i3F9YC2agxiJ88Ax5enAawlp091wrFjpdECbxePqfZMQkaNKxh/3n7GVdkjZN4rT96 wYDnydIkzk5rcmw0gmvI/HN3xuJRaXynwVj85uH4uZiyLgLh3KlXqrBtY3FDIE7W7ARd IlPDqhW78qCmOHjeR6glSvlyl0LVJkWGmFdLSWupfcD7lDhEO/YIUJ+JJaF5O50/euyf Lg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3r4h2akwk5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:43 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35CKTjab014117; Mon, 12 Jun 2023 21:07:43 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r4fm321jv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gKPET375jjOpfgoKKdjGf1/Iup4Rn6vd+yhMK+D4vjK0UNxwNn8h4fA0KBRxWi0FM0HycILY48xfWjvYOnQh9YpFOv9soCOIUFnTFRAPj6lUvOWVWB93zF2TaDmT+5E00ktAupXh8XOaAFCd8L4O6RL5oYD1jJ45MCrlOn0oWu4ocTgwUmqPn5/fjTw7TUA1eg3mj6bMMkr0PO9tjP+s9B2vAqoRKXSBze7AjFwPcr48VEloJAx9vvH+6OBz+W023cmhBeB+OOgsiTOchIkZX1KbhFGplMK4zd085HsyGxhm9H7Z4rsbRID2Iaq9LGlt1Oz9X1JjF9SkHIs8kY1ssQ== 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=q9yPQDWoY3RWIM9fWPlBbfnDA8cyQY7I5wErjxCIeok=; b=T7lYjQWP42uarfB+1UFzK/evnXhRyz5V0mYEupscYjIauTr0wjet3bbQ1nVgK26oigveyixIrConAW5QGfxi0WGEMHJklE65R5KG6cRuNohpBFXmF78jIqQXwQ0kGr14KdvE2YwaC8HYnpCuFSy7wasNlaf8l3391foTygJFYQVHTGim0iE1Iv9BxaS0GG6K5fb3v2q9fieWdjGveJ64Vz4gF9Gm+azlgnlvU/mavCbXE+fMkerqskSAkRc+b+68Udx3QDZHAAozSxaLUsPDte79+YTv33mlF2KhpsINZydpbeK10Tp9FoEooVJ2ydpEDHpoYdRD+pvcljlACQNpwQ== 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=q9yPQDWoY3RWIM9fWPlBbfnDA8cyQY7I5wErjxCIeok=; b=dDmse79R1VteIcC0HGz3qmuWrpX3Wt7Owv90IEbcGzRfmIiFXdbtSzJkABGMOV+oh243zUOI9K8pMVgN/k7HSpVLcv8s4zlAPmB83C+QMCa6MzoUT9DR9WZKq5bgpF98m4i30Ly0X6QgSKqeyDCeYIyUpT/iJyX9XNTfRVum924= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by BY5PR10MB4371.namprd10.prod.outlook.com (2603:10b6:a03:210::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.42; Mon, 12 Jun 2023 21:07:40 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6477.028; Mon, 12 Jun 2023 21:07:40 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v23 3/8] kexec: exclude elfcorehdr from the segment digest Date: Mon, 12 Jun 2023 17:07:07 -0400 Message-Id: <20230612210712.683175-4-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230612210712.683175-1-eric.devolder@oracle.com> References: <20230612210712.683175-1-eric.devolder@oracle.com> X-ClientProxiedBy: DS7PR05CA0081.namprd05.prod.outlook.com (2603:10b6:8:57::6) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|BY5PR10MB4371:EE_ X-MS-Office365-Filtering-Correlation-Id: f1e8c023-456e-42aa-66d4-08db6b890eae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eyC49St4D9ZCTJ/BAaCIo7GiqXZq4pQsgswgaGEximbIuLkJtJN3Hnem5abfTmfcmyhNxhUhW9cP5Y9dYLZpYzp51I72qZ9by3LVJZRmrmK3lz3Ho3wnWd3LAwHzh1j7rhgtHSQI/SDUxGeGg3GJw519AT8N0pLLW9XJQe9i0y1ul4zXypjK94CCMb9EF0HnSgt++65fi/mJFytV0ayGKxozQTygKgUQT7WO5lCzwUQDzVA7hOkSYqZfV4mKJm9Yx8A2mV3MsCM3Yl4g73+GS0aC1CUeEax3SIkRCbww0B2w31enye9H2LJ76tBu8y+oHPtAAM0Ik3eAzha6t0Oq4Xuik6NWGiL/LG5/r8tEiT5dialfvERgngdv6wMtWAHT1qTWRXRhqQrTH3W1K/Ub06SwIYmjm8EpSoxo4jneEWQGCVlUTeRlrpA6ZPIkNBwg8LgoYZsE6/1A/14VZd9AUTqX8d0pkAYj7L9AWL0UeYaoPzSU/b7B8DF+qmBrfpqh8vI0nRV319lfO7y3Uc/yAfgOyLqGP7hKS+zEAj/Te4hXZWYS+DC1V2YfJ9I2HMPIgxMCziXtyAyxM1I0i+KtJnn9L4d+mHkTicem29Kxx0g= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(366004)(346002)(136003)(39860400002)(396003)(451199021)(6666004)(478600001)(7416002)(5660300002)(7406005)(8936002)(8676002)(36756003)(86362001)(2906002)(66476007)(66946007)(4326008)(316002)(66556008)(921005)(186003)(41300700001)(38100700002)(107886003)(1076003)(6506007)(6512007)(26005)(6486002)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xbM2Mi/ggvtnSsqoidxVIOWXvkaOksmNsBQytgGegge1+ZLGfHalUhUCVb7Buml6YqJbrKTZzfZJt6Ub2XpzIxphcgm64uwDYImDEsd+H2VGncFjY/H+vwkX74r9qUPY0gYVDhuA4aPVLLHtCpmptT1skjssWh8cjQ+nchNRrcugnDx9K1FM0zfHJ2fhk4LZF6x9nl3PaEeP56Spa6ReHicGWevuRh0TdSjajkH0ZaNhP5PwnEJ8xH5c4KNcoRlhvVFHyD8dmj5rlPszf87FXXQ0aY65hPDYsg+MteLIhRuTUB8kzPs4C2BR5n4+XtriiRhXlLAq1BY2LgCbODFE+slGHXNhln3x3Oz3Mwwiz/O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0ZZVrJUegemJ7QcqMKlFdNPOqexikXJJMkQK8Ts4NLP1YN0GKc7hBGxDaGh3NxSEvC1KzeI7zZxq779oLN4TLaCIUTTI0T0Me+Xs5WkfXByePfetP7/XJN/DwtRRyXetgDRnUIr82TUm2oYZR2A2wLTzfC71SIyWKKrLh47IxWTacOsMN3C+UBdt04Wq/TR5MpZb5v9v4LhGnENEa1PzGsrwsTIcoS8bT0MHh/M+V/Ayz/mk2QTlDcvJqPo9GDo3CwRw/tQEK67/5uHIq0wtQQvFK7/KEiHLQ9setCC3+P6Fz8xvQFlhKiOx793iOb1UZyNNHTtgaPzzg9fXRDRyNplslZ86N2iTaQHmEsXGRQVOMSne2MrUFyvh6lRmkx4HmdmW9L0R+jNiIyjG26NMUFh6cwwY99A/GuUOmiTdqpcN+ay/x/mVt1SUdNSAsYBABgVMS9YSu55+smOrxLL99+qPCM+OIY9dnKWho9RctMSr6QdgqbvqZ+ZCwJbBqdZuG8pjDmJZMhaOfVplTwphbVK79z/K3O0ViCK2RGG3aroYWPRRQiRMADlapqUxHUWxe7bIUq3yTL6AN6Fl0q1gDdUKwvYN6X3CqRHKocO17V3RrulBZ1IG93s7E6iGzIVy6BM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1e8c023-456e-42aa-66d4-08db6b890eae X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 21:07:40.5055 (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: uZCTu8XpNzGnhX+zOw56XAxkHJMfymyNCoVVOkowwv8jow2e6nkMgfi4kUQcb+tW+aqf7cZOYj4JHhm4CkxFT5hFk2ZTeub8IEjTss65/VQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4371 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-12_16,2023-06-12_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 spamscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306120180 X-Proofpoint-ORIG-GUID: RPei6WxFTXeQyZsfCSfWju8RRLBUkS3w X-Proofpoint-GUID: RPei6WxFTXeQyZsfCSfWju8RRLBUkS3w 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_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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?1768533310532104659?= X-GMAIL-MSGID: =?utf-8?q?1768533310532104659?= When a crash kernel is loaded via the kexec_file_load() syscall, the kernel places the various segments (ie crash kernel, crash initrd, boot_params, elfcorehdr, purgatory, etc) in memory. For those architectures that utilize purgatory, a hash digest of the segments is calculated for integrity checking. The digest is embedded into the purgatory image prior to placing in memory. Updates to the elfcorehdr in response to CPU and memory changes would cause the purgatory integrity checking to fail (at crash time, and no vmcore created). Therefore, the elfcorehdr segment is explicitly excluded from the purgatory digest, enabling updates to the elfcorehdr while also avoiding the need to recompute the hash digest and reload purgatory. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- kernel/kexec_file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index f8b1797b3ec9..1d2cfc869a75 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -726,6 +726,12 @@ static int kexec_calculate_store_digests(struct kimage *image) for (j = i = 0; i < image->nr_segments; i++) { struct kexec_segment *ksegment; +#ifdef CONFIG_CRASH_HOTPLUG + /* Exclude elfcorehdr segment to allow future changes via hotplug */ + if (j == image->elfcorehdr_index) + continue; +#endif + ksegment = &image->segment[i]; /* * Skip purgatory as it will be modified once we put digest From patchwork Mon Jun 12 21:07:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 106897 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp139182vqr; Mon, 12 Jun 2023 14:19:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4emqA5/KNB4NCI8/8ltQiFPOi8NcjIGxbuoeuufD6grHOVQ7tnQJeQVszdBm4C+4OXIUiu X-Received: by 2002:a05:6402:110f:b0:518:30f2:2823 with SMTP id u15-20020a056402110f00b0051830f22823mr5601895edv.20.1686604799505; Mon, 12 Jun 2023 14:19:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686604799; cv=pass; d=google.com; s=arc-20160816; b=Z1LBHrJmg3+utIaCeQKh3gqCAhUnFUukR+peMnNlwKyYqsyPw5xIFHjhdkzfoXjNYq kJ7R34S6Tjw06ze86qEIobgI+LPGGDu/Ur302tdwE6m2/59UfYTtmJgj5tBfvrz4ntRO gb3c/xy8tvku52tYubv1GBgYfwsLCt9abkPITYihl8hPAKowdRrGW+GdrBxG7JZ5Cpna xYmCJ/gRRKAxvcLVCoLUL1dyhpjdyVIn7JxRaY9B2FvRa0ZOddQ6I1+9UwqP/yZ6/ZTE aG1r/CM3O9KfIwXVBfioAJpCO48S8+yQVxkeCBOF3RqgbfZWBn8xs5VdJcame+VN+b5u dyzQ== 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=xuGX5VAufC9o5VNhQVzEJroQvU83AHxOwU7kTgRqNnk=; b=L8vSJ3Wp4f99RTE2CNtvz5QVjbg+wc5L+BZZvx9gq7qe8wJJY503scOS2VacQpSRyy trg63Q40SEdTAa/wmB4wZhmp+ilJqsV5YhJxLkthlAwwJXZPDoeKyBlUqXI4WqaxD3/2 m6FRgEXnE00TilVzh0l5YJNt2qyITohdRlSTAHu22I5tVX9r0mSq39Y/JplOlICOGFJx fq+9dNcwtjeNUI3C01shQfiJB7H9AAr9CSGf0CEJ4PWgpaLJljtUuasS3p2IGN9hGRk5 /xKbfexMRtqAfa7yXjlbBbK0JKeKTZ3TPubE3XpLVswEsQclwt1NVwExBjBQ5lrqlPg7 d0HA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=ePrlhCff; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=hi5ONUpQ; 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 y8-20020aa7ccc8000000b005164d82133esi4121942edt.168.2023.06.12.14.19.33; Mon, 12 Jun 2023 14:19:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=ePrlhCff; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=hi5ONUpQ; 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 S230488AbjFLVPy (ORCPT + 99 others); Mon, 12 Jun 2023 17:15:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237775AbjFLVOT (ORCPT ); Mon, 12 Jun 2023 17:14:19 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2EF22976; Mon, 12 Jun 2023 14:08:22 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35CKNtED003133; Mon, 12 Jun 2023 21:07:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=xuGX5VAufC9o5VNhQVzEJroQvU83AHxOwU7kTgRqNnk=; b=ePrlhCffLV6nz0kYKx9xaVqVvMspo2/YPI0k634E1ZfQmw0eL5TwAL8Eeh1/pNeMgVmU xib/iIqFhD9QfldO75V4lpCbnPR5VEkD+uz4XvvuE3eRH5VXmKXaPekQXBdh6OTdlaRa ISPBojU+880eUR0DNgBa21BAVarHkgaYzHvIxUYt9LFNwCYEiFdvjPmEK/vgdFF8wzZB zJmv0Wjs/EECmkgp3kRcEk7VoeM6RX9SPMM3DpJrD9UaQCmQr6UKMC4yk9QXWFKloJPJ 5TkiQiZJ6gHgUrC/zEkpfoqdpXI6FyAmDWtdAR3sCsuoPlyj/RyBrfoFscuWv82tC4Kh SQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3r4fkdkv62-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:46 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35CKU0X8008319; Mon, 12 Jun 2023 21:07:45 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r4fm9j9p8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E0DtPhQmV56BZ3DoQfoQdUyqNUQqLSjph+MEXWqeeiBDulSO837aOwktOEydrKQGSF9paLFKaIqBRSZpc18E15Urd9xIsq58UvV7cW8TxJ3HnBj1O5DoguOHOs+Ffw1JKLXDEQdL2U/7Cbl07P9URDJVumI7jbWOoKVyGAXhSMK5sTVhRRnlz1vYpTBtFnUGiOgruItnXgKy2Aqn4oN0C1QTSCE82j98bpsflmpLuClta7Zoinjk8SsA7Vv5oLErQdWNeUkigxMv0GjjC5Ktz/iSgpbCtbeRzxAFlXXPxQnLhaYbyHnhilboRIjdI+/QMtrcnFSW969X6r4HIbPklw== 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=xuGX5VAufC9o5VNhQVzEJroQvU83AHxOwU7kTgRqNnk=; b=YdXY4WJ5K1opytkFag5VirbCCGfLQchij5PiYdknPbWDB14VMrPnGmWqOrzvJRL8GaZaMyCbGFRNiETmL5WLmPsLpLzYbc2+MNJy0ZLfe/h20YyO1hsBVE5v7eVy3arKuITgX9daJKU/9zqt5+siQRQRmLigLhhFRKUInOeMQGx2bdQ78AgD09vB6yOkN3KG7+vN8UNtVgDXv43MUm2W+MbRqLxNsXeLGX8ZyGIHhCWsa+ptoHW6HKZdqA/vkI1Bl/7qUjxylm6SeppXHGHnhtoOKgJRJtIu9Rb2VvCVbtSGHwnf3CE2UJnU10BvZ2tYox7YVLYEqfVyLTo5ppZyCQ== 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=xuGX5VAufC9o5VNhQVzEJroQvU83AHxOwU7kTgRqNnk=; b=hi5ONUpQFyelxkAZ5sQWOivJ0fYKV7yydmiizbTOfCJ/JQSEGkPnG9vfLAnqZRTcgWJZtfAoFffay1NbWeW3yREnhDX8GCk3y08MspspX87c8HHr2AP09D8lSlyJ+LqSMGMzO32In9arVjrkyXQDsv8iPpK6UZXdmkGtMvzD75M= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by BY5PR10MB4371.namprd10.prod.outlook.com (2603:10b6:a03:210::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.42; Mon, 12 Jun 2023 21:07:43 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6477.028; Mon, 12 Jun 2023 21:07:42 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v23 4/8] crash: memory and CPU hotplug sysfs attributes Date: Mon, 12 Jun 2023 17:07:08 -0400 Message-Id: <20230612210712.683175-5-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230612210712.683175-1-eric.devolder@oracle.com> References: <20230612210712.683175-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR10CA0017.namprd10.prod.outlook.com (2603:10b6:5:60::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_|BY5PR10MB4371:EE_ X-MS-Office365-Filtering-Correlation-Id: b38c7dd6-bb28-417e-e14a-08db6b89101f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 78PRJ2YgnxiBNmNLxTq9OCLteZgzVkqkMCnmLnPBF4e+oFvm0Ssk///gOvgnYwOUIm9MMUDKNNVUlxxkBKAhnU2mgLhZ7mXWP1b9SyBVeY0nwdWGPoFmNgr10cSfRWdanYZedXaIDOzKzgVX0zKyswqWDgO/Kvv3pcwmwMabl6YHWedfiKO1qc9cYS0bCUYmrphghaWCo90+zcw71+O+HhWKQAh0stCjzeXbZxY4u/Vviha6oIrunLWCXIHfUwlQYluRmcDmHafDIG1LpXJNyLC2c9u4fdiXGyFS7i9w5Gj5A+dwlPdJVkOlsl4Yz6GJvAZOSALU+uxNasJsb9qGzvfyNBVEroecw6rTt5meD40E9XD+5/ttFD/jLg7QOi1JzFy7QAeKj3TirxrYAKwMDMn3MoEs50Qvr8N4vejRm3SnTlFwPl0myF7HdD2EJE0pqPBgA+h0nETKSAD9vOmK9vK/6wHQcKxqPS/xqb6uM3+j7JD+3EK438Bd4+Wb5xBCBseUeyZoJt2m+n4tJVnE85wywTvKIRq0J8clNP7sKp82lG3qK9OzSSRu12TlB6OzK2gfrpQGNYOPuOeTsMtQneMj8my3KXrBryLaW2e2tLo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(366004)(346002)(136003)(39860400002)(396003)(451199021)(6666004)(478600001)(7416002)(5660300002)(7406005)(8936002)(8676002)(36756003)(86362001)(2906002)(66476007)(66946007)(4326008)(316002)(66556008)(921005)(186003)(41300700001)(38100700002)(107886003)(1076003)(6506007)(6512007)(26005)(6486002)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Qq2h9hbiwQTBpfuNBG1q0J1DaUR2Zh9mK5OtxcWmcgc0FjFJKNjMEka9w6z5DmWCatDtltPYYE3LBOJMIihSJIWSasg3AdtNX/ba/ojJwl/63Z8TDY+KWLBRCDTaqHyB8SHkIOIQZIOnAFfDMAw5ahhCFR2ObRJVmE4URcBpJoZctYUN78QbC9ZY2NOC4ywjBlz5DVST95AkkDo+w3m61jc4Qi7YeN1f7estS7R4DoAaAkYP/to17U5JMnkpoyfj1jWFwdlStw41cTTNybaSt92DBfwhi3f+IQMe6cyCxiq7k8GUMQ0uQdIwiL6jgAczKxEH2sDvvzyqC+FHNV9TDj8CvlFi7fPqhX18z+vHTkuyQ0cw59SxSN957NhpeZFmMh/aOpdHqatutaP7gMLa0sKS6cd94FP5vx5KGkJ+hGRWMvszxROpjUuLDyhjncNpRQJVsY7/JtRhj4HIu9O9D079Fbb7PbtZy3xk2tdTklMt7nKK6u61/Tso3ccyPV09HGyronTjC1Qc2DGjHkgBk5msz0aDs6+z7QQXLvpH3BUuvEHW7TBvTMZEsWZo94yftyspab0c+bGUKx6L5YA+i8S823Q93hqj9U1TnfjPtFE9klAasmnRa9BC2TjVIVAtrPRxqWnmiNDbTuaRwgZP3hrakABJopkeFzk1xdAoDuBR5m7SE8U9xSqwFeJcZs8eJoUkKOZUsoev08bmMhVmBAlPpy13irn0SU7MgMfsIZjFYcXkjLNGBXRE+ix2guZ2QbXLfcKZZuW+gjS5xT248d/vnl88bP2wZ0KpEwJgA7uzMr1yDTaqhWHIdtOLkH5eio6v821rv1dGyCdpp35OlKIJsoVlLAIEBfPzyf4WsbbyVXVcehZt2z6JAow752pmJ73BGitN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kUEa8Wstg7BgozjNgyaQvMeCGUlJBZN10SzdAzgLf7SAlgJW78k43bt+ZuYd0Ic= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b38c7dd6-bb28-417e-e14a-08db6b89101f X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 21:07:42.9069 (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: ri6EsE5JARBEhIO1saPfP5X/AA6NGB43Y0BaRIc2eRSD6/zLUU4m+QuOJHDH8WhDLeTCVAJn/hEidNwcaABWOLplPtVLAPQmq+sbmKmVcL0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4371 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-12_16,2023-06-12_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306120180 X-Proofpoint-ORIG-GUID: d_jhI1J6LcfavGSSKTyPs9UTEd3feC9n X-Proofpoint-GUID: d_jhI1J6LcfavGSSKTyPs9UTEd3feC9n 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_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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?1768533314572156802?= X-GMAIL-MSGID: =?utf-8?q?1768533314572156802?= Introduce the crash_hotplug attribute for memory and CPUs for use by userspace. These attributes directly facilitate the udev rule for managing userspace re-loading of the crash kernel upon hot un/plug changes. For memory, expose the crash_hotplug attribute to the /sys/devices/system/memory directory. For example: # udevadm info --attribute-walk /sys/devices/system/memory/memory81 looking at device '/devices/system/memory/memory81': KERNEL=="memory81" SUBSYSTEM=="memory" DRIVER=="" ATTR{online}=="1" ATTR{phys_device}=="0" ATTR{phys_index}=="00000051" ATTR{removable}=="1" ATTR{state}=="online" ATTR{valid_zones}=="Movable" looking at parent device '/devices/system/memory': KERNELS=="memory" SUBSYSTEMS=="" DRIVERS=="" ATTRS{auto_online_blocks}=="offline" ATTRS{block_size_bytes}=="8000000" ATTRS{crash_hotplug}=="1" For CPUs, expose the crash_hotplug attribute to the /sys/devices/system/cpu directory. For example: # udevadm info --attribute-walk /sys/devices/system/cpu/cpu0 looking at device '/devices/system/cpu/cpu0': KERNEL=="cpu0" SUBSYSTEM=="cpu" DRIVER=="processor" ATTR{crash_notes}=="277c38600" ATTR{crash_notes_size}=="368" ATTR{online}=="1" looking at parent device '/devices/system/cpu': KERNELS=="cpu" SUBSYSTEMS=="" DRIVERS=="" ATTRS{crash_hotplug}=="1" ATTRS{isolated}=="" ATTRS{kernel_max}=="8191" ATTRS{nohz_full}==" (null)" ATTRS{offline}=="4-7" ATTRS{online}=="0-3" ATTRS{possible}=="0-7" ATTRS{present}=="0-3" With these sysfs attributes in place, it is possible to efficiently instruct the udev rule to skip crash kernel reloading for kernels configured with crash hotplug support. For example, the following is the proposed udev rule change for RHEL system 98-kexec.rules (as the first lines of the rule file): # The kernel updates the crash elfcorehdr for CPU and memory changes SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" SUBSYSTEM=="memory", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" When examined in the context of 98-kexec.rules, the above rules test if crash_hotplug is set, and if so, the userspace initiated unload-then-reload of the crash kernel is skipped. CPU and memory checks are separated in accordance with CONFIG_HOTPLUG_CPU and CONFIG_MEMORY_HOTPLUG kernel config options. If an architecture supports, for example, memory hotplug but not CPU hotplug, then the /sys/devices/system/memory/crash_hotplug attribute file is present, but the /sys/devices/system/cpu/crash_hotplug attribute file will NOT be present. Thus the udev rule skips userspace processing of memory hot un/plug events, but the udev rule will evaluate false for CPU events, thus allowing userspace to process CPU hot un/plug events (ie the unload-then-reload of the kdump capture kernel). Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- .../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 1b02fe5807cc..eb99d79223a3 100644 --- a/Documentation/admin-guide/mm/memory-hotplug.rst +++ b/Documentation/admin-guide/mm/memory-hotplug.rst @@ -291,6 +291,14 @@ The following files are currently defined: Availability depends on the CONFIG_ARCH_MEMORY_PROBE kernel configuration option. ``uevent`` read-write: generic udev file for device subsystems. +``crash_hotplug`` read-only: when changes to the system memory map + occur due to hot un/plug of memory, this file contains + '1' if the kernel updates the kdump capture kernel memory + map itself (via elfcorehdr), or '0' if userspace must update + the kdump capture kernel memory map. + + Availability depends on the CONFIG_MEMORY_HOTPLUG kernel + configuration option. ====================== ========================================================= .. note:: diff --git a/Documentation/core-api/cpu_hotplug.rst b/Documentation/core-api/cpu_hotplug.rst index 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 c1815b9dae68..06a0c22b37b8 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -282,6 +282,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 b456ac213610..24b8ef4c830c 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -490,6 +490,16 @@ static ssize_t auto_online_blocks_store(struct device *dev, static DEVICE_ATTR_RW(auto_online_blocks); +#ifdef CONFIG_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 @@ -889,6 +899,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 b9903dd48e24..6a8a724ac638 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -501,6 +501,14 @@ static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } #endif +#ifndef crash_hotplug_cpu_support +static inline int crash_hotplug_cpu_support(void) { return 0; } +#endif + +#ifndef crash_hotplug_memory_support +static inline int crash_hotplug_memory_support(void) { return 0; } +#endif + #else /* !CONFIG_KEXEC_CORE */ struct pt_regs; struct task_struct; From patchwork Mon Jun 12 21:07:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 106901 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp139676vqr; Mon, 12 Jun 2023 14:21:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ww6AGuiYZiEmUh/NuybfGTx2469lIDhre9TzfiGTbVIShcyk/wzinBXgnNm/XJb57SNtw X-Received: by 2002:a17:907:2d11:b0:96f:905e:6117 with SMTP id gs17-20020a1709072d1100b0096f905e6117mr11683771ejc.56.1686604862029; Mon, 12 Jun 2023 14:21:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686604862; cv=pass; d=google.com; s=arc-20160816; b=Wlk/0y202LUtwfSDWv06c/E7jLV50qr9hjwOh5fuAcQvUzgCtzLhYUNF7y5FHkrB6C 8pdpxsF3JRd98K34m0GR3g7yhbJGfFJjDmaHoV//vwrDXPIvEoEJIatKqTs82yvlMN3Z vwdYyli7qdToV1TgUwM4Q+d26+iYAbb50OhYoXTiFXkFmivBC1eIHRFNYyEYddMNwmlj 2Z7qKk7mvmmVIPwysmVFsw09r1gGtUWRX7iLNtBqCDsy6tM6ou5RGHbxsk7cCQIPAhUV vtBXbYyIne71jPKuBnR33EbRiU8Bn42zWTo6K144x2Mlyw9tJYhGg261FRMmMhQdp4OP sBOw== 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=bIW0yu58Z5ZXhTnCLH0tFN1HT5VoBr0mDtLIn1ZAbCU=; b=nEtjxm01E+6wSZZs6kRQlSr6nmlpxUH+JahNdEQVPY8u134iddx1W1UIvyg2CuT3F3 U0oxEwmkPkxE9S6Leu+0WEWdOQ6epAOoJZ+wf+XLccLCmxmmhEgSgV2q3YGbeRcEq0lM j84HilQpZ6IUy5IZxLZYCOp6pQfTfixIKiHIECeZsEAk9W0ObU+haPwbefntVpFx6MIM otzhpn6RngfqORy2kFcHLpKwh/et/BabpXJ1a0eGUNjj750pIW91v7/AuDeH944WwVWq GrG/SfGCLpIa5VfzUZclDHWXDjrjAyI129mtUD33wFFtXC8gz39CzWL53MSYIHUBv98R NbIQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=DPumACs0; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=vvW2atC9; 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 u3-20020a1709063b8300b0096b5c43d44csi4688167ejf.833.2023.06.12.14.20.37; Mon, 12 Jun 2023 14:21:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=DPumACs0; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=vvW2atC9; 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 S233893AbjFLVQP (ORCPT + 99 others); Mon, 12 Jun 2023 17:16:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238846AbjFLVOp (ORCPT ); Mon, 12 Jun 2023 17:14:45 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABA6D35A2; Mon, 12 Jun 2023 14:08:35 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35CKNtsi031449; Mon, 12 Jun 2023 21:07:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=bIW0yu58Z5ZXhTnCLH0tFN1HT5VoBr0mDtLIn1ZAbCU=; b=DPumACs0CacMiHyyNdZbWaNsXzCDQhjiN/OrDecc2K0xPaD9EhYfaFYHO8Na5+mzVaXj b7Tjn6j+ASK27zvSPq3cPsEVG71qJ6iA9LECC6pgV1yqVnaNBFMb0y0B4B7VYqhv3jx6 DhcJmktoWlknJgrx0ZHg097NGKpgisStuieLQtoj0/dCXzjf+oAqY1T7nVfUBm4aI0Xq pT/3ki6VtHK4OWWsSUwcq6Kle5PDAfzigZsofh845LV5Oqyi+Y48YFQtmW401qH2l4k9 J6bsancZIRw4/4o+lGSg1tzvB7FLPqZSc1MwAJTl/ZUPVuz3GC7TLjzH3QtniaLHo9jy 3A== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3r4gstuufk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:49 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35CKWd0E016285; Mon, 12 Jun 2023 21:07:48 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2047.outbound.protection.outlook.com [104.47.51.47]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r4fm3a6wp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B9Lrz3Pz2NiuZFzNHrMTRqNjX834U6voKBGkktDKEREYZmiig12IY8yv2N91MStAcel9EZMYzGl6KdTiFB8MZ0ZVFe/OCizsvZwtECBU0HDKXi1p2F0PMweyUkVxiSMZh6VqsnWYJzLidBmVzhReE8EwMq2xeuXCWoEOLKx5QkEnXCM2D4u1bdQH2xeUejnaKAZXXGmWBycBGbz9Z5VRn5noNOVvFm5XKj6f9ybxTVpP9f+hj18i9d1LgYYGH27p+oiNtu/22q7MrHWAeC4NQ+C8FWqVbhiULFYu3eyU4aF5bMLCbdWBsIXj1LvqvdNgTtpgj51J++A5TAkL9dozhw== 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=bIW0yu58Z5ZXhTnCLH0tFN1HT5VoBr0mDtLIn1ZAbCU=; b=YiwjNwEB7Z7vp4Z2gt3i+XCvMVcegvTKQbCO9iJPs6WfzNa8Ux9ubcpeYPYZNSydqKCeYgfmeQb1iqnF4NJkQ1uVnqwDJ4qI49r9jTlSJt+d1llrQp0YniuCy8b9myy4X71FZyN0mg3u40Pcu5ctb8dKZF3o4ToPIRBn3oPmyYe0X1Uva2RQld1o0xcXCreCawVWJoWZwk+cCnRtX0AH+XNNNWb5SY+KHSZ1KZoJ36mgJ+1gwg3Zyz6b/TPiiJWdBVpzRN9CYqr6RJ99qOqEqJc4MC451WsfYo34DA2W9bhvIWKHv4+pa2VPnDPtCA5g3CZakE7BPd/5S2HhM3CzAw== 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=bIW0yu58Z5ZXhTnCLH0tFN1HT5VoBr0mDtLIn1ZAbCU=; b=vvW2atC9ndzdpOlEJLuHf5CAXz2qZVkSJOGa72WTra0Gchtn0xfOu6Bd3tOXPeXLDlfjcNrMPGSUOEbA3Crt5z8MYk+fiZONQ/cx+iqyJaag3eoNgzlYf8xmIGRjmqXSKZowFrIeNiq6syLLNzI4pB3xu2MvlMnhRSbOaW9gQ0g= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH8PR10MB6410.namprd10.prod.outlook.com (2603:10b6:510:1c5::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.38; Mon, 12 Jun 2023 21:07:45 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6477.028; Mon, 12 Jun 2023 21:07:45 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v23 5/8] x86/crash: add x86 crash hotplug support Date: Mon, 12 Jun 2023 17:07:09 -0400 Message-Id: <20230612210712.683175-6-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230612210712.683175-1-eric.devolder@oracle.com> References: <20230612210712.683175-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR10CA0021.namprd10.prod.outlook.com (2603:10b6:5:60::34) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH8PR10MB6410:EE_ X-MS-Office365-Filtering-Correlation-Id: 73717630-a06c-479d-c0f6-08db6b891174 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gjl/z1rWc3LKKQ7N+U0pDoYCn1MnPCRMFuWsCIsi7SmIadg2lzQYm1mhNHhsnPr7mpKDbFT6JqkefUPvyF57MBxHabE6iBV4p60sN7HEM+Nd9uIC0UsFrF2r61KS7Dyh/PTfqzeykDq1MchqTUoDBKNT1SJ3FGkQTOHOdy+48qcuHfKIAxVoP7bXy3Zi8tqjzYnpGS8TybIUQP7tTdRneyZ1w7BCSD0E90HbjTxxaYViepCkjybyI/I7uTml1BcVKz4srDyjDFB1/d1aasgP33a5CSrZbACg2Wf9A92daTy0gCYFrUirP+BYEpscvckCEojW0RGCaUpIBeouZ77/7XsBLFH31GMINUqQWxjHkmmHbCDnpRQKP0oXJNJ0vjuSMjI+xZeHjQV/Sec5yEVLoPcbWDC9k5Vt0j2MM866E8IvdcCEkKK6Ot7eUq1O/tgfLh1EVsni3e6D5X39QXfR7KMpEvn6POzcR68k1EqmAFPaSKviVsTib0QfTWCGm1TDOa2aaOmzpDzbvcXB2XJUK4KTHYQeWf/+taikX121SC1ypMox9kNv0b+FnXoypJPp36WmkFAtsniuNExglIZIITKW2QWhvAz4q5VBumh7514= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(366004)(346002)(396003)(376002)(136003)(451199021)(66556008)(66946007)(8936002)(36756003)(5660300002)(8676002)(4326008)(6666004)(66476007)(478600001)(6486002)(41300700001)(316002)(38100700002)(921005)(107886003)(7416002)(6512007)(186003)(26005)(1076003)(7406005)(2616005)(6506007)(83380400001)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tYVaLUFYWrBx/TgoHsv5KvzkTcSCptaXYpqRxdYfPfNE1S+e+Al2xNo5OLYXbGB/t6VNCRPqnA3e/Qtx6uN8BSZEEsPoFAuKOP/ScdCGmN2I7pDFtSKik665tfNpdpRQNTtLK5xCJ23wkJgr4z8ucgaaHhZPhNOIxKDnUD0qJzFSF6uRK3vkxrPBA/HGrqGmIDiM9QM2SxcP5o96YjrkVNfXJ1v1PpYp1a1sAuq0v9NiOAu0LcpaW8BcfszCrO3AIhElD8wjpdLtHohy9dOO3q1M9k4TyDggyyv2nTzbkg738UqUDE7QcaWx3sxkF1TGVBF6/EthvGHrVKxPA1duoYzfKrBpuNnJ5cLKQIRQf1resiWB5WBGptqaR6gaqc3qjJFntr9950T7y9SEUI4QfeySM4xYZsTkS3P0uPXF7TQBFyd/WUEQrUvg1qUPBIP+hRxztbWB0CMJcs+GYCb1mUWRAPOdOpefEfGlO1fxt3fEHtpSXr6WFN8H7nNIIW8ZQod0PLKLT0SNP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SAzpP6hmwZ+Kmy/B+rxhtQIia2zJdGj5gnFW1yIi+Jo3EKeIdcaYoRydcwesS9DPufjFkDRnxGyK1p6RSz8fZv0ubr/WZADtiLq5DEPUWEiJ7w2LGh/QXTR1N/UoWENHcFCDZsXBfhSwz7t+uI5Bb6QmaFCheSaXdkOmFiQKUmTiTH6zajSgc6cJ6GKyLFEgztvUvhglWoCiCwHs+mLtH8pSRSYCDlyU2KcYJsOL0LLS9zHAShP+INlCoqJ0d8MvbFk6wLBlQJwCvmIBW5Fs1bEOOu6F14/Od2VVEld2olAhyklcx/BojgK6MOrw+fNN1VD/MCEbcT75y2g7YNeRskCuBA3LpyCJDYFWDdg3bzxXCTCi87ReqSKe7cJ2UIszGjsvjtosoSOkd6KrDzCAdIhylgOI9wJDPEzKDM9aTmmPC62bhgWmNXXa6vSFnAEPYry8MKRGGjC64YdTUTexONsHRkho= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73717630-a06c-479d-c0f6-08db6b891174 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 21:07:45.2151 (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: sNmBaBs7iCHBRs3zQwLu8T4vql4IBuSnGoAFTEgrol6G6ivtaIllJSnVenJEL+OFwNsKzL7/DIPhxiw8vt4VL8S9fPo7ZXf5Hm5QbPYFLsY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6410 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-12_16,2023-06-12_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306120180 X-Proofpoint-GUID: vFkX8BPwch_p8PQccIWrm9ogCHa6ycPO X-Proofpoint-ORIG-GUID: vFkX8BPwch_p8PQccIWrm9ogCHa6ycPO 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_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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?1768533379842330117?= X-GMAIL-MSGID: =?utf-8?q?1768533379842330117?= When CPU or memory is hot un/plugged, or off/onlined, the crash elfcorehdr, which describes the CPUs and memory in the system, must also be updated. A new elfcorehdr is generated from the available CPUs and memory and replaces the existing elfcorehdr. The segment containing the elfcorehdr is identified at run-time in crash_core:crash_handle_hotplug_event(). No modifications to purgatory (see 'kexec: exclude elfcorehdr from the segment digest') or boot_params (as the elfcorehdr= capture kernel command line parameter pointer remains unchanged and correct) are needed, just elfcorehdr. For kexec_file_load(), the elfcorehdr segment size is based on NR_CPUS and CRASH_MAX_MEMORY_RANGES in order to accommodate a growing number of CPU and memory resources. For kexec_load(), the userspace kexec utility needs to size the elfcorehdr segment in the same/similar manner. To accommodate kexec_load() syscall in the absence of kexec_file_load() syscall support, prepare_elf_headers() and dependents are moved outside of CONFIG_KEXEC_FILE. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- arch/x86/Kconfig | 3 + arch/x86/include/asm/kexec.h | 15 +++++ arch/x86/kernel/crash.c | 103 ++++++++++++++++++++++++++++++++--- 3 files changed, 114 insertions(+), 7 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 7dff2481abe0..4b39f4059876 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2063,6 +2063,9 @@ config ARCH_HAS_KEXEC_JUMP config ARCH_HAS_CRASH_DUMP def_bool X86_64 || (X86_32 && HIGHMEM) +config ARCH_HAS_CRASH_HOTPLUG + def_bool y + config PHYSICAL_START hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP) default "0x1000000" diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index 5b77bbc28f96..9143100ea3ea 100644 --- a/arch/x86/include/asm/kexec.h +++ b/arch/x86/include/asm/kexec.h @@ -209,6 +209,21 @@ typedef void crash_vmclear_fn(void); extern crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss; extern void kdump_nmi_shootdown_cpus(void); +#ifdef CONFIG_CRASH_HOTPLUG +void arch_crash_handle_hotplug_event(struct kimage *image); +#define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event + +#ifdef CONFIG_HOTPLUG_CPU +static inline int crash_hotplug_cpu_support(void) { return 1; } +#define crash_hotplug_cpu_support crash_hotplug_cpu_support +#endif + +#ifdef CONFIG_MEMORY_HOTPLUG +static inline int crash_hotplug_memory_support(void) { return 1; } +#define crash_hotplug_memory_support crash_hotplug_memory_support +#endif +#endif + #endif /* __ASSEMBLY__ */ #endif /* _ASM_X86_KEXEC_H */ diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index cdd92ab43cda..c70a111c44fa 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -158,8 +158,6 @@ void native_machine_crash_shutdown(struct pt_regs *regs) crash_save_cpu(regs, safe_smp_processor_id()); } -#ifdef CONFIG_KEXEC_FILE - static int get_nr_ram_ranges_callback(struct resource *res, void *arg) { unsigned int *nr_ranges = arg; @@ -231,7 +229,7 @@ static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg) /* Prepare elf headers. Return addr and size */ static int prepare_elf_headers(struct kimage *image, void **addr, - unsigned long *sz) + unsigned long *sz, unsigned long *nr_mem_ranges) { struct crash_mem *cmem; int ret; @@ -249,6 +247,9 @@ static int prepare_elf_headers(struct kimage *image, void **addr, if (ret) goto out; + /* Return the computed number of memory ranges, for hotplug usage */ + *nr_mem_ranges = cmem->nr_ranges; + /* By default prepare 64bit headers */ ret = crash_prepare_elf64_headers(cmem, IS_ENABLED(CONFIG_X86_64), addr, sz); @@ -257,6 +258,7 @@ static int prepare_elf_headers(struct kimage *image, void **addr, return ret; } +#ifdef CONFIG_KEXEC_FILE static int add_e820_entry(struct boot_params *params, struct e820_entry *entry) { unsigned int nr_e820_entries; @@ -371,18 +373,42 @@ int crash_setup_memmap_entries(struct kimage *image, struct boot_params *params) int crash_load_segments(struct kimage *image) { int ret; + unsigned long pnum = 0; struct kexec_buf kbuf = { .image = image, .buf_min = 0, .buf_max = ULONG_MAX, .top_down = false }; /* Prepare elf headers and add a segment */ - ret = prepare_elf_headers(image, &kbuf.buffer, &kbuf.bufsz); + ret = prepare_elf_headers(image, &kbuf.buffer, &kbuf.bufsz, &pnum); if (ret) return ret; - image->elf_headers = kbuf.buffer; - image->elf_headers_sz = kbuf.bufsz; + image->elf_headers = kbuf.buffer; + image->elf_headers_sz = kbuf.bufsz; + kbuf.memsz = kbuf.bufsz; + +#ifdef CONFIG_CRASH_HOTPLUG + /* + * The elfcorehdr segment size accounts for VMCOREINFO, kernel_map, + * maximum CPUs and maximum memory ranges. + */ + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + pnum = 2 + CONFIG_NR_CPUS_DEFAULT + CONFIG_CRASH_MAX_MEMORY_RANGES; + else + pnum += 2 + CONFIG_NR_CPUS_DEFAULT; + + if (pnum < (unsigned long)PN_XNUM) { + kbuf.memsz = pnum * sizeof(Elf64_Phdr); + kbuf.memsz += sizeof(Elf64_Ehdr); + + image->elfcorehdr_index = image->nr_segments; + + /* Mark as usable to crash kernel, else crash kernel fails on boot */ + image->elf_headers_sz = kbuf.memsz; + } else { + pr_err("number of Phdrs %lu exceeds max\n", pnum); + } +#endif - kbuf.memsz = kbuf.bufsz; kbuf.buf_align = ELF_CORE_HEADER_ALIGN; kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; ret = kexec_add_buffer(&kbuf); @@ -395,3 +421,66 @@ int crash_load_segments(struct kimage *image) return ret; } #endif /* CONFIG_KEXEC_FILE */ + +#ifdef CONFIG_CRASH_HOTPLUG + +#undef pr_fmt +#define pr_fmt(fmt) "crash hp: " fmt + +/** + * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes + * @image: a pointer to kexec_crash_image + * + * Prepare the new elfcorehdr and replace the existing elfcorehdr. + */ +void arch_crash_handle_hotplug_event(struct kimage *image) +{ + void *elfbuf = NULL, *old_elfcorehdr; + unsigned long nr_mem_ranges; + unsigned long mem, memsz; + unsigned long elfsz = 0; + + /* + * Create the new elfcorehdr reflecting the changes to CPU and/or + * memory resources. + */ + if (prepare_elf_headers(image, &elfbuf, &elfsz, &nr_mem_ranges)) { + pr_err("unable to create new elfcorehdr"); + goto out; + } + + /* + * Obtain address and size of the elfcorehdr segment, and + * check it against the new elfcorehdr buffer. + */ + mem = image->segment[image->elfcorehdr_index].mem; + memsz = image->segment[image->elfcorehdr_index].memsz; + if (elfsz > memsz) { + pr_err("update elfcorehdr elfsz %lu > memsz %lu", + elfsz, memsz); + goto out; + } + + /* + * Copy new elfcorehdr over the old elfcorehdr at destination. + */ + old_elfcorehdr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT)); + if (!old_elfcorehdr) { + pr_err("mapping elfcorehdr segment failed\n"); + goto out; + } + + /* + * Temporarily invalidate the crash image while the + * elfcorehdr is updated. + */ + xchg(&kexec_crash_image, NULL); + memcpy_flushcache(old_elfcorehdr, elfbuf, elfsz); + xchg(&kexec_crash_image, image); + kunmap_local(old_elfcorehdr); + pr_debug("updated elfcorehdr\n"); + +out: + vfree(elfbuf); +} +#endif From patchwork Mon Jun 12 21:07:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 106898 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp139252vqr; Mon, 12 Jun 2023 14:20:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5PRrNgONOW/oBToUyiCMdK/tOWYd+XxhPl5Gkwho91AMfQ6lYHAazyYHZzoHKb5jSG3ke3 X-Received: by 2002:a05:6402:3445:b0:514:7f6e:ef54 with SMTP id l5-20020a056402344500b005147f6eef54mr5191972edc.9.1686604808438; Mon, 12 Jun 2023 14:20:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686604808; cv=pass; d=google.com; s=arc-20160816; b=DdkNXun4nI/tC1RO+weNo5xdaQJxOPL58X4CIECJZlFM5XyG4a3ipxWlY6CMghq/2r gSBHhymTwldDGnJd0rj69tTmuHHpZaBuF+7LvzKF4PcUzycNa1JZntefe8En7/ITM/zJ GSeYBgtUslxcUhoewogB3P3nn5wg9yc1gtFT0U2TA7D9YzxlIGKBYFcZy+7G3yYHcrKZ 0tTk5dyqHgMledJFtCk2bbnD4vleZ0zNe7zw5866xL6nZJ0HA0Dedt6SaZIMQI/Tus6k ttsy7shQxIMlhCWTR+uweowk4wvBv22GMyViOMy/2WUqIKrevZViLsMXGLkvKuE9ga+i vTtA== 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=jJy/D/tGCP5LCjHyQT9mytgoujHldvFY7lgHb0sgTbk=; b=RYvKH/0kZBEQ41IlosyH82T6VrN/SPidkwaymFj91aw4o/M5j93Ze6Ojj6DQu1g189 t0cWJ2Q31OiRo/8ocLzsCs4p0oE1LZ0FeUI2BGvuoleX1OTKgC93FZ8mn3EMO7lNM3qo n5jsMneCJ4qBEu0KcBvGx27opjeH/81jDdKaadRgbSxJu6nPRqWUdczs0Xt3VAbXKNDh 99yfx6RGdf2PS9sTnseJw+nOTvHrmvoldc81fuDWbQz50xXKU1KHjjmsnfl+60y5VNnK qROLcNqorvtdQ/Su8u103hKgEUgbP/gLcC0JOcnqaLBuF7dYk5zyBZDdoKZBwJR/3nD5 hlVA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=cTy7iS9i; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=a+qli1KZ; 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 d5-20020a50fb05000000b005154f73bf75si6912192edq.591.2023.06.12.14.19.43; Mon, 12 Jun 2023 14:20:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=cTy7iS9i; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=a+qli1KZ; 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 S232662AbjFLVQA (ORCPT + 99 others); Mon, 12 Jun 2023 17:16:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238600AbjFLVOU (ORCPT ); Mon, 12 Jun 2023 17:14:20 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB9532978; Mon, 12 Jun 2023 14:08:22 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35CKNjvx020940; Mon, 12 Jun 2023 21:07:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=jJy/D/tGCP5LCjHyQT9mytgoujHldvFY7lgHb0sgTbk=; b=cTy7iS9i0ZrUKcI9kRarudplF9nrLZjlbjhLQ+yMepb6v4JfkGCo18gDOlB3tAwxEtP1 xhP0bIh/wWpD4h08wClVVzcuQsuJ0yR1uRwKuwjV5X+T4/8RU2LdG3YnaANsPQ18koYp 1aTGUG5MA/ohwQoLsv3ETw0I9xs7mQoHo97vPcKvuDlcmoh04NvYfYXCpKiYOhx8JpHB yiBXK8RKmVo9v8NxDSp/lxBajNH+5wiLjvUKESniAVQvPuJiScoJ4ZpG2HVwBHjyASd8 RDbBm5E19lq/z5mBjIrkZpol7D+bfs4q9hMiE92aeezrw2ykuvS/dXzE/i9ytIZSjG0P kw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3r4h7d3vuf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:51 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35CL7jnI016206; Mon, 12 Jun 2023 21:07:50 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2048.outbound.protection.outlook.com [104.47.51.48]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r4fm3a6xu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SJxGv6IQ6l0bIfdkKNZw5i1bwbAXLtldch1LbY1u1FXa/fKoRKqWaHmA3odlAWnbWKPGFyVDm9uAI7R36aMDCL+i4vo5vC8SAbMVASp9r+CwulN+VMnGWZeebF1ODs0CRonXBJvwqjWOxAYxhzamilrzh1qZVyPQ1rDoH/mb5pktLZK/67TbOlQTkQhq2a0aNyaWPA/QAvy+BUxalAB9pt0LT8mgHQ7mddhFZF+yUCt/08cLpYZZ63Kb9N4vNrkrGdE3tx0tEbrmN0S9ifgsKRhzpGNzklmHRhV5nppNNjcbOjDnKleQG8Ih+IEXLa+ZH0nyDpqT/Uzt6lYm9jw/mA== 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=jJy/D/tGCP5LCjHyQT9mytgoujHldvFY7lgHb0sgTbk=; b=Yky1qgWYjgUSfp+8RksYcz9363Sj3Su14aShvyMcqnZi5viVc0grly05Qvajrj9yTwuxXX7XdyH7iFQnzdMEkdB/knE+fs5z5hCq3hOuw6x2oDVglAEN6OiUD9rTinPJDNRqWHw8x7a75yU76XpMCuluspVfnOEJ4ELuAh/fg0MqurdmWPfkF31P4CzkvR9pc4cgxI0LxpjAPEp6dEE0IMvvvbDFpKSQdvuM+505vDrxhwiBRd6lxXEBwv7K0/WOJoMTX64Niz7I3W1oZm/X4sedfZGxPRtSA5xSlStzAOPoBwIjsgPKsN7FqyPP0vPl5DW6XnwmmP+DOcnwZrsosg== 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=jJy/D/tGCP5LCjHyQT9mytgoujHldvFY7lgHb0sgTbk=; b=a+qli1KZffbFoKwF+tK33ArgD2F2Goi817F5i5NTzKMQI+jv5FymQZ1vOhUBAxfcJqRiF8DmxZeAbo8zh/Qt/0z84GQO68C/Stgt/9bfeMJlyIXvdBERpk3SQzlYv1defv/NEfDerNcWGtVgWYLTBugtbx/jIYyU6mUE5vpK9XY= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH8PR10MB6410.namprd10.prod.outlook.com (2603:10b6:510:1c5::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.38; Mon, 12 Jun 2023 21:07:47 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6477.028; Mon, 12 Jun 2023 21:07:47 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v23 6/8] crash: hotplug support for kexec_load() Date: Mon, 12 Jun 2023 17:07:10 -0400 Message-Id: <20230612210712.683175-7-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230612210712.683175-1-eric.devolder@oracle.com> References: <20230612210712.683175-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM5PR07CA0063.namprd07.prod.outlook.com (2603:10b6:4:ad::28) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH8PR10MB6410:EE_ X-MS-Office365-Filtering-Correlation-Id: c7c9ec9c-1058-45ac-26a7-08db6b8912f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MEKEfav8uIXgIYbvgFDwcMnU4/PWdqAINiz43JwybwkF/HkrCAzHfOIag/5I58z3wbne2VceDQEAQImpdzG6Hd6FMAsmY7In4a9d4jtPlF98QvhcqPJs+1SCzwj+C2oiOslU/eEYrnsAeUvnY4y3EVttwZe0U8oRZcMG7gHAdAuQlptcsd23aa2J4i4Ywu+IVoi+1eWdyOMeOoz7OS/GczUEgLxtpxBeOMlH+6cGbQg/f3W+fL7hTMrR/an52L20PUP/lj5ALrQ2084wa6UpAoxUk4542LePcBGWhT994uQv4AqBH8azYjSOuQPP3bPmEr0RD2xo7fa7Brcv7jqLFhuLe4Co6LfyRr6UAkqNyqofoXxPuhWM9fGqJ698iyyzMzzCKy/Vdy5ouNY71xwCJY6ThSQKVfK4h/gJB7ryk7yrUSMxeEmIc6Lg5GYk77MgCo9+OiDFQc4e7j75hLOP4W22PrHmWXy6xJWS2MaGhQInsg4pgo2YFA5Wo8qJWFSPp+J0yVslJl+sX4aLvikItYlWKeIWfJwf7kScrRt5/nkHmnyC4M06ECVsP1+rF/a/N+1NAqJgqwKptR0xR5lxuUD6Qce3t5LaPrLJ2gEV5ns= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(366004)(346002)(396003)(376002)(136003)(451199021)(66556008)(66946007)(8936002)(36756003)(5660300002)(8676002)(4326008)(6666004)(66476007)(478600001)(6486002)(41300700001)(316002)(38100700002)(921005)(107886003)(7416002)(6512007)(186003)(26005)(1076003)(7406005)(2616005)(6506007)(83380400001)(86362001)(2906002)(30864003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rRiUgfftAk66H4XNSOxJzBc0lIBSKm2sh2gxXyMJBzIF3DSUTa89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n3iNwPqdtAr3SNRv9+uYtZfz2RlHNJzBvizdxqdyWF9yCMOrZdsHFDfDG2SIQDbvnmcnKjfTUva8j04jkR44yDYWHKCAJDztU0t/r3D/dWdJQMiSyIzzS82TMOlEjWBWvYeitlwX5ETnZ6m7BYASSy8TAIwEFl6X/C3cHxfKhXqhHREVqHsugSbAEhPk/GeZJZ4A8iTGZixAfHYxtOCa1n45LwVKc1Dt6ci9RV5QX89AkYK46R1ldbPf0DqaRmh6qbruuL/4PsyN93okvW2s/9uDjlh9oaJM+BY/lvueAHuwDWVJTy4TNC/cPqTu/Ryu+na9dYkH9JgoERfX4+uTtur29WMxbOMCqAGNCWqV2Q99wtNpV3dVUyEx/11Lg+HkA458yxuvjVOiMJBnMmveSj5izGjB9avuqI/JEmWIREVbKn5oadWz/q2vO5egfzTD13sOB1yj5XEnNUjIAOK6CbERoMxYI0Lhd4qqWWwP0UHnatWHWUfnhDYlfLK9fch0TRWFE35pjlGtmmMGsr9FN6JXcPBUBQAoSgVysVCI3rxfNx1V1t5QwdaLFsMkAhFzeihIYrenUPzM8yIOvlqa8y0JgZ5Ve/Jb46kRr9prqfC4Gqd2nMxfA4ZVqNSvMVG65452nIGQaufNkhqvTP7+uyqzectifs0JMV/sHicFJsw53QJZtUwx0rBlZl2b0IfGEHSXcLRMVuLGqYEHFQMIIMLLhhOASd/6GvVsAYlxj1IKLVgt3fTQVqyDZ2WTiE3dCEM6YEQbb4iI0OTI5eFkvevF4K2pgADdrKpcP7GS8WIa1P8Dh36eKjmjbqxv1Nz9TiTcZ423GkXkIuxyAIMEpIWLA/xXuo7lCC1Exp3MRhTV2djDsArw1dGgWRusR72KrVCAprvDyxKFs9sXkstAi/enOFTWfJI+AFAH4fpOfKVhGdfiLos= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c7c9ec9c-1058-45ac-26a7-08db6b8912f2 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 21:07:47.6779 (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: 39QqpBMmq5Myqe0gvzcAto8x/DoiVnIq7oIjubXuVtHn9VdObmWJcwvNT36scz+SbJc8OaWZydIHpnH8jx0x5yPWq3+1nzM4HiX8C/ClXOM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6410 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-12_16,2023-06-12_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306120180 X-Proofpoint-ORIG-GUID: 3MF584oOM9vdOWO_G0xEP1fFIE0LqmOs X-Proofpoint-GUID: 3MF584oOM9vdOWO_G0xEP1fFIE0LqmOs 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_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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?1768533323773189613?= X-GMAIL-MSGID: =?utf-8?q?1768533323773189613?= The hotplug support for kexec_load() requires changes to the userspace kexec-tools and a little extra help from the kernel. Given a kdump capture kernel loaded via kexec_load(), and a subsequent hotplug event, the crash hotplug handler finds the elfcorehdr and rewrites it to reflect the hotplug change. That is the desired outcome, however, at kernel panic time, the purgatory integrity check fails (because the elfcorehdr changed), and the capture kernel does not boot and no vmcore is generated. Therefore, the userspace kexec-tools/kexec must indicate to the kernel that the elfcorehdr can be modified (because the kexec excluded the elfcorehdr from the digest, and sized the elfcorehdr memory buffer appropriately). To facilitate hotplug support with kexec_load(): - a new kexec flag KEXEC_UPATE_ELFCOREHDR indicates that it is safe for the kernel to modify the kexec_load()'d elfcorehdr - the /sys/kernel/crash_elfcorehdr_size node communicates the preferred size of the elfcorehdr memory buffer - The sysfs crash_hotplug nodes (ie. /sys/devices/system/[cpu|memory]/crash_hotplug) dynamically take into account kexec_file_load() vs kexec_load() and KEXEC_UPDATE_ELFCOREHDR. This is critical so that the udev rule processing of crash_hotplug is all that is needed to determine if the userspace unload-then-load of the kdump image is to be skipped, or not. The proposed udev rule change looks like: # The kernel updates the crash elfcorehdr for CPU and memory changes SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" SUBSYSTEM=="memory", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" The table below indicates the behavior of kexec_load()'d kdump image updates (with the new udev crash_hotplug rule in place): Kernel |Kexec -------+-----+---- Old |Old |New | a | a -------+-----+---- New | a | b -------+-----+---- where kexec 'old' and 'new' delineate kexec-tools has the needed modifications for the crash hotplug feature, and kernel 'old' and 'new' delineate the kernel supports this crash hotplug feature. Behavior 'a' indicates the unload-then-reload of the entire kdump image. For the kexec 'old' column, the unload-then-reload occurs due to the missing flag KEXEC_UPDATE_ELFCOREHDR. An 'old' kernel (with 'new' kexec) does not present the crash_hotplug sysfs node, which leads to the unload-then-reload of the kdump image. Behavior 'b' indicates the desired optimized behavior of the kernel directly modifying the elfcorehdr and avoiding the unload-then-reload of the kdump image. If the udev rule is not updated with crash_hotplug node check, then no matter any combination of kernel or kexec is new or old, the kdump image continues to be unload-then-reload on hotplug changes. To fully support crash hotplug feature, there needs to be a rollout of kernel, kexec-tools and udev rule changes. However, the order of the rollout of these pieces does not matter; kexec_load()'d kdump images still function for hotplug as-is. Suggested-by: Hari Bathini Signed-off-by: Eric DeVolder Acked-by: Hari Bathini Acked-by: Baoquan He --- arch/x86/include/asm/kexec.h | 11 +++++++---- arch/x86/kernel/crash.c | 27 +++++++++++++++++++++++++++ include/linux/kexec.h | 14 ++++++++++++-- include/uapi/linux/kexec.h | 1 + kernel/crash_core.c | 31 +++++++++++++++++++++++++++++++ kernel/kexec.c | 5 +++++ kernel/ksysfs.c | 15 +++++++++++++++ 7 files changed, 98 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index 9143100ea3ea..3be6a98751f0 100644 --- a/arch/x86/include/asm/kexec.h +++ b/arch/x86/include/asm/kexec.h @@ -214,14 +214,17 @@ void arch_crash_handle_hotplug_event(struct kimage *image); #define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event #ifdef CONFIG_HOTPLUG_CPU -static inline int crash_hotplug_cpu_support(void) { return 1; } -#define crash_hotplug_cpu_support crash_hotplug_cpu_support +int arch_crash_hotplug_cpu_support(void); +#define crash_hotplug_cpu_support arch_crash_hotplug_cpu_support #endif #ifdef CONFIG_MEMORY_HOTPLUG -static inline int crash_hotplug_memory_support(void) { return 1; } -#define crash_hotplug_memory_support crash_hotplug_memory_support +int arch_crash_hotplug_memory_support(void); +#define crash_hotplug_memory_support arch_crash_hotplug_memory_support #endif + +unsigned int arch_crash_get_elfcorehdr_size(void); +#define crash_get_elfcorehdr_size arch_crash_get_elfcorehdr_size #endif #endif /* __ASSEMBLY__ */ diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index c70a111c44fa..caf22bcb61af 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -427,6 +427,33 @@ int crash_load_segments(struct kimage *image) #undef pr_fmt #define pr_fmt(fmt) "crash hp: " fmt +/* These functions provide the value for the sysfs crash_hotplug nodes */ +#ifdef CONFIG_HOTPLUG_CPU +int arch_crash_hotplug_cpu_support(void) +{ + return crash_check_update_elfcorehdr(); +} +#endif + +#ifdef CONFIG_MEMORY_HOTPLUG +int arch_crash_hotplug_memory_support(void) +{ + return crash_check_update_elfcorehdr(); +} +#endif + +unsigned int arch_crash_get_elfcorehdr_size(void) +{ + unsigned int sz; + + /* kernel_map, VMCOREINFO and maximum CPUs */ + sz = 2 + CONFIG_NR_CPUS_DEFAULT; + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + sz += CONFIG_CRASH_MAX_MEMORY_RANGES; + sz *= sizeof(Elf64_Phdr); + return sz; +} + /** * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes * @image: a pointer to kexec_crash_image diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 6a8a724ac638..bb0e614f2a05 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -335,6 +335,10 @@ struct kimage { unsigned int preserve_context : 1; /* If set, we are using file mode kexec syscall */ unsigned int file_mode:1; +#ifdef CONFIG_CRASH_HOTPLUG + /* If set, allow changes to elfcorehdr of kexec_load'd image */ + unsigned int update_elfcorehdr:1; +#endif #ifdef ARCH_HAS_KIMAGE_ARCH struct kimage_arch arch; @@ -411,9 +415,9 @@ bool kexec_load_permitted(int kexec_image_type); /* List of defined/legal kexec flags */ #ifndef CONFIG_KEXEC_JUMP -#define KEXEC_FLAGS KEXEC_ON_CRASH +#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_UPDATE_ELFCOREHDR) #else -#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT) +#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT | KEXEC_UPDATE_ELFCOREHDR) #endif /* List of defined/legal kexec file flags */ @@ -501,6 +505,8 @@ static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } #endif +int crash_check_update_elfcorehdr(void); + #ifndef crash_hotplug_cpu_support static inline int crash_hotplug_cpu_support(void) { return 0; } #endif @@ -509,6 +515,10 @@ static inline int crash_hotplug_cpu_support(void) { return 0; } static inline int crash_hotplug_memory_support(void) { return 0; } #endif +#ifndef crash_get_elfcorehdr_size +static inline unsigned int crash_get_elfcorehdr_size(void) { return 0; } +#endif + #else /* !CONFIG_KEXEC_CORE */ struct pt_regs; struct task_struct; diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h index 981016e05cfa..01766dd839b0 100644 --- a/include/uapi/linux/kexec.h +++ b/include/uapi/linux/kexec.h @@ -12,6 +12,7 @@ /* kexec flags for different usage scenarios */ #define KEXEC_ON_CRASH 0x00000001 #define KEXEC_PRESERVE_CONTEXT 0x00000002 +#define KEXEC_UPDATE_ELFCOREHDR 0x00000004 #define KEXEC_ARCH_MASK 0xffff0000 /* diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 53d211c690a1..fa918176d46d 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -704,6 +704,33 @@ subsys_initcall(crash_save_vmcoreinfo_init); #ifdef CONFIG_CRASH_HOTPLUG #undef pr_fmt #define pr_fmt(fmt) "crash hp: " fmt + +/* + * This routine utilized when the crash_hotplug sysfs node is read. + * It reflects the kernel's ability/permission to update the crash + * elfcorehdr directly. + */ +int crash_check_update_elfcorehdr(void) +{ + int rc = 0; + + /* Obtain lock while reading crash information */ + if (!kexec_trylock()) { + pr_info("kexec_trylock() failed, elfcorehdr may be inaccurate\n"); + return 0; + } + if (kexec_crash_image) { + if (kexec_crash_image->file_mode) + rc = 1; + else + rc = kexec_crash_image->update_elfcorehdr; + } + /* Release lock now that update complete */ + kexec_unlock(); + + return rc; +} + /* * To accurately reflect hot un/plug changes of cpu and memory resources * (including onling and offlining of those resources), the elfcorehdr @@ -734,6 +761,10 @@ static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu) image = kexec_crash_image; + /* Check that updating elfcorehdr is permitted */ + if (!(image->file_mode || image->update_elfcorehdr)) + goto out; + if (hp_action == KEXEC_CRASH_HP_ADD_CPU || hp_action == KEXEC_CRASH_HP_REMOVE_CPU) pr_debug("hp_action %u, cpu %u\n", hp_action, cpu); diff --git a/kernel/kexec.c b/kernel/kexec.c index 92d301f98776..107f355eac10 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -129,6 +129,11 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments, if (flags & KEXEC_PRESERVE_CONTEXT) image->preserve_context = 1; +#ifdef CONFIG_CRASH_HOTPLUG + if (flags & KEXEC_UPDATE_ELFCOREHDR) + image->update_elfcorehdr = 1; +#endif + ret = machine_kexec_prepare(image); if (ret) goto out; diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index aad7a3bfd846..1d4bc493b2f4 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c @@ -165,6 +165,18 @@ static ssize_t vmcoreinfo_show(struct kobject *kobj, } KERNEL_ATTR_RO(vmcoreinfo); +#ifdef CONFIG_CRASH_HOTPLUG +static ssize_t crash_elfcorehdr_size_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + unsigned int sz = crash_get_elfcorehdr_size(); + + return sysfs_emit(buf, "%u\n", sz); +} +KERNEL_ATTR_RO(crash_elfcorehdr_size); + +#endif + #endif /* CONFIG_CRASH_CORE */ /* whether file capabilities are enabled */ @@ -255,6 +267,9 @@ static struct attribute * kernel_attrs[] = { #endif #ifdef CONFIG_CRASH_CORE &vmcoreinfo_attr.attr, +#ifdef CONFIG_CRASH_HOTPLUG + &crash_elfcorehdr_size_attr.attr, +#endif #endif #ifndef CONFIG_TINY_RCU &rcu_expedited_attr.attr, From patchwork Mon Jun 12 21:07:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 106900 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp139344vqr; Mon, 12 Jun 2023 14:20:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5NP0wHiSF/Wo4P6XcqjgQpaWi2ELa6mwembANk0T0uOGuhDNcz7c1LVPZRyeX5BYrqE9Ul X-Received: by 2002:a17:907:7249:b0:973:dd5b:4072 with SMTP id ds9-20020a170907724900b00973dd5b4072mr8872670ejc.53.1686604821579; Mon, 12 Jun 2023 14:20:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686604821; cv=pass; d=google.com; s=arc-20160816; b=m/QjiTnxOrWkSxwERoxRW6+/E0WaPfZ2az7MSBPVkBp3jowYPLtN5+ff2gUzmnnkTG ztMLA9CJzTYpxG9mitcMSWoL8ap3PWz0FK0c5Jj/FQZLjJgwqfcXjD9BefmFhSzXiNZh KBWL5FuirqV62HxbcVf/13uT5NtqJQ0fkzdMS6OLymRPAiiVL4VCWQ46wl+XTgxwuSKx ju0bVGTk2Wm9uBLO2QaeGSrhl+aEQwdj17cvJKo5R2U9GMDCWXptCariyor47z8NbFcI nsxJrYFOnwU2R4kVUIDnElA6PSkOJjHPDCrjz7md2872QryuNfK0w+NBtOeoHg28qEwy aOdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=kqZzUcUI7g9GrNNQb568EFpHtig8R3NmjYR2Lpu3gEg=; b=pHbCYqS0ott9t/seqCtQZvbDNfaLcDBDqcknYCk1ilWZjgkvC70T6exttdbKkvZYJR 7sA38cRQXDNWDXXCD4hC2qErCxxgfTvhmG5Vpxnv1mvhMXrFLF3nS0efoVBbks8Yuyp7 di0ML0wbgOIS0+R0BD464PvT/GXUAdNIqTpTBVYWox9K58Nozq/Fn8YcYihU9jPUjxXs Am2MT2mgietgIczE1RcZ3Jdu59AnA3JPr+GYGTRusP1iaHMKIpTyJckASXt0feeSAuMu AYZIWgIneSj4ssZRBfk6870fbAELZaGou6uPO7u5EUXga8TJxk0TuzVZ0ZiOicIj1cJ9 GUPQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=cz9NaVXh; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=C9bNmRoh; 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 ha13-20020a170906a88d00b009745124453csi5408095ejb.815.2023.06.12.14.19.56; Mon, 12 Jun 2023 14:20:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=cz9NaVXh; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=C9bNmRoh; 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 S233202AbjFLVQJ (ORCPT + 99 others); Mon, 12 Jun 2023 17:16:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238283AbjFLVOm (ORCPT ); Mon, 12 Jun 2023 17:14:42 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D4CD3589; Mon, 12 Jun 2023 14:08:32 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35CKOQJ8002213; Mon, 12 Jun 2023 21:07:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=kqZzUcUI7g9GrNNQb568EFpHtig8R3NmjYR2Lpu3gEg=; b=cz9NaVXhhRYZ08GL5/YRc3xVj75mpl4HzUEXUsCgrxRR+Yuwy+zHZIIbC/6qkXctPKEe 313X9W0ktxxwVERAQLLkTwW32EkRu2ZUKf4qXtTypk8qKy+8+UXtTq0X1jHgoSYT5arE EoMTcyUuGuXoMNus8MNzPcwDcj0nUJ/nASZZpEMgVw7gc6NHe6m5Xi9PPnqnWS3Gg90Q wtYGU7vqk93ETTwzdvzueGW5re2rWWmyX/Z5bogRJZf8OT/Kx1W2Nm061O96JBbIoOBE Nlr6wh12ZBiWMIWPT82SfxcWnVOb6WapvyYeLfb6Juy3dIqwFHTZIHAmd3N7X/sKdCZ7 xA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3r4hqukwq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:53 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35CKVfDD017798; Mon, 12 Jun 2023 21:07:53 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2048.outbound.protection.outlook.com [104.47.51.48]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r4fm3204k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d1YuPK4TsG4sor7f6ffFLJ1G3F4zz95OydWiERlrIbH0TltZK9HRABjmOAivJqszHPaURT8XZ4mMoZq9LFqkuukxzhow6sWbLWhOQTUA42xLYNhi2i50OIqPJwVN4Z3h936g0w579j2juU5GpaSIO2hAnjdUPm4Per5wNcYi6y/FqhIKvBR1hfs5NIOI0V/DMZD7+YNQrDmh/9GrIMGifZzmxi/7NI+QxVGrYnT4Gs51S55hmQzr//URzLBQOJTon2tsa2cq25GyXNTenksj3UKkNzRn2AEkFUf4eTu2e7hcWLUEnyYrc0gmNBMenfS4Fc4Vu4gGOtUPAieX05kS4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kqZzUcUI7g9GrNNQb568EFpHtig8R3NmjYR2Lpu3gEg=; b=CrAkWG2iFK34rxmxGDoBUXdsUT5GePQQXME/tUghJxW1j2dX7LlPPFV6+LaN8NGPbfPpgLpaX7gsQXgAF7D+7c38Sxu7zcwW81mYoXj45HDf/iuhKruu2/Nxx3vF4Gw2zEvxkYIQg+aM1gDJBiGUPzoK7K8JNeR7cPec3NL3LnnB3dYhYzUv1oTQtguw7kZ540KYylbVig2m/XZ8+EnGxUY0SqqnnI2Ks28nyqVMrZBpDKOC/98BoeEpsM4LvLKnK21Td5wcTMSjafv3dEPF2hkFpy5b4KX9tK+h+mAAu4ngZrGTy40K/bHcGeTN7phlZq3NogriPJrMQe9FfwxPCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kqZzUcUI7g9GrNNQb568EFpHtig8R3NmjYR2Lpu3gEg=; b=C9bNmRoh9MeMeBUe8vtribzHoGCtxwmxZOEI0cc4qT9dV88rzEWCXo+NyJBqOsfLy8MlmPwJIesV2JoEAJDkIx6vyQc7JXNLYiEhPq/b2j89cCNTXuNYA2b/y0t+LiOi0bzDa/EOFat4A9GHD4pEWt4EbR5tJwQRX2oQEm/CSSA= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH8PR10MB6410.namprd10.prod.outlook.com (2603:10b6:510:1c5::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.38; Mon, 12 Jun 2023 21:07:50 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6477.028; Mon, 12 Jun 2023 21:07:50 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v23 7/8] crash: change crash_prepare_elf64_headers() to for_each_possible_cpu() Date: Mon, 12 Jun 2023 17:07:11 -0400 Message-Id: <20230612210712.683175-8-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230612210712.683175-1-eric.devolder@oracle.com> References: <20230612210712.683175-1-eric.devolder@oracle.com> X-ClientProxiedBy: DS0PR17CA0005.namprd17.prod.outlook.com (2603:10b6:8:191::6) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH8PR10MB6410:EE_ X-MS-Office365-Filtering-Correlation-Id: aacf6494-9c28-4064-2cf9-08db6b89144e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nM0l6jGA4v7bF3GFnIfy+reDFIAFDLduWM8lZOmpqjupjB1jBZf7xZYECtli+jrZDn4G6KgNDUckQIGLYbC9CP652Ca0yAX1SCDRo+LfEqYdAAtC/DPL6HZQbYFweiB6eOrQyJZH7YXYhkEaENU7dqR3hAlebcn3swhC1CSZgeN0+5eLvZtCIHLhPrOJYhvrzf8GIwN4LOM3PHeV/1MiQKJW6RYeT8SolJ94mGSQ3YP4SnJ1ny2NNnSvCMFwlZmDG2PbrT0QnqcRV1KJRu6zTtwl0/YjV92tOLMH7n4Ciyh68LQgnlIzLnsS0PrVlpyKei2naI1hDoKpWMotIvv3lfX1eeIc4IB0mIW0lx+RgIU9tTmkLt5SoL0rxTT2TKSlaYttzESX9WfZk3mavWwgi/qypVCIJVfhyYE21bC5V4trnawUNY/YC72d/xhCH0FgtUgzKvNzQs22DfBSi3lUAK4c6vUtpS59JCdURct9G51cYkihx/nv2c8GfYvRRH61wtUtkVgMS0Vqc9jyTcBi4aoUYq+F1e/Y4DQJcNDm5k5TKWBrUp+iSMO4yW3g/kII5btJkyQG1CKZAgYNj/XjB3IQBIw+xQtgVI2DtbJCX74= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(366004)(346002)(396003)(376002)(136003)(451199021)(66556008)(66946007)(8936002)(36756003)(5660300002)(8676002)(4326008)(6666004)(66476007)(478600001)(6486002)(41300700001)(316002)(38100700002)(921005)(107886003)(7416002)(6512007)(186003)(26005)(1076003)(7406005)(2616005)(6506007)(83380400001)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lvgnFFHA3/dZ17Xy1atKIxC4l75yMWKVP0G2/N68JSZE55Gly0nZhie0arLJN/tJQeolXizchsy3RPJFtV5kEqs/obxj9lfgZBaI5wXxVDA2DlOC5t+yJN+JY2lutzlflxjsyywEwEUkJtZ5QCxmWKkpS0crFvutP6Ywwnv17NS6QI96KP3kZf7hKGEmaQO6txuosMLoR+Q7i5sREsolyB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YmLbjE/VGPlgQ+KTHlpyHpPd7CfExxaJ2+v8EO0P4rqwKzD8nRMk3ub0wia9Dy08PMUFsAlQDbVceGnjl0woiSwyJrrldFsREykg0cC1HpiDmfLIr2gDDKdB4Up/5u4DB4t6eLHd5GzmXNUeIiIALoPy4/fokscACIWeFV9nARFmZCdPK0tM30LXro5ooqPiII+KRXATb4wEwSbqcOtniAGeR8iuAV54MzGyqci1pUCyGFHeIafOSGrprLlXGfGz31/fZunazUpFg2+5jAZAFD7vyicVDQrtVGqGfvPMXxlatxVf16TiWsuYAXb1uBIU2LO4zdza2p/fUKfQDOJea4J6k2l4SWWaWYG2H07ws4Mnw9+WftWPhoyydD4kxUhps0bSBbWIwOKC9YZTjm4OvgOw1QDg4arclXB+39DWZM3jVuO7dOTV8QKbhIHD61iv8/P25et/957T25hcZ0qHtnnB2bs8M20wCoH8q1PXpX4WslMGJgm8zNtWZSqSKIDoyvKpt1SDnS4RJWRtDj3oMvpveuDHu7nrWjkl+TbKRP05EzvYhdwkujbkB55mWv23qFPjz0K+29D19zOgm6mSXh/okyE7AEGaAR33UYwbvGxNoz/SIN1QgbFizd81K5ZCb05I1mQuIsdJuKAZguzgk+b0/TgRUZXgpiNj8QUZkj8NqOLXOJCpQnsZGE5lt3A4QFV2UN4gFD/dWrlcOXDG4x3bQwK8bgb33k5++zyAZtr//O4UuebQufvqu43k2jDeDDTIuMvzexc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: aacf6494-9c28-4064-2cf9-08db6b89144e X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 21:07:49.9642 (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: /2wJJL9CQAWC8ZcAc4USXQM/NDeW+133IuD3YB//PIib0d98CU1n+bJUCPMoq+7h1a+BR9VKzk/Z3PyjlwBX2KoKHMD2F8znZKBRd6/KThY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6410 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-12_16,2023-06-12_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306120180 X-Proofpoint-ORIG-GUID: 10FEtue46Nhi5D7w3FUnppHggSbevxaZ X-Proofpoint-GUID: 10FEtue46Nhi5D7w3FUnppHggSbevxaZ 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_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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?1768533337838998229?= X-GMAIL-MSGID: =?utf-8?q?1768533337838998229?= The function crash_prepare_elf64_headers() generates the elfcorehdr which describes the CPUs and memory in the system for the crash kernel. In particular, it writes out ELF PT_NOTEs for memory regions and the CPUs in the system. With respect to the CPUs, the current implementation utilizes for_each_present_cpu() which means that as CPUs are added and removed, the elfcorehdr must again be updated to reflect the new set of CPUs. The reasoning behind the move to use for_each_possible_cpu(), is: - At kernel boot time, all percpu crash_notes are allocated for all possible CPUs; that is, crash_notes are not allocated dynamically when CPUs are plugged/unplugged. Thus the crash_notes for each possible CPU are always available. - The crash_prepare_elf64_headers() creates an ELF PT_NOTE per CPU. Changing to for_each_possible_cpu() is valid as the crash_notes pointed to by each CPU PT_NOTE are present and always valid. Furthermore, examining a common crash processing path of: kernel panic -> crash kernel -> makedumpfile -> 'crash' analyzer elfcorehdr /proc/vmcore vmcore reveals how the ELF CPU PT_NOTEs are utilized: - Upon panic, each CPU is sent an IPI and shuts itself down, recording its state in its crash_notes. When all CPUs are shutdown, the crash kernel is launched with a pointer to the elfcorehdr. - The crash kernel via linux/fs/proc/vmcore.c does not examine or use the contents of the PT_NOTEs, it exposes them via /proc/vmcore. - The makedumpfile utility uses /proc/vmcore and reads the CPU PT_NOTEs to craft a nr_cpus variable, which is reported in a header but otherwise generally unused. Makedumpfile creates the vmcore. - The 'crash' dump analyzer does not appear to reference the CPU PT_NOTEs. Instead it looks-up the cpu_[possible|present|onlin]_mask symbols and directly examines those structure contents from vmcore memory. From that information it is able to determine which CPUs are present and online, and locate the corresponding crash_notes. Said differently, it appears that 'crash' analyzer does not rely on the ELF PT_NOTEs for CPUs; rather it obtains the information directly via kernel symbols and the memory within the vmcore. (There maybe other vmcore generating and analysis tools that do use these PT_NOTEs, but 'makedumpfile' and 'crash' seems to be the most common solution.) This results in the benefit of having all CPUs described in the elfcorehdr, and therefore reducing the need to re-generate the elfcorehdr on CPU changes, at the small expense of an additional 56 bytes per PT_NOTE for not-present-but-possible CPUs. On systems where kexec_file_load() syscall is utilized, all the above is valid. On systems where kexec_load() syscall is utilized, there may be the need for the elfcorehdr to be regenerated once. The reason being that some archs only populate the 'present' CPUs from the /sys/devices/system/cpus entries, which the userspace 'kexec' utility uses to generate the userspace-supplied elfcorehdr. In this situation, one memory or CPU change will rewrite the elfcorehdr via the crash_prepare_elf64_headers() function and now all possible CPUs will be described, just as with kexec_file_load() syscall. Suggested-by: Sourabh Jain Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- kernel/crash_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index fa918176d46d..7378b501fada 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -364,8 +364,8 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, ehdr->e_ehsize = sizeof(Elf64_Ehdr); ehdr->e_phentsize = sizeof(Elf64_Phdr); - /* Prepare one phdr of type PT_NOTE for each present CPU */ - for_each_present_cpu(cpu) { + /* Prepare one phdr of type PT_NOTE for each possible CPU */ + for_each_possible_cpu(cpu) { phdr->p_type = PT_NOTE; notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); phdr->p_offset = phdr->p_paddr = notes_addr; From patchwork Mon Jun 12 21:07:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 106899 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp139288vqr; Mon, 12 Jun 2023 14:20:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6PC3Ms4zpC9N8BS48poMoH77ZUyhw6bQTUONJgJcdjXEbgBzQawBXS+C3BrPrh/QGwetnc X-Received: by 2002:a17:907:9495:b0:974:6026:a312 with SMTP id dm21-20020a170907949500b009746026a312mr10699045ejc.51.1686604814912; Mon, 12 Jun 2023 14:20:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686604814; cv=pass; d=google.com; s=arc-20160816; b=rvrZhFJYNReVrwVWHIhz2YXTLxyp4dJOS51T22U+f0i8xFu41tRwj2+5fwJkl9pW+i 7ZnIi1KozpVXSmLUXuaCH/RMOBVkAUf3sOPzgfrGmNH8ieZmpyLQU7bMM6oaowembxyu pTfAA/k2rVAs1zCQCyC4np/5G0WQaivAIk4GY8j4d7Es2C3DrcxKWn5LwfCSN06Vt2K5 dAQyQ+TmCF2nK85wkUXWNdJPn7qjaSQbpt0C/TKoDDKcT+BAA40ywZQ3PzANznA+dJ3f 4Y4j3/Qqri0A8ECMybZNHaKedSX2B0RLbv9ib5rBMr8n06K84Wm+o2JqqnsRRrzuxYWF RHYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=o+McSM2gKtujfwRfyeOsaE02Y4bKTLqqTyQF/lTUOqg=; b=MYplZ9MPZsoQDX/dZRJvR6olGU2vTIF5ZymVD74ZNiMZjHRl2qh/009QGechYsHNuu DXtjL38tfaaWW9IYq5g70CYVPP4yAbM59QhfU24I7bAorWFNU9k7swQnRsSk/ZJPU/ux G7BsPTDSyEDf2vMt94FNK3tlRIBMFqSCRPo5B0Brflk3zfI4iFSUFI+Oah48z3+j5m12 nLxdO1y3gBPUsjkY6zshxGk5wx3MFFni3/EMTDvRa4F7RH6dpg+qY+0TAai/zhpyS2N4 y9i8ooT3LttcxZTq5kPEWxumaCXR3a5c1X0hSnq6+ws1NjcdBG0zKSoFVjXEaeaIfE5j rNrg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b="te//8Efw"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ax8AnOO5; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a170906284b00b00977d29ecc8dsi5214977ejc.905.2023.06.12.14.19.49; Mon, 12 Jun 2023 14:20:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b="te//8Efw"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ax8AnOO5; 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 S233276AbjFLVQF (ORCPT + 99 others); Mon, 12 Jun 2023 17:16:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233893AbjFLVOk (ORCPT ); Mon, 12 Jun 2023 17:14:40 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1474830E5; Mon, 12 Jun 2023 14:08:25 -0700 (PDT) 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 35CKNkQ4016721; Mon, 12 Jun 2023 21:07:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=o+McSM2gKtujfwRfyeOsaE02Y4bKTLqqTyQF/lTUOqg=; b=te//8EfwaxyOP4yaZY+uGeiOca9qf/cEL4XFcPKdnhor+KjR5nWahzXxp0crSaQ9MNBk OnMPqCptjxnQkd1RCmDxve98HoI21YvW5VW138TLi5wBVZwsy3BOOMIUqw4wISKQi4aG dG41Z2eMaS6mStjfwWYxo1yIhtw0sDWJuJUwJGRvWVGhBK4BDhChXyAIWxkXttYU4xe9 FcfLJWWt5s/J9f6RR/pEkPWIxozr/IBDV7GzfIRqYMykrk1G2RyzqT8eycvzL3A6TPQD ucM+UP+Ps2gMb0Lgm7h77tkayiKhlUWIWG2avtMRKgwsxhB4DXg5sKwHXlh67ii90iFd /Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3r4fy3bwb8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:55 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35CKL4O3008399; Mon, 12 Jun 2023 21:07:55 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2045.outbound.protection.outlook.com [104.47.51.45]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r4fm9j9ur-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jun 2023 21:07:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q4c9gIwWDjlbSrCFcIONNYd5GNSE7s4j0nz7PspCOsqqGcdxerwuC+FggVu8Z4lAkc99U3vI7qY1O/uyO3OG/WYJIYLNXW0hP41UGKpZg5tkuSKQEKagBWS1jupFLH3pTQfTS7KVYXhgMZevoBZyHY1mYurLcFm4hqSaCd03Ju4yQ6AR3sftPy//vjNudyw+lJPojDzpjCy4nkjF0QIfCcBZQZ5hU6Rey+ZJmJ68QoMJWkUIvxxZYadiY3eUihUvthBKAVh8zZ8n5A7aDUCrk5zOKv+VZHGzYooXZ7EX/hHwOoOwMAgMtoAgaUfIkTAz71T55QTcBTOgjvdHlzdcQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o+McSM2gKtujfwRfyeOsaE02Y4bKTLqqTyQF/lTUOqg=; b=BTgPgUuuweWlf5I/xRZnzerAfTeju00pG8+uR+U/YRe+rdJGyDk2N2DyvUCOPXIkbpL1FE6Hq5QrNUIm2+Qo3QhaanT3ulSdG+g6LyyOaCA7P/stYsJIcbyKG6jHjkq8pKBZ+y1L98255zHKknTq0ECtOvWeHugxrOxHgOH1/R2CMNdsxMlX72ML0HDx2BcUdciXaO8knLZyGj4WgjMvA8SrZgGc77iBwudLi/sQplg59VFG3tevPLP5LwEcyimbBHWnfcy3oxUh8Dw6PEHJ91LpcDWlJtoDw8EPLxSAV0vG9jaQKKBY75zSMJeN1FABVV8ZIyp1UY14cSExCDDPHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o+McSM2gKtujfwRfyeOsaE02Y4bKTLqqTyQF/lTUOqg=; b=ax8AnOO5U6T/IkcLs9OE6iMfwQRtJfkEQRm4iYWshhElw7WPdeVrVfCk+wkeVHeMgLYM/LyNsMCViqTJOFz9TZ8IdX4ATIY+IRdNnY+BfhAiN6vmOzRzNnu4e60aNzqPZgSb+3+X8OkTlZboXcUJUl0TtVz5z5o9n7YObTp3KPc= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH8PR10MB6410.namprd10.prod.outlook.com (2603:10b6:510:1c5::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.38; Mon, 12 Jun 2023 21:07:52 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6477.028; Mon, 12 Jun 2023 21:07:52 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v23 8/8] x86/crash: optimize CPU changes Date: Mon, 12 Jun 2023 17:07:12 -0400 Message-Id: <20230612210712.683175-9-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230612210712.683175-1-eric.devolder@oracle.com> References: <20230612210712.683175-1-eric.devolder@oracle.com> X-ClientProxiedBy: DS0PR17CA0019.namprd17.prod.outlook.com (2603:10b6:8:191::8) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH8PR10MB6410:EE_ X-MS-Office365-Filtering-Correlation-Id: edfb1e0c-0efa-4531-541e-08db6b8915ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aw7Kf4U2RBOZYHalfqCdYLfcbGcJ58ZjXAJRhWHUcYUDz+/k4/GHFWhTTprDgUUIgYMhx8X/Wsk18GYlN1ZpateN6ipylM1VI0rL9+aZBDx4qAUWs0uKFrN4kUCI2ZCCg4Wgl1o5s6tKabUlTjURAYqquW7RVtjhVQCgX99TjcAz0WwLJebmSJ3Ubq0kxTR1CfygsVZy2PikKS7SpEGNyyNjvLoC2Q9FGbD1/otZ/sh/m746K1oI3jfWEo8FOsM3INs7zOLi0+OQrVSA5JCRR9Zq7iNyI2ILmErmHKznOf93uCyYMbji8Oey+stYAJkko92zuwuhsxveOuA2q9d/R99vi7RFqXdXhhW7Kcu3F9XTx47c6etSv/NG3IiSfC3ZZFRxjs5KU2ReRN72PwVUTyNgFyBn+EZhy7NG/f8fgjjswkfVfOjTd/SRG99gsw/o9a66C7LCyWDzZ3TKpxBgBGcx7sWwMQnjYdF5fyv2nwdpWDhs0ZOcpXINfCODCqzMRiXJ3B0dsWXUD4AyKyfyyoPW6ie/tNubNPfbV4PBS+rjtFO403Ho8gIbvdKrsn2tb7L+g5HJC7IrvrR/S9Q8zo5bdmFfjh1lCtO6bsv4k8U= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(366004)(346002)(396003)(376002)(136003)(451199021)(66556008)(66946007)(8936002)(36756003)(5660300002)(8676002)(4326008)(6666004)(66476007)(478600001)(6486002)(41300700001)(316002)(38100700002)(921005)(107886003)(7416002)(6512007)(186003)(26005)(1076003)(7406005)(2616005)(6506007)(83380400001)(86362001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: H/GrEbwrvRIG1hpph9pkHYoLzpMWE/87wpHjeAC+ewkSrpyr924CxEfEi92lSSVSJHnKkuGimfnYHbokWM8EtaLdxMIjyIKxJRN5OcT7AAJOkodI1of/cybMsGzAg5zBAFDMxzYFvEeBwZEHNWOBzYMj1IcxGWE2tdwY4TpFpwFtBhP73bilEIbDmtQbfebinXbzNWyD7rillY3CMGxmPm3PzIWk9CU/5K2Cq+BLvjT0yfawnEPxfHo64MzmuH6UWQlxRBt6xoxq1V4wTpUZ2E7EHDNrgiBfLP/3jLpRRnKPBqXdweJVvQT0zd0XRS4Gv5IniRapH7BDYFBH/UTvaaE6aX5r5Fn1WCIdH/sfbLgssZUjSbQH3829FWfi0r+h6zGOKvN5sLQeF4EmN9iOgJNVh1QcMuE2Os5Ggg4xDj7YjsIaRGoRNbxUjjNPmUHqZ/BUmM2kowHFrPOFvVZLYezfjGSdML6bvnSjoK9DIGKkm+S3/gM5mQ2e8xwVQHBxCct3q4xeiTBl4iFynr4MqlYTc+UOEokIvH45A5xU7sHzBsPYwcyPh61opyPZ4M06zcr8rxucQJg34/2Uv3DyOGFwWVTmxu6kE9xyhv2B45h6faSZ8q/VrqZjM0QasUKU59pztbiP21aUvlxF3pnYKiabVF8BqjZEWs7Ar80ZQdZspdVxzNCD2gbNLQU+1+mQXx7UW+FhLTBaxKWy36HGdsiRYlzYEB7I/92F0xUeblJpjfWbZyPmmcxMI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/iqZFxPyYOkDGA2H+9PANJPspWoQcD7oQruHatBqp87s+rkdCMg+f5dtVfZlG+fwSJ6ccj+1TvwiGB5gd43h62TCEaTXY9YnQGv6tvRdn9+i4zMQTLASHhEyT9b05jMxbOIjvOwOtuEa6bEmS4HuFup7rQyVsn+PdV6mgPkT3l65Lavr0bnJQIoKfoHASzq3rRFAYqHSn1LR0e+gODy8uOU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: edfb1e0c-0efa-4531-541e-08db6b8915ef X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 21:07:52.7321 (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: 2kERe+G3banCgkzlGp8aNdX8NZD+Lv74Vtm2oubtsL1Yd01htrwKmPgXSGYZzJ7pLXVEwks7MqNYBbWWO3NoZZwvwVB1TJuvamAtON/5WQ8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6410 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-12_16,2023-06-12_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306120180 X-Proofpoint-GUID: ZsF877mBckACUNC3VPrdpzLiNXxHTu7P X-Proofpoint-ORIG-GUID: ZsF877mBckACUNC3VPrdpzLiNXxHTu7P 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_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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?1768533330848315085?= X-GMAIL-MSGID: =?utf-8?q?1768533330848315085?= crash_prepare_elf64_headers() writes into the elfcorehdr an ELF PT_NOTE for all possible CPUs. As such, subsequent changes to CPUs (ie. hot un/plug, online/offline) do not need to rewrite the elfcorehdr. The kimage->file_mode term covers kdump images loaded via the kexec_file_load() syscall. Since crash_prepare_elf64_headers() wrote the initial elfcorehdr, no update to the elfcorehdr is needed for CPU changes. The kimage->elfcorehdr_updated term covers kdump images loaded via the kexec_load() syscall. At least one memory or CPU change must occur to cause crash_prepare_elf64_headers() to rewrite the elfcorehdr. Afterwards, no update to the elfcorehdr is needed for CPU changes. This code is intentionally *NOT* hoisted into crash_handle_hotplug_event() as it would prevent the arch-specific handler from running for CPU changes. This would break PPC, for example, which needs to update other information besides the elfcorehdr, on CPU changes. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- arch/x86/kernel/crash.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index caf22bcb61af..18d2a18d1073 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -467,6 +467,16 @@ void arch_crash_handle_hotplug_event(struct kimage *image) unsigned long mem, memsz; unsigned long elfsz = 0; + /* + * As crash_prepare_elf64_headers() has already described all + * possible CPUs, there is no need to update the elfcorehdr + * for additional CPU changes. + */ + if ((image->file_mode || image->elfcorehdr_updated) && + ((image->hp_action == KEXEC_CRASH_HP_ADD_CPU) || + (image->hp_action == KEXEC_CRASH_HP_REMOVE_CPU))) + return; + /* * Create the new elfcorehdr reflecting the changes to CPU and/or * memory resources.