From patchwork Thu Jan 5 15:17:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 39640 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp352753wrt; Thu, 5 Jan 2023 07:22:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXt0g7EvPr41J1mGf7H30rGQrmTjMbYMCIPDq3B6+ADdHbNwWEgeTQ4DBtXR7fB8yl8/33Y7 X-Received: by 2002:a17:903:230d:b0:192:a174:178f with SMTP id d13-20020a170903230d00b00192a174178fmr38669452plh.37.1672932140285; Thu, 05 Jan 2023 07:22:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672932140; cv=pass; d=google.com; s=arc-20160816; b=nt0nk2JjT9pIUIQgpRnkO9olnMX1dKyefEO2MI0/Qi3FCqz8ZnKqve7AsDJJ4s2e67 YaZ3cvmb3gmSXhiEQBvJGChlihO208QN95QKO8ldKDalieaGNbdsr+/RNhGhobJhgVJ6 bG5DlDPDl78U6Q5Y+QUDsJE8N8GZFuTT4ma9W8KuGEmEwjg6oVIcOvgBD5rYe+Af0H1q 7IAti1tiIgnceddkG3RBvcZ/otwPf6gZgJow68mzOWgHfdvbcVR5RB5t20XRQVufu2aT UkmJPZBg94uFdbOQQBMvXWnrZIH9e0jJjJXi+eUfgM/QSTSUZG00Qk14kypJsoMN9vqw QwzQ== 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=5a75QrhFo/doCbuYupVXfOmdyYlKZEJF3Mf0nkx/AN0=; b=ovfl/3Fdfz5sCSqyYaHHCjgtMsNfz1YPUyc2HvrOZXya/90w39ja0rXln3J0z1+1cA 1aHrsDifi2gwWh2gSHQwIrTI8Unn7zw2HZZCMs5xO+GCSJsWK0vSTEn5JWvvdADwtSeH 1TZ9/bnZtzRatQweRyQcM/8YkkRdmxA9LH4euBEzlawQQuJyILdJZAmq7bl0DZv/bmF9 Qs2HNS1j5PtOOfev6mjjVcABIWSCndXd5hCXsqaqNVVJcT2uPwLaoIo96DX+FUaffu79 yTIMRBnQ/rnpmn9WEbHNEX3809YezDvx1QO2ZJbbIY04f9IM4bgGypJ63EUUhFTWUIVN vFIQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=K6kOQFop; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=zpI0ySNB; 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 e16-20020a17090301d000b00188ef2314acsi1445976plh.527.2023.01.05.07.22.07; Thu, 05 Jan 2023 07:22:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=K6kOQFop; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=zpI0ySNB; 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 S234094AbjAEPRy (ORCPT + 99 others); Thu, 5 Jan 2023 10:17:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233555AbjAEPRw (ORCPT ); Thu, 5 Jan 2023 10:17:52 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD8E9392E5 for ; Thu, 5 Jan 2023 07:17:50 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 305E4I3R025166; Thu, 5 Jan 2023 15:17:26 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=5a75QrhFo/doCbuYupVXfOmdyYlKZEJF3Mf0nkx/AN0=; b=K6kOQFopEn63W1NE2ZVD2pbH13x0V+q0OT+9LjCWbHdYEUbHIsFvGgXcOwoMBGm4Iux8 Sjdf10SomfYnyJ+G21RoIYMwgadyWW7qHJBC41Dj9MuLs887eUZFmmRglULmuLS7hPon q8uCe4JZ003qLYAJvtp4U0+IUg++trSmkNAme199t+zdns5zbaVHDCHmoEc0SBlHVOgQ e8x0pF6uhEYisWfHWLQ3GknHw7KnytCOoCgtr+C/b7k844d+TXKegH5xh3vEW1/nlf+R 4Z/D+KJF3Pr0e2VslX1rQs4bycoFaGKwqLZ/O31TnjrPhBZRodupPDrGD+cvmRA7v9no ow== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mtdmts0b3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 15:17:26 +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 305EPLlw012026; Thu, 5 Jan 2023 15:17:24 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2045.outbound.protection.outlook.com [104.47.73.45]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mwdf0hp3e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 15:17:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O2jYnxtlIFIStVVula09Ay9IwpHiShCmYDcsSYKr5MFstv6k0Zjv28Lc97Q7A13uF2YKU6y3O4oRca3rfqoU8C370KzaQo93lZ2Tn5bDVov9H0gmmRNAUVBNarNlzxSxmPTZrT6Vy3WGnWjhcvnK10q6/YkIWGIqSlPjSTFOdSJ2oA9kw4e0LfONGuySd1sx+V67A86p9Y3/kEznIO+1bkN1WNjmJeoROBfKxIcmBqyn19z6VHBGzUe40cROzpr34DXaBKeBSjIoGI/1WeKj7hxznwHSRIelZiue4TD6aqfbQorz7+0+SPEbdLRUylHxEmH+8SDRkDW1NMzQWTgPbA== 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=5a75QrhFo/doCbuYupVXfOmdyYlKZEJF3Mf0nkx/AN0=; b=Khz6P8QmgBYXxivYLQOdPwEoY/Re9/7HJ6Igxm0UNquPtA/nsOz64aTIKjyEBkqVSjYQfr0YECe0ogz0Wnl8Owh8Y/3ooiBehGHCLKC62PdMHIcg2f+aug71reSoMaxS60EJ8yccRdIP6FmwLHT1HAS7bdm4uWre917Q84+lEwiEHl2M+EyxNOo/Jti/xqHhLciNwUOb97WUm8B8xo2c73Wfjcu8ExRad2mmqKUmAtZ1OP+ye1ofQcWpMw5C6Jd9UMbGz7DuZMJzLxLcgjsWujhEmego3icj6eZlNr6HuIwhVMWHfmLNF3TmdIWUEzXROLU1zhqF77z6i7CYFH/gvQ== 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=5a75QrhFo/doCbuYupVXfOmdyYlKZEJF3Mf0nkx/AN0=; b=zpI0ySNB7ryUWWSM3xyBQRwcLQGz1UhVMPw2XQR8ZGwLWgyJC+Sk0Xot069pWAFq++VBfpRI4WUf9viEQ5v8CYHVuudW00QQfPZGMSZnLAI3oUvjaRC3Vl684wKsTVhKlIMkMT4F4S/9qKOPYszCThS0oq8nUm7cioDwmDMxwH0= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH8PR10MB6477.namprd10.prod.outlook.com (2603:10b6:510:22f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 15:17:22 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a%5]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 15:17:22 +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 v16 1/7] crash: move crash_prepare_elf64_headers() Date: Thu, 5 Jan 2023 10:17:03 -0500 Message-Id: <20230105151709.1845-2-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230105151709.1845-1-eric.devolder@oracle.com> References: <20230105151709.1845-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR07CA0118.namprd07.prod.outlook.com (2603:10b6:5:330::31) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH8PR10MB6477:EE_ X-MS-Office365-Filtering-Correlation-Id: 919c923d-404f-4443-4d66-08daef2ff186 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9IvuUGm0jWk/jRP/uz8k7udRqdJgnRiPckaxkKpnw3Ciz3/y8cWqf41OvSJ5KlFNocp9DSfrlH96Rik6gPt1WJ7vHhfY9w0Rs7i82dnUTaKAg3arRUEd50jXxIdrPdapmIOTWO0hueLTmq6vjTrnOIgA2sQh7TTcUIlf6FGC4xsuGDFEcLHS88e+6cGXGvhPO3i5XQg8uIat24gCbAbvj/GiMcujQBpmoIKCwsmzie3woj8lbuVyqjj6AiH5VIJMM1R2las61+JKY+oPGpTPVQ3NoFwTMAox/fTy0yfETWsoQ+SE7djfzTry6YLumf04IsPvVqYQyiNh93atpmmeka3wf3KBrDzMSbYigcbYoyFL/25wQz8mdIuZtJJYJmMGo0qrhS2b78kq3KhUIMkmD2OJWR8jI8N1ZzHfcJm3gZ0PnYlWWghUivUg4lZzwNHAB9F+CTYrm0Vxpq0OiEdUJ68qLhhrm5jEUyCkVfypX0srB7TlZhv6+eSDa3Vf9OAznZKshQUc4SzFqXneKeSYhCKBLJcOf19UlHfFixqm/XySwDNQFYRT4h4adqLqb6Zflm354PYXOVzQFdE/kCR+bU9nZEyHiItWIEmKqpambzO0tpIKJbxTloDN6cOT3p5zW82/NtiUQY5779W4yHRa/Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(376002)(366004)(136003)(346002)(39860400002)(396003)(451199015)(5660300002)(7416002)(2906002)(8936002)(41300700001)(478600001)(316002)(4326008)(8676002)(66556008)(66476007)(66946007)(6486002)(6666004)(6512007)(26005)(6506007)(107886003)(83380400001)(1076003)(2616005)(38100700002)(186003)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AnnQCb9U/uW/3/pkgFyHpBfPzNSIC9yfFuobqMH2/hqOZ+SXarTqG8kLdGBgvbcn+xZ64OzLDOX7nFBq0oIjVen5O2vWx/Xzbd3/0HYlWic1wuUaSNEVLpneBM8wfJrsRBQ0boOmKIKDHh33j/kuTKfRDjjNGXQYIOUdjufSdKmT0eVxO8t82PSpZpVt+Psdx0LSD3E6TGf8ELiVYY2sSlMZ4ibUzQaeQqBvRsVmx7OZ0FWDsYM+OYFoWB2WmBiC+zA0zDAxgOMqPLLBxvtKjv83QGZrnQXWKCaOPvngyO6B3RKHhWqOozO7jJk25ZtHioW6iIt9Cu1DyaS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Fc9rascpI0vDx3Flo6q2hc7YXML05X66fdb7YPKeX32FFBNdMV+6ZcsMRd/CZ5R2uM0qVxlhh8TLM/aD5WA3bgv2+QAnXEfdlKfEzxHjTkdu543TQXyXyfzVBgn6xpMLWH4UiFbVNmIxcdHwMOPEM1hJP9ws8BcRL+vBycR49VVpOlf2V/bMsU139df8R7mkqx44aa9bgDhdjg0L5VYxO4F9WBoEpeuOrTtKRkMFIIHv/mHkdGJIPOwPKsuCtI70cX1U+/Aoj0KzJw384nETKi5h1sI5xtsFJQHaPomockvX4wbhoUSoGV2GRwy/W5VUAAwQBBzj5tWog44Qy5nWBLSZ3DBzA3m0++so2lXi4BbQmMiCrGzOADjoTO8aKz7O5Lh1Pn5eLHWDbGw8tWo7BTcNO2u/YdswfQQaC1aN6ULn8XVA4Pjk/oXoSN6ZDOvRr2/VGRZXoLCXODE8SNRiqxXMzwFwUeOvEh39UXvSJpqdyw3kie+J67NsAuW7mMtL1+uoKgMO2LzrFhVe9UXAAY0Z47agpH/wTUTMt4R9va7OCIH3ZpWmK3jA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 919c923d-404f-4443-4d66-08daef2ff186 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 15:17:22.3309 (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: WUESHsk1D+1VxmvKW64+ocGRkaS8KR9n8cdSEj3hG1IPS8uwBTuGfS3TSRdnt9Mnx9FT40KkByyVA+nKqaq5+0QNvALLgYBhbGXPl0PeJY4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6477 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-05_06,2023-01-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301050119 X-Proofpoint-GUID: BD0-Y3udaExVluByWM35Aewg6yXt9YhW X-Proofpoint-ORIG-GUID: BD0-Y3udaExVluByWM35Aewg6yXt9YhW 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?1754196491705756288?= X-GMAIL-MSGID: =?utf-8?q?1754196491705756288?= At the outcome of this patch set, the crash_prepare_elf64_headers() is utilized on both the kexec_file_load() and kexec_load() paths. As such, need to move this function out of kexec_file.c and into a common location crash_core.c. No functionality change. Signed-off-by: Eric DeVolder Acked-by: Baoquan He --- kernel/crash_core.c | 100 ++++++++++++++++++++++++++++++++++++++++++++ kernel/kexec_file.c | 99 ------------------------------------------- 2 files changed, 100 insertions(+), 99 deletions(-) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 87ef6096823f..f10e2266c310 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -314,6 +315,105 @@ static int __init parse_crashkernel_dummy(char *arg) } early_param("crashkernel", parse_crashkernel_dummy); +int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, + void **addr, unsigned long *sz) +{ + Elf64_Ehdr *ehdr; + Elf64_Phdr *phdr; + unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz; + unsigned char *buf; + unsigned int cpu, i; + unsigned long long notes_addr; + unsigned long mstart, mend; + + /* extra phdr for vmcoreinfo ELF note */ + nr_phdr = nr_cpus + 1; + nr_phdr += mem->nr_ranges; + + /* + * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping + * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64). + * I think this is required by tools like gdb. So same physical + * memory will be mapped in two ELF headers. One will contain kernel + * text virtual addresses and other will have __va(physical) addresses. + */ + + nr_phdr++; + elf_sz = sizeof(Elf64_Ehdr) + nr_phdr * sizeof(Elf64_Phdr); + elf_sz = ALIGN(elf_sz, ELF_CORE_HEADER_ALIGN); + + buf = vzalloc(elf_sz); + if (!buf) + return -ENOMEM; + + ehdr = (Elf64_Ehdr *)buf; + phdr = (Elf64_Phdr *)(ehdr + 1); + memcpy(ehdr->e_ident, ELFMAG, SELFMAG); + ehdr->e_ident[EI_CLASS] = ELFCLASS64; + ehdr->e_ident[EI_DATA] = ELFDATA2LSB; + ehdr->e_ident[EI_VERSION] = EV_CURRENT; + ehdr->e_ident[EI_OSABI] = ELF_OSABI; + memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD); + ehdr->e_type = ET_CORE; + ehdr->e_machine = ELF_ARCH; + ehdr->e_version = EV_CURRENT; + ehdr->e_phoff = sizeof(Elf64_Ehdr); + ehdr->e_ehsize = sizeof(Elf64_Ehdr); + ehdr->e_phentsize = sizeof(Elf64_Phdr); + + /* Prepare one phdr of type PT_NOTE for each present CPU */ + for_each_present_cpu(cpu) { + phdr->p_type = PT_NOTE; + notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); + phdr->p_offset = phdr->p_paddr = notes_addr; + phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); + (ehdr->e_phnum)++; + phdr++; + } + + /* Prepare one PT_NOTE header for vmcoreinfo */ + phdr->p_type = PT_NOTE; + phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note(); + phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; + (ehdr->e_phnum)++; + phdr++; + + /* Prepare PT_LOAD type program header for kernel text region */ + if (need_kernel_map) { + phdr->p_type = PT_LOAD; + phdr->p_flags = PF_R|PF_W|PF_X; + phdr->p_vaddr = (unsigned long) _text; + phdr->p_filesz = phdr->p_memsz = _end - _text; + phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); + ehdr->e_phnum++; + phdr++; + } + + /* Go through all the ranges in mem->ranges[] and prepare phdr */ + for (i = 0; i < mem->nr_ranges; i++) { + mstart = mem->ranges[i].start; + mend = mem->ranges[i].end; + + phdr->p_type = PT_LOAD; + phdr->p_flags = PF_R|PF_W|PF_X; + phdr->p_offset = mstart; + + phdr->p_paddr = mstart; + phdr->p_vaddr = (unsigned long) __va(mstart); + phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; + phdr->p_align = 0; + ehdr->e_phnum++; + pr_debug("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n", + phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, + ehdr->e_phnum, phdr->p_offset); + phdr++; + } + + *addr = buf; + *sz = elf_sz; + return 0; +} + Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type, void *data, size_t data_len) { diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index dd5983010b7b..270acae2801e 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -1217,102 +1217,3 @@ int crash_exclude_mem_range(struct crash_mem *mem, mem->nr_ranges++; return 0; } - -int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, - void **addr, unsigned long *sz) -{ - Elf64_Ehdr *ehdr; - Elf64_Phdr *phdr; - unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz; - unsigned char *buf; - unsigned int cpu, i; - unsigned long long notes_addr; - unsigned long mstart, mend; - - /* extra phdr for vmcoreinfo ELF note */ - nr_phdr = nr_cpus + 1; - nr_phdr += mem->nr_ranges; - - /* - * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping - * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64). - * I think this is required by tools like gdb. So same physical - * memory will be mapped in two ELF headers. One will contain kernel - * text virtual addresses and other will have __va(physical) addresses. - */ - - nr_phdr++; - elf_sz = sizeof(Elf64_Ehdr) + nr_phdr * sizeof(Elf64_Phdr); - elf_sz = ALIGN(elf_sz, ELF_CORE_HEADER_ALIGN); - - buf = vzalloc(elf_sz); - if (!buf) - return -ENOMEM; - - ehdr = (Elf64_Ehdr *)buf; - phdr = (Elf64_Phdr *)(ehdr + 1); - memcpy(ehdr->e_ident, ELFMAG, SELFMAG); - ehdr->e_ident[EI_CLASS] = ELFCLASS64; - ehdr->e_ident[EI_DATA] = ELFDATA2LSB; - ehdr->e_ident[EI_VERSION] = EV_CURRENT; - ehdr->e_ident[EI_OSABI] = ELF_OSABI; - memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD); - ehdr->e_type = ET_CORE; - ehdr->e_machine = ELF_ARCH; - ehdr->e_version = EV_CURRENT; - ehdr->e_phoff = sizeof(Elf64_Ehdr); - ehdr->e_ehsize = sizeof(Elf64_Ehdr); - ehdr->e_phentsize = sizeof(Elf64_Phdr); - - /* Prepare one phdr of type PT_NOTE for each present CPU */ - for_each_present_cpu(cpu) { - phdr->p_type = PT_NOTE; - notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); - phdr->p_offset = phdr->p_paddr = notes_addr; - phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); - (ehdr->e_phnum)++; - phdr++; - } - - /* Prepare one PT_NOTE header for vmcoreinfo */ - phdr->p_type = PT_NOTE; - phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note(); - phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; - (ehdr->e_phnum)++; - phdr++; - - /* Prepare PT_LOAD type program header for kernel text region */ - if (need_kernel_map) { - phdr->p_type = PT_LOAD; - phdr->p_flags = PF_R|PF_W|PF_X; - phdr->p_vaddr = (unsigned long) _text; - phdr->p_filesz = phdr->p_memsz = _end - _text; - phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); - ehdr->e_phnum++; - phdr++; - } - - /* Go through all the ranges in mem->ranges[] and prepare phdr */ - for (i = 0; i < mem->nr_ranges; i++) { - mstart = mem->ranges[i].start; - mend = mem->ranges[i].end; - - phdr->p_type = PT_LOAD; - phdr->p_flags = PF_R|PF_W|PF_X; - phdr->p_offset = mstart; - - phdr->p_paddr = mstart; - phdr->p_vaddr = (unsigned long) __va(mstart); - phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; - phdr->p_align = 0; - ehdr->e_phnum++; - pr_debug("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n", - phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, - ehdr->e_phnum, phdr->p_offset); - phdr++; - } - - *addr = buf; - *sz = elf_sz; - return 0; -} From patchwork Thu Jan 5 15:17:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 39642 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp352834wrt; Thu, 5 Jan 2023 07:22:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXs8u6ontNWvqh0ZvuxGEHjTOJrJCJeB1XfyEA+4+B/uHwTpsxb3Llzntxepsi8FhCf4y9IX X-Received: by 2002:a05:6a00:248f:b0:581:4539:3992 with SMTP id c15-20020a056a00248f00b0058145393992mr48889211pfv.25.1672932151075; Thu, 05 Jan 2023 07:22:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672932151; cv=pass; d=google.com; s=arc-20160816; b=yTZFCE98VnSsh38YtuSvF7uOGDeJBe2htHgJtCeaPYhD4cWa4kcMcZ5R9CM4uQ0nvN HSzdUlE0dDMGmazBIXpUnWjVPj1FSTHeL8Q7hWeEuMO5OdRuTZQXbLl/XoCns6W2Cz1K Fbkd+OlSGxdvtv6Qc4FZQYGGDOqMOSxBrlbqoD+M6bg8MkWSSBvUOR/fv9gGzboSe7dv bQKDapZvNI0HQRR5u6/Jo0cUpVkrc0T5k2vjjVSDSuBqBEUARKLKV/zTTjnYHS6F/HWo Y2UVi78cr3E8zRcPDIAv3QwahBwqoskLdKLbEWdBZUTq6LT/ElcQEsk/obmCh75mSV6l 1pSA== 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=dK/yPg3DcF43xzFfTNyKdijHmr+2iIu+qNvpwKO/Ayk=; b=f/7zhJV4t/XgBQaWH+7tARluWmdpvIoPQeNKXXUvxFAMv02fTh7ElKIaH7TzSFCXwQ Y73Y3oKQY6ykFTOsjeSxJ96l8wZ3XRU7bABFkFfyg/Suyh7wXQF4b50w/qTM3114DyvA nyK+5ChiA8a/N+PEFvcj5uDbbsNZ5qvuVTX5jdhZP3/LQ8F5SikGiZj+7/SgYb/FnePx OwcXxZowVX80toTS0+66F5hKENjC7SrxHAhglnAri+VyzjjwvpzWPCBLZ4M13/LkkOa2 wHll5dsEEBi7Bt7/zfd4XpRbpyDQVlxAN819AhxmN7DNoMdnjTMP5tyHnhUPn1wE7RZY UXsA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=1AnOsXcP; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=jw8ESSEp; 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 a15-20020a621a0f000000b00575f86d63easi36876474pfa.170.2023.01.05.07.22.18; Thu, 05 Jan 2023 07:22:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=1AnOsXcP; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=jw8ESSEp; 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 S234294AbjAEPSE (ORCPT + 99 others); Thu, 5 Jan 2023 10:18:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233857AbjAEPRx (ORCPT ); Thu, 5 Jan 2023 10:17:53 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E3374FCE7 for ; Thu, 5 Jan 2023 07:17:51 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 305E4U16012403; Thu, 5 Jan 2023 15:17:28 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=dK/yPg3DcF43xzFfTNyKdijHmr+2iIu+qNvpwKO/Ayk=; b=1AnOsXcPnLA2m2i2yFvX3608c/ja0Xrxpr9/P/8GEsk587MQVF+DG44/Jxxrwvee/t4/ n7ho+jwBUjBZ8aJVuUqtgfoEBoRfjTB/MppOSUodtq0BK56fH721Gmq3ckoSPQtPmDrQ /Z+0M6Kcc5gSXBVynF+udeP0Cjm7m4G3WTWNbznqumuZNQhxvpfYbFN0bgkxWM3+DuRN uavVTwOvqO8Xh9/gDq7xMW9LCFkv159HBMwZ83pHXmEjRbVzn9qk2Sufip89phJLda3L zBcecSg+LnTT1rEmffxutl8+VHtSpVER/ZMmCBRB7AMGxt638RqIKg9uD/vweBIEyFSY jQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mtbp113f1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 15:17:28 +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 305EPKoB040165; Thu, 5 Jan 2023 15:17:27 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2043.outbound.protection.outlook.com [104.47.73.43]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3mwevjmsmm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 15:17:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LpIdwzRam8KKLaAzzQxf9re+OaB8MJxE5aBnEZcoNmBV7nhI9RslU3jOPT3/FzoFKnlQU7ZC+DoGVSp/hAOgjTY2Klf5xkRMgRKhvnF26dvnhSGXpyTRz7gOHBJAl3UBG2uzw7zIsGp5brZ6miKBYFmsTcdWxITVbRzF31AvjLteEV/OI37cYRfPGA0gAt1k28WAWMmmZtFvTSwd1hTYsPp95gMH/8MSg2OdHWhL2G1iq5ilfuWT1NsPg9bfgdANoDPPfBIX6Mf04L0xvQvshGCFwALlaDZDDCbZsOUFYC5aMd3km8pPjMoBRVVXOB9f+ocH8ZWpWrMeMyRneQZohw== 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=dK/yPg3DcF43xzFfTNyKdijHmr+2iIu+qNvpwKO/Ayk=; b=FP6CLbKH4mFL66ZoUMgUPLqUkRuEGvaHXonPoqmFVKf57TpnMTLyBC85lvIDsH9QDYKt5R5yPr2D6q3JZiHufF9spLE2MGmr8JmxIfwwgQK+bX4LgXdHcjbrmpRvS1lTscuJwqSdVDug/hzOwtMm4Hg9pFD3dGZUB9rDNgxdfUltFMg7BtNBHujyyKcuZQkNciMm7Nnruh8AyP8lxQUic9VTBTXbYHnUokSvZORUi3mBvKqqzCizQOyj+L+aYKnBNySHWSWEYmvfG6lw5T/3k4C6ovY6UEZlpSw+Ah36vpsy8W+xVxFiGuXQAOmrPliwODoXAFwD1CT7/QNKD3ZmUw== 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=dK/yPg3DcF43xzFfTNyKdijHmr+2iIu+qNvpwKO/Ayk=; b=jw8ESSEp8B1thtuHCm2p4BK8Qv9djJJ3n9UmQVqfLPnuP06rU24roqWhK5tAFBx0rdUn8PwIbOqJau8KSsa45XuXak2oLK50LPcCuMVN2MC9B30uSSExQWLSIjJmGASMyMzx3K+OakTMfWvzL1FGDxiX33zHJcbXY28sX1WrO5o= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by PH8PR10MB6477.namprd10.prod.outlook.com (2603:10b6:510:22f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 15:17:25 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a%5]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 15:17:25 +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 v16 2/7] crash: prototype change for crash_prepare_elf64_headers() Date: Thu, 5 Jan 2023 10:17:04 -0500 Message-Id: <20230105151709.1845-3-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230105151709.1845-1-eric.devolder@oracle.com> References: <20230105151709.1845-1-eric.devolder@oracle.com> X-ClientProxiedBy: DS7PR03CA0036.namprd03.prod.outlook.com (2603:10b6:5:3b5::11) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|PH8PR10MB6477:EE_ X-MS-Office365-Filtering-Correlation-Id: c8a581fe-d367-40c4-dd53-08daef2ff2fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jBJ2dQouqyadorISjinSYz5+XZStME605EP5u+tWZYnCvc0G+44EIP6hGDuBgLjm7sEIuqPAWXT4NQ2rSvN4Vji5RRJjj9M20M+D3jB0cnf+9w6BbnAUaIuf+6LrZO4Z9lchLcd3+9KrOW/axZd/Mv6ga8UtrwYzwcP6gsu/NAKLety3cUuSTYWRCqA5TfR513IOzrHQ6BeZCrgkHHGF3SMVT+Czi6hEMcT1XbRC4Lk2paqBR6tfl4jwki6le6B8ARu5mnnZWUBftFIiqALimvelyWIQ4gGHLH9OQ1QXjx0FwdsNRF7r4ZR+boHWD3pdoOxciDwZTbQ0wsekKd1I4WL0auT+zFIc7UhdtnWYMWL3kdsJssZnEpdMDcR5RPyeDiheYNxReopSur52yNlsKPmX7TTQYESV8sz/NNKgykUmhIbDO8wIa0DwKoWDlkbjAUx9z2v2fuuycovBOTaeOEQskfT6GgtNOd+F9Q7TaTGxyMVyoHqoyokylYa8OVb9DZfv5/+v8oo9gYnqKRa3fU2qCy0a7Z0lSD/Ts/MZjgFo9HVrTjfyG8kefgO5yjtHAMKdE5tYUaNF4lHXs5yyEC1lAkMb+YIgwo4YxNnGOzS93IeltP7+FTWC15kvOP9AlSldPMjeyjcKceHKajkShw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(376002)(366004)(136003)(346002)(39860400002)(396003)(451199015)(5660300002)(7416002)(2906002)(8936002)(41300700001)(478600001)(316002)(4326008)(8676002)(66556008)(66476007)(66946007)(6486002)(6666004)(6512007)(26005)(6506007)(107886003)(83380400001)(1076003)(2616005)(38100700002)(186003)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eI1R/lr3T3pZKnyxECz7S5zhTtHemHMngP6SzQMzf2Nt0ttM3vbmq8QSwMr+4BKxoSHmIWgL/kpXfDSBLZSZjhjA2lwms3r4Tc8DyUfQg+bME1YDdnQ9/rE+2DHNx5f0z1pEEAZlHhMK1w4JqxXMCi/ymVTL9fhBWfVf9N6XO0doIfF/mJBZm/thQF1hvAbWDJ8DQCconwIqbMweDl7rwnIWA1SVnGNSuigavG09QcuC/QK2zjVAC+NP3mYgvYxc0Mqq/EaVBe94ng49qwJVitqV0G9PnroUbANCqtsiP+sdszp0cObN/fjS56MgGuJEGQ8kO4nGLKFfvrdYbHjaRnlezIqEGw/QTFhMzutUiea3mlt5pe5wxgRdhp/jT/j2y1oczJkXk8JGckhKJFQVYq91aYg97hWb2OEDKLxBhmdETXxH4Kx5LbWJc9yhwTvgalwnVk4U6PG2rkLN+bir+VTIewbGkAQufmwqpBb+MLAyvY/txmUK+AC5fJtbn29WWF3+SMbezQrgtjhoOSSGCRe6MG19JC004jGN+RjvNMXJzjLhD9itpYoaIcPUdsy3RYgTS7ZQRoyxRBmuJgokK0xCrZwtkq4/HlPf1Me3Fjz5WPNyh9Ci97L8JOmuw8x1byXW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MS+xpRfzRhCBfNmD0CvpRjiWz+l+k/OpMX1x1sBtR7gPRHBiBT01O0Rt2iOHFSlhUBFLo2pBwj5p6IdXqsIw6M8XqBDKwr2fun+ORUwAadhLhp68hcJlZ1upY3m0zFOydCe4crWhe8KLMUJGJPII3npSzZehIK8kliIefaExbX2y5Lud8/E8dHKDvOqFnMN2Ky8F8JWhDABOtybpaYBtV9kzq7j8yiFUK/YhmP49ufw/c3fjzo77ws+p3ScWEjvLKj26w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8a581fe-d367-40c4-dd53-08daef2ff2fc X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 15:17:24.8005 (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: KMGjmenyfeReAlPcpGlFGltZiK8L9XzosKRopqny/xuFp+YH7gTU4dZoepXzf2gRDwo7ne4FPvhNc5+cdiSUCPqlJPxJtuRRbvmc5ew8mVM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR10MB6477 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-05_06,2023-01-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 phishscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301050119 X-Proofpoint-GUID: QGM-WDwl6rLpicYkP613CKN3bewjV86z X-Proofpoint-ORIG-GUID: QGM-WDwl6rLpicYkP613CKN3bewjV86z 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?1754196503246300493?= X-GMAIL-MSGID: =?utf-8?q?1754196503246300493?= From within crash_prepare_elf64_headers() there is a need to reference the struct kimage hotplug members. As such, this change passes the struct kimage as a parameter to the crash_prepare_elf64_headers(). The hotplug members are added in "crash: add generic infrastructure for crash hotplug support". This is preparation for later patch, no functionality change. Signed-off-by: Eric DeVolder Acked-by: Baoquan He Acked-by: David Hildenbrand --- arch/arm64/kernel/machine_kexec_file.c | 6 +++--- arch/powerpc/kexec/file_load_64.c | 2 +- arch/riscv/kernel/elf_kexec.c | 7 ++++--- arch/x86/kernel/crash.c | 2 +- include/linux/kexec.h | 7 +++++-- kernel/crash_core.c | 4 ++-- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c index a11a6e14ba89..2f7b773a83bb 100644 --- a/arch/arm64/kernel/machine_kexec_file.c +++ b/arch/arm64/kernel/machine_kexec_file.c @@ -39,7 +39,7 @@ int arch_kimage_file_post_load_cleanup(struct kimage *image) return kexec_image_post_load_cleanup_default(image); } -static int prepare_elf_headers(void **addr, unsigned long *sz) +static int prepare_elf_headers(struct kimage *image, void **addr, unsigned long *sz) { struct crash_mem *cmem; unsigned int nr_ranges; @@ -64,7 +64,7 @@ static int prepare_elf_headers(void **addr, unsigned long *sz) } /* Exclude crashkernel region */ - ret = crash_exclude_mem_range(cmem, crashk_res.start, crashk_res.end); + ret = crash_exclude_mem_range(image, cmem, crashk_res.start, crashk_res.end); if (ret) goto out; @@ -74,7 +74,7 @@ static int prepare_elf_headers(void **addr, unsigned long *sz) goto out; } - ret = crash_prepare_elf64_headers(cmem, true, addr, sz); + ret = crash_prepare_elf64_headers(image, cmem, true, addr, sz); out: kfree(cmem); diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c index af8854f9eae3..e51d8059535b 100644 --- a/arch/powerpc/kexec/file_load_64.c +++ b/arch/powerpc/kexec/file_load_64.c @@ -799,7 +799,7 @@ static int load_elfcorehdr_segment(struct kimage *image, struct kexec_buf *kbuf) goto out; /* Setup elfcorehdr segment */ - ret = crash_prepare_elf64_headers(cmem, false, &headers, &headers_sz); + ret = crash_prepare_elf64_headers(image, cmem, false, &headers, &headers_sz); if (ret) { pr_err("Failed to prepare elf headers for the core\n"); goto out; diff --git a/arch/riscv/kernel/elf_kexec.c b/arch/riscv/kernel/elf_kexec.c index 5372b708fae2..8bb2233bd5bb 100644 --- a/arch/riscv/kernel/elf_kexec.c +++ b/arch/riscv/kernel/elf_kexec.c @@ -130,7 +130,8 @@ static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg) return 0; } -static int prepare_elf_headers(void **addr, unsigned long *sz) +static int prepare_elf_headers(struct kimage *image, + void **addr, unsigned long *sz) { struct crash_mem *cmem; unsigned int nr_ranges; @@ -152,7 +153,7 @@ static int prepare_elf_headers(void **addr, unsigned long *sz) /* Exclude crashkernel region */ ret = crash_exclude_mem_range(cmem, crashk_res.start, crashk_res.end); if (!ret) - ret = crash_prepare_elf64_headers(cmem, true, addr, sz); + ret = crash_prepare_elf64_headers(image, cmem, true, addr, sz); out: kfree(cmem); @@ -224,7 +225,7 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf, /* Add elfcorehdr */ if (image->type == KEXEC_TYPE_CRASH) { - ret = prepare_elf_headers(&headers, &headers_sz); + ret = prepare_elf_headers(image, &headers, &headers_sz); if (ret) { pr_err("Preparing elf core header failed\n"); goto out; diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 9730c88530fc..9ceb93c176a6 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -265,7 +265,7 @@ static int prepare_elf_headers(struct kimage *image, void **addr, goto out; /* By default prepare 64bit headers */ - ret = crash_prepare_elf64_headers(cmem, IS_ENABLED(CONFIG_X86_64), addr, sz); + ret = crash_prepare_elf64_headers(image, cmem, IS_ENABLED(CONFIG_X86_64), addr, sz); out: vfree(cmem); diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 5dd4343c1bbe..c8662a48d455 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -250,8 +250,11 @@ struct crash_mem { extern int crash_exclude_mem_range(struct crash_mem *mem, unsigned long long mstart, unsigned long long mend); -extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, - void **addr, unsigned long *sz); +extern int crash_prepare_elf64_headers(struct kimage *image, + struct crash_mem *mem, + int need_kernel_map, + void **addr, + unsigned long *sz); #ifndef arch_kexec_apply_relocations_add /* diff --git a/kernel/crash_core.c b/kernel/crash_core.c index f10e2266c310..92eb7dc05457 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -315,8 +315,8 @@ static int __init parse_crashkernel_dummy(char *arg) } early_param("crashkernel", parse_crashkernel_dummy); -int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, - void **addr, unsigned long *sz) +int crash_prepare_elf64_headers(struct kimage *image, struct crash_mem *mem, + int need_kernel_map, void **addr, unsigned long *sz) { Elf64_Ehdr *ehdr; Elf64_Phdr *phdr; From patchwork Thu Jan 5 15:17:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 39645 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp353324wrt; Thu, 5 Jan 2023 07:23:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXv79JQt4pRij7gAbthnQa+EQmvLZEGy1M/KoCo8zIBwzwc9ttZIaVEenpKqEvcn1Wjpf/30 X-Received: by 2002:a05:6a20:94ca:b0:af:f77c:39d0 with SMTP id ht10-20020a056a2094ca00b000aff77c39d0mr62014508pzb.11.1672932212395; Thu, 05 Jan 2023 07:23:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672932212; cv=pass; d=google.com; s=arc-20160816; b=QgBaSwsv3RAcIT/EvXwrBUej6A4M2Levu0LyXd5URSs+JmVi8ROYWi1HkvQqVAWXMg pxggwC9+oZbyIJJphlgZtMy9KwRcHadn9etaWkcFtXwR31Lt5kQhzzzqUlgu0XrDm9Rl dq13vpqO02MQG259wEwuJVktv3/T7BqeA6H31u9nfzztxZ8ziYUTKoLsUmKib+/+zdQP enqQnZ+nWEIOzavMXNogAUbvv+B6D+jyBu8wplsS17prRQAEgckIDIVxR2tSc3U1zjcI 25vlS+jrvCwl6srFrMj5nOwuiXS9K3gGgrywC6Rc+squoSAcvZvP0Eq3+libJbveNGF5 YkoQ== 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=0WkScAuPCL2nzHWWGz3/rW0nPs4YZo8Ffn35KwPDCqk=; b=MonOHoU3vou3LiJJN4MdIesgqUfKfuRRTD3Tka9R9PMhbZ6VYWXYc/RanqDbJhELDD arlV1gTyX2j+W4JJ4CCy/izmz+1+nctwnwgEqpFxaBOYry3C7MyTKdgR7QjZKGGaw9vQ anYJbe1GHqHpNmHRlg1SVDaIoVNhbpN/MDxxob6DSpvzAiGtaZsDQBc9nE2r1qPbG7ol kHErGLYvvfpVA7Eh0OolMViIt2aRj6TJtKVWC71w00jG2pLkPkDvXr9v8XxE8V8Wmn4q UjpGtS5693BkC7IDsBgyJAgHR0zpG93woJka9+5clGEgCqr1cmeB5d2+3ETOICFinnZw 4inw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=M+vPBAGF; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=wqfTFTTi; 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 i70-20020a638749000000b004a8375e8edbsi868243pge.451.2023.01.05.07.23.20; Thu, 05 Jan 2023 07:23:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=M+vPBAGF; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=wqfTFTTi; 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 S234332AbjAEPSJ (ORCPT + 99 others); Thu, 5 Jan 2023 10:18:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233893AbjAEPRx (ORCPT ); Thu, 5 Jan 2023 10:17:53 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D2A050E4F for ; Thu, 5 Jan 2023 07:17:51 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 305E448b021184; Thu, 5 Jan 2023 15:17:31 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=0WkScAuPCL2nzHWWGz3/rW0nPs4YZo8Ffn35KwPDCqk=; b=M+vPBAGFO0gfz5w9In+zm/XrnxS6yFVhCcDLsgUM5t+yyM+xTHIhI3ViJOFb3egRk3tu 2EgsGxKey1wHQXV5QklQnjN0AqnfYVz04R77q5W3MRXmM2HU+WkY3JvqnOgiIdRaTZ/D oGwbNM3/Ub5IvF+3UDG5QTuUdbCWzNrjsh3WTPnbOVzbBr/T/zbKn62kWCEeZpsnw0AY iS+NpmUZU41LO2FXs5rOtN332I2lkl6LxosjxhrW52B4w7USlidAQm9ocxdcCUyxOJi1 YaMXiS604TEdGNvRKnFvRFOQYnsUBEIykeCv0RLEaMu9EQBV6b6nlgquMYHJ+rkHgXdz Eg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mtcya901j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 15:17:30 +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 305EPKOc040149; Thu, 5 Jan 2023 15:17:30 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2176.outbound.protection.outlook.com [104.47.55.176]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3mwevjmsp5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 15:17:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JlVk330YNk5lLIwIYEhJpTQ9L0K1hXWjFP+mOk87NpS7kAP881ZI+JPzL36FxXKWIaNcV99mPm2HY6eqvoZhdoDY02A/OH4HjlND1D8lTJ41Sfpi9wRu5X6rGzwCUwJk9TypidEQkfkOfHcg2fl5KCt2B5Nk97F/ShutKzSmDYmW8XIXWmSwMiv+t5C8a4SSYOf6jo4WHh4yEB1oxbG7gVYEiRbJsTDn0LF1zgtzqn/5L2+2h1FF9cqaeYHyGLifJdxHiGNJrcKKtivrO/jCr8ffZ3n4jCQxlAt1P5nspNBqBgL/xrdpyQyWLpJym92aj5ppUC4JX1DaV6Vf+kWzOQ== 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=0WkScAuPCL2nzHWWGz3/rW0nPs4YZo8Ffn35KwPDCqk=; b=agG0MDX6s6Zbir2ZkaZV1sQHVUPHm+3tY5DKZioA5YbIwmSlQToJ2CYKZ6tmfUeh0Zaq8HnxByf9V88nh1mor5jCmx3m1u8aBu5uwgcFVWEUA21PUN1Dn96VgQb8b+tpIm+Nfs78V4bsrft/9DpFaUk5nP/Gtm5IrwzRz6djxVPWQETiV3UPsxKsV6qLoW2NvOK9KKuMwxi+4Uec8AyFW1smnFRyx/hPPB8nWruD+WV2LtRy8SZpSw5BV34vT8wuG+4Mnf1p/Ius8zCND7L6YW1rtHLT/15ohM9dyr1goTfBlg9D/f7YPgZ1Olza+hCKEhiPZDR1HB3PalJiNdRhgg== 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=0WkScAuPCL2nzHWWGz3/rW0nPs4YZo8Ffn35KwPDCqk=; b=wqfTFTTi8lnwGOycQ0V/f+iz0nn5U1nh937UImxNm6ayXVY8c1fpNgqibilIKVbpddmqWWDWG5vExXSY3edTXVJA2OR4aLebxM1u7vQtSHXb5maB5Ez75DJSEL8c4tZxBbYAosBTJaMgYHyZvZaftEA52ySzHb1uxzZ9elKU2dU= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DS0PR10MB7406.namprd10.prod.outlook.com (2603:10b6:8:158::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 15:17:27 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a%5]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 15:17:27 +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 v16 3/7] crash: add generic infrastructure for crash hotplug support Date: Thu, 5 Jan 2023 10:17:05 -0500 Message-Id: <20230105151709.1845-4-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230105151709.1845-1-eric.devolder@oracle.com> References: <20230105151709.1845-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR05CA0042.namprd05.prod.outlook.com (2603:10b6:5:335::11) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|DS0PR10MB7406:EE_ X-MS-Office365-Filtering-Correlation-Id: 803ff4cc-2e58-461b-8b30-08daef2ff47c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ihzza8dsOXIEe31ef7xWOn8lvYaD/5835ZoffgHUsdXyV98NzZ+jKAlrdSPPTr2+oW1sKSsRquPbHF5pogPK7QM/wAO5HQsFPvH9AvnQOthqkOM4YXsyfUOi7/p4INBNbmWiT7b2UuGixf2uKbAWsef/lxFrVrzd4vef/LWfwQHLQigUAUjwDJ9fYMjQrwqODOeD9rwTK5L59wknWHE+ipP8QS/GpPQMHdgYm2QpI/ZSnJeNpEyvL3GmrjHMtIsXYb7jKnG5MVD5rpO3rgqtze3HZAzSPhOgVjUIsaz1Wek2x1CvMFzkQ/2sSpvKQxCgb2MGQUx/3u+OaxyiKT63rS6GbYJiZVRT3mjtzGTKtMamUHCseiBR7+T4C3bf5rzDJi4JNoG80/hTDRNXSgr9HcGaIIj7Sp0P8qLsOT489z7bskhAHncADMg6G2+yJ9xF/1cAOmpCuQ0oKRk0IY/JNlyIkM6Y56EDewqot3xyqElbOhPYrODt8T6Xyl8u6ucxVECDbJ0xS6JQtJvYkTBMzaYIbiTZ6HZK5zdyzS3dCzhh6XeXOk6QtQ5URhjU2IaD1X7k5laIrol5ajqjmMUF8Lyq5mO6bPiZ+7WGwUwK5SurfhQ4NEVREiz48WTDGWnCbjBUhe2A1XMmPRsPXTMO2AJt9bBSE1zp5kf3zptjpkH5/DVpTbNFWUQE8/3yMiyW X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(376002)(396003)(366004)(39860400002)(136003)(451199015)(4326008)(8676002)(107886003)(5660300002)(66476007)(66556008)(6666004)(66946007)(8936002)(41300700001)(316002)(7416002)(6486002)(2906002)(478600001)(6506007)(38100700002)(26005)(186003)(2616005)(1076003)(6512007)(36756003)(83380400001)(86362001)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B10G+YLHkQ9JOeHXDwuCiBCgFlSK9sRJlCK1qZPiHAncP2mJ03qmyxC6foM2J5sAgBDz31gvas+QwTTC8Xx3ct/+YjK0JpdNWVRhateiz2vfmNnxuRH5SkJL3jxP5n2CNH0xR/uft46UQCXDoFLjemSgsaJGfrWXKmX6siSH/sIYtAoeumaVK5KJtrs3kcQUPK9jzjiXq5HyyhUv9eAUjDQcjmUyeWmP1nNmACGnaN/34D1fvNXvRum5MPO6pgRRQ2bspHMJCYK476OZGf5tls4+6jObBuolpVXGlA0TmdWjlLWlwi4bOietswxs7/rWENcQSxeQ6YzWyOSfk4uNmIBbvFEe+238DO7OClm4zEqOmlAz7f4rJkcaV185XhOQg/2SWyFwCHmCEg3/aNACZ9DBTmU/AulioLK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R2mxLjxoVtBsjGj+poW6eYdSEk341iSKuBQSOMV8tW6+0ih3O54vZI31Q1a3u/5nwiL2ACJ9K3YZ5ugypqnIx+FdnJHKsqUUOJYqx5XVGz+p96HODBPDDyFVC9QULcSSFwhPQ/iTX9IYxVrI+dIO/Y1//h1bsCOckaTFrHVG+ILyknt/pkxpdlBsHJZazuUAydY0ud4QiFfjt3MhzV94Ysn0AMxKEQOPUwg4G/ynvRhZkt2GKJO5bl3oayCVu7x4OWoOWAEleZgN7aehwy4GHepMOV1sG0CNSUxd7rdEXih93BgUUGHxYlf4KNB+IuJ/TsXuKe8kosTDHQQeqjeLJPek+LMqIXaZ3POeydG36BHL1i1WJqeb9p/ufFmSYk6b1eeBSFsKj8ChbUUeuKpiJtUgECwXe9CFR80UBqwbvtekpOkBqSizM73678rAGOMRKkGrB0iBCD/sx3TIZ6a6GQbMCWDx5fn23VEIw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 803ff4cc-2e58-461b-8b30-08daef2ff47c X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 15:17:27.3317 (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: QO+HMfERiY8yhhishXFZe+xy7ysOC9X18djv29JOhgLznlL2NAD7z7594PWY3pr/2E03kggFuYqYr3QpiQd1lychzAG1aFEnr2xbiwPSbJ8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7406 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-05_06,2023-01-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 phishscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301050119 X-Proofpoint-ORIG-GUID: p2-1S-9nRDJP5GABQxkm0mADFtpuZNMJ X-Proofpoint-GUID: p2-1S-9nRDJP5GABQxkm0mADFtpuZNMJ 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?1754196567899696865?= X-GMAIL-MSGID: =?utf-8?q?1754196567899696865?= CPU and memory change notifications are received in order to regenerate the elfcorehdr. To support cpu hotplug, a callback is registered to capture the CPUHP_AP_ONLINE_DYN online and offline events via cpuhp_setup_state_nocalls(). To support memory hotplug, a notifier is registered to capture the MEM_ONLINE and MEM_OFFLINE events via register_memory_notifier(). The cpu callback and memory notifiers call handle_hotplug_event() which performs needed tasks and then dispatches the event to the architecture specific arch_crash_handle_hotplug_event(). During the process, the kexec_lock is held. Signed-off-by: Eric DeVolder Acked-by: Baoquan He --- include/linux/crash_core.h | 8 +++ include/linux/kexec.h | 12 ++++ kernel/crash_core.c | 138 +++++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+) diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h index de62a722431e..a270f8660538 100644 --- a/include/linux/crash_core.h +++ b/include/linux/crash_core.h @@ -84,4 +84,12 @@ int parse_crashkernel_high(char *cmdline, unsigned long long system_ram, int parse_crashkernel_low(char *cmdline, unsigned long long system_ram, unsigned long long *crash_size, unsigned long long *crash_base); +#define KEXEC_CRASH_HP_REMOVE_CPU 0 +#define KEXEC_CRASH_HP_ADD_CPU 1 +#define KEXEC_CRASH_HP_REMOVE_MEMORY 2 +#define KEXEC_CRASH_HP_ADD_MEMORY 3 +#define KEXEC_CRASH_HP_INVALID_CPU -1U + +struct kimage; + #endif /* LINUX_CRASH_CORE_H */ diff --git a/include/linux/kexec.h b/include/linux/kexec.h index c8662a48d455..a1838699d7b2 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -33,6 +33,7 @@ extern note_buf_t __percpu *crash_notes; #include #include #include +#include #include /* Verify architecture specific macros are defined */ @@ -371,6 +372,13 @@ struct kimage { struct purgatory_info purgatory_info; #endif +#ifdef CONFIG_CRASH_HOTPLUG + bool hotplug_event; + unsigned int offlinecpu; + bool elfcorehdr_index_valid; + int elfcorehdr_index; +#endif + #ifdef CONFIG_IMA_KEXEC /* Virtual address of IMA measurement buffer for kexec syscall */ void *ima_buffer; @@ -500,6 +508,10 @@ static inline int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, g static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { } #endif +#ifndef arch_crash_handle_hotplug_event +static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } +#endif + #else /* !CONFIG_KEXEC_CORE */ struct pt_regs; struct task_struct; diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 92eb7dc05457..973d7ddff1cf 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; @@ -615,3 +618,138 @@ static int __init crash_save_vmcoreinfo_init(void) } subsys_initcall(crash_save_vmcoreinfo_init); + +#ifdef CONFIG_CRASH_HOTPLUG +#undef pr_fmt +#define pr_fmt(fmt) "crash hp: " fmt +/* + * To accurately reflect hot un/plug changes, the elfcorehdr (which + * is passed to the crash kernel via the elfcorehdr= parameter) + * must be updated with the new list of CPUs and memories. + * + * In order to make changes to elfcorehdr, two conditions are needed: + * First, the segment containing the elfcorehdr must be large enough + * to permit a growing number of resources; the elfcorehdr memory size + * is based on NR_CPUS_DEFAULT and CRASH_MAX_MEMORY_RANGES. + * Second, purgatory must explicitly exclude the elfcorehdr from the + * list of segments it checks (since the elfcorehdr changes and thus + * would require an update to purgatory itself to update the digest). + */ +static void handle_hotplug_event(unsigned int hp_action, unsigned int cpu) +{ + /* Obtain lock while changing crash information */ + if (kexec_trylock()) { + + /* Check kdump is loaded */ + if (kexec_crash_image) { + struct kimage *image = kexec_crash_image; + + if (hp_action == KEXEC_CRASH_HP_ADD_CPU || + hp_action == KEXEC_CRASH_HP_REMOVE_CPU) + pr_debug("hp_action %u, cpu %u\n", hp_action, cpu); + else + pr_debug("hp_action %u\n", hp_action); + + /* + * When the struct kimage is allocated, it is wiped to zero, so + * the elfcorehdr_index_valid defaults to false. Find the + * segment containing the elfcorehdr, if not already found. + * This works for both the kexec_load and kexec_file_load paths. + */ + if (!image->elfcorehdr_index_valid) { + unsigned long mem; + unsigned char *ptr; + unsigned int n; + + for (n = 0; n < image->nr_segments; n++) { + mem = image->segment[n].mem; + ptr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT)); + if (ptr) { + /* The segment containing elfcorehdr */ + if (memcmp(ptr, ELFMAG, SELFMAG) == 0) { + image->elfcorehdr_index = (int)n; + image->elfcorehdr_index_valid = true; + } + kunmap_local(ptr); + } + } + } + + if (!image->elfcorehdr_index_valid) { + pr_err("unable to locate elfcorehdr segment"); + goto out; + } + + /* Needed in order for the segments to be updated */ + arch_kexec_unprotect_crashkres(); + + /* Flag to differentiate between normal load and hotplug */ + image->hotplug_event = true; + + /* Now invoke arch-specific update handler */ + arch_crash_handle_hotplug_event(image); + + /* No longer handling a hotplug event */ + image->hotplug_event = false; + + /* Change back to read-only */ + arch_kexec_protect_crashkres(); + } + +out: + /* Release lock now that update complete */ + kexec_unlock(); + } +} + +static int crash_memhp_notifier(struct notifier_block *nb, unsigned long val, void *v) +{ + switch (val) { + case MEM_ONLINE: + handle_hotplug_event(KEXEC_CRASH_HP_ADD_MEMORY, + KEXEC_CRASH_HP_INVALID_CPU); + break; + + case MEM_OFFLINE: + handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_MEMORY, + KEXEC_CRASH_HP_INVALID_CPU); + break; + } + return NOTIFY_OK; +} + +static struct notifier_block crash_memhp_nb = { + .notifier_call = crash_memhp_notifier, + .priority = 0 +}; + +static int crash_cpuhp_online(unsigned int cpu) +{ + handle_hotplug_event(KEXEC_CRASH_HP_ADD_CPU, cpu); + return 0; +} + +static int crash_cpuhp_offline(unsigned int cpu) +{ + handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_CPU, cpu); + return 0; +} + +static int __init crash_hotplug_init(void) +{ + int result = 0; + + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + register_memory_notifier(&crash_memhp_nb); + + if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) + result = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, + "crash/cpuhp", + crash_cpuhp_online, + crash_cpuhp_offline); + + return result; +} + +subsys_initcall(crash_hotplug_init); +#endif From patchwork Thu Jan 5 15:17:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 39641 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp352781wrt; Thu, 5 Jan 2023 07:22:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXvZ+ndIwRCFh1F5K4Lb1LQg0wZKrCg3qgaoiagH2vnblisQKUBjFgvZNVXayZU6AYPILwxL X-Received: by 2002:a05:6a20:c512:b0:af:8e92:411c with SMTP id gm18-20020a056a20c51200b000af8e92411cmr71403584pzb.44.1672932144041; Thu, 05 Jan 2023 07:22:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672932144; cv=pass; d=google.com; s=arc-20160816; b=Ok6jQvhLqEcfa0gG0TrqWbSM6bZj+VXCNjJt/vnF95Kv1j1K4T6aZjtSxpBFyTqiLu Lcc5uune+D15rxIQyuLPKhX0FzSPRLxjrOTz7PhaW0hFK3FNxBHe/sMkFWUeFcLLdb8Z f2LW/k4OxA0QGR/3RJE50Uyj2lPidx3hanh3vRrM5dIV/v6QyBgc/mYJ7Wh1Y3BV2NxS 2DRMQ5OzSq1+gUZ6HdELwRwBvuG28JQIJZRRrupv6XC7KFXHNeedItysa0Y9b4l9dg02 gfNjS92Y7n2X7Y+uSrgWy7dTm4yuHRZvIH62F4J6vtyiO9IGNsnEnfTcaTjmMBNMI+xn zHbw== 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=hoB+ZXNuIZGger6owOm6C5AtLZTyPSJ9zZfxQpAPnIk=; b=XeKcdAE5B4iE1XZ64UKXVJPtKU4y6ZifURfrHEHmx4CBN2U0XPDCVwPOg6dWz41Qt6 Xloqmby+VpxH0KMwV05Z4AXqSgmfMg/gl3mhLlN4YkqSdYh5/k4gKHuN/5E5xQozph2R jylKf1dVk00i1Z1ZC2hbYaGT7TOxBT14Cmf5mjeoxOTsAPeJ1SAH7flTOIyUBjHlVOux dqu/grGM32J9vaTCTjtGjekArGz+7n8ZprOBqEVZNhZAAmapDs2kdu5qvDDT7+f4iLvq QYVrQa6LckWShE7qBnw0Pdl6TlHR8bEiRSjsi8jHRnhKA39P3oNNNNU04WcDCTGKp1q2 +bdA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=Lzil0qmP; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Ez6oBTV8; 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 144-20020a630296000000b004a50c3a24e3si7794327pgc.633.2023.01.05.07.22.11; Thu, 05 Jan 2023 07:22:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=Lzil0qmP; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Ez6oBTV8; 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 S234234AbjAEPR7 (ORCPT + 99 others); Thu, 5 Jan 2023 10:17:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233796AbjAEPRx (ORCPT ); Thu, 5 Jan 2023 10:17:53 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 517FA59304 for ; Thu, 5 Jan 2023 07:17:52 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 305E4B2k021275; Thu, 5 Jan 2023 15:17:33 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=hoB+ZXNuIZGger6owOm6C5AtLZTyPSJ9zZfxQpAPnIk=; b=Lzil0qmPB8E88wgsmvk/AtzPjY/ieP2TlMFSYyoYVAMebp/hrD3XQ/+JJwCfUKWxYkN4 5Qc/ayBjlF6X7ZS+yRVXOtnCsnkVXQGkT4CpnyG7bMFlxs8T9LT7RUeKAIs36C4V+RET imc28xpVRzNL9EH3qXeSojeDB492E8WCMG8tCehl5HUpYkTAhHU3w81n1tfFdXKYluBD PjT7f89tQfV4QAuLoN1353qVBngI6kSjmeFmzbbnqcG/Dne/AQJtysBZsxA4CEGU4YKO S05MWEjnOxm1QbcdI5DwQWz9Ei6T2croiJgsPI1XpIk/2t5PHYBwkC2Yej6YO22Upu1D tA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mtcya901u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 15:17:33 +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 305EPKPM040220; Thu, 5 Jan 2023 15:17:32 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3mwevjmsqx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 15:17:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TcaakJ6OB9QP1suBHy6re9W86e9a/v2/2PNo43kD4F14zQKNkSiljPqvwU1kvla0zyUN/OaYy6JnBX1zkzDMtXDFPkWt52fO1MJbm8i2l6frbPw+YSXPXvSQq97XjyXNnIco4lYoONkjaM9w9fsNH6xA18RGavxP/GxoW+GISMnkWvyM6YKVdAJ8BoZ9sjF7kHFNb+M6L1AZa0/wHCHvXe4JgjcI5in7QujLgJJMVfxpaZNOjcRnPgmx/3TW08c1XR4sI6vnn2XyzrKExfrKHFaf8gtpwTH5hGGTdK1EQUuxpezhph/1fSsHirikO0HCQNQoqOVNYYFgS39rNGTf9g== 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=hoB+ZXNuIZGger6owOm6C5AtLZTyPSJ9zZfxQpAPnIk=; b=aCB5XYChaeki9vrAn6CO2iWkj8bYMgXDrXNVD2K3OUbGta9Dtp7y4/sNDXCPPzjBQ+Gkl/JLVMstpqkjdfx9S+AexOQvZPRHNp5tNAN9xVpNtS/s4FwiWGsooWaLSJn8515fsY8O7AA/EJ+Xx4qoLizqVrVW0nZAo1Lr/w2T+TUkCL/k/wqzLQuNj7QJU12DCT1Mhy79oVk4dYCX9Bqmg3HkCtq1GljKSd+0XxQ1WhYCWDbmTZ18CJ7ri/r4Da4OnclyChUqytQUbdrmnqgoRBWSICZpdF84JTub67B/VaZPPzlHmoYgUCOEBTOaQPihW57KKMXAyRgKVMMoOa9Q0w== 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=hoB+ZXNuIZGger6owOm6C5AtLZTyPSJ9zZfxQpAPnIk=; b=Ez6oBTV8VHbJ+nh2QOW9VuznAFvKr3xqCydGEXRSy0mMmnOBEbxVIDLR+xYYsFuX1/AcFm8Z2jBFMF21XmkUh4pVbsP3B70Km3fMXxbD9aN4OEGhk3NNUMad6bK3lZX8oppSwRB0f22P08xVuMP/Wwim2CxzIA7oh125gjSWpDI= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DS0PR10MB7406.namprd10.prod.outlook.com (2603:10b6:8:158::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 15:17:30 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a%5]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 15:17:30 +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 v16 4/7] kexec: exclude elfcorehdr from the segment digest Date: Thu, 5 Jan 2023 10:17:06 -0500 Message-Id: <20230105151709.1845-5-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230105151709.1845-1-eric.devolder@oracle.com> References: <20230105151709.1845-1-eric.devolder@oracle.com> X-ClientProxiedBy: DS7PR03CA0195.namprd03.prod.outlook.com (2603:10b6:5:3b6::20) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|DS0PR10MB7406:EE_ X-MS-Office365-Filtering-Correlation-Id: 412bb6ba-d2c9-43c3-c3ca-08daef2ff60f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X5oGXQ3xqK2LQmW8kf+KKEwoifvZ6DM9INWK01lQf5yqnSY81WWrPTYCNL9g3XP8DJHjiFbkqCNbfe4/rxJfyjp+JPwdbzI71UUA+hJqo0BzX92lK+Rt/dwc7YslAcV0rjOfCq0YeIGCimDuq/0qoDx5d243Jd8Sg+YFrG5/KfQ1eUT0Rf6eEOqr2J5IQHlsXQ+JFSLcnja0grRbol/slEgmT6HNP1nYtXhabwHD1Q0y7oZNsNLVBA8Fm1HWBU4VtU2LZ+In+94PfW6xAoZQQG53VeKqDgVVXdSm8kdnFIGkhI0hDJGgJfnQJvItFRbtcsx1FU516AfUWJX2+pU/WOMerertH18uwzq4KecJdBXZPwd4NVcKhbYb33Fgi+TnxArpguIrtQ9RxTwrllcsTkj+8ygMBYPAIn7Tv773ozkriZMqU6M3xLM9Wjutnsxr43f9vS/1CMenke0ZinGkPHzlz/aEInCg2Bno61tGsP4I25yOJ/dmAcnNYKY42hEpb0pELID6Q+p8Let4aYuEMf3tm5S8/lBKNpzzRY9Q7wp+7Q1A7VpDAPNFR27h3rqh9sNDwu0JR8wN7QEy2S1xiMmZKl0oXT/RDXiZxSAOODbsuQt5JUDNm79AIhge86yEf0/qp2ecyMxniitJRnXOvw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(376002)(396003)(366004)(39860400002)(136003)(451199015)(4326008)(8676002)(107886003)(5660300002)(66476007)(66556008)(6666004)(66946007)(8936002)(41300700001)(316002)(7416002)(6486002)(2906002)(478600001)(6506007)(38100700002)(26005)(186003)(2616005)(1076003)(6512007)(36756003)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2ZM7fDmRRsW1LeI06CVOItgcDumqAljId/Fi7oZwN+em/SVIZxENjZFIu5EEtHy1nrT/NV1z3ewgtrmFa+RZ02kp3jPStrAOK6oSTPnCvJwwOqnQwtWBVmVpP4U2gXaxM1SciHTBwNEJDAsTgBoiIBJ7m+b89sVFnFOWpDlu/iKdMrPaE9n06lXlxvKHg/nBvMpV6M+5xtYxfVk3pYunDjQi4dZT9kAiqxdxxjWSsDm5HY/aVuq5VTPInwmutnie/eZ4vxf1+p1LNdzY3DJGsAjrthy0PvHK9wOyNBqQHJK7lDoEf7QlJfLly1li2VMxFuombLpyGMh8out+59PTT18tvtauYCDQDW+susKirSULex4a1ULtGh1a8TCpwOjKmHWP1r6jeUCW1diEdq8RBCunRH2knDCqPnRZuMaX8Xs7rXqWEmO4wxOeMif9PzV+KTd9uwKYfWozeqwrwxmOVsppyvU36bgP/flJWYe6lx0LJvsh1sU4n0KiXJwn9aaQSykbIAEN9a+yNRtFW0CnsDKSHOzozhbe/RjnvfBn3Y6ESXMSIsDeHuQTbWUDPBCG6uQXjIZ2/i0909bpk/Mf29SrwbvMjoLB4eY1r273UfOzLBD8rXj1SRyF8VN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c6qtYBOS9+q4tSnskGm/GNKDefXdiH5Qdf418qLfWLAp2DHrCl+aKzSIpsd4dkP1SniBRrB2KUr0/2BnV3yhgyb5cl0wJpjPVgWvo3xcm3vmm1AcYu5PtzKpVN+cLa83DaZ+zYDq9dWwEUR/lkAd55ogPEF1sR/IPbuQ5M+ewr6c5SZwqGQEur0Ct2MtRmyo/AsX/ED/gQntqcg0kcyJSlufixNZJMrdqTP3kPULc9vqXCXZ+Zj6pVEJeN9Y2dc3XJIRKqCf7PKirIPTG1B/QNcHw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 412bb6ba-d2c9-43c3-c3ca-08daef2ff60f X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 15:17:29.8950 (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: 8MgOxTW/ednTZ+4uVHchnDavhEviJXCnkicvy5yzN+Xurzn0yW9uvHSgaVlcu5tw5zLxECeassl+0LgPCi2B1CsKWg3QtcOWUf/gcXq8ATw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7406 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-05_06,2023-01-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 phishscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301050119 X-Proofpoint-ORIG-GUID: eDMx-5plBCV27ZrjFpbU5lTvvf-ATTT9 X-Proofpoint-GUID: eDMx-5plBCV27ZrjFpbU5lTvvf-ATTT9 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?1754196495549220579?= X-GMAIL-MSGID: =?utf-8?q?1754196495549220579?= When a crash kernel is loaded via the kexec_file_load() syscall, the kernel places the various segments (ie crash kernel, crash initrd, boot_params, elfcorehdr, purgatory, etc) in memory. For those architectures that utilize purgatory, a hash digest of the segments is calculated for integrity checking. This digest is embedded into the purgatory image prior to placing purgatory in memory. Since hotplug events cause changes to the elfcorehdr, purgatory integrity checking fails (at crash time, and no kdump created). As a result, this change explicitly excludes the elfcorehdr segment from the list of segments used to create the digest. By doing so, this permits changes to the elfcorehdr in response to hotplug events, without having to also reload purgatory due to the change to the digest. Signed-off-by: Eric DeVolder Acked-by: Baoquan He --- kernel/kexec_file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 270acae2801e..6e13b3a71fa6 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -723,6 +723,12 @@ static int kexec_calculate_store_digests(struct kimage *image) for (j = i = 0; i < image->nr_segments; i++) { struct kexec_segment *ksegment; +#ifdef CONFIG_CRASH_HOTPLUG + /* Exclude elfcorehdr segment to allow future changes via hotplug */ + if (image->elfcorehdr_index_valid && (j == image->elfcorehdr_index)) + continue; +#endif + ksegment = &image->segment[i]; /* * Skip purgatory as it will be modified once we put digest From patchwork Thu Jan 5 15:17:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 39643 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp353036wrt; Thu, 5 Jan 2023 07:22:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXtsGl54/7SSS9SxHnLjCrE+FAdA0V0J0m+os6lZF78nBeqgF2IwGo88MsScdt/YqVZeF035 X-Received: by 2002:a17:902:8c90:b0:192:a470:2c0b with SMTP id t16-20020a1709028c9000b00192a4702c0bmr22129948plo.49.1672932172419; Thu, 05 Jan 2023 07:22:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672932172; cv=pass; d=google.com; s=arc-20160816; b=x1hU6a4/wfZbXoP8zCO2By8p7prgOvgG+mm9AroVyMeoJ/ytxBOEMeR4rdVP2PQ+7M 1Mfvu4fDulAx2khATr2DlP/JJcM6qyMVeIuP4DWn9OE+fY0SJoGn4h7bmPvIvuY2bHgx oPpvg+/8/Fyh9BCCkWmLNEQ378tVxsfUVmRDAlqlZud79ts0m4WEJA9le4rAYuPmIUph /mYr82OeITIxN9Hoyltpb5iIkgtNfj6ogi1o1wyb/3J23nuxBfgilHy5yd+vaVYfFJKY t8Vwwgewxmss3s+qSYkmedxYWRv2KdVW0H2sN747GdDiKeioXwyt8m4R9O+IP4MjUXDC zaKQ== 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=AIc75cdGTfGHDcpOA+nAXVIZJLskQhQr5iCkcEIv3kc=; b=Y+IvTcahrTRDToCBcR6vOkkzgr55iz1e1+rco5d/b+NHxeN1thvJhoHgOVWUKQ2Pq5 MNjwGnbyBzpMBvilBOYgJWRcQETLBaCDjGFwnCNkQ4X3kMwjfzJ0dj8ybzb8g3OWyHNX 4qWjCD7Tn0aBKSDFivHPVdyLdkNb1SJqX/nMhpDPHkrns6P32hInBEKIRzI4BhFIJZ2F nuel2sPnleq8JVwDwKDYF4VJ84FVIpWvFBFb4XjxC0Qx9ytpNvgdMhB/3Bu4qup4TWi1 ikLa5IbPQsf5q30MRPPgptDavk0idH/vT+gCAKHZ6fy7G4SIIob3qVpgNRxFUS1vdEga Q84w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=nUF8H5OW; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=tDAk+BnS; 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 ju4-20020a170903428400b0016f1781307csi35390848plb.303.2023.01.05.07.22.40; Thu, 05 Jan 2023 07:22:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=nUF8H5OW; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=tDAk+BnS; 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 S234440AbjAEPSS (ORCPT + 99 others); Thu, 5 Jan 2023 10:18:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233555AbjAEPR5 (ORCPT ); Thu, 5 Jan 2023 10:17:57 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C342959329 for ; Thu, 5 Jan 2023 07:17:55 -0800 (PST) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 305E4HO4025078; Thu, 5 Jan 2023 15:17:36 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=AIc75cdGTfGHDcpOA+nAXVIZJLskQhQr5iCkcEIv3kc=; b=nUF8H5OWxFG7xPZ5G8NfJxPO0fnGyOA1ePg+MKgTrNbaJPv3yns3bU3Bu5iRR72zovL7 wk2kOEgjNSLQhyr8yuSA05hCwpTPhY369F4kdH6CzjJu5oF8unbYZebi2eBq0AIpt6k8 Ill92iOkNOUX/H+G6YYbyneaxf8WotnttcpPEdVpO85KlNCn0/S2ckhIccThF0Bvq0Hq 9f6iQYeMQyDovA/4kRpPVV2z6JNcC0Y2CY3fwIJ1towQD+jmaPQxRgF+QixD2m3wqr4l 2jlxszyD7YMG1bayH5WOX+cU2sLd1nv62iFJE1mwGOdqhSVeDFKbCgm8w9J10/O5TSNv Ww== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mtdmts0bn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 15:17:35 +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 305EPJqv033701; Thu, 5 Jan 2023 15:17:35 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3mwxkexkbs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 15:17:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TsFBgtrkv91j+nTPXFjKErsHigOTI54pUDkaY7RnvReE1lRDZE4fGrPSSgCNTeoVcYMghbXTvE26oF6oM+/QoBIsEfk5XeDdeHZJV6S2Nk9OjLCEOo2WHqg/BAyp/TyoKWb8se38rxCfI9mZkSBsIGUMgsrGO5uw5GNyJR1DHWCJvpIeJMApJ2WhyQC7CJUN8ke6LeWFF64baB2RZDmgdNAUIJXNR/Lyd2l5B+NhQk6MShqcs+PkijjKw3SV7uCEZ1oAgMNIkzJdivQq+NjZbvaGqoDam5Ht9HNgXzYL9CQW2XAdsg6+teimT2NXE06mas1hueiNbp8aaUXGXk6D3g== 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=AIc75cdGTfGHDcpOA+nAXVIZJLskQhQr5iCkcEIv3kc=; b=VMcAiX1mxKA+Ag49CcptQB6K4sN0iYeUcPM6FvOA/KdvyyS1eKvLkqXkwKLyW5u7z6eXZeBElywUzeTRTAYsNP1DadnFrxo74vgiRwiZeVXHPnh0wE235ghJXarDXwL2oEFgH95zd0ruMv7xii+8VqCJa7pDEo+h1SRcd7LkFcFiDFEdA1EnuhY4JVzy+p3mm78VpPtienBhDErZKhxUf+bwC03TTY2neusfukLMV8rP/063rZiHxHi4tOt2qFWwfmptaFHjuEOMl60790fyjkbVPmuAuq8fIE59k0wqk+ulkGoAH3GDQa52NSYJTDReXuyVPMJtpdtcrqcZ4qyGMw== 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=AIc75cdGTfGHDcpOA+nAXVIZJLskQhQr5iCkcEIv3kc=; b=tDAk+BnSm6+rTdCpC1rV42XHPFofex4iQHtmoEpbqomcLZuirFKVX22SUDKsOfc/8L7qUuMCPxN4Bq5FQuqo+v6kyoH232JAvoVSZNKTZJ0hx7Yq8g73jZA1Yf7IxpvuvpabTyk+Wt1uqcWK5UWwed686OYTCqSlOVNKedWikvA= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DS0PR10MB7406.namprd10.prod.outlook.com (2603:10b6:8:158::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 15:17:32 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a%5]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 15:17:32 +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 v16 5/7] kexec: exclude hot remove cpu from elfcorehdr notes Date: Thu, 5 Jan 2023 10:17:07 -0500 Message-Id: <20230105151709.1845-6-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230105151709.1845-1-eric.devolder@oracle.com> References: <20230105151709.1845-1-eric.devolder@oracle.com> X-ClientProxiedBy: DS7PR03CA0034.namprd03.prod.outlook.com (2603:10b6:5:3b5::9) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|DS0PR10MB7406:EE_ X-MS-Office365-Filtering-Correlation-Id: eb176ac2-4956-4d31-160e-08daef2ff7a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aRUjqe9WZvoIoeR8ZsP4Iwhx79xZT8AhRvlRRbXJlsQ7oCNR5a/J4Jw6H0rqQyKXWSi9Zz8EXoUC+d9XnToOlglqL0EfzJ3k+UdNDbs+miBTANy0332Q8RL8Dj2dGmianZfz8KcYMw8B4E7lf7LFtXKjf8I6fVKbwLvw4ZQuir99xRIot0KmXeklSfF+qfNE+AnYkzotdKUNTTP1eAqmftYwE7Mk7JRRzqGDvE9BBZGj9Bbv4H7gV2A9/q6fmhVcPDbGsT7SeZ8ILVQRgflwOtW8M2nfOSaTgOlNHhTeHVxQ4Q1usypUNCBq04RrIEYJ/J4rM1PBTRLYwglNjH/pwo2sE0rgfA1hcPEjWTYeKtrgjpJ4s9mJ+Knj7X85a7sYyv/qU7rEsc0jRnB2++Fvz6JmpHksxnNG4EyDBWPUS9fWd+zxPcZ6Sh5jN/4DXmZdyXpeTiAy/T6vAiO3+sMvvb2gnPUXhbqzo91OdFF1vCm0LwlJU1Wfe02PONh6xTdkFu78PEmD8OH7RHxyI9QI2FAzWX6EXdtCa3hT7WB9ErKuh9rTdBmWUAWe9EGBBqvD0ZQMIHPEtefrz9ez9vkV+h9s2XCrm+t7kF2XzIbLmtQf4SluoHEhg6m3jUGOQJUwyMvVeNOPLkqfzdJ+euGxUA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(376002)(396003)(366004)(39860400002)(136003)(451199015)(4326008)(8676002)(107886003)(5660300002)(66476007)(66556008)(6666004)(66946007)(8936002)(41300700001)(316002)(7416002)(6486002)(2906002)(478600001)(6506007)(38100700002)(26005)(186003)(2616005)(1076003)(6512007)(36756003)(83380400001)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7dd/7lo93WH/ggeR2G6vVxeeVCFG0yir2h2sEHv3D/61ivKdVkCpaMArjYhHqIVejiMfRnvYVwOt7XG64bFw/E9BC8objZWUPYMenxQouP6FgMjAYb1P9FEdSBPGv4AO2SWItKiNraczNiLFJUw+fSQHefFRcqlkH5L2oxa4dYCBmpVNGYWOhrhnKt4YnKptKe3vuhX5RzepXRby73SJyL2yw0EBeybkI8BXI7sik7nJuK/iKhjkD/mEdMK53BKLsimKRK1OemvFD1W2dotxrbrIa70tXGy5iqydQTwMzScBdLB9wxcoOrdN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upNpGeNQ4KuSXJ9krY/gEOFL9JL1pVkhAZ3oN4PMxzJWkNegoAHlTvEIBrq0kzdB/7oKzmIMaK9N21Pbu+7yw7NN5ajoVwIa+mOoAnUIZrL+3MAmcOk/03uc57t/BD2noGcB55Kv7cXJ4lP9E/3RMaZ1E73PZi7oVMryrRXesLaGMn7b0vHwZA40cqjZ5Izjw2XL8663Qp8J8PWIFNJ/KHwF4gpOPCCBCLMPRsACIgSOLJVSmCiPbCkVVoiF6nM371sd2L7kErxOU5OeQZQ1w9lJf0ZLc6h20Jb+Djd3umHmPSTx92539oVOSjNkDjUpL3SkzJ1OxMc5x31n7Yqc/ZBKVNuKRc9FnZh3wz6IdZ8ftuLlmhpVOYB3TJZ897+czlDVRjqfe2VnrC7fhkX9xSMRvC7xrrMPG47buLwvtx9OPoi9Kwma3F2AA0UuwAzteGl9tbkK2Dz3qdx6aV/VUlDvBQhRXnNRlQhXFf0JRgcUcIsdwqUQNaY1RC1A+kqHdbT0ljihr4x+Lqj2/JIY+vucw2W/maV51Djpv2kRM6qRkadirOQ3hqHgBlaUOu5rA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb176ac2-4956-4d31-160e-08daef2ff7a5 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 15:17:32.5982 (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: 3zGzcIIeQkvqE1h4S7YOd0EE3EKoPbigKRsVQzMa+EGgOs4b897lOqqmcDz4g9G58kfNT5oSYYdt6ad25IKsqrMejegRpJSGTGTHYLYh5RE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7406 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-05_06,2023-01-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301050119 X-Proofpoint-GUID: yYp3wk1BMn9ch-yXEabeK0XNpOOtzc0s X-Proofpoint-ORIG-GUID: yYp3wk1BMn9ch-yXEabeK0XNpOOtzc0s 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?1754196525872202601?= X-GMAIL-MSGID: =?utf-8?q?1754196525872202601?= Due to use of CPUHP_AP_ONLINE_DYN, upon CPU unplug, the CPU is still in the for_each_present_cpu() list when within the handle_hotplug_event(). Thus the CPU must be explicitly excluded when building the new list of CPUs. This change identifies in handle_hotplug_event() the CPU to be excluded, and the check for excluding the CPU in crash_prepare_elf64_headers(). Signed-off-by: Eric DeVolder Acked-by: Baoquan He --- kernel/crash_core.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 973d7ddff1cf..910d377ea317 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -366,6 +366,13 @@ int crash_prepare_elf64_headers(struct kimage *image, struct crash_mem *mem, /* Prepare one phdr of type PT_NOTE for each present CPU */ for_each_present_cpu(cpu) { +#ifdef CONFIG_CRASH_HOTPLUG + if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) { + /* Skip the soon-to-be offlined cpu */ + if (image->hotplug_event && (cpu == image->offlinecpu)) + continue; + } +#endif phdr->p_type = PT_NOTE; notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); phdr->p_offset = phdr->p_paddr = notes_addr; @@ -686,6 +693,16 @@ static void handle_hotplug_event(unsigned int hp_action, unsigned int cpu) /* Flag to differentiate between normal load and hotplug */ image->hotplug_event = true; + /* + * Due to use of CPUHP_AP_ONLINE_DYN, upon unplug and during + * this callback, the CPU is still in the for_each_present_cpu() + * list. Must explicitly look to exclude this CPU when building + * new list. + */ + image->offlinecpu = + (hp_action == KEXEC_CRASH_HP_REMOVE_CPU) ? + cpu : KEXEC_CRASH_HP_INVALID_CPU; + /* Now invoke arch-specific update handler */ arch_crash_handle_hotplug_event(image); From patchwork Thu Jan 5 15:17:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 39646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp353398wrt; Thu, 5 Jan 2023 07:23:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXvOek2DWak87nqyjG/iKmZ/7Sy5Qs9KlbszYlH6QiTpph0z5ChcA/XkpkssNyyge9eDKU6r X-Received: by 2002:a05:6a21:e384:b0:b0:25ba:1769 with SMTP id cc4-20020a056a21e38400b000b025ba1769mr72638533pzc.58.1672932222482; Thu, 05 Jan 2023 07:23:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672932222; cv=pass; d=google.com; s=arc-20160816; b=LMDghpbsBWCbmBBe1LuXDc4s+srKHXaO7wpjZUQQPjOV5lunBLNkmt0kzQreOhjwM1 +na1MUZXmfZ87GU1i0aTpDkeIlS8jAUkw/wHmUkIKQ5pFLbtblMy3IEFrjqjxilG2A/t vzgyQwPY4YUCy8tqt1ma0dJJHH2t/ecYGTKsys5GTHy7Fae5NeicPuE5G+UJ0qiTSslY AmDhVO+vfiplDnDLJ3sXJw2x4O+EIeY5Uoa7/aiqqonzyQzepu4bAtxmrjgFPB3HzjnV 8WH9wM14teUtPSISlIi9s4p8v0dMuHtq1gxTQWgfsZr1VghDRBnInp/RHn0CZIVhb56E hL0A== 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=ps3BoiAio0MOdjqrZtSNcNm+B6RZlc4pw1ST8PYID/8=; b=NJlszxlogXxJ8vRxlncuPVsXe+TC7aJ7W2+R4fSGgJIM7RGR8DpWkd1NU5bkXdd7pM VLnr4YkWUdbLVziPtb71VSCOi7B+5Ih8sk3rJBU6GO/cJf4ob1aeHB70lPchYPx+mEEl Xci5Bdc0wNwOLm3R3ln5JcBnDFF7s3Qj/1Ex1fQkUI6ODXBQaO4i9ICdlXlaGNwjqEAD ITv+TsWFmdcGIHoiNmT0YxaxiGNSWwiZEkbJTo/XewJsniLDmfnvv6ys11kz29qCbXdt N7i+n9XZnon5Sy59YVwrfA+1lEErsVojdq/x6hX2v4+XRfteQDMdmI6pxjxlIASwHGAF 0+xg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=lH88vob+; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=cGMbwzxP; 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 p7-20020a17090a868700b0021942473a5fsi2072876pjn.122.2023.01.05.07.23.23; Thu, 05 Jan 2023 07:23:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=lH88vob+; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=cGMbwzxP; 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 S234514AbjAEPTD (ORCPT + 99 others); Thu, 5 Jan 2023 10:19:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234410AbjAEPSY (ORCPT ); Thu, 5 Jan 2023 10:18:24 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D55E5C93F for ; Thu, 5 Jan 2023 07:18:07 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 305E3nRx014083; Thu, 5 Jan 2023 15:17:38 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=ps3BoiAio0MOdjqrZtSNcNm+B6RZlc4pw1ST8PYID/8=; b=lH88vob+WW0Z5lt3+bB08sAzI/ml6xfwkPHO7kPnzMHxYLmkX0DAV2ScZBzcennP5dOv j1PDTFLwmqP1//3Md+ERHnLcDBNPVEyBocrQaDNd6xdDMMhDENwjPCyMDexouaOJtjzj 1UPLMycctDTqBeUpwxLFdsOBAiAfOBLemuWOD3LyOSBC4EEBqWZ/EwUXgd79kKBQxz14 bW2HXnYMHX44uypW+tTPFAVEmwF3bBbvAC8hV9s2qAxkFR7MacsiJTkjzpdndp9fME0s EsTguMKMQR7Qh+GiLaKA/CTqWey1unyFqaHC0ibxRX7xXQPTAF5XwBzqtzP9cofQJfyw AA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mtd4c953y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 15:17:37 +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 305EPLm5012026; Thu, 5 Jan 2023 15:17:37 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3mwdf0hpae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 15:17:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EF8YwEAuTawspda7K+7O2v7sVmxVX/hqbgbTZ/yTwF7jcjkj4nXVRUAr6gmgjzX9GRbtEotgfYiTubO5+mHiT8bAzti/gvI3rnWDJRzA/bcYLe2GQ4RKGf897zwIK7GLPpevhdTq2/wn9X/oaBOJPX3xcrDB4/8lAuvcLdCDbBMd9N7wyQOrH0WncOhaAg8zLypI41pNjz12bf3dalUa/+POkV/sZuUWVi5janAb06zXNavpZtZrCiKr+/FT4DdsHmHufPE8o1shAyEFI6WvdvGeHimS0O4D1LkUUrbl6T3YQSIr3CNyVJnKuiqXbU8L4xw9NjBBl/Vwp4CZhf1B6w== 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=ps3BoiAio0MOdjqrZtSNcNm+B6RZlc4pw1ST8PYID/8=; b=gRKbqouOY5SOjJ2TQtZ7R+CiwMSi8OWTPyiDNM5lZspdM8uD4qcl7/yKLEfuBWYO3lW+4Wp+k4TDneCOz4OKK4fkGMwDGQIGVPK2uJegQqXWmPzMgraoy/AvXlIx1kV1BsFuR21g7b948wDv35snWF5cW8fUPffopnlVTPxO+EnN6aU74vGWYz6qpzvRShEp/cTwaDY+FOkucaTuOPKa7XClOYQvnlPBbms77TcmcJ0aIsBnT1Xc+sUIPE4gdBl30uNybUlQWjum9AEMrhzFbKxrRISHo4jVJWejQyTBBTMtq57KaDeogWmZw7KeG0cLc2eSYL/5lQNS47xqdj6spg== 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=ps3BoiAio0MOdjqrZtSNcNm+B6RZlc4pw1ST8PYID/8=; b=cGMbwzxPkpO3cEFXsmWrR4jZSOR/GoJvH30jAyVDLu9MaA7jgz20SbtscCIexzMbIlypwuxBNwivhm5addVlIUNY3awClYY4xwgnd32sLT/fgfhFgn3DThegHWZLax1kSvIMyRL21WgLnLwa5vaY/bFKj71J4Akcb3GVHv6Co4I= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DS0PR10MB7406.namprd10.prod.outlook.com (2603:10b6:8:158::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 15:17:35 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a%5]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 15:17:35 +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 v16 6/7] crash: memory and cpu hotplug sysfs attributes Date: Thu, 5 Jan 2023 10:17:08 -0500 Message-Id: <20230105151709.1845-7-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230105151709.1845-1-eric.devolder@oracle.com> References: <20230105151709.1845-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR01CA0001.prod.exchangelabs.com (2603:10b6:5:296::6) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|DS0PR10MB7406:EE_ X-MS-Office365-Filtering-Correlation-Id: b236afb7-662c-402b-c535-08daef2ff916 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iM1Zso81uviN6nyMzNRzSiz2El8zxFu1k6vXQzwSokXNf3aAD1KYlVFCoa8jEgrGkdrvLVjAP1tWRSLUC3Jq/ETyRmCCBQzwM251z1mtKDLcFrRcZZ+8bPww+ulI+wvpN7Ufu3WS6pt0v7XGifAAn55PHqW967gvWohqVLilW9hquw5jt1IH9Drk8YroMZkFB94X1OYb1/uUt9O43oYf4cBQ39/HJdCiW8rJ+eQc1ASkaZbq1kucdLvsCP3dbTw0Oyx5Sj25RecXzj0tYm7gyHEHEQZ5wJcgkmEAOWJ0GNXDv6hn9AhOeyayjrFXubT5ejxoZzOK01xZLf4dOyWQvatm52yS1gRFOOBc9Ea3/SJ4C/8bUpUDlx2PCYvO+HOG5ZPjg7UGIgt3rKyMA0y8KQeZIfmj9txkzdPWpOd2txHOXl9dJAo6aejsxTBl9Tmt7C14vl83hdYqbQY3srMOEVXm8wfvS1HfCaSddgh7Y9WWzaKzjmv6bZ3iqvQnAOui3MPUBMfyaEoQjzX7unp3TqCgN0XfT2cBXqQfWWXjIRLGVU9JV0EVllcVVEtMUHHqxdwHNIdojc9TLTxGboJFo/vIO/fL8nc5u+bdAQ3SC2fCygyQy1O832ZmLIcOdXSJKcreu1ySuj/OUPAz2DFAiQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(376002)(396003)(366004)(39860400002)(136003)(451199015)(4326008)(8676002)(107886003)(5660300002)(66476007)(66556008)(6666004)(66946007)(8936002)(41300700001)(316002)(7416002)(6486002)(2906002)(478600001)(6506007)(38100700002)(26005)(186003)(2616005)(1076003)(6512007)(36756003)(83380400001)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /DyuNRlYE0jTLZ20mo+v/Gi6oY1ncoIemLYOIS9xlbH5Kh/ham0bdZxA+4Ity/xoVYFzAZGU3zghtIAHpk32hqnHfDF/VfOBf0+OvcuH8f9MDZqPrRVqoGx8AuhpQO7RTyW+ghVuyyaFMcBeEcQtASYscdHTqOJNHLo4UaIMpCsmWKTJ4zZF3Edo1cJnkNfdyQB44JtShesm7kBnNaRX2Z6Le67bqzGpA06+EFh0r1QjHeGpfhdtxG/2z1JTUGIv6jwBIq/vZeLm1DeszEJ/oGji/00E4X+o5lUju+I6bZ6SJvaGNcc6F3DiU6Hk1+aE9FJy4byl8t37o3vBvou8NpUJ0LThtSTgvaUDxss74fiwr+D/B6aoPR5oW0xWCMRQPn5iXmfUSqLjnDDSiR8yVF8W6mJBdg1P+ZkxK4t+rQpvXhmu7aVOHZCLT7tg6ukCcWCXN7VLiubRmIcNqajyoab3B66Q6LM8c5CC+9eS3IDfUq/8AEqaGgxjysfK6dPt4STYVLdA9+wTTyX1DjH9KsRxY1IfxEmJqeaDfxygOi1dy8FxQAwOiuW+4fFUxbsoPVTD5dCkizqlZ8T4WOYcei5mZgCHTQ06W0zEOx7L/rpANjISQAOG7sUJVysWSuiKBOuMXmrzXA032xkEkBWlImFSN/1OIPRLmbgxShJQQNxAKPvLHud1lDUX6Xg+WMSp6FIRf7LBIZG3n0yxbq9nheUsR8BDA+8T8OTYYWtNTTzKo+ofAsWS9GLsq3KAafPqMGCr4sYGsr/l0n1YXgtzgHVl9WPO+bcoZRr0eIrNQW94fsXcfVaniR7dBhZEosGSc8/ydKfYUWuCL7Ba9MhzcgZXDelLt6DOTzzZcLB7+FwPMmJIDJq/kw57EE8o4SKHLeblxmniM5GaXa5S9wNBGu3at+Qr8VQ1cJUEhvuDs6oOpHDogAK2Z4YCrA/M0bBbSJyiORDkRs5fqP7ZHpkZJEnfweXYlL8x1yd1wLLxV+Qb/dOUS4/0Dq53c4Z3Q01yGHeocN2V8LdvSYgPYC8JieRu4eUkj1cmkrNNXNhBzDLEos7psi+lzbx0PhjML7rGSgKcR9mEDixqBosfrUwUUgZFklASte+Y11vmtPLtxV8Fs3RaEvuSgtUeVdDWFPA1nTi25NJACtdfnZrDy1FdYn2MIHMFv/eFUlV5AYQAcGP/844WtJq+u+X25UxUiBf/aWFrX3i7DgvUPBnfRt8eA1XnO5aa842kvAE86jovz444uRUs6eQEO+diisGsAl2ATb67HPceDZIkq1pbG3WQFDNYgw5rt2JV3f8kXZ/Ryc7ScCPowwxcBhNcYWZsKGD820VcE1krS5dakuJESQML0TaBFdMGJFCgOFNfwZaishxYc2sZog3TkntyeJAGJFk8DEMHUqv2Uu7WblguNb6Q8JKj4gu2w4B69DiZCH/PGrcsBQ1ShPBNVEXHeO5rCGpiba4PyZnaciysC2g4O0+vjNBWhv3c9VoT1j7ctUZ+DCYHg7DcX6dSkWYk1hTUieBZdEw857zSDp33TAsmwT0hipvdY8Rchjb2YNZ/aMMt2hVaagMpND9CqgPTKOUJQivQ3W9WaYtWTQyrFudRCXJPCg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: qKdEuHb99nIhFUU4aaIQLFP68eVQs6TCfYYjfbbcjN40++QI9NTX9nhAzspiq2P1JokpKqa7cfkKWfx3UmbEhHuZewriSwmkxRT7GN9qMme881JbeNfR5y3PJxHKnYizp4R+6PXwoLlZOZfeYrIbxNLsWPPFKLqxyWohwYlnfPiMR4CnQt+bknioOQ594cnYbY/+hbuKuiWG3h7qW/+GlUOq5k505GXozkmJfHdFoXq3EJih2GmhO2Wz2o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ijaRj4x59nYzbWk6AZRwJQSAJnFKqGTA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b236afb7-662c-402b-c535-08daef2ff916 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 15:17:35.0345 (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: UeF3rXjKfuF7uYg0iffr50TGE5afFxXsnplyQnEB0xHcOxXO5IK+RWb9f4xiVzv8DWSiORxNE8eh9Gtn7Z0tZdGbYz3U7Ho8Gij5oJQl56w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7406 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-05_06,2023-01-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=995 malwarescore=0 phishscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301050119 X-Proofpoint-GUID: zpRfaj7Z8CU3rbg_WYCe9-FsQN1wc4AK X-Proofpoint-ORIG-GUID: zpRfaj7Z8CU3rbg_WYCe9-FsQN1wc4AK 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?1754196578004150064?= X-GMAIL-MSGID: =?utf-8?q?1754196578004150064?= This introduces the crash_hotplug attribute for memory and CPUs for use by userspace. This change directly facilitates the udev rule for managing userspace re-loading of the crash kernel upon hot un/plug changes. For memory, this changeset introduces the crash_hotplug attribute to the /sys/devices/system/memory directory. For example: # udevadm info --attribute-walk /sys/devices/system/memory/memory81 looking at device '/devices/system/memory/memory81': KERNEL=="memory81" SUBSYSTEM=="memory" DRIVER=="" ATTR{online}=="1" ATTR{phys_device}=="0" ATTR{phys_index}=="00000051" ATTR{removable}=="1" ATTR{state}=="online" ATTR{valid_zones}=="Movable" looking at parent device '/devices/system/memory': KERNELS=="memory" SUBSYSTEMS=="" DRIVERS=="" ATTRS{auto_online_blocks}=="offline" ATTRS{block_size_bytes}=="8000000" ATTRS{crash_hotplug}=="1" For CPUs, this changeset introduces the crash_hotplug attribute to the /sys/devices/system/cpu directory. For example: # udevadm info --attribute-walk /sys/devices/system/cpu/cpu0 looking at device '/devices/system/cpu/cpu0': KERNEL=="cpu0" SUBSYSTEM=="cpu" DRIVER=="processor" ATTR{crash_notes}=="277c38600" ATTR{crash_notes_size}=="368" ATTR{online}=="1" looking at parent device '/devices/system/cpu': KERNELS=="cpu" SUBSYSTEMS=="" DRIVERS=="" ATTRS{crash_hotplug}=="1" ATTRS{isolated}=="" ATTRS{kernel_max}=="8191" ATTRS{nohz_full}==" (null)" ATTRS{offline}=="4-7" ATTRS{online}=="0-3" ATTRS{possible}=="0-7" ATTRS{present}=="0-3" With these sysfs attributes in place, it is possible to efficiently instruct the udev rule to skip crash kernel reloading. For example, the following is the proposed udev rule change for RHEL system 98-kexec.rules (as the first lines of the rule file): # The kernel handles updates to crash elfcorehdr for cpu and memory changes SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" SUBSYSTEM=="memory", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" When examined in the context of 98-kexec.rules, the above change tests if crash_hotplug is set, and if so, it skips the userspace initiated unload-then-reload of the crash kernel. Cpu and memory checks are separated in accordance with CONFIG_HOTPLUG_CPU and CONFIG_MEMORY_HOTPLUG kernel config options. If an architecture supports, for example, memory hotplug but not CPU hotplug, then the /sys/devices/system/memory/crash_hotplug attribute file is present, but the /sys/devices/system/cpu/crash_hotplug attribute file will NOT be present. Thus the udev rule will skip userspace processing of memory hot un/plug events, but the udev rule will fail for CPU events, thus allowing userspace to process cpu hot un/plug events (ie the unload-then-reload of the kdump capture kernel). Signed-off-by: Eric DeVolder Acked-by: Baoquan He --- .../admin-guide/mm/memory-hotplug.rst | 8 ++++++++ Documentation/core-api/cpu_hotplug.rst | 18 ++++++++++++++++++ drivers/base/cpu.c | 14 ++++++++++++++ drivers/base/memory.c | 13 +++++++++++++ include/linux/kexec.h | 8 ++++++++ 5 files changed, 61 insertions(+) diff --git a/Documentation/admin-guide/mm/memory-hotplug.rst b/Documentation/admin-guide/mm/memory-hotplug.rst index a3c9e8ad8fa0..15fd1751a63c 100644 --- a/Documentation/admin-guide/mm/memory-hotplug.rst +++ b/Documentation/admin-guide/mm/memory-hotplug.rst @@ -293,6 +293,14 @@ The following files are currently defined: Availability depends on the CONFIG_ARCH_MEMORY_PROBE kernel configuration option. ``uevent`` read-write: generic udev file for device subsystems. +``crash_hotplug`` read-only: when changes to the system memory map + occur due to hot un/plug of memory, this file contains + '1' if the kernel updates the kdump capture kernel memory + map itself (via elfcorehdr), or '0' if userspace must update + the kdump capture kernel memory map. + + Availability depends on the CONFIG_MEMORY_HOTPLUG kernel + configuration option. ====================== ========================================================= .. note:: diff --git a/Documentation/core-api/cpu_hotplug.rst b/Documentation/core-api/cpu_hotplug.rst index f75778d37488..0c8dc3fe5f94 100644 --- a/Documentation/core-api/cpu_hotplug.rst +++ b/Documentation/core-api/cpu_hotplug.rst @@ -750,6 +750,24 @@ will receive all events. A script like:: can process the event further. +When changes to the CPUs in the system occur, the sysfs file +/sys/devices/system/cpu/crash_hotplug contains '1' if the kernel +updates the kdump capture kernel list of CPUs itself (via elfcorehdr), +or '0' if userspace must update the kdump capture kernel list of CPUs. + +The availability depends on the CONFIG_HOTPLUG_CPU kernel configuration +option. + +To skip userspace processing of CPU hot un/plug events for kdump +(ie the unload-then-reload to obtain a current list of CPUs), this sysfs +file can be used in a udev rule as follows: + + SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" + +For a cpu hot un/plug event, if the architecture supports kernel updates +of the elfcorehdr (which contains the list of CPUs), then the rule skips +the unload-then-reload of the kdump capture kernel. + Kernel Inline Documentations Reference ====================================== diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 4c98849577d4..fedbf87f9d13 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -293,6 +293,17 @@ static ssize_t print_cpus_nohz_full(struct device *dev, static DEVICE_ATTR(nohz_full, 0444, print_cpus_nohz_full, NULL); #endif +#ifdef CONFIG_HOTPLUG_CPU +#include +static ssize_t crash_hotplug_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return sprintf(buf, "%d\n", crash_hotplug_cpu_support()); +} +static DEVICE_ATTR_ADMIN_RO(crash_hotplug); +#endif + static void cpu_device_release(struct device *dev) { /* @@ -469,6 +480,9 @@ static struct attribute *cpu_root_attrs[] = { #ifdef CONFIG_NO_HZ_FULL &dev_attr_nohz_full.attr, #endif +#ifdef CONFIG_HOTPLUG_CPU + &dev_attr_crash_hotplug.attr, +#endif #ifdef CONFIG_GENERIC_CPU_AUTOPROBE &dev_attr_modalias.attr, #endif diff --git a/drivers/base/memory.c b/drivers/base/memory.c index fe98fb8d94e5..a3f37cb57d79 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -495,6 +495,16 @@ static ssize_t auto_online_blocks_store(struct device *dev, static DEVICE_ATTR_RW(auto_online_blocks); +#ifdef CONFIG_MEMORY_HOTPLUG +#include +static ssize_t crash_hotplug_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%d\n", crash_hotplug_memory_support()); +} +static DEVICE_ATTR_RO(crash_hotplug); +#endif + /* * Some architectures will have custom drivers to do this, and * will not need to do it from userspace. The fake hot-add code @@ -894,6 +904,9 @@ static struct attribute *memory_root_attrs[] = { &dev_attr_block_size_bytes.attr, &dev_attr_auto_online_blocks.attr, +#ifdef CONFIG_MEMORY_HOTPLUG + &dev_attr_crash_hotplug.attr, +#endif NULL }; diff --git a/include/linux/kexec.h b/include/linux/kexec.h index a1838699d7b2..0b1ad1ac06e3 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -512,6 +512,14 @@ static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } #endif +#ifndef crash_hotplug_cpu_support +static inline int crash_hotplug_cpu_support(void) { return 0; } +#endif + +#ifndef crash_hotplug_memory_support +static inline int crash_hotplug_memory_support(void) { return 0; } +#endif + #else /* !CONFIG_KEXEC_CORE */ struct pt_regs; struct task_struct; From patchwork Thu Jan 5 15:17:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 39644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp353251wrt; Thu, 5 Jan 2023 07:23:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXsCjhF4BFgIuVad+xOghAaDlsqFFurV/QJuOOy59924lL+h0TRTELIdMMp+qb83L3sA5JNA X-Received: by 2002:a17:903:d1:b0:192:b866:f7e0 with SMTP id x17-20020a17090300d100b00192b866f7e0mr18385471plc.60.1672932203396; Thu, 05 Jan 2023 07:23:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1672932203; cv=pass; d=google.com; s=arc-20160816; b=tIemWD2vaQX5l5xxyD6n+i1A/Pi1RDMdpUpbwdYXkPyLZHscQ7iX1gWN0Wo3L8zCnX EWow9v7rVvP8Ms3O0TipHi1gZLFHTKbypz5jsQCw5dS+pKz5u3nnuqq+qG/sjh1vpHXM s+RdJf55qFOUP3G7RdFTBh/GomIg64VTuwcjHUzL816YOO/s6WpD6ktFPEVFAtsabcz4 q5SEeQXfsKhrduIKD5t+YRkJAL5B4/80wcNFxYbJn+ywrKcFgzutpgsDty2boLR7ym1L pimFTtL+cr+gAaRuvKww6ZUEQc5QedaKus/Hvbz8MMzhnHaIr+NV7sFKeDDVrfaLGIqR eWng== 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=kf2FxYLSwP0EI6eMVR2LyhMitN8ghGBJj4oacoLulxY=; b=m8j6OZ1OCz4JrTvlaZyBpaaqwjxsoGsDkYjKEo2fiTTa5RvlMWYSwUODqIuCuoyDEh 0X6r6m1cUBtDzGygqsXu2O2Sdam1aTe3sVfDDm5yeoQA6+qvmhMOzCq7NNqFffxvWKUa QGA3/n/itfA0ZJRl1TLvQSd7pBBFLJq5cYW+aAToyxItwMk92ZAjpeWtiRmoCGvHesN/ FzTErRV+5jTgcYAn9VR3/nHsj1kslMw97yLOgPGNuSvsOBZ1ua0O9kMbB1CH7jA3m9t/ 0SfuTawTq+pksyeTE6NLfAwsBpD/7l5hOucwhOJqiKK9noKPF2Q/sqpaZb1bp1EgLv1C xl6A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=YILeJt87; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="gJ/dFnTV"; 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 c18-20020a170902d49200b001929a1613f1si24231288plg.470.2023.01.05.07.23.11; Thu, 05 Jan 2023 07:23:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=YILeJt87; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="gJ/dFnTV"; 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 S234460AbjAEPSv (ORCPT + 99 others); Thu, 5 Jan 2023 10:18:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234457AbjAEPSZ (ORCPT ); Thu, 5 Jan 2023 10:18:25 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71E2A5D404 for ; Thu, 5 Jan 2023 07:18:09 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 305E3nS0014083; Thu, 5 Jan 2023 15:17:41 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=kf2FxYLSwP0EI6eMVR2LyhMitN8ghGBJj4oacoLulxY=; b=YILeJt87bvdc05xqI3xePE5nl+AZmp1awiK1eQ990Hmgj1nwEb+IsmFjvmQqdQTo+DrD 9dyN7++FTyZhFkAWWnZMTbbabYgWi/ik8l5hJhTu1G24End6kEpC6sdIpNS6/Qet9Djz YdWTQLu/fS96COdPSS7wJrYDs9xlo30KlnbIFplO3FZlWl/zA/NZHPCWVL45ny0nEiqY 19sgvk7pDY3DF9+w5ZmSKt0RDDEuuj+FPYHP46fVIuCyFpuKDeVxya4onzW/MkB+cxVa SKE6S49EziR3Ve2ulagygWOHeDvjKl5/Mbnh7+nR4Lb/FLH/Qy5w2TuEgaBMrt1NH//X tQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3mtd4c9542-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 15:17:41 +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 305EPKX7033733; Thu, 5 Jan 2023 15:17:40 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3mwxkexke8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 05 Jan 2023 15:17:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V+T3uVj0dSw/lH2ZXES1iD5smtFDX6nZIoSBxQS92C2JVsQMaNm1njEEzMjS/9kWh1P39YvrE01QcDYOhuGsu9PA/Rr+AVlSXjMObP11AH05DhyHyAf/2XygbN4lSPfyCCbc1Kw+o1oLRbiI5YF7rfS/aWbOOJGG8JLHAcrTd8xaPmscZGTCXN1uJk1NJOt2yoCbJC2w2NQSg+MjSOL5uyzJME0IFKQ5Si1Vn1+m4j8WxRG1GSWq/q0QTKUodzdh9r8ewqw0hTJ8HEJ6QVros4kPTYeyUKrWA9ywVnH7qe8z35L9sHDxxmd9fNHQmYnhHHDiL86B08q8a0awUjoysQ== 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=kf2FxYLSwP0EI6eMVR2LyhMitN8ghGBJj4oacoLulxY=; b=P3caMEF5fPX4lnyypZrymGGQgLtq+eALpxiT5Zm0i2WpfIxaTdFx5WBA8lVJc7CqoSAtQnCAe9ehrNiJDjuFtQC16omjE8lSccz3vpP4N/Wf0psNtV92poB/L9gAqzoZhvnWezyrhK6dWoNqQNBg4iEE3Tb4E5XD21FlRagXk7zNh8cdiZBgYDXLUM4jLtcsBsZWNKqT1R79Y+929tguky9ijxLG1iHFkqY0+oClu04r5rdw1JfRiG5iWUyDT+ZUewHz7PqbdP3TtYsnvy5SYVn/dPhLS6ML52BjV7AZOlrkoUxQgIT2HRrGagyF4mTrSwwTG4UTnL+HN3e0mvbV5A== 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=kf2FxYLSwP0EI6eMVR2LyhMitN8ghGBJj4oacoLulxY=; b=gJ/dFnTV0cExaGP8btTv+tIuBeVKdAGDlpem+1+Lf5DX9F1BrCljnM6R+/Bv5t48BF8LBlzUa5D8byuM30guCA6S+QmOSoWRxKRhu+OnxTOR1Pc9FsDwruFvQA5rB/fy8lOW99Zcld3v6pKL0/nQvpFpE9+1atcD7getzxwgukQ= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by DS0PR10MB7406.namprd10.prod.outlook.com (2603:10b6:8:158::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Thu, 5 Jan 2023 15:17:37 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::e301:fde6:85e5:b45a%5]) with mapi id 15.20.5944.019; Thu, 5 Jan 2023 15:17:37 +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 v16 7/7] x86/crash: add x86 crash hotplug support Date: Thu, 5 Jan 2023 10:17:09 -0500 Message-Id: <20230105151709.1845-8-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230105151709.1845-1-eric.devolder@oracle.com> References: <20230105151709.1845-1-eric.devolder@oracle.com> X-ClientProxiedBy: DS7PR05CA0020.namprd05.prod.outlook.com (2603:10b6:5:3b9::25) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|DS0PR10MB7406:EE_ X-MS-Office365-Filtering-Correlation-Id: 32d1bc42-988f-464d-12c6-08daef2ffa8d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zbhtawma5kTxwX5GQoNVSqGT9FHbyCNqNG5Y/MZJsrKxyobn0pWARcLyqts5xBMvJ27Lq2am6e/GUqom+ivyUZH3Mc6W0u1+xacoW563EO2e4Zqz/oSU5eAVXhSdN0/CvfqZD59TGrEz4n/+gqiNXmwxTOAxkKyyWPdroAtm10v0KBH2Zb+v7SNEzJ1ms/L/cNGRkaTlPK0nfykxAPX8NttcWE3YH7xnTIrmznyUEHkPCUYBb5d0bxBkbSL3XpdJOusd9mq8nuIDSiXUgX6G/tZXoGIGECUOvDavQ8fPzwzr1UAiA9QiuSBnM/v2NGmQ+XUsjpCwsJ9EAc9CZOwYKjcWA4GP9tx0NCfyhpH1M2QMEveQujp069W2TaZ/uIYQdkj/+xj6KyyZW0qQeN8KLl+geLyhx9YUYkm6ZzdwL8UV/0RQ491BaHswQaUvnlrRYDfMDfqo/6dyhixe03vExM/mKUzeL9p7UO3NkQM2dDW8JMdaLOnec0idvZ6lQk6kp6c9ivIGzkTkV3X50lmo9IwvDHwR06YuDcVQ+/Uz9BwhB4fAakxN7ltitoEyb1xHApznamGymutN9igLnRVApbNhZV7WY9TIMuENfBjXgygLgxys4ErgZH2h7qAFxE95eP1OPSgpDJxhoIDRbuSv6Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(376002)(396003)(366004)(39860400002)(136003)(451199015)(4326008)(8676002)(107886003)(5660300002)(66476007)(66556008)(6666004)(66946007)(8936002)(41300700001)(316002)(7416002)(6486002)(2906002)(478600001)(6506007)(38100700002)(26005)(186003)(2616005)(1076003)(6512007)(36756003)(83380400001)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Dypo+CJkBDSchHnanw9h9A4IqQnj8AnXhnnEPLivUt8Strzj9UGQ1OIfpHrqm4iwTrpnX4XdjO3T40rFiFJwwn1qbuzg/JET6Ty1/we4fdcUPwOknLGbuiz72lfCYb0aofPzbB8uhIt5sG4tdKMCVWClqUwlgLKD228b/Y8N9B68GUGNoDxLF3fLWP2QiYc4ooPv8i2Cf5g37ErIdwXpsR6bMB4VasQXl5CWVYJ1RmYmwDY2LIND3GNgmgvMEpUByzZLUse+eIv25oTs9512c/8xc+trcIi+7YiD3firtEc9umJkSvjNX70dCsq3dpT3lFTqjbeTR62pCoHK60zFvLWdcncZDDBqmsYW6RaMGp+pMuZQ9Dpg9BSeLdOw2GosU2YmL1j8Dgw2bWnMzTDw3jiA0n50u/uNJJvQorbpY6GbIumTZVkSoq4z4Wuj27AVKkWGwJV0+lSFu5maEpi54c7RDNba0QiXXhUHPUesBD4wxLMsfB9otlJ3SjJUWZ7y31lyqImkGxlRoEQikgP//P8T1ovaE1bnGRF0z541JE61VA80NXuiqm4MDpEx1vCR4C3smv9GxVxN1uhyrCHyopJtRC6eWnJstFj3Mn/wBJvz+GUPRE+CBHnQEpuN+J8yiwSxJ4ugcGGmNWu75sXvLe/Lfe1QfJxDRBeKGLVAPkeYWQzWNk2I+GktxZX3ia6b2Jz9PRYQy+BXaanoOxlWWX7KBOe/BIPd3WUnmGanuxlJsdCInW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i716hrX/EGo5DTN8SNV3b7CMM4Bc0wl475MtWVP3vEiYMxY6zfWBC9mgcg0qCcoj7l004kMFNw6CCs1+uYI/v7hDio73tHRC6GTqibU23Lnc1tbqe6Pi0RwMazkpqL3fqTCvgqjxmxxz1nBTVqAUgw8xGqcTqRqfNOyTuokA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 32d1bc42-988f-464d-12c6-08daef2ffa8d X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2023 15:17:37.4584 (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: XIhnECzn5M80pFPy7v5LkEKIur1qby30HJhaKRTuPgFpV2lGlbLBUMVsHUSywLHxwBRCwVa5QPOCF7A7ckfMApzHAGMLhVmjk5XnjAvLb70= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB7406 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-05_06,2023-01-05_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301050119 X-Proofpoint-GUID: HUeNc3H9Ley_o-CKcIfugSH7jkQUR6jl X-Proofpoint-ORIG-GUID: HUeNc3H9Ley_o-CKcIfugSH7jkQUR6jl 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?1754196558204658898?= X-GMAIL-MSGID: =?utf-8?q?1754196558204658898?= When CPU or memory is hot un/plugged, the crash elfcorehdr, which describes the CPUs and memory in the system, must also be updated. A new elfcorehdr is generated from the available CPUs and memory into a buffer, and then installed over the top of the existing elfcorehdr. The segment containing the elfcorehdr is identified at run time in crash_core:handle_hotplug_event(), which works for both the kexec_load() and kexec_file_load() syscalls. In the patch 'kexec: exclude elfcorehdr from the segment digest' the need to update purgatory due to the change in elfcorehdr was eliminated. As a result, no changes to purgatory or boot_params (as the elfcorehdr= kernel command line parameter pointer remains unchanged and correct) are needed, just elfcorehdr. To accommodate a growing number of resources via hotplug, the elfcorehdr segment must be sufficiently large enough to accommodate changes, see the CRASH_MAX_MEMORY_RANGES description. Signed-off-by: Eric DeVolder --- arch/x86/Kconfig | 12 ++++ arch/x86/include/asm/kexec.h | 15 +++++ arch/x86/kernel/crash.c | 112 ++++++++++++++++++++++++++++++++++- 3 files changed, 136 insertions(+), 3 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 3604074a878b..09e9b7a091ed 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2119,6 +2119,18 @@ config CRASH_DUMP (CONFIG_RELOCATABLE=y). For more details see Documentation/admin-guide/kdump/kdump.rst +config CRASH_HOTPLUG + bool "Update the crash elfcorehdr on system configuration changes" + default n + depends on CRASH_DUMP && (HOTPLUG_CPU || MEMORY_HOTPLUG) + help + Enable direct update to the crash elfcorehdr (which contains + the list of CPUs and memory regions to be dumped upon a crash) + in response to hot plug/unplug of CPUs or memory. This is a much + more advanced approach than userspace attempting that. + + If unsure, say Y. + config KEXEC_JUMP bool "kexec jump" depends on KEXEC && HIBERNATION diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index a3760ca796aa..1bc852ce347d 100644 --- a/arch/x86/include/asm/kexec.h +++ b/arch/x86/include/asm/kexec.h @@ -212,6 +212,21 @@ typedef void crash_vmclear_fn(void); extern crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss; extern void kdump_nmi_shootdown_cpus(void); +#ifdef CONFIG_CRASH_HOTPLUG +void arch_crash_handle_hotplug_event(struct kimage *image); +#define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event + +#ifdef CONFIG_HOTPLUG_CPU +static inline int crash_hotplug_cpu_support(void) { return 1; } +#define crash_hotplug_cpu_support crash_hotplug_cpu_support +#endif + +#ifdef CONFIG_MEMORY_HOTPLUG +static inline int crash_hotplug_memory_support(void) { return 1; } +#define crash_hotplug_memory_support crash_hotplug_memory_support +#endif +#endif + #endif /* __ASSEMBLY__ */ #endif /* _ASM_X86_KEXEC_H */ diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 9ceb93c176a6..76e2431dec63 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -42,6 +42,21 @@ #include #include +/* + * For the kexec_file_load() syscall path, specify the maximum number of + * memory regions that the elfcorehdr buffer/segment can accommodate. + * These regions are obtained via walk_system_ram_res(); eg. the + * 'System RAM' entries in /proc/iomem. + * This value is combined with NR_CPUS_DEFAULT and multiplied by + * sizeof(Elf64_Phdr) to determine the final elfcorehdr memory buffer/ + * segment size. + * The value 8192, for example, covers a (sparsely populated) 1TiB system + * consisting of 128MiB memblocks, while resulting in an elfcorehdr + * memory buffer/segment size under 1MiB. This represents a sane choice + * to accommodate both baremetal and virtual machine configurations. + */ +#define CRASH_MAX_MEMORY_RANGES 8192 + /* Used while preparing memory map entries for second kernel */ struct crash_memmap_data { struct boot_params *params; @@ -394,10 +409,37 @@ int crash_load_segments(struct kimage *image) if (ret) return ret; - image->elf_headers = kbuf.buffer; - image->elf_headers_sz = kbuf.bufsz; + image->elf_headers = kbuf.buffer; + image->elf_headers_sz = kbuf.bufsz; + kbuf.memsz = kbuf.bufsz; + + if (IS_ENABLED(CONFIG_CRASH_HOTPLUG)) { + /* + * Ensure the elfcorehdr segment large enough for hotplug changes. + * Start with VMCOREINFO and kernel_map. + */ + unsigned long pnum = 2; + + if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) + pnum += CONFIG_NR_CPUS_DEFAULT; + + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + pnum += CRASH_MAX_MEMORY_RANGES; + + if (pnum < (unsigned long)PN_XNUM) { + kbuf.memsz = pnum * sizeof(Elf64_Phdr); + kbuf.memsz += sizeof(Elf64_Ehdr); + + image->elfcorehdr_index = image->nr_segments; + image->elfcorehdr_index_valid = true; + + /* Mark as usable to crash kernel, else crash kernel fails on boot */ + image->elf_headers_sz = kbuf.memsz; + } else { + pr_err("number of Phdrs %lu exceeds max\n", pnum); + } + } - kbuf.memsz = kbuf.bufsz; kbuf.buf_align = ELF_CORE_HEADER_ALIGN; kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; ret = kexec_add_buffer(&kbuf); @@ -412,3 +454,67 @@ int crash_load_segments(struct kimage *image) return ret; } #endif /* CONFIG_KEXEC_FILE */ + +#ifdef CONFIG_CRASH_HOTPLUG + +#undef pr_fmt +#define pr_fmt(fmt) "crash hp: " fmt + +/** + * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes + * @image: the active struct kimage + * + * To accurately reflect hot un/plug changes, the new elfcorehdr + * is prepared in a kernel buffer, and then it is written on top + * of the existing/old elfcorehdr. + */ +void arch_crash_handle_hotplug_event(struct kimage *image) +{ + void *elfbuf = NULL, *old_elfcorehdr; + unsigned long 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)) { + 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