From patchwork Fri Mar 17 21:21:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 71444 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1906wrt; Fri, 17 Mar 2023 14:36:34 -0700 (PDT) X-Google-Smtp-Source: AK7set+3EXiOwCa8iHZaxWOC3H+w0D2A2dYsbK03ALv2Ux3na8NAgUdX64a6k2PFsnTv1PXQhcnv X-Received: by 2002:a17:90b:291:b0:23f:3b90:8bd7 with SMTP id az17-20020a17090b029100b0023f3b908bd7mr5606192pjb.1.1679088994289; Fri, 17 Mar 2023 14:36:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679088994; cv=pass; d=google.com; s=arc-20160816; b=fLJoiA/eYl7FcEyOQwZyL0TaGXOYhbvn9Xq4Zl8H1JS9KgEhDPPA1BAFAWcKUfBDtF 0tySji8yRgl+T5Zl4PDvG3IYgaN/esukL6GkElFXmX7gUpnFRnZ9zDCndEhxY3M+wmN5 71925o4U+P2A23QGObL9ZSR9e6rsBLpe6sNEAOMPmfRuohhirPdSm7AuHCj1+RwS97do TzuKSSPUIy2T5ED0qnp2Km20OnIBDhPZkuH1TNI35fvCXbQTfKdN/CWQMvwS6/n3GfVg CW0U5dnKU2Ds6hV2PkVkMp+Ho720f4OKqWORK9FuCRyFHnqP0Q4ckqEneE5pLIWLAgvJ rv9Q== 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=lEFD23QmTLYYK8yQVsZjvDDMz2M6TsVx+IjtH4pAOEY=; b=KiVwzPu3S5FGLdXloGEyYnM4dFAn6FtM1i2eZhMzVrSsg+lQZmsDAGsdMY+ZMAqLS9 mBJexVHBVBfUbOoWf9FEdyEj9expanzP1WDoaxHo7O09bYdnWM75Xm72wOhOzrZ2nxxq Y84noxXl8dQZWNhJtOSu2GStxnrshtWj+Cb+iuqDjX8LNyE/LpJfTRi3L6dartVDP+M5 RKDbQHwLz4OAPKvRjGyyTi+2gSuvUWqZ38inDzyydDMvqlm6BkAFZO7NVScu8h9gaPF8 iwkyG2lxJyFKwHOM64foUcRdV74hYezLdLfJ3ThvJH5izGQp+K3WVpO1zbFyv579bMKo vMpw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=xUBT7aQO; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=p+sDKTNx; 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 ep2-20020a17090ae64200b002372f2c4d9dsi8220035pjb.44.2023.03.17.14.35.53; Fri, 17 Mar 2023 14:36:34 -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-2022-7-12 header.b=xUBT7aQO; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=p+sDKTNx; 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 S230187AbjCQVWV (ORCPT + 99 others); Fri, 17 Mar 2023 17:22:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229972AbjCQVWQ (ORCPT ); Fri, 17 Mar 2023 17:22:16 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0A72C6DB7 for ; Fri, 17 Mar 2023 14:22:11 -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 32HKf69G014642; Fri, 17 Mar 2023 21:21: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-2022-7-12; bh=lEFD23QmTLYYK8yQVsZjvDDMz2M6TsVx+IjtH4pAOEY=; b=xUBT7aQO4FOwCNXucJquHJztzdLWhRW93O0jNFwrcg7N5Y/kMGVhZkVGa/7ZOg8pohBb 4rtHtwKrZDHYRoyDYiElKG+kUAoqU8dUtmEK0cG8ej/NwLU2xgtVA+x3BPzzSRa6bAAE WQvCPP62F9oLus/+nyAHdyW/Aa4QE88BCwrI+If37k8/pgx/BQb8cqbPL/xU0C5v7kJl AD+YZSfqZgBGKOmu+iKgOAEvevK6QYJY0m4z3DS1QGWZ3lGwpjkgKy2nQLSjeH2bcvNV 1gnnd913drgFnSKSe5dFmTZo2ZhVokW/xX/uHM7+A3+ChsyrMsiW/xdsoMfeKLdGlnPi Kw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pbs29vscm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Mar 2023 21:21:46 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 32HLLeZh015579; Fri, 17 Mar 2023 21:21:45 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3pcu2uc461-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Mar 2023 21:21:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M1m2vmcpu+RWeTgQMFIbpbTl/iuUZJRLVA+wS9iwZegoUQzZMLiPpRq76icivr0wSCDz6hkG/wWzLKvga0q6gTCzd5obH7WTCQdFRN1IXE0uRmUWSkevAuFakEM3T/v3zRrYOiLjI6o4HTBEN5igk8B9c5mIzrKdw5AIQ2p8C43n48qyIaOSitnhZBDQ5zLNSVYbj8eN5NOMvf4Egakg6sh6rMO8Pu1dCT24VXrdOPbgquW138xmNRD2XJ4M7jRq1BkM9QeYVXG3J08kvJ0T9JGk2roV+1ZlU4kX/nwR8VHlShI7GHDhzvbp3hQ2TewalU9I8Bd+XkbWcsBWmVAm+w== 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=lEFD23QmTLYYK8yQVsZjvDDMz2M6TsVx+IjtH4pAOEY=; b=DF6cEG7wDiEhODcKQ/mM5AM/NZGOlmdGxJs8nCoK9o3wX8OLKJrdvcek3n0MAc8sisWzfyrvcYj+johsKe1AUpWEgZa+Klpq0GjcoNNKbUGx3/xpQVGGzYQKIoamH3Q9dmJ3xv2OuuL8faWxV0Wjrug4UydHuApraYH/l277H4Bp4hYQlSmMBCnMQnNg3hlyNX9mRR9zqlvU7lSD7EtELlkHM477oB2jQETgedsJ3Jxobqqes6N3/AepRPMBgTRMhTfdUOhZVz4+JsBpYqgjPnVsaQtxjY+ujmQ4U9YL6O6iBkdrT9dqfgs8fv9QxgpnGkl+t6G205xEP5TSh04aLQ== 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=lEFD23QmTLYYK8yQVsZjvDDMz2M6TsVx+IjtH4pAOEY=; b=p+sDKTNx4FHrr05mdoVuSrgc/OfZ+9mVaTnsTTHhq2ekR8dS2tvFsorrt2/ZXoCrqpUGD2Wp82I8MwmoTj9IHC0x25r9gag4PaKqTWkCx+z6+2DPFNDY+yUTdoB+eHbVoHnm4YCztEfH83eHthj2LWhvhCOx2AhHXLq2oy4Yc/E= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by CH0PR10MB7483.namprd10.prod.outlook.com (2603:10b6:610:18e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.24; Fri, 17 Mar 2023 21:21:42 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38%9]) with mapi id 15.20.6178.035; Fri, 17 Mar 2023 21:21:42 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v20 1/8] crash: move a few code bits to setup support of crash hotplug Date: Fri, 17 Mar 2023 17:21:22 -0400 Message-Id: <20230317212128.21424-2-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230317212128.21424-1-eric.devolder@oracle.com> References: <20230317212128.21424-1-eric.devolder@oracle.com> X-ClientProxiedBy: DS7PR03CA0205.namprd03.prod.outlook.com (2603:10b6:5:3b6::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_|CH0PR10MB7483:EE_ X-MS-Office365-Filtering-Correlation-Id: 86e562a8-87fc-4a24-b02c-08db272d9a84 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RdZeykuIp8T7Gl6Op67drQbJy16LsvuJ8JAH2I1S6IJ2V5tFgWEWgVnJAmcQgGGMWmmQk+o5y+/Lk8pN7S2xjLxTxan+td5kLW1tM/YTGMdVB80MGN8XNP62kZinZjwM45TECxUzifNW4zC6ADR31ksMKkBT3PA7Saqp2FifhdU4rLf9Wfg6mL9Jq8C6zJcBq+/+YzBOU7CxKCvJForkRCYKb/1wlqw5L4FDCKQ0uncpMmkExjQ24xN2933IyAd8xzeVaRlvBgZO4RKRh33rJM8oEqPZcPgmyc35Ru73XocJJJCKsC79lh5lRNAO1V6fO5itxLn0RHSP82spb3loMmQTRTspkePSv/eVRDfi2OXEAqDUicAth0UZ4IF0G939tpLKzw0Ryl8kVVVcQpwPqA4fUzCK/G7LuyaIg4if2WtOcDPj6PNJZqz61c3j6idqO1ZGARfwi8bt6dkvARTlJhi41CTgLHNkUyd71Pk8+2i1rYOn+sktMb9HcP6geeoDS7tPUzxF66LjTIZeq9b1qug9nBINWTk7ZdJZUd3jRJCqq/aYwns8lZPiJsREWdVlCSEe1eGDz8yRqF/C/o4b9wBW/bBAVlL0fYBQjltueH/imIZMh1bzmsK3uj1g9Vq4MUKoLHohKu8QzrzEe5CnQA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(346002)(136003)(396003)(39860400002)(376002)(366004)(451199018)(86362001)(36756003)(38100700002)(2906002)(41300700001)(66556008)(66946007)(4326008)(8936002)(478600001)(66476007)(6486002)(2616005)(5660300002)(83380400001)(30864003)(8676002)(107886003)(7416002)(186003)(1076003)(26005)(316002)(6506007)(6666004)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wmydCeBvfa8V8s/KdY1VAEtZb/07ESKtPA6d9l3bsb7UhpO94kZyhN8w7B8KPZebD3nC0IMJwGKbi6NViS96SL7mjwDj/TDhE0OisOPJIVSEAJc/9aMBMW7isGvelLB0iUrO0w2qLkmsui1L8+Ix7vQFupNxw97UWkOqviGMKkGSTkKR5fmWqrmpM+Itb9dWjT1vRRYOPNB+EmiIXNJHhnKIZ0UshsuTKMO5Kt7KyRsu1YN5LIJUIlUyJ9u1omNM3LxO3mW4Jwj1Jijz4olAIl2S7ezy9KfsT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Jfv9yS1WS4dL9NZef6piPSekS5WEEV1NfIE17rGr8WS/aREyvOr3kPEi8eGSONZtT/bMWUEzrnZoAK2TgkfeWxD6R7NJF6HDfhmKM+j4S1Und2IS7n/j43lkYgCh4WFu6VfPuUp6h2RIHuG5btbGxSnL3YeqZSgShe0rchfV0ZvF2dDm4AUwq7lKyk04PPd6WJVh3b1/0vsN8zRQDX6q35Jg1x27ws4H+g+gdW4sMknC6oet47GzoJDLubBZpYk62xPTXW6TK12HiH9kbPg9m6s3T7C94hEMAutcGG0Ej1HjqEsmCvp2Es0Zj6q1cNEHFstFTmDHXQpaRkFm5SxSyzaaUkgo7yyYm4bSLKeq/o6BuBHhAOP4BACM/Yedb/5kGzP24hh3FI0YqjgTVrds/DDC8NDw5Ieg60YNrKIQ0DREexyF4pmHNX0vEg5DAbj+4sjv8KSq6ZHYkKs9Hl1YE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86e562a8-87fc-4a24-b02c-08db272d9a84 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2023 21:21:42.6673 (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: BHNbhj4y+f4pZPSIZbQw6zeoGJ3ArI4VyxuwTlVp2nW8QfmdBSlpMP16ULIJhu6RTySSJ6oQZc1796gu2IJKoZTcKMTUexVu1cU5OlKby10= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7483 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-17_17,2023-03-16_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303170150 X-Proofpoint-GUID: Eo9MuTX3IfEr4WLvdBimCSVDltD_mQdC X-Proofpoint-ORIG-GUID: Eo9MuTX3IfEr4WLvdBimCSVDltD_mQdC X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760652421210518766?= X-GMAIL-MSGID: =?utf-8?q?1760652421210518766?= 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 --- 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 6883c5922701..61443f8395f7 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -105,6 +105,21 @@ struct compat_kexec_segment { }; #endif +/* Alignment required for elf header segment */ +#define ELF_CORE_HEADER_ALIGN 4096 + +struct crash_mem { + unsigned int max_nr_ranges; + unsigned int nr_ranges; + struct range ranges[]; +}; + +extern int crash_exclude_mem_range(struct crash_mem *mem, + unsigned long long mstart, + unsigned long long mend); +extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, + void **addr, unsigned long *sz); + #ifdef CONFIG_KEXEC_FILE struct purgatory_info { /* @@ -238,21 +253,6 @@ static inline int arch_kexec_locate_mem_hole(struct kexec_buf *kbuf) } #endif -/* Alignment required for elf header segment */ -#define ELF_CORE_HEADER_ALIGN 4096 - -struct crash_mem { - unsigned int max_nr_ranges; - unsigned int nr_ranges; - struct range ranges[]; -}; - -extern int crash_exclude_mem_range(struct crash_mem *mem, - unsigned long long mstart, - unsigned long long mend); -extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, - void **addr, unsigned long *sz); - #ifndef arch_kexec_apply_relocations_add /* * arch_kexec_apply_relocations_add - apply relocations of type RELA diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 755f5f08ab38..45d241aebe3d 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 f1a0e4e3fb5c..0b560064579e 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 Fri Mar 17 21:21:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 71437 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e54c:0:0:0:0:0 with SMTP id z12csp39339wrm; Fri, 17 Mar 2023 14:26:22 -0700 (PDT) X-Google-Smtp-Source: AK7set/87DiIi0+lPLIrBYwMgfE9JlX9OyO0RzKzCffYzWqlTkWDNz6h1Ks2ptQ5MhUVidoyFdtY X-Received: by 2002:a17:902:ea08:b0:1a1:8550:4be3 with SMTP id s8-20020a170902ea0800b001a185504be3mr8899175plg.2.1679088382202; Fri, 17 Mar 2023 14:26:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679088382; cv=pass; d=google.com; s=arc-20160816; b=RTOeyIp6jpDxoRKsSi2HUqLStFQJvnebqrAzudryzOiJ7h+xmzASF30fphMupwjO6I CpZ7tvI5cSJZZe59DX7MUJYh6AfvSeSWVVDAagKLuZB17lHUoikkYPU4ildz909I7YDP AW4PhLa9KQU09jfKNAUI54g2exuO+Cu0xFwn+FmN03BqvjRntfhPR66HQZ268Veo8VQk WVoKUZN8jE+MCRDn0UTw+IfjFFTbyDnkMOVsKNqpAxLD3jnXRDqQ24WbFI1smOXNtYcL oy2ZHGCbjdFJzkWcsB1+zJ2Vxy9bP6mHbYP58SgiIErYfPcEuu82xYb2C9Si0URaHw1k XH9Q== 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=dWDUPNdNa1wXrIEc16j0Hj94FPhGJwZFBydAztIpZJs=; b=0yFv46FS6SixkFFoRiIf4cs4l7wQymSd3sE66Gb0IhFptPnwXxut/V09t5QvnpIqWX BKFZ6AOBdCGbvko7VVeA0YAAMxuHkpctO+eiVl+7e6QSn5dSxZq/rfCYhUd4dI6012ls 9IDi5I40XGf1esxrPqUMwzrur3MtB/IwDtVLX7rAV2Ip33CiN4RsOrk24OajYVTRY1rn g7yyk39DU+vM9+L/dW5LUGVZKvnasUZV6vUVoWH8FWByx1LaZT0IE0WWz/zdGbQNpjjt xeUco+7hiyzOV1Z2y5l+fYUOPRoUs1ieLirtv6xoSM4JjH19qoovBanhwYOcvo4Sx6s+ uhvA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=sbOdbEfB; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="F/r96uBu"; 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 i14-20020a17090332ce00b001927e835ffasi3732190plr.119.2023.03.17.14.26.06; Fri, 17 Mar 2023 14:26:22 -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-2022-7-12 header.b=sbOdbEfB; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="F/r96uBu"; 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 S230284AbjCQVW3 (ORCPT + 99 others); Fri, 17 Mar 2023 17:22:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229733AbjCQVWS (ORCPT ); Fri, 17 Mar 2023 17:22:18 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9173FC7959 for ; Fri, 17 Mar 2023 14:22:15 -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 32HJOhhL018089; Fri, 17 Mar 2023 21:21:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=dWDUPNdNa1wXrIEc16j0Hj94FPhGJwZFBydAztIpZJs=; b=sbOdbEfBxP3w3/AkEgB4i0hvAMS1Z0X7TqNwyyQ4eJDg9IO61P3yMfwwET4gYWPY+DmB TJKBQpD3OLGgFGc5Y6e/bPQZHXESSxRVD1P9xYT9DqeUfq4Bb4x9ovijJ/38pSnVYIhY TV3gFkZUOi29d4PaU5K89K2owJRX2Bn0w93ilRNE+hXYdfU9ajgxxCmgzTckVd9yvkm/ yeYLFI82LKlCX3pyk0WLzT67JWwX58XOQTCyLzyWNQ7gSk1LZ/wRfk96/BlNxHdRNDQ0 uichA85SQi4iXk231hzZZmNrw1M2dlbr4M0G34A2eRuX3mPUTcAu2hfOa+wm3bRIxBNM JQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pbs29cyqa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Mar 2023 21:21:49 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 32HL6d4Z002397; Fri, 17 Mar 2023 21:21:48 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2176.outbound.protection.outlook.com [104.47.57.176]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3pbq48ah43-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Mar 2023 21:21:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hDd7N7C+yUyvCXZNbSkETY8vcHEjdpsFQBaLViiZcvP1u756RRfUetP0Bu84Fq75w1fqAqgoRfC6jtl3EuO10osx6gvIeYqtofZWSMjILAFQu4b/6YVTtH9ekqDg5YcFbuLwPHFhNGXjUJ+2qpHVQc7Wi7XY0Gx9PNKJ/+hmLk6GfHACLcXgDmOMihvIHZO12PbtY9AScCgQxWn7O+DB5F/+/J3MBZrhJH6PoBJS9y8GegQkjhCadyP9xqEQwufMsiSbaNJA5etDthQEzZEXvac862LFjOdECZ2SNgj+uaBCA+YUMxSirgULRNSWBlRg3DVh9Wivssxl49HthB1qAQ== 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=dWDUPNdNa1wXrIEc16j0Hj94FPhGJwZFBydAztIpZJs=; b=Paah4cjqXtW+IZDCxcJl4IB8MIzyXLK9JjUQRCYBIQyWajS9rZn51OC9I8iwRZLVT2q7q/jy12ye98UnoqZBQoQV3ajJ/JILmfOgVl0bMWRiGcX08Ms5AAaRLkRzDoi1TfjnAMDSqEHZ9HSe9jGRuk7PUulbNkwTjInFFuJ8YGWhmW3C8I87t/XSG1WIRAKgS34QqwGO+ZLkRxN6xUTCK8XYEmRKC0/tV5vXWc3bL/ICK8N9AlJ3Bwql89JU0G/VLfOdry0m+zP3ic6nPYGSnrJs9X3zJ+xucwwbq4vPpQ7PyU0YRpSx2x7W3/Os8fVli7q2CQUX1PXYcgOpuZ3Smg== 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=dWDUPNdNa1wXrIEc16j0Hj94FPhGJwZFBydAztIpZJs=; b=F/r96uBupQ0IWXTgFZrU8PUElz3lYdceJQx46dEA9npItAx12CblZxorURmXRmM2ANrIL7a8UGlL4ukkSOg0+JanrQZ2dv2Qi623Is1IghFB7q6PRmuwsZmvyJ6MpRt+lfLcAZpbdxLfmsd4xzNYeHS+1LOLxtBi7hx9B8QETfE= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by CH0PR10MB7483.namprd10.prod.outlook.com (2603:10b6:610:18e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.24; Fri, 17 Mar 2023 21:21:45 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38%9]) with mapi id 15.20.6178.035; Fri, 17 Mar 2023 21:21:45 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v20 2/8] crash: add generic infrastructure for crash hotplug support Date: Fri, 17 Mar 2023 17:21:23 -0400 Message-Id: <20230317212128.21424-3-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230317212128.21424-1-eric.devolder@oracle.com> References: <20230317212128.21424-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR04CA0023.namprd04.prod.outlook.com (2603:10b6:5:334::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_|CH0PR10MB7483:EE_ X-MS-Office365-Filtering-Correlation-Id: 61e27402-d9d6-4bf0-1ed5-08db272d9c28 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CR0J4Q8L1JQMCyD9f+BiNDUir0Adub1T776s0Kfbg4LhDkWS7RgXUqm/+8GYHXnHoGWwmt8KKX1wCHQoin5huNtt/dzJLG/QEnTq8OIyHPtJ9e/1Q6X9wN4IJzhNuZUNZYhMn8MPwTlqMsqq2rcMwH3Kz/z5zeeOPeh2LQWxcYy9wEArEBACYvhtR9DFqV7hZyEelSdVtsJE5EP6XEb+OkMJ3SQ2/jtQBP8oiTCLxeyYyc1ClFKLM0v7/KywyTED7Gd++o7sNUyvy5Mv2/G7NZFi7hYzvL3YkTYZvbkFYCb9YDFu+Op1dYXNfVsBKB3z7br4WUZ1ozHCwKxaYrrA3yWS73KocCxIXZiREluTAAt0Ix9AGE/4p3QdKKUkDkKdkvJVlXmviepcP42WKxLRgcSsggq/iFCMTXbfNDOsahY/k+yS57UbLOynNtGK/L4RCo1w9w0jStL49GRknwV7as2cyhrMr2aZDkpQR2Rlvw9iQRbRNwg5mJSzVkLeITRx2CUmhCKsn6rhvk6sliY9vJFF6HpFvrolh4+1e4yGXikOsjWn8k5LboMhgOEIl62BSwrq667H4TjnsXgdXmyZZwBpS4BUQh/LxyBW0I5FwI4RAdATOKe1S2hHOVHMbUDJjCQOHNFEWQwMLaWlHW7iyUazFlj9/ZKuzZt89Y57bBVM9jNB7TaQZr7Yqlfbe2gk X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(346002)(136003)(396003)(39860400002)(376002)(366004)(451199018)(86362001)(36756003)(38100700002)(2906002)(41300700001)(66556008)(66946007)(4326008)(8936002)(478600001)(66476007)(6486002)(2616005)(5660300002)(83380400001)(8676002)(107886003)(7416002)(186003)(1076003)(26005)(316002)(6506007)(6666004)(6512007)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Tr6JGPpor7Th2Dg6b1yVJqqOgmbM7+aaPDr6JadbSJhMcIhrYxP/xKInDflnHEImeLhQy1zhND9BWJwx1vzHZEAwvRbQe9Pg87A6RtehCqlD0IrvP/+sDjNgLRnaTE/QJT4oGyOSTY4CH3w2s4xm2Iz9AwZXSza4CKo3NKhTqERV0SXvLieqi9I3ZrO6aUb29Uxz9mL7uHQ9GuWH5bYjDEHizGH2OaofWGsJzAKfpLDbXcOFpgo6CsqQUjA2uVwXMBYxhrAV7lKmM4SvEqqQJD6FSTkdNEVRimC9BEm//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Gh3Uc/1Fyji1fc7T1d8VQlaT8DSroeX1mDAwHJGG45aWn3i9E7cpzCFOvuZzQb3y+cH77LBu2SZI1DAmEJLHWI6S6t7otMM0W0X9ZxWUWP50bz7x0il1azQu11Q4Q6c8ejyT2Z3eBNNp/itdrGK7PItQIK7C+Gd3Zpce5oI67AZdp8gJ5AuNbolGtg6ydUqQAiE2ZDCziNXZm7DdOFesEadTPq7kX/RxBiuvABsCRPp+FE4Tsl3zclO3SrrbQY2U3bDqEcGjGzwqs+ldrVYHVOmXM+l/DT5/zjPHKwQ9U60nL2kupkxiQKeQsrcKfhdJ/HbCimO45zOX2yGsAM9H6gI1c1AxghnF7K2SIqgDGPHRzwXQTdXieH28IJR9rqbYH+ugGNlWAIwfYS4dXqb+AmPaSzZb3rdVE0X8vYSmjq2zS2t7rMQyC3PLwYjlWual2E5h5hMZhTc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61e27402-d9d6-4bf0-1ed5-08db272d9c28 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2023 21:21:45.2130 (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: liOAH7/GS/zWjfOVUoLTUe3RgyTCmcl/1xrv9pjkeqjK6aPhfYHKM1YyU3zER9shxSTnXHWSt342a5wDopzzFe+xILAYiORCwRmSgE1BSV4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7483 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-17_17,2023-03-16_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303170150 X-Proofpoint-GUID: FsIPkwnwoukHdJzU9bvfNmmBjLA9fn1X X-Proofpoint-ORIG-GUID: FsIPkwnwoukHdJzU9bvfNmmBjLA9fn1X X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760651779444515948?= X-GMAIL-MSGID: =?utf-8?q?1760651779444515948?= To support crash hotplug, a mechanism is needed to update the crash elfcorehdr upon CPU or memory changes (eg. hot un/plug or off/ onlining). The crash elfcorehdr describes the CPUs and memory to be written into the vmcore. To track CPU changes, callbacks are registered with the cpuhp mechanism via cpuhp_setup_state_nocalls(CPUHP_BP_PREPARE_DYN). The crash hotplug elfcorehdr update has no explicit ordering requirement (relative to other cpuhp states), so meets the criteria for utilizing CPUHP_BP_PREPARE_DYN. CPUHP_BP_PREPARE_DYN is a dynamic state and avoids the need to introduce a new state for crash hotplug. Also, this is the last state in the PREPARE group, just prior to the STARTING group, which is very close to the CPU starting up in a plug/online situation, or stopping in a unplug/ offline situation. This minimizes the window of time during an actual plug/online or unplug/offline situation in which the elfcorehdr would be inaccurate. Note that for a CPU being unplugged or offlined, the CPU will still be present in the list of CPUs generated by crash_prepare_elf64_headers(). However, there is no need to explicitly omit the CPU, see the discussion in the patch 'crash: change crash_prepare_elf64_headers() to for_each_possible_cpu()'. To track memory changes, a notifier is registered to capture the memblock MEM_ONLINE and MEM_OFFLINE events via register_memory_notifier(). The CPU callbacks and memory notifiers invoke crash_handle_hotplug_event() which performs needed tasks and then dispatches the event to the architecture specific arch_crash_handle_hotplug_event() to update the elfcorehdr with the current state of CPUs and memory. During the process, the kexec_lock is held. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain --- include/linux/crash_core.h | 9 +++ include/linux/kexec.h | 11 +++ kernel/crash_core.c | 137 +++++++++++++++++++++++++++++++++++++ kernel/kexec_core.c | 6 ++ 4 files changed, 163 insertions(+) diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h index de62a722431e..e14345cc7a22 100644 --- a/include/linux/crash_core.h +++ b/include/linux/crash_core.h @@ -84,4 +84,13 @@ int parse_crashkernel_high(char *cmdline, unsigned long long system_ram, int parse_crashkernel_low(char *cmdline, unsigned long long system_ram, unsigned long long *crash_size, unsigned long long *crash_base); +#define KEXEC_CRASH_HP_NONE 0 +#define KEXEC_CRASH_HP_ADD_CPU 1 +#define KEXEC_CRASH_HP_REMOVE_CPU 2 +#define KEXEC_CRASH_HP_ADD_MEMORY 3 +#define KEXEC_CRASH_HP_REMOVE_MEMORY 4 +#define KEXEC_CRASH_HP_INVALID_CPU -1U + +struct kimage; + #endif /* LINUX_CRASH_CORE_H */ diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 61443f8395f7..f9bd46fcbd5d 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -33,6 +33,7 @@ extern note_buf_t __percpu *crash_notes; #include #include #include +#include #include /* Verify architecture specific macros are defined */ @@ -368,6 +369,12 @@ struct kimage { struct purgatory_info purgatory_info; #endif +#ifdef CONFIG_CRASH_HOTPLUG + int hp_action; + int elfcorehdr_index; + bool elfcorehdr_updated; +#endif + #ifdef CONFIG_IMA_KEXEC /* Virtual address of IMA measurement buffer for kexec syscall */ void *ima_buffer; @@ -498,6 +505,10 @@ static inline int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, g static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { } #endif +#ifndef arch_crash_handle_hotplug_event +static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } +#endif + #else /* !CONFIG_KEXEC_CORE */ struct pt_regs; struct task_struct; diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 45d241aebe3d..ec1d68569f6b 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,137 @@ static int __init crash_save_vmcoreinfo_init(void) } subsys_initcall(crash_save_vmcoreinfo_init); + +#ifdef CONFIG_CRASH_HOTPLUG +#undef pr_fmt +#define pr_fmt(fmt) "crash hp: " fmt +/* + * To accurately reflect hot un/plug changes of cpu and memory resources + * (including onling and offlining of those resources), the elfcorehdr + * (which is passed to the crash kernel via the elfcorehdr= parameter) + * must be updated with the new list of CPUs and memories. + * + * In order to make changes to elfcorehdr, two conditions are needed: + * First, the segment containing the elfcorehdr must be large enough + * to permit a growing number of resources; the elfcorehdr memory size + * is based on NR_CPUS_DEFAULT and CRASH_MAX_MEMORY_RANGES. + * Second, purgatory must explicitly exclude the elfcorehdr from the + * list of segments it checks (since the elfcorehdr changes and thus + * would require an update to purgatory itself to update the digest). + */ +static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu) +{ + /* Obtain lock while changing crash information */ + if (!kexec_trylock()) + return; + + /* Check kdump is loaded */ + if (kexec_crash_image) { + struct kimage *image = kexec_crash_image; + + if (hp_action == KEXEC_CRASH_HP_ADD_CPU || + hp_action == KEXEC_CRASH_HP_REMOVE_CPU) + pr_debug("hp_action %u, cpu %u\n", hp_action, cpu); + else + pr_debug("hp_action %u\n", hp_action); + + /* + * When the struct kimage is allocated, the elfcorehdr_index + * is set to -1. Find the segment containing the elfcorehdr, + * if not already found. This works for both the kexec_load + * and kexec_file_load paths. + */ + if (image->elfcorehdr_index < 0) { + unsigned long mem; + unsigned char *ptr; + unsigned int n; + + for (n = 0; n < image->nr_segments; n++) { + mem = image->segment[n].mem; + ptr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT)); + if (ptr) { + /* The segment containing elfcorehdr */ + if (memcmp(ptr, ELFMAG, SELFMAG) == 0) + image->elfcorehdr_index = (int)n; + kunmap_local(ptr); + } + } + } + + if (image->elfcorehdr_index < 0) { + pr_err("unable to locate elfcorehdr segment"); + goto out; + } + + /* Needed in order for the segments to be updated */ + arch_kexec_unprotect_crashkres(); + + /* Differentiate between normal load and hotplug update */ + image->hp_action = hp_action; + + /* Now invoke arch-specific update handler */ + arch_crash_handle_hotplug_event(image); + + /* No longer handling a hotplug event */ + image->hp_action = KEXEC_CRASH_HP_NONE; + image->elfcorehdr_updated = true; + + /* Change back to read-only */ + arch_kexec_protect_crashkres(); + } + +out: + /* Release lock now that update complete */ + kexec_unlock(); +} + +static int crash_memhp_notifier(struct notifier_block *nb, unsigned long val, void *v) +{ + switch (val) { + case MEM_ONLINE: + crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_MEMORY, + KEXEC_CRASH_HP_INVALID_CPU); + break; + + case MEM_OFFLINE: + crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_MEMORY, + KEXEC_CRASH_HP_INVALID_CPU); + break; + } + return NOTIFY_OK; +} + +static struct notifier_block crash_memhp_nb = { + .notifier_call = crash_memhp_notifier, + .priority = 0 +}; + +static int crash_cpuhp_online(unsigned int cpu) +{ + crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_CPU, cpu); + return 0; +} + +static int crash_cpuhp_offline(unsigned int cpu) +{ + crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_CPU, cpu); + return 0; +} + +static int __init crash_hotplug_init(void) +{ + int result = 0; + + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + register_memory_notifier(&crash_memhp_nb); + + if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) { + result = cpuhp_setup_state_nocalls(CPUHP_BP_PREPARE_DYN, + "crash/cpuhp", crash_cpuhp_online, crash_cpuhp_offline); + } + + return result; +} + +subsys_initcall(crash_hotplug_init); +#endif diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 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 Fri Mar 17 21:21:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 71449 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1949wrt; Fri, 17 Mar 2023 14:36:43 -0700 (PDT) X-Google-Smtp-Source: AK7set9ETkG/ire9QW16MO2jA2xPIBNmVxBTxSGCwE/jI9WFnpi4RYsn6crDabdqYxd7x4BtFtbP X-Received: by 2002:a17:903:3291:b0:1a1:956d:2281 with SMTP id jh17-20020a170903329100b001a1956d2281mr6650985plb.3.1679089003153; Fri, 17 Mar 2023 14:36:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679089003; cv=pass; d=google.com; s=arc-20160816; b=gOOz6AU4oocxsl3wTZzvDv2WivaZdjU0OwsNfJgL7KQ1CjrGyW24FUr4RRpNRHjY1/ oN1Ff0TPkDyS7qHVrMsgAqeg5mLc/mxZHAGU1wyZNQAjS9KHkwa0L/5OKkk2VLBbgKrJ 2nQDZg+WXmWeMZROhHgrTPGzUbHm+iUl5hmF/LNjHV53nSnRUmSQWZZgiHwmdOXg6lK6 ZLnF1xE1FuKl2UleHs2INwcOEQ4jQzLzKFsd4SB7Du5Lr3f5wizxhfX1p1tC1EpaVqlI i7awLP8+W8lnGzCAMkyBZnKAgVoXTaicX+TQvNmu7yErPtvGtG+u/Gcrg2TTCaQZua9w tQuA== 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=Org4+NnKw6uTV1agrqqdx4KYgAc/VaNJCq4DuJhC63I=; b=tig6EhBLy8zKShkkRCd07EX7qHbPPmx5ER7h4z700nXxcZjFqNWqSM+cLli6tsQAS8 lw27l8nFf9Y3lLXDcqm7hyp6qqDuVZzpqjBAWTwtesJHv6cv5/bQI/117cKt90RMd9uF EzSuIWggwgqUuxBKjTxbIoJcRPmYJETQFZAZRLbm+kV1+FLd3LOmOXos5aQAe9cKaBHM 2+G2Wcq/JGQBnZQWjQn90GsmoDA/XYCb62IBtf8pdUqo3TK+Jnt1LunU3iKoWrg17FGm vk49R9X7VWwJqNurxgo9zYCadCcmk+gFLZOOHNvdJUYA31uZy6aFDbo3FASQ61ATxCdc CRmg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=svxmm6d8; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=NEbmkqQE; 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 d8-20020a170902cec800b0019e3728f17csi4019836plg.209.2023.03.17.14.36.20; Fri, 17 Mar 2023 14:36:43 -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-2022-7-12 header.b=svxmm6d8; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=NEbmkqQE; 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 S229974AbjCQVWQ (ORCPT + 99 others); Fri, 17 Mar 2023 17:22:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229733AbjCQVWP (ORCPT ); Fri, 17 Mar 2023 17:22:15 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE480C6DB4 for ; Fri, 17 Mar 2023 14:22:11 -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 32HKeYYv014378; Fri, 17 Mar 2023 21:21: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-2022-7-12; bh=Org4+NnKw6uTV1agrqqdx4KYgAc/VaNJCq4DuJhC63I=; b=svxmm6d8ksgcoMmBY83snfwe3hIrq0mcEBtxJOm/VdNqwgfN+dwWVIxg0g1Q2n3BzruT pdqAa6vEyHDSlqD+HRWLHHt490SR0f2DnhY2dWBO6EYAqx0f2aTyO468fdPa+bsiP9qg LXZnO2+EBg7FAlIvHOIpb9ItdZOwGo+QzFKGZRgI9Pl2sywS8rLWRtM5ZvSpSpwDxl3o jgfh3VPSeb47kKNGiG5YDGYs9PfqUrElG7udxA/Vm/N7XvLKMlwJfsS/uZeGIPa85pci XSaauKs/xXzL92yoAcieRab3XACsB+bz5Br50FUmYywnKO3yIA1SHDhTYwRHRtMbMI79 QA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pbs29vscq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Mar 2023 21:21:51 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 32HJJNJ8001238; Fri, 17 Mar 2023 21:21:50 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3pbqq78jgv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Mar 2023 21:21:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yi8sgPl/2RerOAY55VMe9YoOiSALGBRVEeIt8b1+CDFavCap7ShXNwvXzU+S1B4C6OMBgJzUHf+5OYYb4BXDSFgUKnsoORvwWb2u08Yu1vChDvg2GqGa/t/K7+1Xun1XwcSK/hCdQQYtYAEXGCfl8eYHIQB2NBwZIQcwznp/amdlkYQht6mzu7maH8gDTVLpa+RhWKSh42God0XuELKEJiP6ow2diUj8+3V4WbDO7plzTXNtHXPgt+KJaPJzg0mMRHlOVpLawbPEUfP9Z/iDWrxjAY5JZtXyfXyZnUzeheXvK89KFiEB5hIlbODBZLK5T/2sAVDUFqPb3O2XGjwetw== 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=Org4+NnKw6uTV1agrqqdx4KYgAc/VaNJCq4DuJhC63I=; b=NSLc3k3aoZvgKh9seDSBeZZRbaDFlJXtdRSgnyLbLrefhKKAkycOZpZVQhZVDeuL6ZFT42aGoOBp+9ILyujug6dwjPh97xXu8YgY9Rb4XloHjgdcuajY8QrhVf00rxSHSqIegBSvIG3t/2/JfXEp809qVPuUmRJyH+ppv9/+9kVWUKiZHhuK4w3aldk9hddCD+KuDr/rXtmtzxnK6uBUBq7aQdkvOynD7O/2a5jkVXKHNkL+7yC4RF1elaZkb7Z+dU2qjSxxn5BEr/YupW2m9G+MQsR3qEXfO5qfgSweqNtaJrzTIcaDKUQt+N3dusanvkLi9VMHMLhmeJy+VgtH7g== 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=Org4+NnKw6uTV1agrqqdx4KYgAc/VaNJCq4DuJhC63I=; b=NEbmkqQE0twYYLAGHe6Aai3CK/ONSRnaRuQ45vvEem9rhtm6lkRtra6UresKbyUVQW/G0apN2fJPfTeT8iIZSAYEzv2TBXNEJb3b9Gz9OwTFWur1BvpZDM1xikc27f5cbgt1wJN6Cj0iVEHnDybc/NS+q9t/d//hS3yCkqpKQ6s= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by CH0PR10MB7483.namprd10.prod.outlook.com (2603:10b6:610:18e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.24; Fri, 17 Mar 2023 21:21:47 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38%9]) with mapi id 15.20.6178.035; Fri, 17 Mar 2023 21:21:47 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v20 3/8] kexec: exclude elfcorehdr from the segment digest Date: Fri, 17 Mar 2023 17:21:24 -0400 Message-Id: <20230317212128.21424-4-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230317212128.21424-1-eric.devolder@oracle.com> References: <20230317212128.21424-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR07CA0066.namprd07.prod.outlook.com (2603:10b6:5:74::43) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|CH0PR10MB7483:EE_ X-MS-Office365-Filtering-Correlation-Id: 72c25d7e-7f65-497d-386d-08db272d9db9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sIDtwoZJQPn9IOIHF7dk5d9jNYj2h9+Po5U4mlRSFxDcndgxvMsBRm8nWOeXQkHEM+K9D6tAh+5hN5fwgXJ2dgEd3N422IO53keujJXXzFq7IfuBrQgdausPVLRbCz745LAvRKvfFsxiTl8G/jEHycTPNgvAskqPdWC/WY5mPfZxz9s44BnBNt2xQcalE71koKl02sKJDoNIpNHJhY52n9BON5p+/SlpbwoIZ+moT6KUPGIUmGObGqKgcfdybmSNd/zU/2HTkirU2Er0Z/JpNf5OnsPSSuGOrMS4vmJfYwoixDTASBm2W1EjHal92rtibjrjlck9ONqRCOrQsKQ6JyqhgSCc9HZXgBqtb2aKY+kolhTCH5zs5blupvgQdeFNgLru2k8JuZbYjlfUF55DR5uUB/bzcqarg5iFD+0jJtfbAict0/YYjt3FVCHxQiKmyDg+zog4JbcfpLVqOvIoykD3enIImbsQu+tBRIxFfYqbplFCThPb0P6toCQV3JXAYtR8AyLMcLkder/IgNN6Nyh/vnE+YtmYTQU4cOQQ6gLaNp5nvNTJmowQfhyiXtsqK1VM7WW4VcjcwhuFb+kR6mM+y+sWNswHoUdiC+gf5eYluwjgrMmxD0UxgLhmgo1Aue8NcTdjqLThoo93Ya6fNA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(346002)(136003)(396003)(39860400002)(376002)(366004)(451199018)(86362001)(36756003)(38100700002)(2906002)(41300700001)(66556008)(66946007)(4326008)(8936002)(478600001)(66476007)(6486002)(2616005)(5660300002)(83380400001)(8676002)(107886003)(7416002)(186003)(1076003)(26005)(316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uSZ5baAaITGMTBjvn5+QaMozpWq8kmNMY816JNQwZB9VJ0N37AVnODBc/vz94Rsacz2MOIuZn5Klb0i9GND/EBZ0OY/3qpM2RVlJmYH7SN7nEN86pGBU2otarTMYad5ImGhcnxKdHVWInzVVd7cM0txz0jodrQwLgWNhsR2S67rIarNcJtez5lQbhFBtR6mosypoiVEvNHHJcNd99bHkyKiLF2lryh8unYR/gvb9ZWuFeTq/DN/l/2r+KA/NEtWM9OVRnGXIZWpiJPgTf/slE0X15l/weGqpfCBpxMFqFtEqFOyBpF2I379gRfgUiBv7Nm2VXe7yBFsDRt3r9qq9l2brZu+ZxPLgBaw0n0I1CKlHhDWTihWVuIKdOCcC71/J4bHOLF41/OblUbjm7o7xyzWt9GUUcxejTrpUzp72ZzWgnxwpK2pNW4jpc84RTTV9vaA+2IzB40Ppix+IWhKiYRuXIj70LEFXwjaVZ+cMuYCQ5mRPyft6e5lWUffo5bzyZia5KUG/bGA0WV/EqWo1oj6L9E1v5fkg2waLe8tGXGBbp2g6jFA7JOw+MZJmrrvbtOD+fQpeo4u4V7ZnfsjUjJVPLC7PZJCb896n/kwLLQQl/cEeYF8hqhjPzcTwD7CAzMRMvdC79Mq5Z0qLg2RjKLWABZkFSStfVkIT9ejFyK8TzOnGeTxUytikeGsYxDtXTwyd1ksvsd+njqcyrKdP4hcrMiiy6vOijhkU+A2kETy4O2lf/dM97sKv8GVwSR/qFnZqERxB+6plpxcB+7SdPWuu2SSYCZvANKtpSooHqbEElrBTY13WNGe4s= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72c25d7e-7f65-497d-386d-08db272d9db9 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2023 21:21:47.7948 (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: 1GgpIK8y06i2/cJ+KssW2hfVqUZ5cx8Ns19JUNzeZvZMICelEINcr+QywVi4NlMA/iqAx4dCOkd5N5f5/wGtyOpzXeECqTr6dHJt+KBvcag= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7483 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-17_17,2023-03-16_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303170150 X-Proofpoint-GUID: KpjrLRn2iQ3FpcsC7QLqUXhMVWTV7H98 X-Proofpoint-ORIG-GUID: KpjrLRn2iQ3FpcsC7QLqUXhMVWTV7H98 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760652430728280216?= X-GMAIL-MSGID: =?utf-8?q?1760652430728280216?= When a crash kernel is loaded via the kexec_file_load() syscall, the kernel places the various segments (ie crash kernel, crash initrd, boot_params, elfcorehdr, purgatory, etc) in memory. For those architectures that utilize purgatory, a hash digest of the segments is calculated for integrity checking. This digest is embedded into the purgatory image prior to placing purgatory in memory. This patchset updates the elfcorehdr on CPU or memory changes. However, changes to the elfcorehdr in turn cause purgatory integrity checking to fail (at crash time, and no vmcore created). Therefore, this patch explicitly excludes the elfcorehdr segment from the list of segments used to create the digest. By doing so, this permits updates to the elfcorehdr in response to CPU or memory changes, and avoids the need to also recompute the hash digest and reload purgatory. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain 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 0b560064579e..a28f01318a47 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 Fri Mar 17 21:21:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 71457 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2157wrt; Fri, 17 Mar 2023 14:37:20 -0700 (PDT) X-Google-Smtp-Source: AK7set8S8Z2eXXvPwD7xcs0gcC8m4W+wk2nhtbZJYbjkCYqMyzxFGyxq59qLb+2qBMXt0YRwNziS X-Received: by 2002:a05:6a21:32a1:b0:c7:af88:4199 with SMTP id yt33-20020a056a2132a100b000c7af884199mr10858596pzb.6.1679089039837; Fri, 17 Mar 2023 14:37:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679089039; cv=pass; d=google.com; s=arc-20160816; b=QgYCJdnxA055JYzhU2ZzrMLVqJkUhcfVLugKMxjio7m4YkWFhBGKk3oCCsoHTdanDo 6eZb/xXJ7r7mkC7I16x99+LNu9k0zvkRoH/FBMbBis8gOfx9L6Z6FP9G47Sv65X1ac0M FIQYBOHZhBkzu5UFow4KmcT+O3FZS+5wFs46nYBjggNnHhF+QCXe649Ncw/GBGz0RE+P J/gMuYWkJN+VXbxHjE70Z/wcn/X/BWkUxIFhz1NHSW/Fa/4okUAEYWQShXYTSGCCb66Y /MGz+1ltsYZ5VOEd4rfT+/LuaL238JrixDNGr7USVaoG9xs7M14zGatQytEpqTd6slGV HwoA== 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=ffU+kjuYuTVR2ucWynkeRq8pM8/PmVRs5cUAVYP0Sqw=; b=IFe8YDzZP6gvn+egHwxOCeK2MgWpJAmmrX+UY/AfSmv3xSJXbWcK2FWLuoBHNVy2Q8 dPWjVimFryjIQA1oIjurESbZc3BIN/xVKHxXlHR9ygn2SyGtb8sUM04K2ANXdM4IX/mc K5q3HGr8hsVJmr5El/AiokCVuecPgxgmQKkZJDVQqipd2VpIUbrMvCTmiQosnpKBOA/3 qy6NafswhiCpBeNyJXYomJhoCEjoKgJdDjQg7Vb7PkVVzq0N0IrXeVgWO03zMCMAtVme fRe+pU70wpXDeYK5lVqdPwWGlvfNhOlcFq3i79BVzEvHY00I7pVKmlC3n36yFJYukQCz 9oVA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=t0t2MvOJ; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=dt96EwZF; 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 d26-20020aa797ba000000b005a8adc698casi3313582pfq.189.2023.03.17.14.37.05; Fri, 17 Mar 2023 14:37:19 -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-2022-7-12 header.b=t0t2MvOJ; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=dt96EwZF; 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 S230016AbjCQVWT (ORCPT + 99 others); Fri, 17 Mar 2023 17:22:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbjCQVWQ (ORCPT ); Fri, 17 Mar 2023 17:22:16 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEF20C794D for ; Fri, 17 Mar 2023 14:22:13 -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 32HJtqCd027660; Fri, 17 Mar 2023 21:21: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-2022-7-12; bh=ffU+kjuYuTVR2ucWynkeRq8pM8/PmVRs5cUAVYP0Sqw=; b=t0t2MvOJD1MrztMABmOZrrzxPnzfSa0moVBmZG+9NZd8IfajMZFVDTFglyTAXVPPhLno AT73/lfVQ5FcouiZ08bmd78W/LyMw/jJVyUSyRM1wKW0ZBrvA/L7+Zzk9Pg2F+GatSnC BBTco74yagaU3SFzzfJWaw/pENPVZNx1wvnGgA0hFWu+Ibhfh1NCq2R3NrwNM7r08UAm VvTLzcc8eTwK0YrcTzvfoSGLI+DlcetZ1VYEXKkZRFYhZlfupllq1jnuUpRpcwXW+Mmy JWFgRu+KwLxvRk+JoRo2aEwdBrH2f2KZRW3+8iJl2fAgOqQtiE9MExwnBjkviXzVwv3U hw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pbs28myt8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Mar 2023 21:21:54 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 32HJAlNp020704; Fri, 17 Mar 2023 21:21:53 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2045.outbound.protection.outlook.com [104.47.66.45]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3pbq46tndv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Mar 2023 21:21:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GoydcxxkNPfsty/unU+SIb/Ij4kget1As8Nb+0X3+ddiWWRCdHB4fxMEbBm68pcd0P97+0J8ni0XGVF0Mn6mTjpVrQ2RBu/cM0bVw2H6nYmGQPQSVVTpInFJ4bkeWXvHP8qRe8+5AJXPl2E2ujYJPd6hNMKCcckGeO2LeZ2bCjZKdOcv8+OkByL9zbh0AfHhiH6+ryeoiSQg7p+QrTwu3JcuxPeaDgot/8142A7PY7B2zEZDfZBiUof8ytWi6Ktn1Wg5a1rMJMEsUcuypkPtJ3cmRM9ejotifK/zpUNTUs1qBoQzX1WsCskQsCEJJ/gtxpZ+Tf/5u3MR+cT6Ya9M9w== 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=ffU+kjuYuTVR2ucWynkeRq8pM8/PmVRs5cUAVYP0Sqw=; b=kY+vkD/0ayYLkHvXfXt9QKS0u4oORRhC5qETMmT16TN348TZWNZosELQTjekVpgNpOBPwBBx+oyaoAjQ74swyUVMR7ZMaZP9p1BiHH11IkUtGbnIdnHfDK/s8mtjYUePDnwr3kpf299dwyqoBN9sxK/x9fNsfr9z0LgZpfWT0K2wGoC2YwbAnrFrsZnRwDKKkPQY51Rcfx8quoLmIE7Dfwk/aP3qMgeaJxWM5m7n0Zp8nAEz1wD591fT4MHjsAn8EoOGl9EakZOaLOh5tICeaD884msIdiQvL1TyYvudjqAFNM9i0YgsGl5gRcYKcHuCPfuApkgDw/qx3l6Ptm3zTA== 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=ffU+kjuYuTVR2ucWynkeRq8pM8/PmVRs5cUAVYP0Sqw=; b=dt96EwZFdusPGx3my4CGyZUYin8q6ZEGuYkdEo9su8laZY+ogGuubRW6kIiodb/UtWs+DcRTS39IMnn8qeQko86pneQwlo5jXyywCXYlXrjmCi4IM4J9z/cfWMxIkbU409AjiJlV2rxG/6Eb+m7W0lD2nyx072KkNGrJLcbKtLI= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DS7PR10MB5901.namprd10.prod.outlook.com (2603:10b6:8:87::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.35; Fri, 17 Mar 2023 21:21:50 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38%9]) with mapi id 15.20.6178.035; Fri, 17 Mar 2023 21:21:50 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v20 4/8] crash: memory and cpu hotplug sysfs attributes Date: Fri, 17 Mar 2023 17:21:25 -0400 Message-Id: <20230317212128.21424-5-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230317212128.21424-1-eric.devolder@oracle.com> References: <20230317212128.21424-1-eric.devolder@oracle.com> X-ClientProxiedBy: DS7PR03CA0275.namprd03.prod.outlook.com (2603:10b6:5:3ad::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_|DS7PR10MB5901:EE_ X-MS-Office365-Filtering-Correlation-Id: d6838ff9-c71b-404a-bb57-08db272d9f31 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6G1RSEHk2+EncbpMaluhG0zLDrdxQerDYScgSbLLtvL+U3rVCltPSEl4812EeJbLk3Annb3QHUUt7EoWcPc2WEXnu5n0f2LQKHLSxtN5aocseRY1u8AZ2a74rpDO8W7oT7GierHYE/ddjngfBy6z1hudlrsn3DIpN6fINx+6TuMVekih6FcH3tJ/fI4dc4L0kBmnTYCMo2i1lmXP9Bw2QgAQVqXg6ug/7ls/JDb3N79YieT270ibDVlldstcOwi4d7QL/CPY0pubzdUt00hnxMn+43bQDcTZoz/mPBZgrj4md8+QezcFKlKKs7oqkknyRhBA/5wz56qFjJNkmwGn1DHMpvx+SupV2gzAqw/PKz8EZ/TxRErAWdzImgb9IQJ877wxszYVq7lRcKj77MmJx7N/7+uqT4EEjZdG7qibxt1yc4x4niDwzevjKkphT4rFxLuUAGacyngR6vvuNPYfMSGPEpSKZAuYJcjaDLg8qVKJlc2Ym2adsmf14WwbkTRzqOpUyxiz4/7XHISaAnFqmINSgz6YKUGOK01sDaZKLpAS2Bs0020e9Y2L/060H2Mv5urpu0gbJiA/80YrePMEjzuKkzzyM9WaJ/64e5Oth47Ep5NcQjEyWUS880n79aKxCgLO+kiFwhOW3Burt7/WEA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(136003)(39860400002)(396003)(376002)(346002)(366004)(451199018)(86362001)(36756003)(2906002)(38100700002)(41300700001)(5660300002)(7416002)(8936002)(4326008)(2616005)(6512007)(186003)(6506007)(26005)(1076003)(83380400001)(107886003)(316002)(8676002)(66556008)(6666004)(478600001)(6486002)(66946007)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kn9daDAWYYRVlwD+UjolnjuXccu8lF87DfQYxgSY6XG6bfvbM6MYibTFiXRTkJfLff+sTy0OdiACJBhNmy/gnWgAgLcAlLC5eBaQ7nGohHSQ1wA/txeTpHA/9/TfjgWfIXjHNlqiYvLpPUgmI+61huu/TqMIsrOqnfy+ZPa8jfyOuaqcliR69VmmSdlylgt5hSOMN4Ao8IfiHjgevNL3ToUnhDpTPmr664TjI4toEDx159ev1pHXzRBYY3ioEf6NHOvUaviPL0rLXgG0DZOjBSOV5rQCyTgFD6iA13GVyjVxLbHVq+cnm+xZBt8dk1mZd5JXS+seBF4J9AX7GFdn519KfTewqRiR1V3Zx18XlSYyP1V3YknN8r8iuWBVAaXTxkO1LhdBLMwZ8EPMcoY7BFoYMbzcsIbRG8c7S3f7K7nd6T6138WVPP3uqF7836eG6qlZ+nfWBJ1WWdQs4XgRfsKN82FV87PCUVeNJYV49gV3BglJ+S0sesPdtr78OHmTG5iEO2kOxaaf2XJgF+8ztY5j2uRLZM2GH4MYODre6lD5uo4Zj/YZcL5P++ohkvstCcKm+e1GFqxfw+jDsXRxLs9POofprqGNeCWgs8sOK1eKRbnAIPU9pQO0bKoJUzZoVWYscGox1l5cQg1dwxyi66xNeghoC7iP9v56P9UWr9tfSx/SIlCZJSTpXz6GY7JDUh/WzM5X6cUvud67crpTXHg/OLT42mZWp8ponghZaTtHeB28peBoty2o5ZuZUMxNEDu/vGKJWEz/T2hKd3S9yXd2YblQafsgcAuo+q4Q/qQrCWSdmDh7uhiemUsfWrUfADl5g9+apUcC5PVQrQU00lTWx4ZoglzGy5agba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.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2023 21:21:50.3092 (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: t4pSWli5FNA6OTnUhT2WkxZbx3Z2ufORVeoWSwmbELDM2a569yeYresd5G4m62KUNg8vRyDtc+SwRw4y7vz6Uhal9R8T5rvlmbOWcSkw1VE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5901 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-17_17,2023-03-16_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 mlxscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303170150 X-Proofpoint-GUID: 1IGPnSx0-6mOGM6z63ckCZ_Kxwecq6AH X-Proofpoint-ORIG-GUID: 1IGPnSx0-6mOGM6z63ckCZ_Kxwecq6AH X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760652469052762951?= X-GMAIL-MSGID: =?utf-8?q?1760652469052762951?= This introduces the crash_hotplug attribute for memory and CPUs for use by userspace. This change directly facilitates the udev rule for managing userspace re-loading of the crash kernel upon hot un/plug changes. For memory, this changeset introduces the crash_hotplug attribute to the /sys/devices/system/memory directory. For example: # udevadm info --attribute-walk /sys/devices/system/memory/memory81 looking at device '/devices/system/memory/memory81': KERNEL=="memory81" SUBSYSTEM=="memory" DRIVER=="" ATTR{online}=="1" ATTR{phys_device}=="0" ATTR{phys_index}=="00000051" ATTR{removable}=="1" ATTR{state}=="online" ATTR{valid_zones}=="Movable" looking at parent device '/devices/system/memory': KERNELS=="memory" SUBSYSTEMS=="" DRIVERS=="" ATTRS{auto_online_blocks}=="offline" ATTRS{block_size_bytes}=="8000000" ATTRS{crash_hotplug}=="1" For CPUs, this changeset introduces the crash_hotplug attribute to the /sys/devices/system/cpu directory. For example: # udevadm info --attribute-walk /sys/devices/system/cpu/cpu0 looking at device '/devices/system/cpu/cpu0': KERNEL=="cpu0" SUBSYSTEM=="cpu" DRIVER=="processor" ATTR{crash_notes}=="277c38600" ATTR{crash_notes_size}=="368" ATTR{online}=="1" looking at parent device '/devices/system/cpu': KERNELS=="cpu" SUBSYSTEMS=="" DRIVERS=="" ATTRS{crash_hotplug}=="1" ATTRS{isolated}=="" ATTRS{kernel_max}=="8191" ATTRS{nohz_full}==" (null)" ATTRS{offline}=="4-7" ATTRS{online}=="0-3" ATTRS{possible}=="0-7" ATTRS{present}=="0-3" With these sysfs attributes in place, it is possible to efficiently instruct the udev rule to skip crash kernel reloading. For example, the following is the proposed udev rule change for RHEL system 98-kexec.rules (as the first lines of the rule file): # The kernel handles updates to crash elfcorehdr for cpu and memory changes SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" SUBSYSTEM=="memory", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" When examined in the context of 98-kexec.rules, the above change tests if crash_hotplug is set, and if so, it skips the userspace initiated unload-then-reload of the crash kernel. Cpu and memory checks are separated in accordance with CONFIG_HOTPLUG_CPU and CONFIG_MEMORY_HOTPLUG kernel config options. If an architecture supports, for example, memory hotplug but not CPU hotplug, then the /sys/devices/system/memory/crash_hotplug attribute file is present, but the /sys/devices/system/cpu/crash_hotplug attribute file will NOT be present. Thus the udev rule will skip userspace processing of memory hot un/plug events, but the udev rule will evaluate false for CPU events, thus allowing userspace to process cpu hot un/plug events (ie the unload-then-reload of the kdump capture kernel). Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain 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 182c6122f815..f779894c6abe 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 f9bd46fcbd5d..0ac41f48de0b 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -509,6 +509,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 Fri Mar 17 21:21:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 71438 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e54c:0:0:0:0:0 with SMTP id z12csp39750wrm; Fri, 17 Mar 2023 14:27:30 -0700 (PDT) X-Google-Smtp-Source: AK7set9aYOdYACahw8am2syKZQDhUDYQ5kENlDEYT9ftqKj6gI1X4SNvYZmgO6v/jhylPKnb6TB2 X-Received: by 2002:a17:902:b682:b0:19c:13d2:44c5 with SMTP id c2-20020a170902b68200b0019c13d244c5mr8922919pls.3.1679088450627; Fri, 17 Mar 2023 14:27:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679088450; cv=pass; d=google.com; s=arc-20160816; b=eTrEtJgGZwQ6bIAH+72QMd7NvksDQXoro/p5UbaYlxoxLS9YZoRpgZEDnMbmof65dR roxPPpm9DRfO1icADoDaUMmyjzVDqtYDohQq+PM/Dr+TwRDiP/l/qHeOTfMpPq4JUWoJ oV1HJdyeHsCmslLGZQSgy3CskOwrq5UDr1tqYBiq4iyJFkHL0NzEDMXyQzo0abIpdPho ure41o3rhCWEgIvbLhmISzuvIwHzKy1aCe+pONUBcu5whqovry62v5s59PRDCRkyBQMx sMfwC+RCoE0Kptl1eCZJER/jHgls+44TqfMXf/kPSH1X/uDp5oKhpPMRmiftfVx9vfBM 0Y0w== 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=Z39c7i32oLUZ4ubge8eBGitLtIahF77IQjSiLkcr4yY=; b=r2VAm4kgC+9jbsoagPKC9SQRKMNx/rWQfk8tw4KuW8ZeZX0YPjUt7j5FIyZoCkpFv4 hq1bzwPZqs8S0MHtm1GU7fOXjtzR0axBuQsIY1/kWtqYfly4Kap/rnYZ0sTSgfmCAeQ1 io1tbRmGxabuSgUFFhRysuH8qWsFkBJECx23+xQGE1I1OK231V2gpjhYbdSLciSMEsKN fObsfQLVi+nwzJ1USJT9bGxGIpDISbdtQOKH7bE/kEABBpOjpmV3+arySdTZFmresByW 6yxHKTyfsukXQiel1OVsQnlfRFuyv1GEiWT9i/nhDAUOzLNgXyG1a8g4dgNq0RWd7WIn 0dtQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=diBignMz; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=H+QjnQQd; 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 c12-20020a170902848c00b0019edbe2894fsi3219646plo.504.2023.03.17.14.27.15; Fri, 17 Mar 2023 14:27:30 -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-2022-7-12 header.b=diBignMz; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=H+QjnQQd; 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 S230079AbjCQVWi (ORCPT + 99 others); Fri, 17 Mar 2023 17:22:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230116AbjCQVWT (ORCPT ); Fri, 17 Mar 2023 17:22:19 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC2BAC796C for ; Fri, 17 Mar 2023 14:22:17 -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 32HL1nYY024725; Fri, 17 Mar 2023 21:21:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=Z39c7i32oLUZ4ubge8eBGitLtIahF77IQjSiLkcr4yY=; b=diBignMzdEGkUcMw4ioLTpqZlMYMezyF8IDD0/KYzTX7yNWVCUwgMtOIRKK9oHvKgdAx zXBSRHw+5EdZYxe6KdLZwlRqZzAy1XEpe4Akb1RJBgMrXnwXL2vSx+BqfiY3EPkPRG9z dAvBWHNOIJaEGuw6oqplfBVLUsWh7JoL87hH7gkAFJpR200JLr55EfgnniEGYnG2McwW 25jZGWJN+GcjIYJfmY93MjYsGyHGJrjZPOUBAOugU0gpiQyF89P6hyqs1zsNkGBl8Xa2 9JNF3kEes0mNBeXzOkzdtPQbXk2LRrcLLDhUjMJDyYHv+L4pyM4c0Otw+5lTCGIavCmY Dg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pbs294seg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Mar 2023 21:21:56 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 32HJNwnt001119; Fri, 17 Mar 2023 21:21:55 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3pbqq78jjx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Mar 2023 21:21:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PJNG1PGbMjp0wqkjNpyB6F6R+vUj0K5P9+5T8DzsVc7Mng/r7/8p7v2sLYXMnFRXqdeyDYNTnXQtUQ2CvXikA6uVPPct3bknrOOKcnpprU5r/NieKFCHV5AsvaapBBLLK+f9mEjImB3ZdjBX4tZdrlgDO2Fpdg/IRGPMX5+oXJKhoNJc8XsA5ykbf018ZR/b9mbUgd4iY5iJ/QuZo9d0swzt/lojLWsmO3q0xePE09xKlES9iJusxa8jGOHyBB2WU58tixy5sTCVcn6MttZ8uVKOSz+V8rkv3b3mjdHDej3aaejd1DrcHvHQ/rwfLijw3Hd1Yhdmv1goakAMTrIkVg== 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=Z39c7i32oLUZ4ubge8eBGitLtIahF77IQjSiLkcr4yY=; b=e9H9n3fCd/5tkegc1Qo1SS+i07VQYZcjkqYSP/Uyp6UyRxvv6y99rNm7acg3XOaJTjQfVMZZ73LXp4Nls3s6+FiRut0KujpQlJCwzOk67SqnKa+aMhL6DN4Fa+znPSvKMsHSzJF///kPOetfWRbtCAN74tChKg84Kwh+IXlxaMraDb3aRyjpnSQPEu0bIsg3uGfREGSpvcNgTJ6liADCcfxPkYCX8hFls8PcOwtOdXdX+heBnFRS2/uwBt8VZbvppJixRZBgq6OjoRLhZvXViWqMoPSwnlnVLSalktnBD1OrmkFZuxtMNqbYhqqsQMQAw4uxrjBRVfsATCdK+KHXgA== 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=Z39c7i32oLUZ4ubge8eBGitLtIahF77IQjSiLkcr4yY=; b=H+QjnQQduv6CQdBI+4bilVn34PQvjqfhdkFasD2fZyYVhn4uVgU1AeMEYQpw4g4pUgFz4CSqRh0kO7RHTxj30ViiGtgML4/s1YU9sLERBegu9oDBOcQsPkP6bx+6Szw0DdIKENhAyHOSoKwxStI/movQX/uxxWI1tswnfcfzXNQ= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DS7PR10MB5901.namprd10.prod.outlook.com (2603:10b6:8:87::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.35; Fri, 17 Mar 2023 21:21:53 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38%9]) with mapi id 15.20.6178.035; Fri, 17 Mar 2023 21:21:52 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v20 5/8] x86/crash: add x86 crash hotplug support Date: Fri, 17 Mar 2023 17:21:26 -0400 Message-Id: <20230317212128.21424-6-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230317212128.21424-1-eric.devolder@oracle.com> References: <20230317212128.21424-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR11CA0038.namprd11.prod.outlook.com (2603:10b6:5:14c::15) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|DS7PR10MB5901:EE_ X-MS-Office365-Filtering-Correlation-Id: df57ee8a-33b6-488c-3bc1-08db272da0bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WFaGoHlyDWfVsuQ84cUukZ1EEi459Z+Gau3ltYVpvGfLD0Rmdiczuoxuip+LloCpvz0xrb/utMfEkr/CVN3WfzjLdRglMGpM/tyBOxWWwXyeKlKnlZsRIGAbLamPuzYS8U5qlDtGOalr7Zlmn92pjWf89tyYtAwt44IkDqkijkd5qZjxLQsaYezOORwSw6azGw73guCBmY9apSvAF40NaF1hZ4CvGpF73/zzEOdDq2dgxS+RE3ymDLIJvgnTBkq24C6t2EPqEB+LLwc94B49yAgW2uBKaXHwKakXIelbD9hteKK1xU6zO8/8qucWxUbbyApEe/irRT3kEY/OAVwicHcawPiPw+oBlTUM5/EX32dOXSwQb9zJlriiBjvSVHY4J/Qbwm+OTfS2AAOYi+9n269k1/gGwZdnaCAu3cgzaCvgT8OSlDyHp3qXvyENqlLl+KxqxO82LWNUd13zpDYSiPbX1Tww/OS5G2e+f0CL353GVe8gVe/eje8WK0zqTEhyrPPea3FPQhOkp0I9I74Z/5dQd8NpOFED9NMjvD57UP4C5FNhwXq3rmiDui4f4mWhmUyNLGKwCQSRHdSdomPeYTqiWqdUPxsA8YWdRmMHjO6bsCZI3RPiDhaURqYCFxasWLj03pTp7XQVnmXwmCDe5Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(136003)(39860400002)(396003)(376002)(346002)(366004)(451199018)(86362001)(36756003)(2906002)(38100700002)(41300700001)(5660300002)(7416002)(8936002)(4326008)(2616005)(6512007)(186003)(6506007)(26005)(1076003)(83380400001)(107886003)(316002)(8676002)(66556008)(6666004)(478600001)(6486002)(66946007)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Mj0VBWgjmdBFM2NJenCc0wOwSjgdIdV5dz/7wBzEoA4ZqFmYJWCkBQKq0cMFeQ60SykIfdBm4UQ0A8zeSayYaUvMdN6TDpIWxfSvKnZSZBGaRyjQSeF5hDMPiEVg1MWfXMx5HWwqs+u6k+JU12A2IxHdqTb5Yissy/Hdg2hE6iqpDRxc5FSzM33mi7GqgMq5dOuO6qOP5hgbSTS1ZNWS7llc2l+4KrmzPyZbzhd84ai0cCEFUAxnrdNrFtRgpWtbEOtnp9lShBZoGdl4ASD8y0o/0V0JvGHVEauV/1YGsqCn5r+1Yuz03vBRALj4ULa2Koz/n2ybA0/sWs4DQosqIcRYGsWuiyRb1nFZH9Vzq0wqfrWJ4Webo4NKz2L5ZSvzPS2BnCOLrvHTkKmpNawE3YrRgyp9mKFYkldmfDCay8uL2yOHWP9eKQfYcOpCkc2ztuflo/oLKah62Dhv8L6esrXxVTr0pJHQsq5dSwRFd0IxpaZp5zsg6bEFkjTb6x435PTp+yQKodKAFot34vq8g/myzK3dVP9CVfUHGmPWZlic3fnQFBTqyRSAA5NfzdZCCmy+/2OjpdAwNaksJDkKOfoA7qXJOnjgr2ytfnXw52u6hokEqD7vQjqwTweAlgrEIUX2hbP8jk3BJNztOh4F0OYKLi3vu2bzseUnflMdLqnSDyomay8i80rrwCDejCJm7jB3CbhKGUFFRp7JwHL0J58I+8pOQYNBmWWelUk5AErh18YfM/gk5W6ErQBTwH9S+oMtUy/hJrfgqcmCsOQyioEqQaIes9/FhqgRSq95mKv2dGuhgW7AO2Qk5lOxIw5h7C6oAvXFMWrUwOptWsi/yGiax7PI2d2dIZo0gZZO0K877f07vOzxwHdglD12uizGuQtg8EIaBUJUMcqMkX3tGLl0MTrGLENfnyz2WW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pTVr7zTJbxky5ZUMrWIo20+HvZ7ZH4toMixPEqJLEdTXidSpZ70zvbhIYj2NTI/4jTQlR1ha/0/vFOxdX10sSWIhsfCYEbkCAh6WokzKjTi7nqy3vVITz/RQ6h6UdtgqDeUE2Gq8MD2U2uwr61NSuZw2B+b7jobVAX5lcTwo/B5bhWBPoNVgtZpOyBJKNXK9ylxKeyVIqYGMtVbxcJVH2q+A71VIIpHS0Hf5trQGBgzSxRolZDmmSFjHVgV3/2JtuLPMQINE9gLvXbSzdhwdDF0i31b9l09I1KCuv/nK+w/G7ooGUavNkMqq+IStWo2QEpQPoJfxy5k//LLhyW/4qYUBEXG0Uz1u0kpRL3xHvhnQxzTUWqq2/BSnEzspuV+kuNy4ZePbJAX0P4AbMe0jvPNU9u1ocR2Dt5VkyPK8JiMD5cXHbshqB7rDDD78syhatmyOoRoYQ6JLF0khnh8OcYy2e2VYs3Bai6BjxWg9/2ClkFHwWm6oMDNKeq/Qy/wb98vsB6BuZQly+xsQj//k1Y767pXgqJXfidr2+2z1VOwzpo5fB7y/tNAfZQ+4NUAo7zLeyGqtKy/5BfaC29Dl80Q+LqN4TQbvAQnCSEVATGkCHrc7OLFQbaxt7vvCdrY9MsRNyaHgdtw8zMI7C8whfrJCfkEL6pfpAIg2gC84UZDuv0E7Yj0eC2aHzfqEkiywRiWo+wzBN9xSJ9ftd9AzvNbd3dr5Aqe8tWAWqcf3jHsDH2axhlQKNoTI7O4P12fnW7qDOQuhUsQgq4J1h/wmAzn7Ys/xzP9maJmE2YJXzktJf1ks3feKuiwZHgEOM0vliEf0sWiHHWadzxz8MbvEGhmrELcN5/HPFazhf9i10Gc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: df57ee8a-33b6-488c-3bc1-08db272da0bb X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2023 21:21:52.8724 (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: yx+eXMDHDgk04Qm1UUfyibYNvr9UcVR/TYiD0kaLs8LIUORgo/bBz8Zqnjt9I7O4ETSSzL42TmATjkpFT6clH90tlfCse3y39AC8qgcKhl8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5901 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-17_17,2023-03-16_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303170150 X-Proofpoint-ORIG-GUID: 8weVSYYs08WI2NxRHGj3E8nweGNr2ins X-Proofpoint-GUID: 8weVSYYs08WI2NxRHGj3E8nweGNr2ins X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760651851644686856?= X-GMAIL-MSGID: =?utf-8?q?1760651851644686856?= When CPU or memory is hot un/plugged, or off/onlined, the crash elfcorehdr, which describes the CPUs and memory in the system, must also be updated. The segment containing the elfcorehdr is identified at run-time in crash_core:crash_handle_hotplug_event(), which works for both the kexec_load() and kexec_file_load() syscalls. A new elfcorehdr is generated from the available CPUs and memory into a buffer, and then installed over the top of the existing elfcorehdr. In the patch 'kexec: exclude elfcorehdr from the segment digest' the need to update purgatory due to the change in elfcorehdr was eliminated. As a result, no changes to purgatory or boot_params (as the elfcorehdr= kernel command line parameter pointer remains unchanged and correct) are needed, just elfcorehdr. To accommodate a growing number of resources via hotplug, the elfcorehdr segment must be sufficiently large enough to accommodate changes, see the CRASH_MAX_MEMORY_RANGES description. This is used only on the kexec_file_load() syscall; for kexec_load() userspace will need to size the segment similarly. To accommodate kexec_load() syscall in the absence of kexec_file_load() syscall support, and with CONFIG_CRASH_HOTPLUG enabled, it is necessary to move prepare_elf_headers() and dependents outside of CONFIG_KEXEC_FILE. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain --- arch/x86/Kconfig | 13 ++++ arch/x86/include/asm/kexec.h | 15 +++++ arch/x86/kernel/crash.c | 119 ++++++++++++++++++++++++++++++++--- 3 files changed, 140 insertions(+), 7 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index a825bf031f49..316fdaa9a68e 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2119,6 +2119,19 @@ config CRASH_DUMP (CONFIG_RELOCATABLE=y). For more details see Documentation/admin-guide/kdump/kdump.rst +config CRASH_HOTPLUG + bool "Update the crash elfcorehdr on system configuration changes" + default y + depends on CRASH_DUMP && (HOTPLUG_CPU || MEMORY_HOTPLUG) + help + Enable direct update to the crash elfcorehdr (which contains + the list of CPUs and memory regions to be dumped upon a crash) + in response to hot plug/unplug or online/offline of CPUs or + memory. This is a much more advanced approach than userspace + attempting that. + + If unsure, say Y. + config KEXEC_JUMP bool "kexec jump" depends on KEXEC && HIBERNATION diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index a3760ca796aa..1bc852ce347d 100644 --- a/arch/x86/include/asm/kexec.h +++ b/arch/x86/include/asm/kexec.h @@ -212,6 +212,21 @@ typedef void crash_vmclear_fn(void); extern crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss; extern void kdump_nmi_shootdown_cpus(void); +#ifdef CONFIG_CRASH_HOTPLUG +void arch_crash_handle_hotplug_event(struct kimage *image); +#define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event + +#ifdef CONFIG_HOTPLUG_CPU +static inline int crash_hotplug_cpu_support(void) { return 1; } +#define crash_hotplug_cpu_support crash_hotplug_cpu_support +#endif + +#ifdef CONFIG_MEMORY_HOTPLUG +static inline int crash_hotplug_memory_support(void) { return 1; } +#define crash_hotplug_memory_support crash_hotplug_memory_support +#endif +#endif + #endif /* __ASSEMBLY__ */ #endif /* _ASM_X86_KEXEC_H */ diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index cdd92ab43cda..0c9d496cf7ce 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -41,6 +41,21 @@ #include #include +/* + * For the kexec_file_load() syscall path, specify the maximum number of + * memory regions that the elfcorehdr buffer/segment can accommodate. + * These regions are obtained via walk_system_ram_res(); eg. the + * 'System RAM' entries in /proc/iomem. + * This value is combined with NR_CPUS_DEFAULT and multiplied by + * sizeof(Elf64_Phdr) to determine the final elfcorehdr memory buffer/ + * segment size. + * The value 8192, for example, covers a (sparsely populated) 1TiB system + * consisting of 128MiB memblocks, while resulting in an elfcorehdr + * memory buffer/segment size under 1MiB. This represents a sane choice + * to accommodate both baremetal and virtual machine configurations. + */ +#define CRASH_MAX_MEMORY_RANGES 8192 + /* Used while preparing memory map entries for second kernel */ struct crash_memmap_data { struct boot_params *params; @@ -158,8 +173,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 +244,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 +262,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 +273,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 +388,42 @@ int crash_setup_memmap_entries(struct kimage *image, struct boot_params *params) int crash_load_segments(struct kimage *image) { int ret; + unsigned long pnum = 0; struct kexec_buf kbuf = { .image = image, .buf_min = 0, .buf_max = ULONG_MAX, .top_down = false }; /* Prepare elf headers and add a segment */ - ret = prepare_elf_headers(image, &kbuf.buffer, &kbuf.bufsz); + ret = prepare_elf_headers(image, &kbuf.buffer, &kbuf.bufsz, &pnum); if (ret) return ret; - image->elf_headers = kbuf.buffer; - image->elf_headers_sz = kbuf.bufsz; + image->elf_headers = kbuf.buffer; + image->elf_headers_sz = kbuf.bufsz; + kbuf.memsz = kbuf.bufsz; + +#ifdef CONFIG_CRASH_HOTPLUG + /* + * Ensure the elfcorehdr segment large enough for hotplug changes. + * Account for VMCOREINFO and kernel_map and maximum CPUs. + */ + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + pnum = 2 + CONFIG_NR_CPUS_DEFAULT + CRASH_MAX_MEMORY_RANGES; + else + pnum += 2 + CONFIG_NR_CPUS_DEFAULT; + + if (pnum < (unsigned long)PN_XNUM) { + kbuf.memsz = pnum * sizeof(Elf64_Phdr); + kbuf.memsz += sizeof(Elf64_Ehdr); + + image->elfcorehdr_index = image->nr_segments; + + /* Mark as usable to crash kernel, else crash kernel fails on boot */ + image->elf_headers_sz = kbuf.memsz; + } else { + pr_err("number of Phdrs %lu exceeds max\n", pnum); + } +#endif - kbuf.memsz = kbuf.bufsz; kbuf.buf_align = ELF_CORE_HEADER_ALIGN; kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; ret = kexec_add_buffer(&kbuf); @@ -395,3 +436,67 @@ int crash_load_segments(struct kimage *image) return ret; } #endif /* CONFIG_KEXEC_FILE */ + +#ifdef CONFIG_CRASH_HOTPLUG + +#undef pr_fmt +#define pr_fmt(fmt) "crash hp: " fmt + +/** + * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes + * @image: the active struct kimage + * + * The new elfcorehdr is prepared in a kernel buffer, and then it is + * written on top of the existing/old elfcorehdr. + */ +void arch_crash_handle_hotplug_event(struct kimage *image) +{ + void *elfbuf = NULL, *old_elfcorehdr; + unsigned long nr_mem_ranges; + unsigned long mem, memsz; + unsigned long elfsz = 0; + + /* + * Create the new elfcorehdr reflecting the changes to CPU and/or + * memory resources. + */ + if (prepare_elf_headers(image, &elfbuf, &elfsz, &nr_mem_ranges)) { + pr_err("unable to prepare elfcore headers"); + goto out; + } + + /* + * Obtain address and size of the elfcorehdr segment, and + * check it against the new elfcorehdr buffer. + */ + mem = image->segment[image->elfcorehdr_index].mem; + memsz = image->segment[image->elfcorehdr_index].memsz; + if (elfsz > memsz) { + pr_err("update elfcorehdr elfsz %lu > memsz %lu", + elfsz, memsz); + goto out; + } + + /* + * Copy new elfcorehdr over the old elfcorehdr at destination. + */ + old_elfcorehdr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT)); + if (!old_elfcorehdr) { + pr_err("updating elfcorehdr failed\n"); + goto out; + } + + /* + * Temporarily invalidate the crash image while the + * elfcorehdr is updated. + */ + xchg(&kexec_crash_image, NULL); + memcpy_flushcache(old_elfcorehdr, elfbuf, elfsz); + xchg(&kexec_crash_image, image); + kunmap_local(old_elfcorehdr); + pr_debug("updated elfcorehdr\n"); + +out: + vfree(elfbuf); +} +#endif From patchwork Fri Mar 17 21:21:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 71436 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e54c:0:0:0:0:0 with SMTP id z12csp39282wrm; Fri, 17 Mar 2023 14:26:17 -0700 (PDT) X-Google-Smtp-Source: AK7set9JK3zUll13Ha2tG6UInUKdop16CELjVI5s756QjfCCFV1JUywweLq12r1LoZQtNOEXTKUy X-Received: by 2002:a17:902:7296:b0:1a0:463d:fd09 with SMTP id d22-20020a170902729600b001a0463dfd09mr8118021pll.1.1679088376726; Fri, 17 Mar 2023 14:26:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679088376; cv=pass; d=google.com; s=arc-20160816; b=Ay1GyuguzfAr8iSqTX/BEUsyYS8rVSy0YRqIp9Ya+qtnceNL0+uaZpyIooIXSguQF8 etqKLNO3zz00pxqbqOFDTnhKuwbID1/uVJk+xPmdOAzo99P/WudJE26jULN97y6jzzNT 3P59yPMkplcxRSFXyhhXa58jfGvDATzj7Ne2WgtwXiQJBM7yJ7kYlA2j6WPhEQYgy5eJ 4iK/JHIj1rcgaIkn1FcubivkZXL/uOTuF3kP3lgKema7vBDu63J9H/qF9BPNOyG2O1kf oEOz6BcV2IXvVPGN/1AhuSeCJnJY1MSby+Ll9JxJo3LuwkYP9xV0CRqSetin1ZGd1bdZ gwlg== 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=zN3cT91sjc+CGW/b1TMScu30sdafxLLQAsYvU3EjQmg=; b=Zxa1BRcJY0V1fLmvdffvpZONPnJ8i7Etgg4K5snTNzu+qTkKeIPQENsNw9RxKjmej/ dnMQxmXGvWY3M8NDxbr7BF8Jril+rC9kqukHDOp3ahvPYqKV6exVLi6L0gW2K6se7wCj SFfCCp4JKgVtQZvZEcz6fExGy/0bw615AyGgEG0Ys3UNXKGMPDoCPlJGeQ0fFaVctSqA hl6R2ijwf5L3NKj9ihupqvLMj+qirLOC9v3QTf8veSFKfi6vwWoz4F2Yh7FPqMEIuMYL shURejBGj8YpJz6nmKzaooAi3NBhrigYRbzOZk4jEpvDIxVlzKdeTS+FEVX5VVpoyKbl Orfw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=EEGiHi+n; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=jqaKSyzP; 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 b2-20020a170902d50200b0019ea3ee6f0bsi3520925plg.492.2023.03.17.14.26.00; Fri, 17 Mar 2023 14:26:16 -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-2022-7-12 header.b=EEGiHi+n; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=jqaKSyzP; 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 S229585AbjCQVWZ (ORCPT + 99 others); Fri, 17 Mar 2023 17:22:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230002AbjCQVWR (ORCPT ); Fri, 17 Mar 2023 17:22:17 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DB69C6DB6 for ; Fri, 17 Mar 2023 14:22:16 -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 32HKuWPd016808; Fri, 17 Mar 2023 21:21:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=zN3cT91sjc+CGW/b1TMScu30sdafxLLQAsYvU3EjQmg=; b=EEGiHi+noxqqonm8N/cPUy0tqhbYYWnzmdK8YMqecNO1Ydjl2kDL6OCy0e3j5Tyyugca oAppxfrrPufy04NdRnMLfOwZBi9ftOxRqQ2VZbJ3Mio4oMMqtW7trX1YDRWFgwv6tbGQ yG37ocEVYy8OqQybClMWQ/K7c0UTvG7+6E6tl04uKB49vg/iyM7SgvsaIQ6JKjkHUsup WJuEa1GcG36aKlD/jBv22sagbMRYxf86U9ElKqD9f8kIJLqhCc6zYb/pmQfyVLSxXMxR DQ88Mmgcl42bJyBM6IWjUatPauelFEFAbAi2ldqVrqKUiY1nD/SbtA4COz+soLGFb1Xl ZA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pbs29cyqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Mar 2023 21:21:59 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 32HJJcjq015649; Fri, 17 Mar 2023 21:21:58 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2045.outbound.protection.outlook.com [104.47.66.45]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3pcu2uc4ae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Mar 2023 21:21:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LOQxDg7u1oTcSI/OcSVXAQZG7lLFs5WLp+cT7VbnTtOKr4XlCv0vTv1+NE+KZMTEbpKhAC96EWTO7CqwTIX9S8vX8YqSuwpZJtKQWm3lirjEUeFma7poa7tz+/GT7s4V6taoXtjA6myY87ZJ8UPlru3FU9HnhlMRtfmBtjasGW2JXv2o53DBuZ6fL70kCKro64QoW6J2SY+ifpOd7TGXIM+n+ew7W0Lyl2Uvrbunwu+bP/PNunNDVR4KlcgthtnnI7IGC9kiHieYVc92lVTHZ4ttxYsl6y5hlOFuayP73NwwBdikncDGZ+cyLYOhS3hvtmeXxoKHHPzdC0aKWoI9Bw== 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=zN3cT91sjc+CGW/b1TMScu30sdafxLLQAsYvU3EjQmg=; b=WGbEn9IKSL/OaxzP5R7XWGukuTCPQHJM221yne33TDaToXVqDaE6ARMUd5uuqNj0F3bqjQiUmF9Wx8HIvh9uzrPte3+ZkOgH3umMOlSBPBk8GFtuXchB15zgWtGRbVLv/oCVNL5ZPDNHbmJhzKGLWP+zD9IWKRecOccDDGLBk5LLIs8A8F98pHCeewl0SZsoIPnl2eD4GXHy2zsGicQRQTXOvpSwArg8nX86gyYuSP/q/qLtj5PUfbKWJQh1UL/2s3Gvkbyj82X10/gqWHPOS0PD7LzTuXS8oFbv2tNK/Y4FARRLFExztFSau6HdVZUgl2XGU4Mgbw+wXhkDhUkzgA== 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=zN3cT91sjc+CGW/b1TMScu30sdafxLLQAsYvU3EjQmg=; b=jqaKSyzPc1rbn+Sx0pkr1ZNuJ3bEOALnd2HCzyTzY84/XRWhL9jsGDPm1tDc+lR5xm/RtngeKn0Y45Nc0mvjpkK7UgEWw1h1uX9SfHF3zVsdZViREymqBcwb2kyEV5ArwI1DlC4mXwQeojswGxrADF08rf93mtFyPnaiT9A0Zrw= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DS7PR10MB5901.namprd10.prod.outlook.com (2603:10b6:8:87::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.35; Fri, 17 Mar 2023 21:21:56 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38%9]) with mapi id 15.20.6178.035; Fri, 17 Mar 2023 21:21:55 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v20 6/8] crash: change crash_prepare_elf64_headers() to for_each_possible_cpu() Date: Fri, 17 Mar 2023 17:21:27 -0400 Message-Id: <20230317212128.21424-7-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230317212128.21424-1-eric.devolder@oracle.com> References: <20230317212128.21424-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR13CA0044.namprd13.prod.outlook.com (2603:10b6:5:134::21) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|DS7PR10MB5901:EE_ X-MS-Office365-Filtering-Correlation-Id: f679fa2a-3d6e-414e-4b78-08db272da280 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fyxVBL/zErCt18ZDf8apk62BjYgjGGdu3Sfxx3/29scfAWjCyCL2p7Sv0DrFDdk8CciuS8dupwutqTKcQalGgUHVZeZPUM4VDXsPFh1ujPkWuuggxURkqU2cvlTEnDMCXgYLTZYPM6eGmJOTa8ClyY3gbal5XNnd2X6WS2PfmsXd5Y3Zk5/m2XJkbUi+CcezNMnncxdbE9jKAmfP0KiIrN1Dv4pgKH0OXA3BNSO1OWP9m3dncs0qmr8T8fy/DDOtYTxOWBJ8DitNHXoAt7mjVi/ddYEidJDjt79Azni585laGMcLe6ZtzRFDjCwZKTX4tC7DnyUNgtV7tAsuIzZI0HJRg4fbAesxVCBjGNA6LVBE5fRLFB1OGWNFEzclzEMBxrGopYcWSe8gCuDiXwaiRCRMdYsPel58yu1SqeXFaDaR0YdFc6Xx7VMrFIoOqEfj2v5IN1AHgQqWY8BdOI40Y11bmM2494x5n6UXwIJNP89jCWClS1a1GfmPFRuMxRzbvC/+ACY5b/u3Pa0lR2xA+phVuzXCCjrdst8aY5w483eeCxVNmQReYclzFFeuWOskpXrPUE8ts7/JJU+5ZArsnk/v5hysViJc1jfmQDeV3VT4WntIvWAh5h8VEYL9vhbdV3gv4RbNNjV8lFazpOytiQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(136003)(39860400002)(396003)(376002)(346002)(366004)(451199018)(86362001)(36756003)(2906002)(38100700002)(41300700001)(5660300002)(7416002)(8936002)(4326008)(2616005)(6512007)(186003)(6506007)(26005)(1076003)(83380400001)(107886003)(316002)(8676002)(66556008)(6666004)(478600001)(6486002)(66946007)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: J/xzcdYAsT2roT1IVtsKHRfNJUWTJ7kZ5pQq5YcJtmR3XTFNV3a2rADrGr9iGJ9tio2Cks45XNZLR5yrsem7G/jQQ1khAocByUwbQstGtd0xP7NbAw7/vkO8+VCgx8ceHWxOE9/HsD7WmZ4p99pNO5FlwONCDMnHE5H7ogR8t3uMbrWyxij/ncmuOQMCjJ4AEZXl3TyC41Bx/iyKFpJSYpNz0VTk0XRKIU+batQnMO25e6TofmtZAjdGy7QRAGYGmY/zeZRKiJABS5gOnGGH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hzGMVEz4RwdXOEXpx4T0ot/XFPQN0f0NjHzrVudf8mgpqY/iHI60ZH0vMAEOeI3QSXVmSE8WUvSPneWCj5ojbzDEnLE0HuewAKLhLfJu+W3Egzx3vqi0sbjgL7lWAcYJhKhColHp34GGZQFTMY7Q3RydeKolhq/ktMMZ0oUk94TETDF9svI4WrDDtkUF0o3Vi9+XMvu7Eq8e/3cJ5eV6Zw4HkMky0gMeWKKxGNVGdvlUon8/8m5BCBg+uEawCRrpaY0c9sAUg9wMf+DExZ6/CRipFJt74ekPAsTcgzpL+HoRZ+6hfjQPMk70El/1zJh4l1ct1GtLx1Pd741l9rY/FcWBf/GBx+w6JgeiHeumTGf1iYEhTG0ch6JrlyB1301LcFLJ6UF1VReqKsvt5VCnXuEKbq9CEUr7iMew269TgPZ9yUm/kmGsjJgUwY3soWJUGwpPtw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f679fa2a-3d6e-414e-4b78-08db272da280 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2023 21:21:55.8260 (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: h8Ejamc+RWZFE2meZ0BR5Rip9MyodBx0MrmZE9BQXZyNqpNyU5ZlDf+hwGSz7qKCakf0zdsSmXACPffxifTeprIp8sjNEHjeM773OjGkAKg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5901 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-17_17,2023-03-16_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303170150 X-Proofpoint-GUID: Dhls-A_tCITodXZ66z23di2RPLG2I2UL X-Proofpoint-ORIG-GUID: Dhls-A_tCITodXZ66z23di2RPLG2I2UL X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760651773436434075?= X-GMAIL-MSGID: =?utf-8?q?1760651773436434075?= The function crash_prepare_elf64_headers() generates the elfcorehdr which describes the cpus and memory in the system for the crash kernel. In particular, it writes out ELF PT_NOTEs for memory regions and the cpus in the system. With respect to the cpus, the current implementation utilizes for_each_present_cpu() which means that as cpus are added and removed, the elfcorehdr must again be updated to reflect the new set of cpus. The reasoning behind the change to use for_each_possible_cpu(), is: - At kernel boot time, all percpu crash_notes are allocated for all possible cpus; that is, crash_notes are not allocated dynamically when cpus are plugged/unplugged. Thus the crash_notes for each possible cpu are always available. - The crash_prepare_elf64_headers() creates an ELF PT_NOTE per cpu. Changing to for_each_possible_cpu() is valid as the crash_notes pointed to by each cpu PT_NOTE are present and always valid. Furthermore, examining a common crash processing path of: kernel panic -> crash kernel -> makedumpfile -> 'crash' analyzer elfcorehdr /proc/vmcore vmcore reveals how the ELF cpu PT_NOTEs are utilized: - Upon panic, each cpu is sent an IPI and shuts itself down, recording its state in its crash_notes. When all cpus are shutdown, the crash kernel is launched with a pointer to the elfcorehdr. - The crash kernel via linux/fs/proc/vmcore.c does not examine or use the contents of the PT_NOTEs, it exposes them via /proc/vmcore. - The makedumpfile utility uses /proc/vmcore and reads the cpu PT_NOTEs to craft a nr_cpus variable, which is reported in a header but otherwise generally unused. Makedumpfile creates the vmcore. - The 'crash' dump analyzer does not appear to reference the cpu PT_NOTEs. Instead it looks-up the cpu_[possible|present|onlin]_mask symbols and directly examines those structure contents from vmcore memory. From that information it is able to determine which cpus are present and online, and locate the corresponding crash_notes. Said differently, it appears that 'crash' analyzer does not rely on the ELF PT_NOTEs for cpus; rather it obtains the information directly via kernel symbols and the memory within the vmcore. (There maybe other vmcore generating and analysis tools that do use these PT_NOTEs, but 'makedumpfile' and 'crash' seems to be the most common solution.) This change results in the benefit of having all cpus described in the elfcorehdr, and therefore reducing the need to re-generate the elfcorehdr on cpu changes, at the small expense of an additional 56 bytes per PT_NOTE for not-present-but-possible cpus. On systems where kexec_file_load() syscall is utilized, all the above is valid. On systems where kexec_load() syscall is utilized, there may be the need for the elfcorehdr to be regenerated once. The reason being that some archs only populate the 'present' cpus in the /sys/devices/system/cpus entries, which the userspace 'kexec' utility uses to generate the userspace-supplied elfcorehdr. In this situation, one memory or cpu change will rewrite the elfcorehdr via the crash_prepare_elf64_headers() function and now all possible cpus will be described, just as with kexec_file_load() syscall. Suggested-by: Sourabh Jain Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain --- 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 ec1d68569f6b..30ba30cadf2f 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 Fri Mar 17 21:21:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 71464 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2418wrt; Fri, 17 Mar 2023 14:38:10 -0700 (PDT) X-Google-Smtp-Source: AK7set9IZxAkRq8p0Uxrte8Im9QFTrs6wjHHsZNVcqBV+VLWxlrySFAHPuebi7tpK/HdH8yzcbUS X-Received: by 2002:a17:90a:2a0f:b0:233:b57f:23c5 with SMTP id i15-20020a17090a2a0f00b00233b57f23c5mr7620896pjd.2.1679089090214; Fri, 17 Mar 2023 14:38:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679089090; cv=pass; d=google.com; s=arc-20160816; b=W9+YT/Y6E5Mr/8+fJC5noFVWHKikIPgJWmIJGByED8KTyAxPX/ylR5uj86cQPa8ZU/ OsdGd/2sqCSQ1ZoJglmI1nO3IsHIdPH8KH92oV8j7yXtlbYLlMM4Cg24SGTuMaaJ5dEV x76SSyI5wDfKSzJcwTCTwMYRHfcByaf2owy7E3462iIwch5v85zvV8zeOsY6Rjbp4PjH wEO0dgaPp35IjVaDR/6GTh9In91eUQBgM6CJVgAuh8OnFiWvNPtJNVrKHFlEMSyT4XUW NDOQnkKOUQWGR8DQUKCmE2yVT3TnchXjtOoRiWEe+eumgI/kVyghVv/s3qyYlLaJoSvh nunw== 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=g1wxY3LICoo5vWQ+zWVRd+wf6XK2Gcx/FSKiBxH+Ieg=; b=ZG6c+iPFVQwDoEKMUm/s6lrC4SumT0HyWtBwYbzqnf2BpUOQSgojDBS4IlBtxTS2Hr myWwpV7SRKW2txAKT5DFoq5OVuOQ2jAq0x4q552pjBNxyYLJRonFrNcCchh3LPOFwe9h J8/7j5QgnwfkIeUfn+9fTAHQa1lD1L1DvxqqE6QYztR62b5ITOSEChXheDpUXFNjtdyo EFYh4JjbRryU847hMTY9Uqo4Q+g4JKOfi2KRgHKtd6jNsvWwxuGCtDf0UcQbXYO9t2u6 Dl17QLkgSnka76BvFtzCRZFmEyg961sULxmnzubblifOObcZ+/ZJSwf+xKKL/GMesWaQ fS6g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=GyHNPqaK; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=UmJ9SKyj; 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 n4-20020a170902e54400b0019b0c650267si3599575plf.510.2023.03.17.14.37.57; Fri, 17 Mar 2023 14:38:10 -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-2022-7-12 header.b=GyHNPqaK; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=UmJ9SKyj; 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 S229647AbjCQVXP (ORCPT + 99 others); Fri, 17 Mar 2023 17:23:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230002AbjCQVXB (ORCPT ); Fri, 17 Mar 2023 17:23:01 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB7FACA785 for ; Fri, 17 Mar 2023 14:22:35 -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 32HJUQ03020643; Fri, 17 Mar 2023 21:22:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=g1wxY3LICoo5vWQ+zWVRd+wf6XK2Gcx/FSKiBxH+Ieg=; b=GyHNPqaKnNIfqcWCYBYj0AC7YpWOEmYV8zyFcWLYrm3ktRTIhdZRBRPE3a0Sq2Gcy1sq 6/JpSl+eo3533RwK3EaWv4p2XFqDwg506B32RIVwBPf6sWJI3b1YELrrbQzSPCESS0IG tye9GRdK2DLaZlBzifDRzIClHs27NOctVxsmwAlk4h/5F+V3tYLJ1BsPaMmxWuxCrHVb voXcH3vSJAzAwP3mwWw7tR3fjL4Au/y2lVTIwra+UssZ93dCtMKovFUaW3X8030Oqrxa a65pHUjybneSCsJV419SzKlH+pb/kAOaqr2IqPQ/CWWIOYP7T143cGx++nLq6QPTJZgN vg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pbs2651q3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Mar 2023 21:22:01 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 32HJAVhh002489; Fri, 17 Mar 2023 21:22:00 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3pch08j9q1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Mar 2023 21:22:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lPIha0LgA/u3GqH+WrEhnEYOzAwVzpzV5EJHYJyqiuujvvgqFE2fV7AOvs98Me4Lelg+agX2/SJW8xenn8zPfXzsaMCI6+GhBrDJ3Qou0Xr3lZMjHzZP1nG8n1ZbNPd06Bz/gEov4X9K0gYVgMFRhTtxXLlhabYQ+dw/Zn/XDHu7qJHAzv8oRxXPjaE9zpbj+A2D5w7ZS0sNwjGWvNMdJ9n31sbZE8Wt5YtfW03K7mM7cmcFkkcDJzzyvcY6Taou7ch+tfIo2gfGkJGI+61EdyUTo2ntjBAtMjjVuYnPQH56RcC4KTitko6JoKC869xAEl39MHnSfWcVskHCQ+kLPg== 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=g1wxY3LICoo5vWQ+zWVRd+wf6XK2Gcx/FSKiBxH+Ieg=; b=K8xF2pWb+qMFw6G8dgzPtn52SQD37ug12+Z8mprjR5Mom81BOozN2iBZILTw73Wzr/e7ZQd2lwpEsgyDQpckxcec5s4Ai/RnX2l2wpW20iiLHzvejFuiyP5zgHG2wwep892r9BEYqE2Z+vkyu+hfuLdqrfRiSW7UuPYifw6wdZmHbyB5imv+dtirt8sXsOW/Bo4otTTcjBjpbXNQHqqmNdRp5ZrlP4EF8mbKky2iOrp/CnGzq1NUMK+fN3Rcr2QQFVcaKiCJoRbm3MW/KnUDPyUK8mkSvhf7h/qIoKVYL3SSvhIji5oWDeQDnap3rz5l6z/iRioYK0msvBygLW6yVg== 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=g1wxY3LICoo5vWQ+zWVRd+wf6XK2Gcx/FSKiBxH+Ieg=; b=UmJ9SKyjQuL7UA+FDaeFIoLwnnOH2tE2d9QAeMZZ40nakRu/TAwgI2evlGN1aAVapzOW11f31Vj4xczodqkJTZVtow1OCrCAYa3J1jGbev2Na1kLPFZlIxJKwOWZxZWMGvn7ok8h2uoMzM7LCK0j95FYS+0l6oGljQgbBED/aw0= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DS7PR10MB5901.namprd10.prod.outlook.com (2603:10b6:8:87::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.35; Fri, 17 Mar 2023 21:21:58 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::671e:6486:6996:c38%9]) with mapi id 15.20.6178.035; Fri, 17 Mar 2023 21:21:58 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, ebiederm@xmission.com, dyoung@redhat.com, bhe@redhat.com, vgoyal@redhat.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, nramas@linux.microsoft.com, thomas.lendacky@amd.com, robh@kernel.org, efault@gmx.de, rppt@kernel.org, david@redhat.com, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v20 7/8] x86/crash: optimize cpu changes Date: Fri, 17 Mar 2023 17:21:28 -0400 Message-Id: <20230317212128.21424-8-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230317212128.21424-1-eric.devolder@oracle.com> References: <20230317212128.21424-1-eric.devolder@oracle.com> X-ClientProxiedBy: DS7PR05CA0054.namprd05.prod.outlook.com (2603:10b6:8:2f::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_|DS7PR10MB5901:EE_ X-MS-Office365-Filtering-Correlation-Id: 1006161c-94c9-42b7-b0ed-08db272da41a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5wjmQOqC/i3ucJWBjhhxN4B/KIXqNDckkAIIJzXs+/3A25iEF8NWvvpZjzxfFcdX2k/Y5s1V/gK92njGsiXF7aOAzQ17Q2jkBaT/8hQJg9EbXIqFnwdtqXoP916u8G+VsMw9TUw0sGG10EWjZvtOanUBDg3aI3AVqmwDf4dFs4uCkGrELg6D4H4ipTElxO2o0T6Ds7J8ua6Z1Pvmyd4CsC05UYZw+9PEKEg80qtiipCzerGu05VhKUOsFnWjePs6FuHMQHtk9Eg14vacHO1P+HxwzW/OyVFjLFX9WgrdE++lPguvhVGMFpGo6eLt5UQ+T5kFTLFGZrphX4H0fu/tsY+ZRb8SoaFBhJPocGHIJFsPG7oTB6LJTJUOa29+5hHdFESSDD3yFtdPZGYedx3zkmXTAiBRAImWjn5zlLc+U4luAjQur1kgRs/xm3cJo6670y6p3/XyosGsGkj7AaZ5I59UM76YxeVJEDb0vcMqYt+6JVZu91Cxmd5V8l8I1IJcUZgQ5oyB4CUK2cpFGCGQ4XHhTr1mkgI6dgAZHJj0IhrbPEI1MRWyCWwUsMHyyyiGTRkhgb6c2a4VS4VQV+iBw8Tb+qx1lDrGjrI+jmTe6XVDGWs6adtkFb6HjH3FDKEyhCups9q7Pfen1pq823tlAA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(136003)(39860400002)(396003)(376002)(346002)(366004)(451199018)(86362001)(36756003)(2906002)(38100700002)(41300700001)(5660300002)(7416002)(8936002)(4326008)(2616005)(6512007)(186003)(6506007)(26005)(1076003)(83380400001)(107886003)(316002)(8676002)(66556008)(6666004)(478600001)(6486002)(66946007)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6OaSFJpWu3CdwIwTDrOTPcOR914oDEb4iKZeOQi+v2bOPcxJOn0ukEvn+ZHOc2KjvubXAU8kd7GRiRQyV8ks4xVwRO8rLwTSytJAbcTq6onCjM+x+qy3zOum/qUFVJyQLu3nvf2X8CuMrE6Hr15yFSAaKQ19nLNLNJ3qrQLekb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+WTthwzv/H6FyRog7jxpH8+OB9WKGt3eOiQhQEkz4JZsRUM/UlnoorCbdvh2KCX8eqCNNA7MsceCRsMXmohpHeOMvXXf5mrgyX4dHXh7+/ik8cWnw6PR5eT18WrsTzCOkOKnEqikyEyO5bE8bkqp35X7zVmk8XjXbw7JsJmzzNBNZBfLxKN4CjmpfvgNyHX6oyNEL8Nv8uGf5xSoliuM70SxHWCRE5yzDVhnEgAQArVMsWwq7L68zBdVEPsfYOWg8el213DAWlW+s8Hsmy1A9I9wdDLMsutBpHau5PJP4rhV+3+e+MXZi/gR2gRODG98tHlBBOwg7gTricKSC9bR+GmJXnMt/d//c/QpoZ5HkJedt8njaX6ugIyG27c/SUghDFDRD+K/OPs1qms3f/kCxJ8afo2z6FGXjstCAOaktliCERod+xD0RhEv3dSLYvfjdgFpebOQKxFzHLezugwKnMAYXClCId577cyqucdvK6gePXT8OpityBKpDnQWlQfrve5BGwySH8lb0PlIYZ0OeGXn+jnS5ZKRvooxkN2M= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1006161c-94c9-42b7-b0ed-08db272da41a X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2023 21:21:58.5156 (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: HY6AeWuQgiaIGHwjB/NLlgyLEBqIMa5WooeMuVofPkHL1ZsdjxMJvC9yfDhA15Zs6rTHKGI6F9EcdcmGOeZoI2gssCEH3Cg7/t2Smpd8ovc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5901 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-17_17,2023-03-16_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 phishscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303170150 X-Proofpoint-ORIG-GUID: 8Zlx89WUXmEXL5fSB-2NI3gezei0pgKl X-Proofpoint-GUID: 8Zlx89WUXmEXL5fSB-2NI3gezei0pgKl X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760652521861428413?= X-GMAIL-MSGID: =?utf-8?q?1760652521861428413?= This patch is dependent upon the patch 'crash: change crash_prepare_elf64_headers() to for_each_possible_cpu()'. With that patch, crash_prepare_elf64_headers() writes out an ELF cpu PT_NOTE for all possible cpus, thus further cpu changes to the elfcorehdr are not needed. This change works for kexec_file_load() and kexec_load() syscalls. For kexec_file_load(), crash_prepare_elf64_headers() is utilized directly and thus all ELF cpu PT_NOTEs are in the elfcorehdr already. This is the kimage->file_mode term. For kexec_load() syscall, one cpu or memory change will cause the elfcorehdr to be updated via crash_prepare_elf64_headers() and at that point all ELF cpu PT_NOTEs are in the elfcorehdr. This is the kimage->elfcorehdr_updated term. This code is intentionally *NOT* hoisted into crash_handle_hotplug_event() as it would prevent the arch-specific handler from running for cpu changes. This would break PPC, for example, which needs to update other information besides the elfcorehdr, on cpu changes. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain --- arch/x86/kernel/crash.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 0c9d496cf7ce..8f7b0b7fba90 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -456,6 +456,16 @@ void arch_crash_handle_hotplug_event(struct kimage *image) unsigned long mem, memsz; unsigned long elfsz = 0; + /* As crash_prepare_elf64_headers() has already described all + * possible cpus, there is no need to update the elfcorehdr + * for additional cpu changes. This works for both kexec_load() + * and kexec_file_load() syscalls. + */ + if ((image->file_mode || image->elfcorehdr_updated) && + ((image->hp_action == KEXEC_CRASH_HP_ADD_CPU) || + (image->hp_action == KEXEC_CRASH_HP_REMOVE_CPU))) + return; + /* * Create the new elfcorehdr reflecting the changes to CPU and/or * memory resources.