From patchwork Wed Jun 28 18:52: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: 114013 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9140382vqr; Wed, 28 Jun 2023 11:58:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6h7p0s1A6x6lG/st6e4fP6607RlTJDXfgyMh/aOxfuzLqec9+P7qEmQwKDdJ+sJKYilSG/ X-Received: by 2002:a17:90b:2dca:b0:263:ed7:3574 with SMTP id sk10-20020a17090b2dca00b002630ed73574mr7613068pjb.1.1687978691287; Wed, 28 Jun 2023 11:58:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687978691; cv=pass; d=google.com; s=arc-20160816; b=JtW/U8Fx/eTlimPhziOKSDvK/W9u1cweZEvvfA2VbXbnZtxbforsC3sD/3lCU1g6Vv p4np7GunYvxPQB9Fk5VDrgK2F3zmvmjp4BKilNkJV1TSXb4FulbjTKwpl6Ougn3hfPat dGViYKQIO3IsoijkhG85deDftElMs0ZtLJkG5lz49brLkM5Q6bn0MK1L9kzvoI5sKzFD k6OvM2Zap3O4RXHqcxXgLqw02wFHU1KZn7Ugm/BZE/PN89LL7/xXdGc4zIpq5EkTNgXq NgEZJrzGVqGWvrdWyK6lDvuuv9I8BzuW2D+lOipZyvBTWIOc6HaFMyMBWo3XrLw50aMh BWLQ== 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=dQejAYGv2H1JUTWNdtQZvoo9JVQ3oX0sh3+sTuDyzRQ=; fh=j+K5GuuLTbxxisV+wJRNZBqbr6zhGMwAghI8ANXi4rw=; b=bStO8PWiq/Sgie5NgsaQqI/E1FO9aJZYLQkp22dNfwnIyEwRXb5UL7YyEDiMXmkbRN omxFzG/8hVPeGpGa5NVJtMGgErYpgr+9Udho84Ed63VNzNxX3nFgQPZrHyxHzwW9NzQ4 qUlFjV7Ekot25/c5vY4fxdyvi40DLE8oDwu4HAWXWu9byOrZtMAI+jGx26ngbS1NfoWR 1jYUgzl+tkXZbzH4JBMeF8ZNsBqVJa6/H6Q+kFvtFxp0XjHVn7t9Gb65HbL4Nr1iPjVS aWXL4u+ayQumh3d7o80POBqeibpdbsO5t0vswv6eNJTWHsfAFK+S4RDZ4C68xNxlkeK+ yH7g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=HombQ+eN; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WsIme2Fn; 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 h9-20020a17090aa88900b00260b6ace91dsi11319013pjq.44.2023.06.28.11.57.58; Wed, 28 Jun 2023 11:58:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=HombQ+eN; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WsIme2Fn; 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 S231598AbjF1SyO (ORCPT + 99 others); Wed, 28 Jun 2023 14:54:14 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:60978 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232259AbjF1Sxc (ORCPT ); Wed, 28 Jun 2023 14:53:32 -0400 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 35SGx6o8006757; Wed, 28 Jun 2023 18:52:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=dQejAYGv2H1JUTWNdtQZvoo9JVQ3oX0sh3+sTuDyzRQ=; b=HombQ+eNOPsqPghdQwD6thsZEeQjBiNmyG7EnLYBSPmnRceKKM0rrWqA3azxZwlnTKkb uGokOVCSpAlk0HHNKzZDcviB4+fWRKKc6FBfuJsfS6IMmmZZjAz7PhfjAfFrb4CLRLpG Nph2Zf5bfo5QsApVU3b73ommvlDe/vTb/fBzYrVDfWDm23ozSxO68MhMjmEGjfBryFts x9oieIqm3qKvGc0Aw/sd3HbNi9GWB/tPrj2QBPUjgP4cceY/8a5tG6Yfhga3fQI5kqgd VAV7IiNH0N7Cr+pmszMw6dBV9zND20f2Q6SUkD1s/hgt/z4JCcReIQFVCBv83Dzx83BK qQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdq310pef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:32 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35SHe4Ke004035; Wed, 28 Jun 2023 18:52:30 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2103.outbound.protection.outlook.com [104.47.58.103]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxce4mc-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C/33d++ySfunQFmTRdjPxGkX6dvU+ACzwnUMSvlicKP7/vxJosmCwoL2RjWnpBsHgX+HiqEKBF6TnovZj5EaDPpm2pEeBddoqB0QEDlPjIWJWeBHTBs7Cw41xuqiBlaiQekKLf6KQgZnXpaq2XgL3P75t13cbbVxef63a7IfX+DOZPTpDP9MYeNiByTptqkpv06jEnBE9AENGriCTMp4W15AIo2OnyL6zSF2gLdvDqES4yqmNxoCstQuXScBKRDiBkssbnjjlhb5dwtFhMQL7u3KIjC9TeS7ueiqMIigKV2wvwoun5/zJhWExi+01UAnkjwzIg3Cq2/4Jul23joX5w== 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=dQejAYGv2H1JUTWNdtQZvoo9JVQ3oX0sh3+sTuDyzRQ=; b=D9hQfYzOxV1x8kor0GnF/J+P69ER14i2f1jf21RXSg09cakDCrkGvE7ggp0BYGEYHnXEp27+8Egd1eeoepSxA8qdOd0pjGnvVyU00xeSzmiBPkx00b608IBBN+c3idU/l88aKOvBIPGDZ+Ehz3PIHWRThlbVm1sTGvnuGq6XaItFFwCrQC+14Oo7TQPG8hd8rL9gaFx0VneSOLnpYSnP3GlRY7Wlx/DkJxfB2AtaJSSuRg0GfxUvHi93lluUVvv8Eq0bMyNiBu/n2rebmVYoWpJYblU+eNHu+rfCafHlt4Kw8PWrYnsJrMC+ABqt3eAg1OjLnnpOHvtvVPLV8KGEJw== 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=dQejAYGv2H1JUTWNdtQZvoo9JVQ3oX0sh3+sTuDyzRQ=; b=WsIme2FnQ9GzwhcnmcbqVkqCyjDBeC2ed5lectcqbnpsJ/rn++70gPFnyWAvVHPlVqR0u5oq3btxnhwTitxdB8J+SEM7epjgYc97M39l3KVZZbg6nFcWj4aR9En1T9NjU06SPEWrYc8F+ZShKhraj92X8L1c4M/xdfCPWPGh5NY= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by LV3PR10MB7820.namprd10.prod.outlook.com (2603:10b6:408:1b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 28 Jun 2023 18:52:27 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6521.024; Wed, 28 Jun 2023 18:52:27 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v24 01/10] drivers/base: refactor cpu.c to use .is_visible() Date: Wed, 28 Jun 2023 14:52:06 -0400 Message-Id: <20230628185215.40707-2-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230628185215.40707-1-eric.devolder@oracle.com> References: <20230628185215.40707-1-eric.devolder@oracle.com> X-ClientProxiedBy: SA1P222CA0007.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:22c::22) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|LV3PR10MB7820:EE_ X-MS-Office365-Filtering-Correlation-Id: 1aa4aea2-2df9-4640-a24a-08db7808d1ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9+eWqSd0sy/pq0RONHW0oOz12baVBf/3tA1Oft+a0v5lij7YM2nf0YfFA9b59cTBGS1CyL75vaWccnSt8g6j9sFA3CsGBZI+BVKwCnU+8bWbhGiHTZKKJMI4bpn7k2j6/f+NCwJbKpkhkzYoEs5fGXWUf+7kWTb9JSJNlvUJz5Q9NXo6fkaZdUAnsS3CYHpAo4eVlNJMo/rZMpucEUF1LmN5qNjE8fXL6viLRxK6VN6APAa4sZl8R/+ZCrdwltoKeBXqbMwLoNKxg1I+4/J8DpzprbzCTW1Hy8W6FuOI0L6vplaF7/jnSxEQemBaiZdD09wi6NX/mGVGjkWit9+QRO54JY21/+Yiw8b+RilmUDsrUOK+TiXZEpjjUrWGdLCwsVII5cb0Is6G9WDDCWjVYPgtoQV+1DMD5l59XflgCdOILJG/0bDbZfdgfFLDcDVwe643eqnlNzIvPk2pTpgYnNUAsN9qRupFtxDyl1aMD5RorUfDhEJOTwISigOPIisjYQp6iXguYGF+1qByg6BI6w66jhFLaxtnA2CFDnA/4vkNt3dPaEopqky+/Qa0RtfriVcewFugtOkoHzzLOyX5SBtstxQUazGtivKE5OByiWCyGHFZmlXs/gHmEz9DXTWw X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(2906002)(83380400001)(316002)(26005)(6506007)(6512007)(1076003)(6666004)(6486002)(186003)(478600001)(86362001)(107886003)(921005)(2616005)(66476007)(41300700001)(8936002)(7406005)(7416002)(4326008)(66556008)(66946007)(8676002)(36756003)(38100700002)(5660300002)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mq3drL/U4UjBiuoIpOg+pJ5ctcfc1o6YTxu1x2j75t9ZDxQNo4170nX0HaIHKjSILMAVS3yag6OGTU5SJanpQ1GQ2vfEssfmg/ou2Caac2eAqFoXDpuv0jFjvup+yPvnT6hqNZH1ODxdR8h31KS0zYGsPoPG8jhG11rWnICjZKC3banepKkJ5pK3whmsuxuZQp8XZ7eX5Bp5BshcyRIpdqyJFnCrMkCWn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CKoSLGGRmkpiwQD5qdXB73lUQgfKQbzVaOFnbSRxUwrgaxtFiU4TGOSUn1bQmLIOHstJEE5KizzgfVFNBhZYfxoUTSn8efXISGH4WIaZN6aMDIWLs8zkkyRmiySUvZPG47FIApYWvzPAvv0Y15vOaGGJ+L7Pwgk4uVWXPgdKkZHgOlPX1AfyWlrOOvh1MF9IAMcNs7xsj3hjNnU+oDP2WtK4axuzAqpP7/q7Ek8Iet6jlKbU81hT/pWyx4h6A0P3E6B4q5n+N1OBPFdwuGenOjwjkMoEJy+/gC7hXSfimYQZtqfZ/jiFOTznGLBzeeZftzn2ZQC5N7uqWhsA/dGYM5oDth9Xa/rkG+t+Lpt3DwPLwF9AeZXsk67iCENyhOazMUmHsJCl1ViRMMVs2830NrNUrG8ElEXlRt8TOhcPegWFtCgykKsnsoSvZvsTnm01gprMcL8GUp+h04GyxDaj3wP7nFk8C+/cqyx9tY6kLVnK1H02fepJQgJhehBXE/4LYR1kuTOyAXmGWHVG3xsPmqpkPh6q4hamCH+AS5XF/8/qBtsD0h3Ks2/f0EwJOMjA6bGXy1XMtpCXXrBW82k66Uc3rXCzVCsM1sadxsP2IYJTRukuAqNKJHUZy6Q2eg18fgpxwAU89q4AOm/Kp7CakOmuqOsFLCJeofEqjJa6d7iMfxzSWciTDhYMAOqTFwxJCpkm8NLQ3H4A60yDD4jC++ohTofedVGzq98QB0rwbwklNJYWB9aC1BCtlaPOeT9HcPRc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1aa4aea2-2df9-4640-a24a-08db7808d1ab X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2023 18:52:27.6903 (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: IcdwKapL7HyiDgESvQl5GsFgMPIqY9BCOiLroShHr1HpKIWw77EssmSurKac3mc2ZGiopKhh2fikCwTtyCmlK2/LeY98uIvIERguDhjXj0Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7820 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_13,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280168 X-Proofpoint-ORIG-GUID: oEXffXnd2Y81TX2BViXK3FOWUDQGyxbc X-Proofpoint-GUID: oEXffXnd2Y81TX2BViXK3FOWUDQGyxbc 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?1769973944083730427?= X-GMAIL-MSGID: =?utf-8?q?1769973944083730427?= Greg Kroah-Hartman requested that this file use the .is_visible() method instead of #ifdefs for the attributes in cpu.c. static struct attribute *cpu_root_attrs[] = { #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE &dev_attr_probe.attr, &dev_attr_release.attr, #endif &cpu_attrs[0].attr.attr, &cpu_attrs[1].attr.attr, &cpu_attrs[2].attr.attr, &dev_attr_kernel_max.attr, &dev_attr_offline.attr, &dev_attr_isolated.attr, #ifdef CONFIG_NO_HZ_FULL &dev_attr_nohz_full.attr, #endif #ifdef CONFIG_GENERIC_CPU_AUTOPROBE &dev_attr_modalias.attr, #endif NULL }; To that end: - the .is_visible() method is implemented, and IS_ENABLED(), rather than #ifdef, is used to determine the visibility of the attribute. - the DEVICE_ATTR() attributes are moved outside of #ifdefs, so that those structs are always present for the cpu_root_attrs[]. - the #ifdefs guarding the attributes in the cpu_root_attrs[] are moved to the corresponding callback function; as the callback function must exist now that the attribute is always compiled-in (though not necessarily visible). No functionality change intended. Signed-off-by: Eric DeVolder --- drivers/base/cpu.c | 67 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 14 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index c1815b9dae68..75fa46a567a1 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -82,13 +82,14 @@ void unregister_cpu(struct cpu *cpu) per_cpu(cpu_sys_devices, logical_cpu) = NULL; return; } +#endif /* CONFIG_HOTPLUG_CPU */ -#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE static ssize_t cpu_probe_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { +#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE ssize_t cnt; int ret; @@ -100,6 +101,9 @@ static ssize_t cpu_probe_store(struct device *dev, unlock_device_hotplug(); return cnt; +#else + return 0; +#endif } static ssize_t cpu_release_store(struct device *dev, @@ -107,6 +111,7 @@ static ssize_t cpu_release_store(struct device *dev, const char *buf, size_t count) { +#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE ssize_t cnt; int ret; @@ -118,12 +123,13 @@ static ssize_t cpu_release_store(struct device *dev, unlock_device_hotplug(); return cnt; +#else + return 0; +#endif } static DEVICE_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); static DEVICE_ATTR(release, S_IWUSR, NULL, cpu_release_store); -#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ -#endif /* CONFIG_HOTPLUG_CPU */ #ifdef CONFIG_KEXEC #include @@ -273,14 +279,16 @@ static ssize_t print_cpus_isolated(struct device *dev, } static DEVICE_ATTR(isolated, 0444, print_cpus_isolated, NULL); -#ifdef CONFIG_NO_HZ_FULL static ssize_t print_cpus_nohz_full(struct device *dev, struct device_attribute *attr, char *buf) { +#ifdef CONFIG_NO_HZ_FULL return sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(tick_nohz_full_mask)); +#else + return 0; +#endif } static DEVICE_ATTR(nohz_full, 0444, print_cpus_nohz_full, NULL); -#endif static void cpu_device_release(struct device *dev) { @@ -301,12 +309,12 @@ static void cpu_device_release(struct device *dev) */ } -#ifdef CONFIG_GENERIC_CPU_AUTOPROBE static ssize_t print_cpu_modalias(struct device *dev, struct device_attribute *attr, char *buf) { int len = 0; +#ifdef CONFIG_GENERIC_CPU_AUTOPROBE u32 i; len += sysfs_emit_at(buf, len, @@ -322,9 +330,11 @@ static ssize_t print_cpu_modalias(struct device *dev, len += sysfs_emit_at(buf, len, ",%04X", i); } len += sysfs_emit_at(buf, len, "\n"); +#endif return len; } +#ifdef CONFIG_GENERIC_CPU_AUTOPROBE static int cpu_uevent(const struct device *dev, struct kobj_uevent_env *env) { char *buf = kzalloc(PAGE_SIZE, GFP_KERNEL); @@ -451,32 +461,61 @@ struct device *cpu_device_create(struct device *parent, void *drvdata, } EXPORT_SYMBOL_GPL(cpu_device_create); -#ifdef CONFIG_GENERIC_CPU_AUTOPROBE static DEVICE_ATTR(modalias, 0444, print_cpu_modalias, NULL); -#endif static struct attribute *cpu_root_attrs[] = { -#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE &dev_attr_probe.attr, &dev_attr_release.attr, -#endif &cpu_attrs[0].attr.attr, &cpu_attrs[1].attr.attr, &cpu_attrs[2].attr.attr, &dev_attr_kernel_max.attr, &dev_attr_offline.attr, &dev_attr_isolated.attr, -#ifdef CONFIG_NO_HZ_FULL &dev_attr_nohz_full.attr, -#endif -#ifdef CONFIG_GENERIC_CPU_AUTOPROBE &dev_attr_modalias.attr, -#endif NULL }; +static umode_t +cpu_root_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int unused) +{ + umode_t mode = attr->mode; + + if (IS_ENABLED(CONFIG_ARCH_CPU_PROBE_RELEASE)) { + if (attr == &dev_attr_probe.attr) + return mode; + if (attr == &dev_attr_release.attr) + return mode; + } + if (attr == &cpu_attrs[0].attr.attr) + return mode; + if (attr == &cpu_attrs[1].attr.attr) + return mode; + if (attr == &cpu_attrs[2].attr.attr) + return mode; + if (attr == &dev_attr_kernel_max.attr) + return mode; + if (attr == &dev_attr_offline.attr) + return mode; + if (attr == &dev_attr_isolated.attr) + return mode; + if (IS_ENABLED(CONFIG_NO_HZ_FULL)) { + if (attr == &dev_attr_nohz_full.attr) + return mode; + } + if (IS_ENABLED(CONFIG_GENERIC_CPU_AUTOPROBE)) { + if (attr == &dev_attr_modalias.attr) + return mode; + } + + return 0; +} + static const struct attribute_group cpu_root_attr_group = { .attrs = cpu_root_attrs, + .is_visible = cpu_root_attr_is_visible, }; static const struct attribute_group *cpu_root_attr_groups[] = { From patchwork Wed Jun 28 18:52: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: 114003 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9139773vqr; Wed, 28 Jun 2023 11:56:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ZVvgAVJEfTKq79Vmg1ZIQtzgCRbASbQ3AJc9/PDR8ogeJmSSN0/74mhbmEd2WEdqdvqlg X-Received: by 2002:a05:6a20:244c:b0:11b:3e33:d2f3 with SMTP id t12-20020a056a20244c00b0011b3e33d2f3mr43924652pzc.0.1687978619011; Wed, 28 Jun 2023 11:56:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687978618; cv=pass; d=google.com; s=arc-20160816; b=qfIhKTlbV93BsLE6QVu6Lq3d7pP53Ol9WkEnTiyWCrYq1FOeWHtrT1Ng9M6ND4KelA 5I/m1ZjMClsqupL9mMr5UePCKP3vUbo1pf56RXaSlg8UsgoMKwlQ+BPkKoJUT1LxGP0V rdcKTusJSrDPDiFD/bUNLaA9RoB/h6C5/GWaOJHNzug5dJ4JQ2a9q1A8+Z8+QY4S3us5 rqdkfYYViEBVwevRQOYei6cJjJ1KYC/Q0J8GlPW/uDRbAgNWfxXEK1h0d/GvIAET4YbN YyP1CVLU0L2sLUXm4BOaiBYzNIyY4QTsdnWApmx7uVmSmd8X72mJbBrIGIeXWVMQKzKl PIRg== 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=Nlp/oHypkgqILKUkxsjCRnUeHefJfb6/VFa3Fe0IQP4=; fh=j+K5GuuLTbxxisV+wJRNZBqbr6zhGMwAghI8ANXi4rw=; b=J4u1rrJlBd6hGylCop1k1cpMlt/J/4d2w0OvRPT10F6Mf4xjqv+cToJqI8j3WP1nTn 06eMcRyAWvI3q6acRXYSEfFwYiGjX7qXA+38j/TGlTNzT//1w87PnollbFpjXLNReYnT 5BUENH7RtF5ofJBAgwuk/pqC7zd20jlObbxunomcc8iMryuJ1f+Hh7Dysz0ycFTsL57/ 4ei0JEhe58t9VUs0vhAr4LqoNZGHu6Ag+Z0tMr0l7TdFyJU2I/SEqBIpI3+C404FPB4O wvQr3ivqnSrIJDsLK97+Hzbr9NXI/vgx7zzbDSvcAHD8O/2fS1ee7yxaZ/Fy37Qd9SN9 Djaw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=wEDojz5E; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GA8eWVcf; 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 fi30-20020a056a00399e00b0064d533abfd4si9530072pfb.189.2023.06.28.11.56.45; Wed, 28 Jun 2023 11:56:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=wEDojz5E; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GA8eWVcf; 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 S231346AbjF1SxT (ORCPT + 99 others); Wed, 28 Jun 2023 14:53:19 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:37092 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231916AbjF1SxQ (ORCPT ); Wed, 28 Jun 2023 14:53:16 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35SGwlru011815; Wed, 28 Jun 2023 18:52:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Nlp/oHypkgqILKUkxsjCRnUeHefJfb6/VFa3Fe0IQP4=; b=wEDojz5EXTZD9bYL4oDmK+Z6WGFb+A3H/lYaWc0gt7UOV6qavrq/dwQqz+GP4TWJ2z9/ im4MwaWaj8UFfo/TJvsSL05l76dRtgEIDitmpbAh7ksD58YPStLAonWbB1Lnu9BFry+u CBMvs9eSUK6Wrw5IUJdmKD7W0wqByOh3fQM4XM1czBi630Q+kaeYcy59yDRnFgii1YGW 7JGHSVfMSg/lQELXhuvghz69cQaC77kvmwVKcisMMOPTf15PrfUZMR0LN+vMDBuGlqIu qpUh1qWzCKHZ4REeX0/EQsdqB9GLTWhghrNPxYzavIEcSaQDr1ge6VMXMImYeo8H5kR+ nQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdq938me7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:34 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35SIAF0N019910; Wed, 28 Jun 2023 18:52:33 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxc6cs4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hRBaetnxKKQp16askjhdKNsw/z5/+vPpD/4818cWZo7tEFkP58IJMuGp4xOJPNoVT06k3YwSZYAS+YwZ0xEuni2umvGCYlnDBsHAoEgvlh6WzYdQo7XW3tWmQi3CH7gS0OeYKvLXXdU5fChUZ7AHYYY1f0uM0x0Y4R9l4CluNm3uHKfNwsksFtg+BSEZMvbp+QUQ6MwhcPZrg0tukBAt7Q4DXLpG9mNKpMgedWJeNXEG1XMSqyGBxH+nEJhNISMugEXii3Jj4I201ibVkc6X11jHaiQcn9B1HaJ/hbHZohR+qDTIsNqxnfV84JuTtXWaK3UTGkcdo5AfMVQ9vmfnJQ== 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=Nlp/oHypkgqILKUkxsjCRnUeHefJfb6/VFa3Fe0IQP4=; b=PmNdQ/ThdzVQfNdxP3VWOOeK4j7Ic2xEDc05r2NuFrU0GBn5vp6k245Py+CGbP0mgtzBQx8oZELXQM7xEn3SGLriEtDb9EOG4oOQkI+HLk8PD8z1BlpIiCE+JvYj3slCE4D1yEle/QzpKu0+mwAKNtecTRlItGa3HAwYn6xawxIKM9BnqcwgTyu9hZpWxPiHpYsJAs5rKIiNZVjTP0LCZB9e1S+9QbXaeCb1f8n1RXy4ERlpy/mOxm526/y43GETLziYT0LTsN1N9juFPahVDYxM1EIaNPBJ3HEoz2tFzrhyWYjv4m4Y3mE4gpbWRHxEuW7zJeE5ofcspzsQTcG4Gw== 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=Nlp/oHypkgqILKUkxsjCRnUeHefJfb6/VFa3Fe0IQP4=; b=GA8eWVcfriY0UOBZC8Lz6w6JmCn78MsjrtwVmoayL7Gz33cLfUqjZA3kykZHn+IHAHjacWQyEQZ4UTbYSbFyvCJuEfefI42/ZCTOu85S2DgP1TDJQtFPoHnoxwqP6v6w6y/fyvd/0k6ffwLK0n1dS2yb/rLk3OotTHF9VK0nADE= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by LV3PR10MB7820.namprd10.prod.outlook.com (2603:10b6:408:1b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 28 Jun 2023 18:52:30 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6521.024; Wed, 28 Jun 2023 18:52:30 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v24 02/10] drivers/base: refactor memory.c to use .is_visible() Date: Wed, 28 Jun 2023 14:52:07 -0400 Message-Id: <20230628185215.40707-3-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230628185215.40707-1-eric.devolder@oracle.com> References: <20230628185215.40707-1-eric.devolder@oracle.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|LV3PR10MB7820:EE_ X-MS-Office365-Filtering-Correlation-Id: 31af01ab-f988-47d9-40d3-08db7808d343 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZY0pl8kacdguKCc6ErHusyUYZHjwavz/+DZ6xiuj4hZ57L6LVnqNLRDjaKgezJcaShFI09xDvPAJisV6j7cBfWS/2GoxK6OeVNeceTHxhIyivKceicC6/2vOHjD5x9yLRspRRNbTeZl/iixzTZbpY7LWrRHjsPMVimHbsRiwaee24nG5clyMeAxCgYP06GGY6vD8OJXPc+HR+KHHG62aov4+HtIzGe2w+elgTQEyqeDY3Z0GfVr/tngs1gkX12F9km/2GLvGLva4xi8/mch/QeHvVAdN8AQPa6IDwOt/SYOpWY7T6Tq+ib78tWWb9YONCVEJfwJYn2foOzGyApUHvwJhs6lMMYydrbz5rXVOfqyTbZcEMp3fG7RH+5hreC42AOzLXf/1+UmJKncvVEwYa9dTazYPhgYVEck9hOU1KXLcZxCAYZY67COu3fp9JdkJwBY/Tz8Ekq+3mqiOvMRUdyp2xE9+t4KnvbzHNWdU3ejGnyJwrsDe1d9bih/iSqfnzhwcJQGfdqvQblQ/pmEz2pA7xyE3Ua64ncwFQ3peGaUP+qZ6PlJ+Qbpuf0rqj0GgPK7gTnybOwNsTx1whgj3ZI/PNC7Nvl4m0c+XJwLWWs0HpM6OUea0MO74wVd5dw6S X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(2906002)(83380400001)(316002)(26005)(6506007)(6512007)(1076003)(6666004)(6486002)(186003)(478600001)(86362001)(107886003)(921005)(2616005)(66476007)(41300700001)(8936002)(7406005)(7416002)(4326008)(66556008)(66946007)(8676002)(36756003)(38100700002)(5660300002)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 34tY1uLMlIKWQ3svrmqUzGTts3kIr6IrckEWIAw6shL6QMPzHCpSnT1aC+kDv+0WNuhJ29rbGHerWR1sVb9Pxbji0ZAxMVb4zgP22VUhAiEy6uPXVF9AaB/Jc1DErMz1z8pJQmBH/Ur6CioYDq6OpQ6SpTYQwy+yus2xhtH8ltY4NQbFq/UOKZx3TgOASORncOFs2AKCT7aSA7QDNtgIFhkD0u8wZr7q1/zPK+bQqmPUQTEu4SzeFTsZRH83ltP+FlA5GnE8qmVApa6QdeFSu8X7ZXpr2CKZSQAVACw6Q+T1OTPsNnwHt5HosKoV177bLtCFaDWTmNpZqVrp5sEAwxV4PTolJm6KGB5VLRHz6QVtVByYS3S484lcpHgFWf5tNA2c41GaPqlphPWfvdayW/ZZOaSzZy5JYcOvE7S3Pf/zoXPxk7zlo2vn5aP0o7tHzh4HzLuoSGKMkSgbjd1q+4o6U0VoR66lVnD5gU0bBvGzyu43sqaIgELSddqxWR6sHlUuQWjcJ3bs0U72AiJO3oAei53RUCMZs2r6thHb4SuUzASXNFv/8dADj38/uYUdx8pEFmNiMxXLFVSPv3aqKLlLjm5hYxP3Ua76Dx7RRTl0GVIb4cCJ9BdJhTH4/YqjV5Irxrs9GCqvkM7GkDOR/bkl1SRCgJS3HOugh87a8nMqVKv9sCsHX/7Bngwo0FOxJOLTAVj3XyPZ/6MghXS/WQJ66loqQ0VuxVikv2J+1Cn92ZJ+yZUsPYdL0zSmeGewVA2gOxMvGjAXd7ZDcy4ETd5vrG5LXpvN+wpJFS7t05hDks2aRk1y3Xt8mLcPCU/oJjsTt9Zm5LERFK0OASpQeh7yD4V/ZPKIQ+Cw9PkT4++9/gIwpbkVDFYi1wpSitjxH4l1TifTBPtMxsdJQnfng1qc9wsty80CD5tUnshbW50OBQGsMwn7yvytwVSB762cF5G6V5+4l5KY1Y57ZZ2Ztdccj8umU/dtyURlVUmbNeQmQldOkM50hGi0R0oekRzFutLh8qnUhknXZIelDffGG1DWlKiRRQ2Mr8N24v2MJ86vDiuzzx0LfKUbE77nI6bJwhutfUnchVw2PqsNTivkEhGZq5lNWutcx7kXrCA1K4NCJ/Rj13Y+EFoz+Tgs8WYvCpXhvJWHrM8C3rtLXweFqdWzVDqxS61908coGAU2JfrGCGHsIe+PHEI0EyrgH6GehgeyxERupoDLVq/lDT7O/e6h+p4X0hpth4XTyBUqg5ruIojonurCNIYqfZrlFK4L1JjxAmD36urVogCUerlNvIiajWBv9hW1q5Xhtq44+0LXEpZ2rQwf3no+fb30+R/ae2vP8G+PHkm7bzRRDmHZoBfbL89dakCy0gx5F7TEcvjsNxUBBEqKOe4XNF9zmdHCEGjjoFwGSMqz7JFUIt0h4dtysfvZLYEXlSPpMs6Hffkg7NpXyHBiWxta+03IOoCw9XCl40AAYyElachV3v9YlFBGNDnnq+G8q/VKoL7fz4biKmGeZ4ddcpL5zMQolhxGHVZIOkgix2QBS5MtbBS1Pd9YMIG2fg7jm5/7Mv+CNetVqSnzisxgDzq2/B6N1iZFDZCRt1F+7JJZ/OkYOD6/+g== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: URtZn70u93EDMt5K8iBYG9b1i6pKmF4dtfdHn4qbRrWGH596NgTZX5R/gWoZviPm1EViYVYpBzI1RaqQYpJz91gZ5D3V234gYFeKLZmcpD8G33vqMs/YRVit7yMutp7gDANazLxUSoUb4xfuBvuqDiBwyLXYAqzQY7mGqeqSzx2l9oDgZmK1VB1l+QHU2DxepZgXbQqk+T3tYpFPigo0UYNkl+xQj+JnJ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hJuuY8T+6ArvHpTMUCoA8LZz61YOnqVYGOKgGx5+ZKPLZ2WPalUfL4UQ0FO/fvuwopj7LEOQNPu7viUZgpfcNinSxnWSXc6HQyr51Iv9YpK0LleEYbquRnRC4jSNmOtHUAggD4UqpMgUGqr7tM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31af01ab-f988-47d9-40d3-08db7808d343 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2023 18:52:30.4452 (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: GeboyiBjZ05uQafzkaxyon6u7g6sRF5T2XOSWdWAc21AAb1JcyA8UGYQv67XOHBXUCXBEJhne9hRm6zj+jYIHuNh2/3K5WBsTh/QqdmXCgw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7820 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_13,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280168 X-Proofpoint-ORIG-GUID: Z38sp8V1JUnGnibKTkDYpu9lWibXkn8Q X-Proofpoint-GUID: Z38sp8V1JUnGnibKTkDYpu9lWibXkn8Q 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?1769973868683101691?= X-GMAIL-MSGID: =?utf-8?q?1769973868683101691?= Greg Kroah-Hartman requested that this file use the .is_visible() method instead of #ifdefs for the attributes in memory.c. static struct attribute *memory_memblk_attrs[] = { &dev_attr_phys_index.attr, &dev_attr_state.attr, &dev_attr_phys_device.attr, &dev_attr_removable.attr, #ifdef CONFIG_MEMORY_HOTREMOVE &dev_attr_valid_zones.attr, #endif NULL }; and static struct attribute *memory_root_attrs[] = { #ifdef CONFIG_ARCH_MEMORY_PROBE &dev_attr_probe.attr, #endif #ifdef CONFIG_MEMORY_FAILURE &dev_attr_soft_offline_page.attr, &dev_attr_hard_offline_page.attr, #endif &dev_attr_block_size_bytes.attr, &dev_attr_auto_online_blocks.attr, NULL }; To that end: - the .is_visible() method is implemented, and IS_ENABLED(), rather than #ifdef, is used to determine the visibility of the attribute. - the DEVICE_ATTR_xx() attributes are moved outside of #ifdefs, so that those structs are always present for the memory_memblk_attrs[] and memory_root_attrs[]. - the #ifdefs guarding the attributes in the memory_memblk_attrs[] and memory_root_attrs[] are moved to the corresponding callback function; as the callback function must exist now that the attribute is always compiled-in (though not necessarily visible). No functionality change intended. Signed-off-by: Eric DeVolder --- drivers/base/memory.c | 78 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 13 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index b456ac213610..f03eda7e1c9c 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -405,10 +405,12 @@ static int print_allowed_zone(char *buf, int len, int nid, return sysfs_emit_at(buf, len, " %s", zone->name); } +#endif static ssize_t valid_zones_show(struct device *dev, struct device_attribute *attr, char *buf) { +#ifdef CONFIG_MEMORY_HOTREMOVE struct memory_block *mem = to_memory_block(dev); unsigned long start_pfn = section_nr_to_pfn(mem->start_section_nr); unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; @@ -444,9 +446,11 @@ static ssize_t valid_zones_show(struct device *dev, out: len += sysfs_emit_at(buf, len, "\n"); return len; +#else + return 0; +#endif } static DEVICE_ATTR_RO(valid_zones); -#endif static DEVICE_ATTR_RO(phys_index); static DEVICE_ATTR_RW(state); @@ -496,10 +500,10 @@ static DEVICE_ATTR_RW(auto_online_blocks); * as well as ppc64 will do all of their discovery in userspace * and will require this interface. */ -#ifdef CONFIG_ARCH_MEMORY_PROBE static ssize_t probe_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { +#ifdef CONFIG_ARCH_MEMORY_PROBE u64 phys_addr; int nid, ret; unsigned long pages_per_block = PAGES_PER_SECTION * sections_per_block; @@ -527,12 +531,13 @@ static ssize_t probe_store(struct device *dev, struct device_attribute *attr, out: unlock_device_hotplug(); return ret; +#else + return 0; +#endif } static DEVICE_ATTR_WO(probe); -#endif -#ifdef CONFIG_MEMORY_FAILURE /* * Support for offlining pages of memory */ @@ -542,6 +547,7 @@ static ssize_t soft_offline_page_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { +#ifdef CONFIG_MEMORY_FAILURE int ret; u64 pfn; if (!capable(CAP_SYS_ADMIN)) @@ -551,6 +557,9 @@ static ssize_t soft_offline_page_store(struct device *dev, pfn >>= PAGE_SHIFT; ret = soft_offline_page(pfn, 0); return ret == 0 ? count : ret; +#else + return 0; +#endif } /* Forcibly offline a page, including killing processes. */ @@ -558,6 +567,7 @@ static ssize_t hard_offline_page_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { +#ifdef CONFIG_MEMORY_FAILURE int ret; u64 pfn; if (!capable(CAP_SYS_ADMIN)) @@ -569,11 +579,13 @@ static ssize_t hard_offline_page_store(struct device *dev, if (ret == -EOPNOTSUPP) ret = 0; return ret ? ret : count; +#else + return 0; +#endif } static DEVICE_ATTR_WO(soft_offline_page); static DEVICE_ATTR_WO(hard_offline_page); -#endif /* See phys_device_show(). */ int __weak arch_get_memory_phys_device(unsigned long start_pfn) @@ -611,14 +623,35 @@ static struct attribute *memory_memblk_attrs[] = { &dev_attr_state.attr, &dev_attr_phys_device.attr, &dev_attr_removable.attr, -#ifdef CONFIG_MEMORY_HOTREMOVE &dev_attr_valid_zones.attr, -#endif NULL }; +static umode_t +memory_memblk_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int unused) +{ + umode_t mode = attr->mode; + + if (attr == &dev_attr_phys_index.attr) + return mode; + if (attr == &dev_attr_state.attr) + return mode; + if (attr == &dev_attr_phys_device.attr) + return mode; + if (attr == &dev_attr_removable.attr) + return mode; + if (IS_ENABLED(CONFIG_MEMORY_HOTREMOVE)) { + if (attr == &dev_attr_valid_zones.attr) + return mode; + } + + return 0; +} + static const struct attribute_group memory_memblk_attr_group = { .attrs = memory_memblk_attrs, + .is_visible = memory_memblk_attr_is_visible, }; static const struct attribute_group *memory_memblk_attr_groups[] = { @@ -878,22 +911,41 @@ void remove_memory_block_devices(unsigned long start, unsigned long size) } static struct attribute *memory_root_attrs[] = { -#ifdef CONFIG_ARCH_MEMORY_PROBE &dev_attr_probe.attr, -#endif - -#ifdef CONFIG_MEMORY_FAILURE &dev_attr_soft_offline_page.attr, &dev_attr_hard_offline_page.attr, -#endif - &dev_attr_block_size_bytes.attr, &dev_attr_auto_online_blocks.attr, NULL }; +static umode_t +memory_root_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int unused) +{ + umode_t mode = attr->mode; + + if (IS_ENABLED(CONFIG_ARCH_MEMORY_PROBE)) { + if (attr == &dev_attr_probe.attr) + return mode; + } + if (IS_ENABLED(CONFIG_MEMORY_FAILURE)) { + if (attr == &dev_attr_soft_offline_page.attr) + return mode; + if (attr == &dev_attr_hard_offline_page.attr) + return mode; + } + if (attr == &dev_attr_block_size_bytes.attr) + return mode; + if (attr == &dev_attr_auto_online_blocks.attr) + return mode; + + return 0; +} + static const struct attribute_group memory_root_attr_group = { .attrs = memory_root_attrs, + .is_visible = memory_root_attr_is_visible, }; static const struct attribute_group *memory_root_attr_groups[] = { From patchwork Wed Jun 28 18:52: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: 114005 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9139776vqr; Wed, 28 Jun 2023 11:56:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ61YOyeLYjwqxAmNHBPbBwdpC+wrEl3MDl/iEgwYu2HDQD7zY7ydF85RRjbynCDSa+hSc8X X-Received: by 2002:a05:6a20:8e19:b0:11a:efaa:eb88 with SMTP id y25-20020a056a208e1900b0011aefaaeb88mr44585197pzj.3.1687978619416; Wed, 28 Jun 2023 11:56:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687978619; cv=pass; d=google.com; s=arc-20160816; b=cs6OqPyg4HaotJIFNQt9Z4GbZ1lHHCGibyrHhr3aLAn9Df0JiUSeieCgRTxqC7baqh TNr1GQIdgEb7v0yUhPZYPXlx5wW/AqArdl2AVNzoO1wX7UiGhq5ANwnksymoBoFGcsbI aWLXbJNJJeukw576FyxLu31JQgdnAbzGq36tpPnWbF/7B8qFdatz3zq16MKZ4tPiDt7o ZO9UhH7LyQBL+vSmXNVFoF0ua7VTKp2QN+VdZPwWD2RhnF+/fmggGG6aXIo9Vsit1yIL HAPX4VWIG73yv838mKDlYWjUoU/itjjUuTTrZwzxXJrv0QZiI4coeyf8aUNXwge09b9d nx1g== 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=4JLI7/JunPAOiUTOIZei3N9WOAFJGTtHQ2DxGwPOSkk=; fh=j+K5GuuLTbxxisV+wJRNZBqbr6zhGMwAghI8ANXi4rw=; b=iS81kpPz/QlLptLXHn/mEs2mNKQPMfJEBckf9wS9xXxLPlcFBFgVQ17j3KWExycI/x lf0eY8kkqrHmMhT2Ldg/nwKlEF/tEdJ8RZ082V1NERfRi8T+jlWoy+cy4xDYi1FoE2HA Wu1/eseamXoPYs/A7SoULiW+uzgpXZgJ+rP8MSlfAAWBfVPm2OCWdGml/XRQ7VA3ALDu muV6rKUbaHHqrDEQCcREZMz0doQWSUM/vEH801t9iALWII/eJFtkd4vdR85mSDKmAsYc +CGojXizhXDOLFpqu62lI84iwYlFCc3L2XwNzm04bGn28sP0/xhuwFnCDPR9KZrl6Beh oCtQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=hnG+PxYL; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=zyD8Waio; 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 l5-20020a056a0016c500b0064d3e917a90si9732049pfc.180.2023.06.28.11.56.45; Wed, 28 Jun 2023 11:56:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=hnG+PxYL; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=zyD8Waio; 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 S232235AbjF1Sx3 (ORCPT + 99 others); Wed, 28 Jun 2023 14:53:29 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:39670 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231522AbjF1SxR (ORCPT ); Wed, 28 Jun 2023 14:53:17 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35SGwmDI002032; Wed, 28 Jun 2023 18:52:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=4JLI7/JunPAOiUTOIZei3N9WOAFJGTtHQ2DxGwPOSkk=; b=hnG+PxYLB5svitMuKtsT3iwWyqgDxb/rCPg1cS5LSuolv5TkqaJznLvMCjxwcv2A6GgM xLds+n0L2993GI1PNYgol/qYLlmp4BNhO8uLhxoM2Oq9WIJgPxMDOOh313Fl77QfUPQq 52+byu/0Lo+BX2T9YDvQY5MBrOod585u5iP7iuzzjkw3UK3/0BNhscRaSXuCYsruR4vf GM49LTlijsgFlin34/KVmx0D82Cc0lQNDh9Mf/XCnYpFmw6626agiN2JqHe7CXCPfXWW hBVQoOxBFflrq0BZRCjikOFcUu6X/mn13SldJVetnnVysldKHIbhumfqLgeNbEhpI5cx Jg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rf40e6use-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:37 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35SHZ3Vt008634; Wed, 28 Jun 2023 18:52:36 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpx6dhrv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f+3zmGr4+BJSzJRsA5SMyCoMw6u64H8f2rJdGYRJCddMiGo9wt0iP53OGCfJLQjczuSGoh6mDBPe4Opi0Vjw3gbP2cHdhgImnLL/NPuUSjsF4UK9eTn35z9vHvBMW27Dx5NbcaTI3A3GPtjcnoZBgXWEjphAkeuZK0MoBCSu3kYb8JpNBuu544TB5L/CfKQVg2DircPaoE4Vn0I/aUiRHEEHqkgTRG3hilRY7fco6AEj9oDYbkrBGGcuFAncV7NttjKtxXoNjVHfpmY+pnn7PxSpwIoColjZPTLynI+fwKefmHCvD0faCupbfU1UHnQbgWBmNH/R2EraTMtHLRN0iQ== 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=4JLI7/JunPAOiUTOIZei3N9WOAFJGTtHQ2DxGwPOSkk=; b=Nm8sLvo5eOcf8FRh9lxKzgPUs7iM/0OwLWyU0+l372kU8Tg0XH3FW38ib4OMXsbkABuwBAc9yymE9JP9+5YHw1utetfrdaWdvVTi3fDSMgDjYL97J3q7H8uyiX8VYRUL7OcUQ4iZj1zfKjJ3TuRYfjVzQRz80wkLvjM5b092U2NqEXOPr/aYJJ+HRq4iH8GNVZ2abnQ305+tNRtabS5z4c44lszUucGVUvNGkHHk+LAnDap8Fw/JgPuP7c1DTWvoMLaRnT4BCWRtnjZSDheK8Z9NySYVQQ3Nx5FkvU+DwDoWDqSuwOcfV1ENGvXKfUSvwXtSNlcfeKRduHhZeCz9hg== 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=4JLI7/JunPAOiUTOIZei3N9WOAFJGTtHQ2DxGwPOSkk=; b=zyD8Waiocr7eBORT8yYjHqDqu3j6wgL9vJh1QrYb1owm4LkoBAXDSj8ZyZEa4rufDnjkMKnXFWOA51I7YBhVslnkAf+asE05zG5/V9s1jNg5ZJCsAkrtKC1rT5bj2Boir6AKWuZtxKjB7beWuWe4BCuDsbhGS2fIfPqjjLklTgk= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by LV3PR10MB7820.namprd10.prod.outlook.com (2603:10b6:408:1b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 28 Jun 2023 18:52:33 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6521.024; Wed, 28 Jun 2023 18:52:32 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v24 03/10] crash: move a few code bits to setup support of crash hotplug Date: Wed, 28 Jun 2023 14:52:08 -0400 Message-Id: <20230628185215.40707-4-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230628185215.40707-1-eric.devolder@oracle.com> References: <20230628185215.40707-1-eric.devolder@oracle.com> X-ClientProxiedBy: SN7PR18CA0012.namprd18.prod.outlook.com (2603:10b6:806:f3::35) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|LV3PR10MB7820:EE_ X-MS-Office365-Filtering-Correlation-Id: 8872453b-d0a2-44cb-6b2d-08db7808d4c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2KAFW1ta+sTSRu+3X/fLWDlAM0i1jTD2zV8Ruul/dkW4YhHKl/MtCmddx84DkC8PBnRc+R4AYD5iqlRA8INU+GL7M5uAVz+GMwrvpyyC5mzJvWC+ngihNs8uQn+8ZZJcNv8hwjiJUzx6KPWb0iqMAexL309axAPOSmS0h6Wx4C21niOWDQYAj2iiTKJJRpjhaXk9+ZwY6GUxH3P4zS14wOzCOFTUtxEUIre44kLaK66ghTzj9ii+321uU5mVCW4/E4IzRtdwqkw4FqrnQkz1DEKi88iiTGbruEcVNrrRkT6cec3arovq397knoPa27SiW7FyY/xzk8qAS5ciPHmiJZIpv3uxw85/MoCWl4Pyl0jcMNRTPfZUeN/+M/hhgDuFZR5+dJiwMpmLxOJeWqvUtEw0ZmcZneCk9wgb6sk7ahnvTAFQmwziW4Ftn2kvfJqInGEcpP+3/WanPUGPSlj/SY9oOgSzvCIN8AxZJhG2OC/bsm41D6zrXWfvqB+pVtC3kpcdCNqkD1bObmp/FiIi3wJCGVoCCD4kGJn75YB64nWveRY4W4EKwDtM62qkYBJQuJxPjXGjRDsHqsQkcrCKG9TlsnVLWx9JPvI8wPN1p1w= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(2906002)(83380400001)(316002)(30864003)(26005)(6506007)(6512007)(1076003)(6666004)(6486002)(186003)(478600001)(86362001)(107886003)(921005)(2616005)(66476007)(41300700001)(8936002)(7406005)(7416002)(4326008)(66556008)(66946007)(8676002)(36756003)(38100700002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7LnFo3cB54DcdJnHiiA1fiBXsgeHJOMewKdoXLcvK2iLHnbar/HRD3qYAcx8Howx+I/4Hb2BUKCA99xfI53V99ENbX/x89zE1jZkRlvziHKII2bO0xO9M/uin8pDWoyjsZH7H7qnU42truymlCi5j1rNaT+RMTaEd6xXYPtQBwu8ggbDYe/VX6W4gicSX+jS4kNou4kpaveWP2WYDmLqiGVsW6hlj9GUChYG4KzpxUayfR8b79ZMj0thM+/uJ0EXP+/zEUtYJFY15FB9nGgKZ5MTTCbbXVAWjtSGhDQgqPtChvalP0HaAjP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JvyyFlhJ2O7+FukdZszvvkfLhOrLYR143+VCxb9mZieoRyuYQ8EZPd6pekOV0xIVNMd9kvpDmoWktbywWtFewaRtg7WPuwoYza5iFKw06XPDu/RWjc3YxeTOx12xtOlbNwR0CHWjIngD5f+xozr4IuUzSfvcfzWu/T+5He4VcUt5Zep6LE3hifLwf+PfRq9df9idd10vmxkkZ+vdVXAch0cCUsR3T57wo4A9Ivg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Ml3VpvlL28HBaRLSZuE3fywwElEgjVoJb01ZDm+ji2GfBCxx4HSL05KvvzWL400dCIGWAhD6nqk5GnlDeZQzbvEPAWePT7zX8pLl/Z1O52oYrRa85EKIR/Dqd9NNQADPQybB98w37e8YORkj0KwpX/pERQZ+NOsIpu/ZYxR8DdP2fwQ3QufbD5oFcSo/qgyCsltB9VNUkez3qGCMy2BN+zh+x7PNzTN1eeFEnsUBWxS9svyQ+GfmovlD6HnkvfB79fR/gvewfGlCeT0UX113+72MOobaKQ9PpGo+9d0sSbsgHekbLJz2VcCZ/4RK9z5he+p43Mn+NtMWk3kuyPzXSUBHkDWHm9W8hvOFxr+c7x4P7By53Dr6Rx2fyxo3QqtSSZOstrOXQ6f55r1EFzPDhiOErN0LxlD1clmy2bdKW7uTRai1/FonfgXDpFAkXYMTyp/ZxD0Mxk+TG2EGkzmfp9WjhP9dGV5yq15h8YlGKgyHgbNcI6bXAx5RibBUPKTJJhNzfKy30BO+KFu8Rb1QTaaqNCWUH88WBw/W8XynV4isXqWBvZHwc2x91OUc7extlO1hvZHkrIJmDNWQMEvhAn5l4LJKUWFc+VmBs8GfpDS2lPVWZJHLSeuJPT4hDSUVZN9En+K18Iv0g10cblhettaG7ZGIvydH6bTQGMFW4sqU+dKp17fyX03PIpAWiXOHuajh6q4rA7bNRZbZjadh2W3sV2Zhf9/qeD79OYCHBZM3dhGh7+FqtGd74BJRusG+HqNettG8mgYPveGUjZW6yCooocOxWgHhQ0YEu2T+6l51z4S/0EpDSJPEREWQu5rAWHbG6498s/ULzfOLbSbhMLDT/CAD9Gtd8Df8NvwSw9KfIqv2D2eFq+xw/E0kd3L/rA8JdlP6cdhSJPNzE5PzTlG/5Kh0O92Z/L0Zrci0P8M63RWxMY+Zeb8ApWRTZzc50yKmnioT+y0XPYEETAQJMmvbzoAAXBg3t2Pe+UMLc5gL7dMeFojrEmcQeay44DoBgLadSwTZTxXwQFp5AncJUG/1SfxN0ZpSU9BaUu8T+nYLvRd6Hw0xYvA9YG9cDnH/+lmVaeQ/UA+py5M35Fptow3Ia+Y/w8t/1otQTI3RxPcDKvpJPZx8xdEGG2DlzdJ+Js8T2MiJwCvkxKTi5BmLHgNdTaartILxCiye9tXj7S3s6cm1AIO8FYgyeM3qE2sH8A5Jsw5p32IlOmDfW80eXVynTQsQQaCaMjZ6uPMnEsLl0uSLT7dA55Z4S5r+/uRV+JhWsls3wfdvUvYOcJWpV+P5zTAYVxDBEdErEEVHSD+mA5wkkA9uq0l4uobZLl0VAFNPEpsyGmIokhddQjGyTMH4nmMxi0wRA5D0aBgWmF6BsYL4S+oECaQkvFSdxzw+nSTcJHQkYADUFwQfgQXRyaqQV9AHy82GG36C0P/52Hk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8872453b-d0a2-44cb-6b2d-08db7808d4c5 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2023 18:52:32.9536 (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: aX1fCev4dlCmw1kiCCtfYcfQBPaI3blcY0liHLSMRbowgiKjcsCfviXKMTQ2FmQ1npcPNQYEAQilai+hRh6mcRzTNcfAXjNRd8BqZL0E2NQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7820 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_13,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 malwarescore=0 suspectscore=0 spamscore=0 bulkscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280168 X-Proofpoint-GUID: GD2Zt6Tz8fNfjiZBbm3A8mxycceacrA7 X-Proofpoint-ORIG-GUID: GD2Zt6Tz8fNfjiZBbm3A8mxycceacrA7 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?1769973869164568123?= X-GMAIL-MSGID: =?utf-8?q?1769973869164568123?= The crash hotplug support leans on the work for the kexec_file_load() syscall. To also support the kexec_load() syscall, a few bits of code need to be move outside of CONFIG_KEXEC_FILE. As such, these bits are moved out of kexec_file.c and into a common location crash_core.c. No functionality change intended. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- include/linux/kexec.h | 30 +++---- kernel/crash_core.c | 182 ++++++++++++++++++++++++++++++++++++++++++ kernel/kexec_file.c | 181 ----------------------------------------- 3 files changed, 197 insertions(+), 196 deletions(-) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 22b5cd24f581..811a90e09698 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -105,6 +105,21 @@ struct compat_kexec_segment { }; #endif +/* Alignment required for elf header segment */ +#define ELF_CORE_HEADER_ALIGN 4096 + +struct crash_mem { + unsigned int max_nr_ranges; + unsigned int nr_ranges; + struct range ranges[]; +}; + +extern int crash_exclude_mem_range(struct crash_mem *mem, + unsigned long long mstart, + unsigned long long mend); +extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, + void **addr, unsigned long *sz); + #ifdef CONFIG_KEXEC_FILE struct purgatory_info { /* @@ -230,21 +245,6 @@ static inline int arch_kexec_locate_mem_hole(struct kexec_buf *kbuf) } #endif -/* Alignment required for elf header segment */ -#define ELF_CORE_HEADER_ALIGN 4096 - -struct crash_mem { - unsigned int max_nr_ranges; - unsigned int nr_ranges; - struct range ranges[]; -}; - -extern int crash_exclude_mem_range(struct crash_mem *mem, - unsigned long long mstart, - unsigned long long mend); -extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, - void **addr, unsigned long *sz); - #ifndef arch_kexec_apply_relocations_add /* * arch_kexec_apply_relocations_add - apply relocations of type RELA diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 90ce1dfd591c..b7c30b748a16 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -314,6 +315,187 @@ static int __init parse_crashkernel_dummy(char *arg) } early_param("crashkernel", parse_crashkernel_dummy); +int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, + void **addr, unsigned long *sz) +{ + Elf64_Ehdr *ehdr; + Elf64_Phdr *phdr; + unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz; + unsigned char *buf; + unsigned int cpu, i; + unsigned long long notes_addr; + unsigned long mstart, mend; + + /* extra phdr for vmcoreinfo ELF note */ + nr_phdr = nr_cpus + 1; + nr_phdr += mem->nr_ranges; + + /* + * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping + * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64). + * I think this is required by tools like gdb. So same physical + * memory will be mapped in two ELF headers. One will contain kernel + * text virtual addresses and other will have __va(physical) addresses. + */ + + nr_phdr++; + elf_sz = sizeof(Elf64_Ehdr) + nr_phdr * sizeof(Elf64_Phdr); + elf_sz = ALIGN(elf_sz, ELF_CORE_HEADER_ALIGN); + + buf = vzalloc(elf_sz); + if (!buf) + return -ENOMEM; + + ehdr = (Elf64_Ehdr *)buf; + phdr = (Elf64_Phdr *)(ehdr + 1); + memcpy(ehdr->e_ident, ELFMAG, SELFMAG); + ehdr->e_ident[EI_CLASS] = ELFCLASS64; + ehdr->e_ident[EI_DATA] = ELFDATA2LSB; + ehdr->e_ident[EI_VERSION] = EV_CURRENT; + ehdr->e_ident[EI_OSABI] = ELF_OSABI; + memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD); + ehdr->e_type = ET_CORE; + ehdr->e_machine = ELF_ARCH; + ehdr->e_version = EV_CURRENT; + ehdr->e_phoff = sizeof(Elf64_Ehdr); + ehdr->e_ehsize = sizeof(Elf64_Ehdr); + ehdr->e_phentsize = sizeof(Elf64_Phdr); + + /* Prepare one phdr of type PT_NOTE for each present CPU */ + for_each_present_cpu(cpu) { + phdr->p_type = PT_NOTE; + notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); + phdr->p_offset = phdr->p_paddr = notes_addr; + phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); + (ehdr->e_phnum)++; + phdr++; + } + + /* Prepare one PT_NOTE header for vmcoreinfo */ + phdr->p_type = PT_NOTE; + phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note(); + phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; + (ehdr->e_phnum)++; + phdr++; + + /* Prepare PT_LOAD type program header for kernel text region */ + if (need_kernel_map) { + phdr->p_type = PT_LOAD; + phdr->p_flags = PF_R|PF_W|PF_X; + phdr->p_vaddr = (unsigned long) _text; + phdr->p_filesz = phdr->p_memsz = _end - _text; + phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); + ehdr->e_phnum++; + phdr++; + } + + /* Go through all the ranges in mem->ranges[] and prepare phdr */ + for (i = 0; i < mem->nr_ranges; i++) { + mstart = mem->ranges[i].start; + mend = mem->ranges[i].end; + + phdr->p_type = PT_LOAD; + phdr->p_flags = PF_R|PF_W|PF_X; + phdr->p_offset = mstart; + + phdr->p_paddr = mstart; + phdr->p_vaddr = (unsigned long) __va(mstart); + phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; + phdr->p_align = 0; + ehdr->e_phnum++; + pr_debug("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n", + phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, + ehdr->e_phnum, phdr->p_offset); + phdr++; + } + + *addr = buf; + *sz = elf_sz; + return 0; +} + +int crash_exclude_mem_range(struct crash_mem *mem, + unsigned long long mstart, unsigned long long mend) +{ + int i, j; + unsigned long long start, end, p_start, p_end; + struct range temp_range = {0, 0}; + + for (i = 0; i < mem->nr_ranges; i++) { + start = mem->ranges[i].start; + end = mem->ranges[i].end; + p_start = mstart; + p_end = mend; + + if (mstart > end || mend < start) + continue; + + /* Truncate any area outside of range */ + if (mstart < start) + p_start = start; + if (mend > end) + p_end = end; + + /* Found completely overlapping range */ + if (p_start == start && p_end == end) { + mem->ranges[i].start = 0; + mem->ranges[i].end = 0; + if (i < mem->nr_ranges - 1) { + /* Shift rest of the ranges to left */ + for (j = i; j < mem->nr_ranges - 1; j++) { + mem->ranges[j].start = + mem->ranges[j+1].start; + mem->ranges[j].end = + mem->ranges[j+1].end; + } + + /* + * Continue to check if there are another overlapping ranges + * from the current position because of shifting the above + * mem ranges. + */ + i--; + mem->nr_ranges--; + continue; + } + mem->nr_ranges--; + return 0; + } + + if (p_start > start && p_end < end) { + /* Split original range */ + mem->ranges[i].end = p_start - 1; + temp_range.start = p_end + 1; + temp_range.end = end; + } else if (p_start != start) + mem->ranges[i].end = p_start - 1; + else + mem->ranges[i].start = p_end + 1; + break; + } + + /* If a split happened, add the split to array */ + if (!temp_range.end) + return 0; + + /* Split happened */ + if (i == mem->max_nr_ranges - 1) + return -ENOMEM; + + /* Location where new range should go */ + j = i + 1; + if (j < mem->nr_ranges) { + /* Move over all ranges one slot towards the end */ + for (i = mem->nr_ranges - 1; i >= j; i--) + mem->ranges[i + 1] = mem->ranges[i]; + } + + mem->ranges[j].start = temp_range.start; + mem->ranges[j].end = temp_range.end; + mem->nr_ranges++; + return 0; +} + Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type, void *data, size_t data_len) { diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 69ee4a29136f..e9cf9e8d8f01 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -1150,184 +1150,3 @@ int kexec_purgatory_get_set_symbol(struct kimage *image, const char *name, return 0; } #endif /* CONFIG_ARCH_HAS_KEXEC_PURGATORY */ - -int crash_exclude_mem_range(struct crash_mem *mem, - unsigned long long mstart, unsigned long long mend) -{ - int i, j; - unsigned long long start, end, p_start, p_end; - struct range temp_range = {0, 0}; - - for (i = 0; i < mem->nr_ranges; i++) { - start = mem->ranges[i].start; - end = mem->ranges[i].end; - p_start = mstart; - p_end = mend; - - if (mstart > end || mend < start) - continue; - - /* Truncate any area outside of range */ - if (mstart < start) - p_start = start; - if (mend > end) - p_end = end; - - /* Found completely overlapping range */ - if (p_start == start && p_end == end) { - mem->ranges[i].start = 0; - mem->ranges[i].end = 0; - if (i < mem->nr_ranges - 1) { - /* Shift rest of the ranges to left */ - for (j = i; j < mem->nr_ranges - 1; j++) { - mem->ranges[j].start = - mem->ranges[j+1].start; - mem->ranges[j].end = - mem->ranges[j+1].end; - } - - /* - * Continue to check if there are another overlapping ranges - * from the current position because of shifting the above - * mem ranges. - */ - i--; - mem->nr_ranges--; - continue; - } - mem->nr_ranges--; - return 0; - } - - if (p_start > start && p_end < end) { - /* Split original range */ - mem->ranges[i].end = p_start - 1; - temp_range.start = p_end + 1; - temp_range.end = end; - } else if (p_start != start) - mem->ranges[i].end = p_start - 1; - else - mem->ranges[i].start = p_end + 1; - break; - } - - /* If a split happened, add the split to array */ - if (!temp_range.end) - return 0; - - /* Split happened */ - if (i == mem->max_nr_ranges - 1) - return -ENOMEM; - - /* Location where new range should go */ - j = i + 1; - if (j < mem->nr_ranges) { - /* Move over all ranges one slot towards the end */ - for (i = mem->nr_ranges - 1; i >= j; i--) - mem->ranges[i + 1] = mem->ranges[i]; - } - - mem->ranges[j].start = temp_range.start; - mem->ranges[j].end = temp_range.end; - mem->nr_ranges++; - return 0; -} - -int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, - void **addr, unsigned long *sz) -{ - Elf64_Ehdr *ehdr; - Elf64_Phdr *phdr; - unsigned long nr_cpus = num_possible_cpus(), nr_phdr, elf_sz; - unsigned char *buf; - unsigned int cpu, i; - unsigned long long notes_addr; - unsigned long mstart, mend; - - /* extra phdr for vmcoreinfo ELF note */ - nr_phdr = nr_cpus + 1; - nr_phdr += mem->nr_ranges; - - /* - * kexec-tools creates an extra PT_LOAD phdr for kernel text mapping - * area (for example, ffffffff80000000 - ffffffffa0000000 on x86_64). - * I think this is required by tools like gdb. So same physical - * memory will be mapped in two ELF headers. One will contain kernel - * text virtual addresses and other will have __va(physical) addresses. - */ - - nr_phdr++; - elf_sz = sizeof(Elf64_Ehdr) + nr_phdr * sizeof(Elf64_Phdr); - elf_sz = ALIGN(elf_sz, ELF_CORE_HEADER_ALIGN); - - buf = vzalloc(elf_sz); - if (!buf) - return -ENOMEM; - - ehdr = (Elf64_Ehdr *)buf; - phdr = (Elf64_Phdr *)(ehdr + 1); - memcpy(ehdr->e_ident, ELFMAG, SELFMAG); - ehdr->e_ident[EI_CLASS] = ELFCLASS64; - ehdr->e_ident[EI_DATA] = ELFDATA2LSB; - ehdr->e_ident[EI_VERSION] = EV_CURRENT; - ehdr->e_ident[EI_OSABI] = ELF_OSABI; - memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD); - ehdr->e_type = ET_CORE; - ehdr->e_machine = ELF_ARCH; - ehdr->e_version = EV_CURRENT; - ehdr->e_phoff = sizeof(Elf64_Ehdr); - ehdr->e_ehsize = sizeof(Elf64_Ehdr); - ehdr->e_phentsize = sizeof(Elf64_Phdr); - - /* Prepare one phdr of type PT_NOTE for each present CPU */ - for_each_present_cpu(cpu) { - phdr->p_type = PT_NOTE; - notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); - phdr->p_offset = phdr->p_paddr = notes_addr; - phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t); - (ehdr->e_phnum)++; - phdr++; - } - - /* Prepare one PT_NOTE header for vmcoreinfo */ - phdr->p_type = PT_NOTE; - phdr->p_offset = phdr->p_paddr = paddr_vmcoreinfo_note(); - phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; - (ehdr->e_phnum)++; - phdr++; - - /* Prepare PT_LOAD type program header for kernel text region */ - if (need_kernel_map) { - phdr->p_type = PT_LOAD; - phdr->p_flags = PF_R|PF_W|PF_X; - phdr->p_vaddr = (unsigned long) _text; - phdr->p_filesz = phdr->p_memsz = _end - _text; - phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); - ehdr->e_phnum++; - phdr++; - } - - /* Go through all the ranges in mem->ranges[] and prepare phdr */ - for (i = 0; i < mem->nr_ranges; i++) { - mstart = mem->ranges[i].start; - mend = mem->ranges[i].end; - - phdr->p_type = PT_LOAD; - phdr->p_flags = PF_R|PF_W|PF_X; - phdr->p_offset = mstart; - - phdr->p_paddr = mstart; - phdr->p_vaddr = (unsigned long) __va(mstart); - phdr->p_filesz = phdr->p_memsz = mend - mstart + 1; - phdr->p_align = 0; - ehdr->e_phnum++; - pr_debug("Crash PT_LOAD ELF header. phdr=%p vaddr=0x%llx, paddr=0x%llx, sz=0x%llx e_phnum=%d p_offset=0x%llx\n", - phdr, phdr->p_vaddr, phdr->p_paddr, phdr->p_filesz, - ehdr->e_phnum, phdr->p_offset); - phdr++; - } - - *addr = buf; - *sz = elf_sz; - return 0; -} From patchwork Wed Jun 28 18:52: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: 114008 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9140093vqr; Wed, 28 Jun 2023 11:57:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4xcVmCxn6TajYFLW2gVhmQt9TmOw92F3DkrXgQSD0gbNbM3Rny1Cq90dNlFQR3pkmmcKon X-Received: by 2002:a05:6a20:432a:b0:126:c759:27f8 with SMTP id h42-20020a056a20432a00b00126c75927f8mr14063974pzk.2.1687978651489; Wed, 28 Jun 2023 11:57:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687978651; cv=pass; d=google.com; s=arc-20160816; b=u1CcqunmjVElCRcPYHEXCvjIKPBIhTLRAspz3QSziIKGKkoR2lN/JMp+Urm7SBh+uY ua//JoayMPzKBNYkJaEAySAZGy0lvEhsWNPNumi30W4gmglskVg+XRYkpFl0s4yx/8ad 6YehABvmpO4GnSH6H47qSFc6YAmTbiBdlPm/OPwlMKdbAGpire4CqzZ9dxi8hZ30lic2 1AwLovwUr3TAYNS5KKSd1qMcoL9tFHYkYNPkykQ7YGryeHPCOqgJwFsyp30kjJUvZGMD F40jGQ0ghcU0Iq5Xie2hMarlZPz8CxeRVCllfho6tUpvBd9blHqPUNBebNUKbKZDwG1m CBUQ== 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=rAap41MLGGcantWJmWHHzuP2VyBfpqCHGeczaU2RdgM=; fh=j+K5GuuLTbxxisV+wJRNZBqbr6zhGMwAghI8ANXi4rw=; b=HoV8EXsCEqTIFNNBnG2ho3iXyQUtB7TTANeJ+dYqMpY0DEu4LoeltzjJz8pi4demML HtlvLzSSuHe3FBqIsQnXMjNbSEisp3sXr4YV3tr2qCCQ167xZTCCWU7EuVrHjFO49OzT NaOUK9zHWerJ9aJko/WNb5D//XR6ozLvdHCRF27PEfU9UkGvYs4J8et3Th2fZ4YJJY2I z3lh0B4rW7JgH4aL+wIVArU6YNqcPkY/DaKhtas6N5nM2QUNZd3+0BxrNb9JiZLL0Sz8 Ba85fpIXhUWx0CZszkQ3Itm2lN1qAtjxUBTaGh352qwtcocoYVgbzTB5YUuFBlqGUjsp dn2w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=u+Ozt4EL; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=HeNTZQzL; 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 z11-20020a6552cb000000b0055339136a7dsi9180397pgp.883.2023.06.28.11.57.17; Wed, 28 Jun 2023 11:57:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=u+Ozt4EL; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=HeNTZQzL; 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 S232208AbjF1Sx0 (ORCPT + 99 others); Wed, 28 Jun 2023 14:53:26 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:37278 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232033AbjF1SxQ (ORCPT ); Wed, 28 Jun 2023 14:53:16 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35SGwo5i011874; Wed, 28 Jun 2023 18:52:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=rAap41MLGGcantWJmWHHzuP2VyBfpqCHGeczaU2RdgM=; b=u+Ozt4ELNamIEIZ/KCtDR/dZ1DjX95u/fv52TPZVqL2lq+5P85cKLGsGGYAg9RVrqc08 EXeeyxwg110q2zNwh9NUi7mFxvrs54paq8ZLtwAd5jKuA5NjzaWnRK9UeAhU2YMvzoE6 mp1eMtTdTWSnSKQ3DyQLAnt5foCzEmNaoduKR4wyW5WjTqFIAGqYrC/qxr7B9yMKe+30 W5+GA14pcmy+Tjb8fICim55/0rqatpV9lL1eDEC4WWzHacP42oHhtwIGKolU9ilcku/k 5sLFw5eATujuOodMio35K75ZRd32edqLklMecUUhTobhMdk9MdifV9KNz+JDtsISBDgx ig== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdq938mfb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:39 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35SIDli6029650; Wed, 28 Jun 2023 18:52:38 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpx6dmh6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CHpfgg0OxLtsrFSBUXRdE0x683O6AhfKUcBHky2hYLUIn3ZgqgIT0ZHKAVgxlY2Eod9CmGg1X8tvXyz0dRqm3f5rtbxuXRBCort5vSxb2woE4WlEbkwO21dzlUvFmv14XpSzmeKOL4o5ZM7qBWVRorvFHpxz6pcHMtqgXZ9XjCyo7WExXT2Q1Oi30ne8Ht+2eqtfW2QBgj2QNGMmsNe/zHw6KIuY3i1wpp10VZYZ+UrjJoYGg2PjmfP+yNdbZlWCYPmge5yIzTGRcm4+8sF7HxaNodYU1xfBOucnLm848ppaXfdIJJE6Jno5WGOSDYcUnp9oGJOnnytigyO76EbpPg== 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=rAap41MLGGcantWJmWHHzuP2VyBfpqCHGeczaU2RdgM=; b=Tia7nsWEL4Za06sBqz3kVU4iLPquqS/E2liT1DLftZNkA+XVW42YS9SsLvhXzDKtCBK7ceJ5v3OyX2fwjuABKkEd9LMnNhfCdUdtYeSJ+1jrzAn1XFaGltvK36GDELIe1JlPRF6IJD0TNNcHpymzK2bUKvZMRefaLGCdis1tzvE+lv1n8rIMXNAsLkzKtvhAPkSQL2Vrp3Ewimwi4bqxASkBC1dBjP2CkIIKiYyQPuiPA4akV/BW0/uQNmCof5ctIpr8+ruG7fk6pm7UAriLVDsrb1MU72uU6t6WJ42ukHE1qn5oKTUAZI7Tb51+J4JMwuJl9hl1hYkT3nQEB10VBw== 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=rAap41MLGGcantWJmWHHzuP2VyBfpqCHGeczaU2RdgM=; b=HeNTZQzLOD+BLWN6NgaNrCqFpy6Zj8Uuy+attDy3Roljiaq1dFtMywSn8oDbvJvf4JDzgmWMdpBXD1uQLZ+7Zc6qxhRHuBm+/mgqcL+kV2tvIkP4OPoi32qB+xh6f0z28MLONJLPetdGiT7YgEk53Yslbd/bwGJczYiupfdZfdc= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by LV3PR10MB7820.namprd10.prod.outlook.com (2603:10b6:408:1b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 28 Jun 2023 18:52:35 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6521.024; Wed, 28 Jun 2023 18:52:35 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v24 04/10] crash: add generic infrastructure for crash hotplug support Date: Wed, 28 Jun 2023 14:52:09 -0400 Message-Id: <20230628185215.40707-5-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230628185215.40707-1-eric.devolder@oracle.com> References: <20230628185215.40707-1-eric.devolder@oracle.com> X-ClientProxiedBy: SN7PR04CA0189.namprd04.prod.outlook.com (2603:10b6:806:126::14) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|LV3PR10MB7820:EE_ X-MS-Office365-Filtering-Correlation-Id: fef5c95c-e490-4fad-571d-08db7808d66b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pRBviYGYX3gFUotVM1R+56k0Yb5jdcOYV+prZOTpPc4ikI88bEJV6ecrT2LqNDW29oCUD9JLGt5g7mQIO+cFADXf9rXZ6ApiCK5R6Hkys/8GB9r8pWbpV5kjXokmThLEgkivkhpiLGG2jrIUMcKdd31WUNK3QxMCR6KkBXQB7IcArL1mc1E5/voQbk4iwrubbV0F4QNk1oi7TuSiC8UowD/qE8YBteOrj5lAhUd9pE1Em9Q268evWqB+97bXo1L0XQvEHHVUcdZyVHWA0tlD/qPmqvbMLXacCDs/Fzhic0cL3MoY3tW/rZX0mUbLR+FLTwYJX1nnm3ib+SyEK6C0jr8hxkRBxG/TWDmFIMtmzfEq/Nhy5C/D6OLJnH9EyFyV+m9Gt8u5aM/XAwkfcMmSTXJCk66VW/+Et6cV7FlnbOW/eutUGOQp+30FYpapfecljJdFgcmwSfyb2Xc0q0XZroc1GlyDO9QBAt1eHPysw4Hy6vZ6beDQtTGxnWOiALub3qJ0EIjrpXcwdqAttGTySC4nDOvMdBp254GOGcEyC9W836yJBbPFddsR1W1AyZMtdMaPEiDgMLTJoeBTr0pGNJN1O9zaMa47LE2lLASno5R304tNj2zlKvAicQUeNR1t X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(2906002)(83380400001)(316002)(30864003)(26005)(6506007)(6512007)(1076003)(6666004)(6486002)(186003)(478600001)(86362001)(107886003)(921005)(2616005)(66476007)(41300700001)(8936002)(7406005)(7416002)(4326008)(66556008)(66946007)(8676002)(36756003)(38100700002)(5660300002)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Dt0FifDCjW/joEUTDHMn6in0SxB1eyEbL+91FxnV2gP8tBSbgyITsE3g5erljXSL6qGIzNQOAnCwUOfyy86FzGAUf9fI1g6hCWJkCRab7uMkck7vK75g6oV3SeqySN5OO2/Y8cPdlwF2buDaGFaySd5m1OvE2tNnbE8CmhdqEhu88cOpX9QWjYzCL/CUuEQna3frdQl3JY9kDxzocBvLJ3yJhkkGLRhPcoqxbtcQtU24TqlBvgY5J4VJTESdp6YBl4/46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oUtFZ1NPcLx9yqxltbMwMCBxyTKjyPuuC/laSsmZt3ox5D4dm5dX+8liursORS6BRGPQEo2xryy01YpGGBIinE42dxLvqxGIJmetqnmhd5HwiNH6YgsNaBeJZH7qEb0nbsza3mS9WCUw3fmzuw5PEU+axuQeWJm20K5s0Vwsjvs2cLHdFTWXF7bfkb8LNcZjcO58CPLwLoxFDd/eeq5ELsdnEm6sqvZ9rsQGhTaGy4XbIq/ivz6qiXPQvOfqIECY7fLtITw7dSNs27qZVINuZ4s/JWn61uU8fotDfHqbOeuZu1tdFzD6+/WRk6kv9MG8EuvloTxJRlB9PUHRUlpY1ROncEDJ5g6T5nfIYpdjeJNwjgoql89UIfYnUs1bYsM8pwspcUyrjzWQe2EVgokD//7+pE/QI/yN3Bwj6weNksY1uPPQ8Njf7YOaPbCsRY7r0MOwdz9wobgM4X67cFvFH9HomK5oOiyja+MjYrTZ4D51oLc4tMOtdNLDWxVYWV/MMQNSNC/Fr1d4CYXPE/uwtOq7lQSnBdxD895+DLx+GFNqEqR2vEiSdH1HSUzpj0RilS9MaGqH2/T6htW3zVmElezxuYCtHoZj1Al+ZEIB9xoqXrZtWilVQELUlN6crjydbKSxlI7ks0irwFvg9W7OcifJMHAlKpCLXUQiRC/26wcQlhjjq4djHq3qTyGL2W5j0vSE4MXek51/olR1GBHKWyfOFAAKpsbk590TTSU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fef5c95c-e490-4fad-571d-08db7808d66b X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2023 18:52:35.7536 (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: fonRkjWN2IG4Dv1PpafefE4Y5/oiojFvy+Hz5AH9a6E1hOYrKAaeY6IAKSfsZUAE+zqWn6Qx2RccU0LsDKAYGzOAvIXYCHRPReGwSqnSENQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7820 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_13,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280168 X-Proofpoint-ORIG-GUID: C5V9V5jb0H9Cf2VEhxQmtxM0txuOQyLP X-Proofpoint-GUID: C5V9V5jb0H9Cf2VEhxQmtxM0txuOQyLP 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?1769973902103874002?= X-GMAIL-MSGID: =?utf-8?q?1769973902103874002?= To support crash hotplug, a mechanism is needed to update the crash elfcorehdr upon CPU or memory changes (eg. hot un/plug or off/ onlining). The crash elfcorehdr describes the CPUs and memory to be written into the vmcore. To track CPU changes, callbacks are registered with the cpuhp mechanism via cpuhp_setup_state_nocalls(CPUHP_BP_PREPARE_DYN). The crash hotplug elfcorehdr update has no explicit ordering requirement (relative to other cpuhp states), so meets the criteria for utilizing CPUHP_BP_PREPARE_DYN. CPUHP_BP_PREPARE_DYN is a dynamic state and avoids the need to introduce a new state for crash hotplug. Also, CPUHP_BP_PREPARE_DYN is the last state in the PREPARE group, just prior to the STARTING group, which is very close to the CPU starting up in a plug/online situation, or stopping in a unplug/ offline situation. This minimizes the window of time during an actual plug/online or unplug/offline situation in which the elfcorehdr would be inaccurate. Note that for a CPU being unplugged or offlined, the CPU will still be present in the list of CPUs generated by crash_prepare_elf64_headers(). However, there is no need to explicitly omit the CPU, see justification in 'crash: change crash_prepare_elf64_headers() to for_each_possible_cpu()'. To track memory changes, a notifier is registered to capture the memblock MEM_ONLINE and MEM_OFFLINE events via register_memory_notifier(). The CPU callbacks and memory notifiers invoke crash_handle_hotplug_event() which performs needed tasks and then dispatches the event to the architecture specific arch_crash_handle_hotplug_event() to update the elfcorehdr with the current state of CPUs and memory. During the process, the kexec_lock is held. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- include/linux/crash_core.h | 9 +++ include/linux/kexec.h | 11 +++ kernel/Kconfig.kexec | 31 ++++++++ kernel/crash_core.c | 142 +++++++++++++++++++++++++++++++++++++ kernel/kexec_core.c | 6 ++ 5 files changed, 199 insertions(+) diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h index de62a722431e..e14345cc7a22 100644 --- a/include/linux/crash_core.h +++ b/include/linux/crash_core.h @@ -84,4 +84,13 @@ int parse_crashkernel_high(char *cmdline, unsigned long long system_ram, int parse_crashkernel_low(char *cmdline, unsigned long long system_ram, unsigned long long *crash_size, unsigned long long *crash_base); +#define KEXEC_CRASH_HP_NONE 0 +#define KEXEC_CRASH_HP_ADD_CPU 1 +#define KEXEC_CRASH_HP_REMOVE_CPU 2 +#define KEXEC_CRASH_HP_ADD_MEMORY 3 +#define KEXEC_CRASH_HP_REMOVE_MEMORY 4 +#define KEXEC_CRASH_HP_INVALID_CPU -1U + +struct kimage; + #endif /* LINUX_CRASH_CORE_H */ diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 811a90e09698..b9903dd48e24 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -33,6 +33,7 @@ extern note_buf_t __percpu *crash_notes; #include #include #include +#include #include /* Verify architecture specific macros are defined */ @@ -360,6 +361,12 @@ struct kimage { struct purgatory_info purgatory_info; #endif +#ifdef CONFIG_CRASH_HOTPLUG + int hp_action; + int elfcorehdr_index; + bool elfcorehdr_updated; +#endif + #ifdef CONFIG_IMA_KEXEC /* Virtual address of IMA measurement buffer for kexec syscall */ void *ima_buffer; @@ -490,6 +497,10 @@ static inline int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, g static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { } #endif +#ifndef arch_crash_handle_hotplug_event +static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } +#endif + #else /* !CONFIG_KEXEC_CORE */ struct pt_regs; struct task_struct; diff --git a/kernel/Kconfig.kexec b/kernel/Kconfig.kexec index 5d576ddfd999..7eb42a795176 100644 --- a/kernel/Kconfig.kexec +++ b/kernel/Kconfig.kexec @@ -107,4 +107,35 @@ config CRASH_DUMP For s390, this option also enables zfcpdump. See also +config CRASH_HOTPLUG + bool "Update the crash elfcorehdr on system configuration changes" + default y + depends on CRASH_DUMP && (HOTPLUG_CPU || MEMORY_HOTPLUG) + depends on ARCH_SUPPORTS_CRASH_HOTPLUG + help + Enable direct update to the crash elfcorehdr (which contains + the list of CPUs and memory regions to be dumped upon a crash) + in response to hot plug/unplug or online/offline of CPUs or + memory. This is a much more advanced approach than userspace + attempting that. + + If unsure, say Y. + +config CRASH_MAX_MEMORY_RANGES + int "Specify the maximum number of memory regions for the elfcorehdr" + default 8192 + depends on CRASH_HOTPLUG + help + For the kexec_file_load() syscall path, specify the maximum number of + memory regions that the elfcorehdr buffer/segment can accommodate. + These regions are obtained via walk_system_ram_res(); eg. the + 'System RAM' entries in /proc/iomem. + This value is combined with NR_CPUS_DEFAULT and multiplied by + sizeof(Elf64_Phdr) to determine the final elfcorehdr memory buffer/ + segment size. + The value 8192, for example, covers a (sparsely populated) 1TiB system + consisting of 128MiB memblocks, while resulting in an elfcorehdr + memory buffer/segment size under 1MiB. This represents a sane choice + to accommodate both baremetal and virtual machine configurations. + endmenu diff --git a/kernel/crash_core.c b/kernel/crash_core.c index b7c30b748a16..53d211c690a1 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include @@ -18,6 +20,7 @@ #include #include "kallsyms_internal.h" +#include "kexec_internal.h" /* vmcoreinfo stuff */ unsigned char *vmcoreinfo_data; @@ -697,3 +700,142 @@ static int __init crash_save_vmcoreinfo_init(void) } subsys_initcall(crash_save_vmcoreinfo_init); + +#ifdef CONFIG_CRASH_HOTPLUG +#undef pr_fmt +#define pr_fmt(fmt) "crash hp: " fmt +/* + * To accurately reflect hot un/plug changes of cpu and memory resources + * (including onling and offlining of those resources), the elfcorehdr + * (which is passed to the crash kernel via the elfcorehdr= parameter) + * must be updated with the new list of CPUs and memories. + * + * In order to make changes to elfcorehdr, two conditions are needed: + * First, the segment containing the elfcorehdr must be large enough + * to permit a growing number of resources; the elfcorehdr memory size + * is based on NR_CPUS_DEFAULT and CRASH_MAX_MEMORY_RANGES. + * Second, purgatory must explicitly exclude the elfcorehdr from the + * list of segments it checks (since the elfcorehdr changes and thus + * would require an update to purgatory itself to update the digest). + */ +static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu) +{ + struct kimage *image; + + /* Obtain lock while changing crash information */ + if (!kexec_trylock()) { + pr_info("kexec_trylock() failed, elfcorehdr may be inaccurate\n"); + return; + } + + /* Check kdump is not loaded */ + if (!kexec_crash_image) + goto out; + + image = kexec_crash_image; + + if (hp_action == KEXEC_CRASH_HP_ADD_CPU || + hp_action == KEXEC_CRASH_HP_REMOVE_CPU) + pr_debug("hp_action %u, cpu %u\n", hp_action, cpu); + else + pr_debug("hp_action %u\n", hp_action); + + /* + * The elfcorehdr_index is set to -1 when the struct kimage + * is allocated. Find the segment containing the elfcorehdr, + * if not already found. + */ + if (image->elfcorehdr_index < 0) { + unsigned long mem; + unsigned char *ptr; + unsigned int n; + + for (n = 0; n < image->nr_segments; n++) { + mem = image->segment[n].mem; + ptr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT)); + if (ptr) { + /* The segment containing elfcorehdr */ + if (memcmp(ptr, ELFMAG, SELFMAG) == 0) + image->elfcorehdr_index = (int)n; + kunmap_local(ptr); + } + } + } + + if (image->elfcorehdr_index < 0) { + pr_err("unable to locate elfcorehdr segment"); + goto out; + } + + /* Needed in order for the segments to be updated */ + arch_kexec_unprotect_crashkres(); + + /* Differentiate between normal load and hotplug update */ + image->hp_action = hp_action; + + /* Now invoke arch-specific update handler */ + arch_crash_handle_hotplug_event(image); + + /* No longer handling a hotplug event */ + image->hp_action = KEXEC_CRASH_HP_NONE; + image->elfcorehdr_updated = true; + + /* Change back to read-only */ + arch_kexec_protect_crashkres(); + + /* Errors in the callback is not a reason to rollback state */ +out: + /* Release lock now that update complete */ + kexec_unlock(); +} + +static int crash_memhp_notifier(struct notifier_block *nb, unsigned long val, void *v) +{ + switch (val) { + case MEM_ONLINE: + crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_MEMORY, + KEXEC_CRASH_HP_INVALID_CPU); + break; + + case MEM_OFFLINE: + crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_MEMORY, + KEXEC_CRASH_HP_INVALID_CPU); + break; + } + return NOTIFY_OK; +} + +static struct notifier_block crash_memhp_nb = { + .notifier_call = crash_memhp_notifier, + .priority = 0 +}; + +static int crash_cpuhp_online(unsigned int cpu) +{ + crash_handle_hotplug_event(KEXEC_CRASH_HP_ADD_CPU, cpu); + return 0; +} + +static int crash_cpuhp_offline(unsigned int cpu) +{ + crash_handle_hotplug_event(KEXEC_CRASH_HP_REMOVE_CPU, cpu); + return 0; +} + +static int __init crash_hotplug_init(void) +{ + int result = 0; + + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + register_memory_notifier(&crash_memhp_nb); + + if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) { + result = cpuhp_setup_state_nocalls(CPUHP_BP_PREPARE_DYN, + "crash/cpuhp", crash_cpuhp_online, crash_cpuhp_offline); + } + + return result; +} + +subsys_initcall(crash_hotplug_init); +#endif diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 3d578c6fefee..8296d019737c 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -277,6 +277,12 @@ struct kimage *do_kimage_alloc_init(void) /* Initialize the list of unusable pages */ INIT_LIST_HEAD(&image->unusable_pages); +#ifdef CONFIG_CRASH_HOTPLUG + image->hp_action = KEXEC_CRASH_HP_NONE; + image->elfcorehdr_index = -1; + image->elfcorehdr_updated = false; +#endif + return image; } From patchwork Wed Jun 28 18:52:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 114010 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9140308vqr; Wed, 28 Jun 2023 11:58:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7mzY/p+zsmDra2JnGR/6Z60w+RRFGVfxu16hNR2OHyARIyQKuQqje/Cx+hi0R3x2jXhFKf X-Received: by 2002:a05:6a20:8426:b0:11f:7829:6d6c with SMTP id c38-20020a056a20842600b0011f78296d6cmr41414660pzd.3.1687978682299; Wed, 28 Jun 2023 11:58:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687978682; cv=pass; d=google.com; s=arc-20160816; b=ea2BaQ+V+ELCcmypjYf8Xc6Jb4Ju6sUqKEIc28k98wDBky4caqGi+Wv715qQuYGSPs 9F6m3arU0OlQ3epsnAe9d3zvTHcUXsaD1SQm4my+9QuskfGR3mnRKaw+aR6rRQf3xiG7 z6ALzsgSXBI0Kv1MZD4CZb6+TcH29yKYS0PJe0JnB4dRS/inM/PKWZBNHsGowvP47hO/ 74L4XqtTd/oQdiiHprh08Yov2Wmf5+ivbn2z4NHfjoLN+EsnKl99wEj4epO7hbjSfIgb fyyoTZxWbJhC/xDR/Er22VebBMQiDgjj+M0kCvQd3tkd9OyIoEYUlJIYjUrSZgZX1dVF AJRg== 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=W8iEv38eAoUWiIac6DamuSVNXvMP78ssEHCbdxW608k=; fh=j+K5GuuLTbxxisV+wJRNZBqbr6zhGMwAghI8ANXi4rw=; b=zKW6qDD390OfU5G+Ofxifagrl5fuEDp5Ez7ESNZkfWU/mJfxpTkTwfAqiv7FWkqxag JyaLyJ0fsvrgxUu7QlNOZEtby51Fu437FXaKTuRLA8HN1CLF1k2l59KOQNn4S3zCwDDo qvTrCvdysEZR8JokSVL2JBQzE9LmIRxEbona8oFWOrXFRc9BFcfoqsugXE+BXgXU9Wer sOi0t84VJkWrhgEB5+5J/GzZy+lholSLOS7AWcWMlN9E9qppF7OBl0aE0EoIuXzO+rTE vwBTjsTpYPwRUVVceWu58NG/RF/90FJ6/mT5b0CqL4RoBtsfoJLlrB1PpKVqxiBD9FkQ LCyA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b="Jm95YVh/"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=pFoUCWYO; 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 f6-20020a631f06000000b0054fcdcbf4a3si9740999pgf.142.2023.06.28.11.57.49; Wed, 28 Jun 2023 11:58:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b="Jm95YVh/"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=pFoUCWYO; 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 S232137AbjF1SxX (ORCPT + 99 others); Wed, 28 Jun 2023 14:53:23 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:36150 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231672AbjF1SxQ (ORCPT ); Wed, 28 Jun 2023 14:53:16 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35SGwwb1019770; Wed, 28 Jun 2023 18:52:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=W8iEv38eAoUWiIac6DamuSVNXvMP78ssEHCbdxW608k=; b=Jm95YVh/IdrTZhjHKwce8+4Lfl0yxzm+4gJEtx2ICMtRwc2NnprzNDYSz+210SmKjWbZ as4TK6tA2jvzOVOPLYUPBpzEjVZeVWql78FYO36y542FPfy4W8Tz4spR4VF/S74ArED+ fMLo09fDxvypssjL1eiRa43NhyDz9vNQbPBtRK+Exz07ndqlDq5fdVeZBTFf+66Zf2Zl b6S/EnrTiiWIIJ5orN35+OCr6XXXOOUG7XgEXKNQMzBHSMt61vOoskYRroM/dRNwDPzp AEIeTl4+8cfU1jmtnENBAxmKwWUemellebcNqhVAbXj+Qi+v4IWFgFbNLzPFVHMCdGsW iA== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdpwdgjua-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:42 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35SI734F019935; Wed, 28 Jun 2023 18:52:42 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2106.outbound.protection.outlook.com [104.47.58.106]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxc6cxu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iN85890X1L3QqQdoRYsYt9+kZj7X6nigTm/keRQvMidQl/vKKHsmk1Rb6zSI7SHzVou5X0uy2c12bw6HHe3K+Hfo0NXiB+OJa7zCMp15eI9G+t2vHeXwlpfCpNBlKb/7306qkwNLBQo4wCPtt8G7XdAKf6yDJUDgWe3o3ahWdwVm0NaMcXN7WCPmB3iklcmq5ec6y7ToEJnGiDnXBBjGFz3nPffkooUYCC5+O+gbygYfjJqvm3AvXDAlEHB9fMzy8XnjhrRMsWklqCYrf0Oik/4eYgM2c4NMe/mpH6cKs18QHfGVGwzJZQbdS0M6lt+yhchpXu9Wu0/A72sUUidjaA== 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=W8iEv38eAoUWiIac6DamuSVNXvMP78ssEHCbdxW608k=; b=hlpr8sRJxwzsDl5/ihTt+avl1dUviTrgRIwZK8ZDgpL8/Uena4IQhWq/0poJOQyk42B7T1QG+WBfEfjtI2Js5oblJVDx0uHqOnOUwhwN1I4oiNN4vRLidEU3R+JCCUA8JA2RlqeTSnXRP9Ex90iK7sk36BXLwf8vZjq4zamGVc3w2+offMNbQqi7b+x88rTrfQqWXpESdBp4FNlhH6O/nbzi4Nug1DhOYvGZoi2gzjDmhzPoEHY2M3A3Gs9V0a2hW7/XhFGkIRjDdrffzPvrATsGx1N0Bqk7/loArASxyny//aVNNrteLqKzQKPaA0kYfSuqBs4woemwzlWA7HgjKw== 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=W8iEv38eAoUWiIac6DamuSVNXvMP78ssEHCbdxW608k=; b=pFoUCWYOItcaZpuDwr/nPFxCeaEqzbLF0n5hKSxneETf8NBjXu32H+Ybi7crKgbiooLc8AAH7J/OeOuXiGJh0Phjvd8oGN+Ayj4yYUbZpyLA/pRT7bpAVCr/tfT3z3V5vG2zGI0szNBR0xg/fHjVi/AS6vh2YQLlMWWWJkEaW6s= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by LV3PR10MB7820.namprd10.prod.outlook.com (2603:10b6:408:1b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 28 Jun 2023 18:52:39 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6521.024; Wed, 28 Jun 2023 18:52:39 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v24 05/10] kexec: exclude elfcorehdr from the segment digest Date: Wed, 28 Jun 2023 14:52:10 -0400 Message-Id: <20230628185215.40707-6-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230628185215.40707-1-eric.devolder@oracle.com> References: <20230628185215.40707-1-eric.devolder@oracle.com> X-ClientProxiedBy: BYAPR06CA0066.namprd06.prod.outlook.com (2603:10b6:a03:14b::43) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|LV3PR10MB7820:EE_ X-MS-Office365-Filtering-Correlation-Id: eaed10e9-5c79-4776-10a0-08db7808d886 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t386r8HUs28xlgMjUDoRYpF1VT3uZLNxmnEkrSXc+jm/lubkmYhbzk0Tc+qGjAKzkxyM9No4G220ImRlN1ezXNPGirfp3SPIerL4kyLdBTU4YPazX3BBZAUMHfqubJm/Pl/XF3nrK87fOo7xED4+QYYo1cyPx4pDaGsd9DQo4qY2vuDBIQz82HuNBSC1V5OdpXu5q68Ch7xtkaOD8iyYA2B0aqf1t1nkIB9kCTH0ZBB3rGYZ4YaCEsAEOhDUDg0NZHnywPZskoiJ39HrqIYe3XAEDMeN+mW72JYa38221ixQNyoLzkDsVZtFhZT2vJRpBatIHmpt5bHwkI9+0/KgvhUx2xmWvoCMP+4KweW6rA0p8BsLNeEmSoUjn6sCgdD0aXZGgoYkiZdGs6WqPzlJB+rfJY8PURW5LGgZwToMupdxh1Z6QqoGaiX2nE0wdJ6Ljy5DspCm15jupYsLDOpDE7tNjWjChCSi0XpEqa5J3VFU0jeCrLx7FG7NYI82Y2q7l5qUhf0nxb5cGUSEKg+rexNReXxoDi0N+ptjmgRr5G6ZgVUvmZO+vvbIE7j5+HL9CRfmnSWwVxcFz1VMW9oiHa9woI8KgifOo8jc73x8nRA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(2906002)(83380400001)(316002)(26005)(6506007)(6512007)(1076003)(6666004)(6486002)(186003)(478600001)(86362001)(107886003)(921005)(2616005)(66476007)(41300700001)(8936002)(7406005)(7416002)(4326008)(66556008)(66946007)(8676002)(36756003)(38100700002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xYMLAUdqxVmlpVWIjCQXE+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-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2023 18:52:39.1861 (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: CabDA/wNt1COCA0O7zUOufHH1+y6x14vNpJmtylY+vnbiN8OUZ0EtxtPNWUN/ZIjeBejwIW7FwD7P0kziomlTEesWf1GhGldDBxNsNrdbNg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7820 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_13,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280168 X-Proofpoint-GUID: p7Z3ezR82gokJ_E6YVAEIVr5Gh-_7ICq X-Proofpoint-ORIG-GUID: p7Z3ezR82gokJ_E6YVAEIVr5Gh-_7ICq 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?1769973934597192274?= X-GMAIL-MSGID: =?utf-8?q?1769973934597192274?= When a crash kernel is loaded via the kexec_file_load() syscall, the kernel places the various segments (ie crash kernel, crash initrd, boot_params, elfcorehdr, purgatory, etc) in memory. For those architectures that utilize purgatory, a hash digest of the segments is calculated for integrity checking. The digest is embedded into the purgatory image prior to placing in memory. Updates to the elfcorehdr in response to CPU and memory changes would cause the purgatory integrity checking to fail (at crash time, and no vmcore created). Therefore, the elfcorehdr segment is explicitly excluded from the purgatory digest, enabling updates to the elfcorehdr while also avoiding the need to recompute the hash digest and reload purgatory. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- kernel/kexec_file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index e9cf9e8d8f01..824ffc5282f4 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -726,6 +726,12 @@ static int kexec_calculate_store_digests(struct kimage *image) for (j = i = 0; i < image->nr_segments; i++) { struct kexec_segment *ksegment; +#ifdef CONFIG_CRASH_HOTPLUG + /* Exclude elfcorehdr segment to allow future changes via hotplug */ + if (j == image->elfcorehdr_index) + continue; +#endif + ksegment = &image->segment[i]; /* * Skip purgatory as it will be modified once we put digest From patchwork Wed Jun 28 18:52:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 114012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9140318vqr; Wed, 28 Jun 2023 11:58:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ41+V7KiBBGgKHFmgaiT4L6xBOEJ5nvSS6MxyJl6CQg9ARnBNg8NWiFwOX4EEns0OqUqdYZ X-Received: by 2002:a17:902:d489:b0:1b4:ddef:841e with SMTP id c9-20020a170902d48900b001b4ddef841emr43225235plg.4.1687978683554; Wed, 28 Jun 2023 11:58:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687978683; cv=pass; d=google.com; s=arc-20160816; b=GFdMM9S+db/WcxPGvBS5ZdnIRnUfd1afouD+Vd6whKkq756F68s1KE4ffUpkhzCJgc eLBoF3LEPXob6yMHySMnkMPVdNznxW1UKenAZxiZcBowlaLP/brapO9e9UqfY/LV7G50 /QkmDi/ZbywvamNk3FTmpHIfpwAguICouEiXizElVOQbGO2B8xVE0IXkpFXxoyTANxpE dCyMysOQbj6M7O8auJdy7JB35XlIN+HK4oeTq/1xmcNbFZoJf3yOWbTfavUSy0V+5uBz 3odjfR1Tykvu8jlv7c3QmCe8G7lUdLGXNqaiYITZDyY8uNRBZ1NFOEQRssId+CQKOoGs sJyw== 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=tEYS0yDl8S2sr5DunT4eYxKqOSSB+yq8j9ejKatbFv8=; fh=j+K5GuuLTbxxisV+wJRNZBqbr6zhGMwAghI8ANXi4rw=; b=Fp5KHpiyOKs/wZaqKmBwlm08ydjTDzv/023ljBp55EfGWrIx52gnnAMSNVtvSKB1Yw Lw/v6wRQdcOA3GTT0iVUGeZNX8t7IB/O8R9DBTUxYUndkqtfJVhvOYtOxREwmLetGKhi wcS0b5lR7nyKVzy7KKwoAe1E5EFQEZDcI2M5qrAWatnp3kxd+t6dEKPGcY6mM3a45w+b uTmlsHAuWKvlJZKzHzx8gLh+xq+NsnqAYW+xt/7r0Vw74VfagStrGPs8DcmqkAQCaVq9 E7efWZjLM8nyrkgweLm/eWui7D46BOIGRHYeOJl64Q6Wbw+Nb2LzZrq0SXi9IqEYo8AX 0I3w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=NqrYM4K3; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=vp3S16hp; 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 bg9-20020a1709028e8900b001b049aae135si8889267plb.246.2023.06.28.11.57.49; Wed, 28 Jun 2023 11:58:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=NqrYM4K3; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=vp3S16hp; 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 S232260AbjF1Sxf (ORCPT + 99 others); Wed, 28 Jun 2023 14:53:35 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:40894 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230038AbjF1SxS (ORCPT ); Wed, 28 Jun 2023 14:53:18 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35SGwl4A011796; Wed, 28 Jun 2023 18:52:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=tEYS0yDl8S2sr5DunT4eYxKqOSSB+yq8j9ejKatbFv8=; b=NqrYM4K30qLVrv0o10e/ukoMS2qarFN6G/pdXtrPgDzXm3Hs5sZmSARqbT98CoC63LT1 Ca+hhiz9jlvroJ1a4L8b3H074mF1bAB0T8xAEBgJEe9fQswxXrVw7zDfDeJOSq5eQXNR 1is+0KHN8shxvIUhFxdbJUxIT0UI34B7SjSD+61kFV7lJOnU2SUPzyupVMySLwRidUcd 2Dvrpvt+dSwo4PoK4DLw5uNxie4m0ZflXHL81kgQZ50s2wwHm2jxbdah29TCKGZAVDK4 t+pG+clazW2ClfydVXSnNdQ6uKWxAuyV3mFxE1jEDqpKGA86jtRJKokenPuRzCDSUsXE 5A== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdq938mh2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:45 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35SHHbPT038244; Wed, 28 Jun 2023 18:52:45 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2108.outbound.protection.outlook.com [104.47.58.108]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxcx3km-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DA/eZmPr3z2dJIJ/QI/LfcOWHtzBg54lcPaABoz/RaikWjW3U9FL4j30t4WKiIo6eaq+fe8AeKWTlE6jWHahTikZyFSH9HYBwsL3cOkGTfnEXH6A9lJTFyJWViYfF2abH0W+TZIelxCMOTdR22K4Nc98NmJAEiTmzJZbDtsEsjaXERP2tUdVN6TFpoAr78Mo/EHGwhRNT/JCyY7p9F4g+nEfktLc+HXwTzytLNTPY/pTyfDE8COqjdAZiNQOTfCnMJkM5k10T2xdTY4RgwwQIvkYa89MHAxLxQG84RkCXMMGgPufVg8zrPaWtSqvviqGcvnkKRpQLTMhNoEy98t6yQ== 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=tEYS0yDl8S2sr5DunT4eYxKqOSSB+yq8j9ejKatbFv8=; b=HQj5gwQ1Q9H2cmt3W7GF9LYPDpEbHb/6B5GIKPT99w2BHiyk3hS48ae9kcNgjz3wOjBRjLr1aSs2Idix64TsUWBGquwmaXQQ7lJteAD4Gwg4rFY4OATDQtaMOfyjm0r3L63G13FLxhRyApGRdzeYzpDJEyLNnQ+VWcaji3NpJDY3f0Zr3TsYWMddJ0PlRZ7qPsd69j/C7frqnvRA25kZFiu+4mImQfWiakrwueXIjnb2k9aiWsWuqG+pWkTcyX3DnLXl8yNN+7yCLj/5PhBkLBmM6scNQ4LfU6WwqSELRTFvc330l5ixFDWZW8EDjQijLFSWgFNCUqc9L+UB4lPfrw== 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=tEYS0yDl8S2sr5DunT4eYxKqOSSB+yq8j9ejKatbFv8=; b=vp3S16hpkktLxBi1OProO6E5kUjWscoKZl2kO6Yx51eAInxLI7iZJbjRfVKySCIVOmJjMvB7OP3A6Tl2cvOWctukuL+Uf8Nd1kmddKrGPuLp5FbXOn+clv7d4GKFOPndfoqmwh4WlbPOa9zpm55c494/ffbOraug2gKWaZT9SzE= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by LV3PR10MB7820.namprd10.prod.outlook.com (2603:10b6:408:1b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 28 Jun 2023 18:52:42 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6521.024; Wed, 28 Jun 2023 18:52:42 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v24 06/10] crash: memory and CPU hotplug sysfs attributes Date: Wed, 28 Jun 2023 14:52:11 -0400 Message-Id: <20230628185215.40707-7-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230628185215.40707-1-eric.devolder@oracle.com> References: <20230628185215.40707-1-eric.devolder@oracle.com> X-ClientProxiedBy: BYAPR06CA0060.namprd06.prod.outlook.com (2603:10b6:a03:14b::37) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|LV3PR10MB7820:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d9c7fa5-e45d-4c08-9473-08db7808da67 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iaGirDnm0pBp1aVwMOAh8uT4EmbmEiU+nsWb2SIuCWgg12aFttvtfHpXC794VDRktwRT+kjoLF3nD3vN+hAQv3MKu02eAZqIcI7rLEE7HwtBn6BGeBgdptSPHTYtP3JoYqjqnXkgwVjyEUr0D4w9V4oF8s7AcgBdaGz7pp6Hi3ns7SbvzZdz0at5JxzoGfdYtXmXeb+ZBannC0tQVpjKj5fpTQXyU1y0Gg5Rae//WvTrKrewwn/r7zevRV2lmYX1qJtkvwuc8oLRxzGFyvBs6dZ8ZvM54V5L4vFwPvCl4pMgA8/GIxgFeetdiw/Ls1RvXPwvoVDd8M0U+qHIBlTfHodnVhI366hXuFsMDCTTpk+mM7yQ59sYz7aRVRuikOS5Vd0wFt1gZohjbEZefTH2Nldv6XtS+P6erfqLxQlcB1lgHBD68L/FihgPExPVfWgXZH8EtnYYg+HNynjhNRty2h/why4WQXnbAKSWA7J8LWO1UsmkKxazzqtv1BHPPxVjLd+qV3Gx4QXwNWHdAxh+I9g15uWvlLNZvNeNWW2sK2JT8NrwEm7simNYJ4FKcIg4ob5V7ywb/7lt6FPTeajkQ9MI1i5f6MnQ3BfWfrtIE24= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(2906002)(83380400001)(316002)(30864003)(26005)(6506007)(6512007)(1076003)(6666004)(6486002)(186003)(478600001)(86362001)(107886003)(921005)(2616005)(66476007)(41300700001)(8936002)(7406005)(7416002)(4326008)(66556008)(66946007)(8676002)(36756003)(38100700002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PC7AmOTCri7Ak0GV1SXH+vea2N8voprshiRerM0GG11UhRMOzdvtQR0zVLTVOWoZjvmV5Dg/Pq9Qu3EcImgHnCMnTRy0S6GNIjRN1IaNM5wLPA9aFf33SBn0u91RDPcS7lNaBip8LkH19hI5+1TWDvHSeSh25EvlaNwTPatByPN4dA4XOxQtxbhUf6pGBkKpVICI/iemIzVcsHjT58M1Ce5Q+him9q9lJWo3qHdnSDK7lr2zz2g4BGzFxbG+7+6gHKIXqmQoe955x71EsXhZFINOK94w2ptuLkBW0z+jsxuRmdp2akj6qE6yQk/Un2wANGjrH2ILlqdEgcdBgqvUlZ2p+pr09bZwp1OHGvPZEyxwiOI+X0UBMLAC/xNgCQkKzENDDbDIHqRJyL6PfTwOagwhXXoQkJlUwRpHYWiWX6wGwDmvw8m2Y1jtKs3uU+TJb2xx6WN/2a6RTEVVrXDy/JEv+WcG6z7z1SxYgK8HH/vaQcNDoLCxLc7hqpd4LypMQ4cMChTExO+/Q+ynU6w7ekumvqfr5aTJCqU57J7MO+++0yLqQrV2ICPQQR5y56pWpdhV7DRfqelUBlvQ0pHWf8XWKJlYlsSTUysNJR9WZpZhsuMTINM9JUNlfclp2vspb3w4gFJQHZ1g2YZlXWn7b+EEYr76x6TyqfbW70Q+fTfFzphChlOSLv3W1w9kxHvek9+LMGD8KhFx77lNIPxsVvPJvWaVUV+I+LQ93aQhZqfqrx5lwvtJViloYLt1P5Nii6CTV+5vYEllNhpV2RqMN0xOrh6aFw9hSnt8RL5/DAdym/K1ytqNEvA/IvQj5NcS6e62mG6167PwzzEjU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eBz7kDvgKu9pyBOHyvZwfzfYA3PcNsAyleYb+3sj7Np4lhRaEwbv1OTcQMJ0Qavr3Cez1gj20DAWMWHAWlguz0K9iI5y37KH+TPtLOCrBwb0hDnR38qMtdIPEhYlK4biq5Cwx7ND5Da1N12P6VPCksZUuD5o= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d9c7fa5-e45d-4c08-9473-08db7808da67 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2023 18:52:42.3442 (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: BeDtKLvJDGZ2M2mCtivPjOkDPyH/imdw2hqDLkcKcufz2Xd1AHsHQVQOeQZNGZTFrafFj0QuBN2f5PV4SEulGAJdskwcb5Kh6a3feLaDYwA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7820 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_13,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280168 X-Proofpoint-ORIG-GUID: wYbCvOt5bUjwjpVYwI7BR2yxDhXqcphV X-Proofpoint-GUID: wYbCvOt5bUjwjpVYwI7BR2yxDhXqcphV 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?1769973936028317422?= X-GMAIL-MSGID: =?utf-8?q?1769973936028317422?= Introduce the crash_hotplug attribute for memory and CPUs for use by userspace. These attributes directly facilitate the udev rule for managing userspace re-loading of the crash kernel upon hot un/plug changes. For memory, expose the crash_hotplug attribute to the /sys/devices/system/memory directory. For example: # udevadm info --attribute-walk /sys/devices/system/memory/memory81 looking at device '/devices/system/memory/memory81': KERNEL=="memory81" SUBSYSTEM=="memory" DRIVER=="" ATTR{online}=="1" ATTR{phys_device}=="0" ATTR{phys_index}=="00000051" ATTR{removable}=="1" ATTR{state}=="online" ATTR{valid_zones}=="Movable" looking at parent device '/devices/system/memory': KERNELS=="memory" SUBSYSTEMS=="" DRIVERS=="" ATTRS{auto_online_blocks}=="offline" ATTRS{block_size_bytes}=="8000000" ATTRS{crash_hotplug}=="1" For CPUs, expose the crash_hotplug attribute to the /sys/devices/system/cpu directory. For example: # udevadm info --attribute-walk /sys/devices/system/cpu/cpu0 looking at device '/devices/system/cpu/cpu0': KERNEL=="cpu0" SUBSYSTEM=="cpu" DRIVER=="processor" ATTR{crash_notes}=="277c38600" ATTR{crash_notes_size}=="368" ATTR{online}=="1" looking at parent device '/devices/system/cpu': KERNELS=="cpu" SUBSYSTEMS=="" DRIVERS=="" ATTRS{crash_hotplug}=="1" ATTRS{isolated}=="" ATTRS{kernel_max}=="8191" ATTRS{nohz_full}==" (null)" ATTRS{offline}=="4-7" ATTRS{online}=="0-3" ATTRS{possible}=="0-7" ATTRS{present}=="0-3" With these sysfs attributes in place, it is possible to efficiently instruct the udev rule to skip crash kernel reloading for kernels configured with crash hotplug support. For example, the following is the proposed udev rule change for RHEL system 98-kexec.rules (as the first lines of the rule file): # The kernel updates the crash elfcorehdr for CPU and memory changes SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" SUBSYSTEM=="memory", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" When examined in the context of 98-kexec.rules, the above rules test if crash_hotplug is set, and if so, the userspace initiated unload-then-reload of the crash kernel is skipped. CPU and memory checks are separated in accordance with CONFIG_HOTPLUG_CPU and CONFIG_MEMORY_HOTPLUG kernel config options. If an architecture supports, for example, memory hotplug but not CPU hotplug, then the /sys/devices/system/memory/crash_hotplug attribute file is present, but the /sys/devices/system/cpu/crash_hotplug attribute file will NOT be present. Thus the udev rule skips userspace processing of memory hot un/plug events, but the udev rule will evaluate false for CPU events, thus allowing userspace to process CPU hot un/plug events (ie the unload-then-reload of the kdump capture kernel). Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- Documentation/ABI/testing/sysfs-devices-memory | 8 ++++++++ .../ABI/testing/sysfs-devices-system-cpu | 8 ++++++++ .../admin-guide/mm/memory-hotplug.rst | 8 ++++++++ Documentation/core-api/cpu_hotplug.rst | 18 ++++++++++++++++++ drivers/base/cpu.c | 16 ++++++++++++++-- drivers/base/memory.c | 13 +++++++++++++ include/linux/kexec.h | 8 ++++++++ 7 files changed, 77 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-devices-memory b/Documentation/ABI/testing/sysfs-devices-memory index d8b0f80b9e33..c50725ebebb7 100644 --- a/Documentation/ABI/testing/sysfs-devices-memory +++ b/Documentation/ABI/testing/sysfs-devices-memory @@ -110,3 +110,11 @@ Description: link is created for memory section 9 on node0. /sys/devices/system/node/node0/memory9 -> ../../memory/memory9 + +What: /sys/devices/system/cpu/crash_hotplug +Date: Jun 2023 +Contact: Linux kernel mailing list +Description: + (RO) indicates whether or not the kernel directly supports + modifying the crash elfcorehdr for memory hot un/plug and/or + on/offline changes. diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu index ecd585ca2d50..598b0fa67481 100644 --- a/Documentation/ABI/testing/sysfs-devices-system-cpu +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu @@ -686,3 +686,11 @@ Description: (RO) the list of CPUs that are isolated and don't participate in load balancing. These CPUs are set by boot parameter "isolcpus=". + +What: /sys/devices/system/cpu/crash_hotplug +Date: Jun 2023 +Contact: Linux kernel mailing list +Description: + (RO) indicates whether or not the kernel directly supports + modifying the crash elfcorehdr for CPU hot un/plug and/or + on/offline changes. diff --git a/Documentation/admin-guide/mm/memory-hotplug.rst b/Documentation/admin-guide/mm/memory-hotplug.rst index 1b02fe5807cc..eb99d79223a3 100644 --- a/Documentation/admin-guide/mm/memory-hotplug.rst +++ b/Documentation/admin-guide/mm/memory-hotplug.rst @@ -291,6 +291,14 @@ The following files are currently defined: Availability depends on the CONFIG_ARCH_MEMORY_PROBE kernel configuration option. ``uevent`` read-write: generic udev file for device subsystems. +``crash_hotplug`` read-only: when changes to the system memory map + occur due to hot un/plug of memory, this file contains + '1' if the kernel updates the kdump capture kernel memory + map itself (via elfcorehdr), or '0' if userspace must update + the kdump capture kernel memory map. + + Availability depends on the CONFIG_MEMORY_HOTPLUG kernel + configuration option. ====================== ========================================================= .. note:: diff --git a/Documentation/core-api/cpu_hotplug.rst b/Documentation/core-api/cpu_hotplug.rst index e6f5bc39cf5c..54581c501562 100644 --- a/Documentation/core-api/cpu_hotplug.rst +++ b/Documentation/core-api/cpu_hotplug.rst @@ -741,6 +741,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 75fa46a567a1..26c85f3c8193 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "base.h" @@ -132,8 +133,6 @@ static DEVICE_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); static DEVICE_ATTR(release, S_IWUSR, NULL, cpu_release_store); #ifdef CONFIG_KEXEC -#include - static ssize_t crash_notes_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -290,6 +289,14 @@ static ssize_t print_cpus_nohz_full(struct device *dev, } static DEVICE_ATTR(nohz_full, 0444, print_cpus_nohz_full, NULL); +static ssize_t crash_hotplug_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return sysfs_emit(buf, "%d\n", crash_hotplug_cpu_support()); +} +static DEVICE_ATTR_ADMIN_RO(crash_hotplug); + static void cpu_device_release(struct device *dev) { /* @@ -474,6 +481,7 @@ static struct attribute *cpu_root_attrs[] = { &dev_attr_isolated.attr, &dev_attr_nohz_full.attr, &dev_attr_modalias.attr, + &dev_attr_crash_hotplug.attr, NULL }; @@ -509,6 +517,10 @@ cpu_root_attr_is_visible(struct kobject *kobj, if (attr == &dev_attr_modalias.attr) return mode; } + if (IS_ENABLED(CONFIG_CRASH_HOTPLUG)) { + if (attr == &dev_attr_crash_hotplug.attr) + return mode; + } return 0; } diff --git a/drivers/base/memory.c b/drivers/base/memory.c index f03eda7e1c9c..f1b9d8fccace 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -25,6 +25,7 @@ #include #include +#include #define MEMORY_CLASS_NAME "memory" @@ -494,6 +495,13 @@ static ssize_t auto_online_blocks_store(struct device *dev, static DEVICE_ATTR_RW(auto_online_blocks); +static ssize_t crash_hotplug_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%d\n", crash_hotplug_memory_support()); +} +static DEVICE_ATTR_RO(crash_hotplug); + /* * Some architectures will have custom drivers to do this, and * will not need to do it from userspace. The fake hot-add code @@ -916,6 +924,7 @@ static struct attribute *memory_root_attrs[] = { &dev_attr_hard_offline_page.attr, &dev_attr_block_size_bytes.attr, &dev_attr_auto_online_blocks.attr, + &dev_attr_crash_hotplug.attr, NULL }; @@ -939,6 +948,10 @@ memory_root_attr_is_visible(struct kobject *kobj, return mode; if (attr == &dev_attr_auto_online_blocks.attr) return mode; + if (IS_ENABLED(CONFIG_CRASH_HOTPLUG)) { + if (attr == &dev_attr_crash_hotplug.attr) + return mode; + } return 0; } diff --git a/include/linux/kexec.h b/include/linux/kexec.h index b9903dd48e24..6a8a724ac638 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -501,6 +501,14 @@ static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } #endif +#ifndef crash_hotplug_cpu_support +static inline int crash_hotplug_cpu_support(void) { return 0; } +#endif + +#ifndef crash_hotplug_memory_support +static inline int crash_hotplug_memory_support(void) { return 0; } +#endif + #else /* !CONFIG_KEXEC_CORE */ struct pt_regs; struct task_struct; From patchwork Wed Jun 28 18:52:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 114009 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9140104vqr; Wed, 28 Jun 2023 11:57:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4p6f8J4+QzGHjqR9Us1++d310nznhCmz+Uc5LACIAGb3uZj4wZuJ+1IwVUYkm4rk7epyTm X-Received: by 2002:a05:6a20:9187:b0:121:84ce:c629 with SMTP id v7-20020a056a20918700b0012184cec629mr626951pzd.0.1687978654271; Wed, 28 Jun 2023 11:57:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687978654; cv=pass; d=google.com; s=arc-20160816; b=JLYi2aYkoqlwhKrlRzIDIZkD3bfky/0g61yatfjVwKrxtc3Lh9QAJHPzStIkHT0F43 P2vqrQoUWCki6HE7lU3jxVqj5KBsHeSd8z9eWsuBQmc5YMvcwX5ZJq3gkruc7rpOKYng X9YKYBO/n573ls4Mp3F7ihB0F1H7ZJWPXrVwbYBAuaZYRXOQ3Q1V6l1/6Kkn66X0pOkS HwaI4+RzLF6x4ZDXNy3hfllXZw1QSehhFdE4NGmYyjgG3maOKYuA609jfTRI5zP1Y56V y8V+CID/IeGA8Zdf8OMehjaAAuprOD6/x1GxCsVuqfZol8pl+tfYsfsja2VPov9tZ4Bh hx+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=OCr5zrFqhJdkDnvbZF8hy5NfQnLo1d6CmVojxbAKj4s=; fh=j+K5GuuLTbxxisV+wJRNZBqbr6zhGMwAghI8ANXi4rw=; b=uGj+jcIdBUhH/JnCX8m/88VP6k2JS4cQSzsYPe3jrCKX4s5XMRCDy5rE44JPpaYQWM LV0w9/55cgFTjU5F+YhAj6kWh4ganRc7wi0JtSXAnD348xjKM24Uda845M97X9m4hpJh 4cvpPoaB+ow0/1PGRxNrHbWu/Q2c7sHej/ezuYDwtpAsiu9akFPssw1H5TJMajYoyP/l Uv1f/EDVVsYI619Z+aXRHVmSThxKflb5hbs9Msd2xoK2TuSEbIHIgDeDk+J1U/W0ncBj kSmUwp/vHmqqpD3liu4iuIsE3KwGsAkkoVaCAIQWDGL6S/O3RxH5XcdIlTdSwQBNd/e3 9brg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=lEgLG7qV; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YhATAq0b; 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 i6-20020a170902c94600b001b34159f341si9912287pla.596.2023.06.28.11.57.17; Wed, 28 Jun 2023 11:57:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=lEgLG7qV; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YhATAq0b; 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 S232667AbjF1SyG (ORCPT + 99 others); Wed, 28 Jun 2023 14:54:06 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:59560 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232251AbjF1Sxc (ORCPT ); Wed, 28 Jun 2023 14:53:32 -0400 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 35SGx6RN006753; Wed, 28 Jun 2023 18:52:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=OCr5zrFqhJdkDnvbZF8hy5NfQnLo1d6CmVojxbAKj4s=; b=lEgLG7qVVMHvyUlEIGJBOgjofPkAf+XbcjPu4W5nzvjh3wnuGlA18tUHrLuH1jSzFoKx PqZp8C95it/DfqgGxeEWSY7g7i90+JIJB7FU+plmmdbD20uMSY+1X7sskJI2+XTcAxbs r0mU1TiPI252o9WgphE7PVx5tjjgZbne/yOJVUu5CJXAHZRCLUNK43SGKMXFB1mZklGm HITlcquRJYvCm5jSaq38tf3ySq94g/4LwSVs8aTmcb0ISRRPyGBXPmROXgdywGsm46vM ob3IfrXOjoC2z3Mm8txr6FkXZYbf58W5N1ppDg1gjIEvN9Zjzc9d6oP4afi4gxwS6Lfh SA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdq310pg1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:50 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35SHaNjJ013088; Wed, 28 Jun 2023 18:52:50 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpx6n2wd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A9Em39nZDiGuesOEkZfjaMp7L/cSCL5k3bGdc7tdExLLIS2PRJ9zpLWbV1uPpHLeuXJlVIzoUPu/SDjoaKN9mZuPvAlg53xJcyVCsL3xqi91v4Z20ZDnJ0oK7nak2XMO6XVu9Uw4tY6YrwyLsQnubffSkUzKR5e1Lvb90PL7WRnnPtrEhzLEBV4HjAQgCZsBXQT22Ly+0Vvul5uMN7q0gQYSVwUyaEg4hJWGZCgNGkcFVjQ9FwfY21THtQBUWCXDKCpWt5PwFD8oBBozUfGeIbo1ltCPoEVyv2rrGHTp4RxnkIpRt0DZC9vZ+BNiLMdksnJLZPJgZCkPXU88X2EeRQ== 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=OCr5zrFqhJdkDnvbZF8hy5NfQnLo1d6CmVojxbAKj4s=; b=VYUcQ79+rZp+nk/5js/gKmFE4CEH2hsC2rvs5/g1UsUWd5C6xiCRoScoi/hAgBZS6+66cgWS68YclR3ZFe6fSrUeGZSMvzwfJj+BozgYR3wtPUrCPngdp+tCrkf3d61A1rCIhZZeesjTQcbWFkx4M7x7RrdYaqA3vNKS6WwE4BU4dk7ahFvSw7PSVh8Tj8RrnJNmdix/UkTWOKlkaKi8nT5VkqNRrcGrvf2Qts6/J9HoiBYbT7s+xgFke16ZnT17EbW024oy7CxN/V77QCFSZIxEUSeoveU7AAeSBwvirjcpsYyI1d8VPGEXmDvo/ve169gvNiqcTWH+2LZavGOKrg== 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=OCr5zrFqhJdkDnvbZF8hy5NfQnLo1d6CmVojxbAKj4s=; b=YhATAq0bsmCdG97eIHi2MwV4TU7UrgYSPz4hvJz1Jx2IyLJSYLIRmc3UtuR2JN2/sruCJ/vjz//JGUjZQ3/rM9Zj8xGgKpkhgt0GjSCV/B2aD9tVoKdgTCVbKdunqIMwJvFF8MPj9LAWLHr0rODBYNu0/jx1heZbGrIWtdiiGK4= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by LV3PR10MB7820.namprd10.prod.outlook.com (2603:10b6:408:1b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 28 Jun 2023 18:52:45 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6521.024; Wed, 28 Jun 2023 18:52:45 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v24 07/10] x86/crash: add x86 crash hotplug support Date: Wed, 28 Jun 2023 14:52:12 -0400 Message-Id: <20230628185215.40707-8-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230628185215.40707-1-eric.devolder@oracle.com> References: <20230628185215.40707-1-eric.devolder@oracle.com> X-ClientProxiedBy: BYAPR06CA0006.namprd06.prod.outlook.com (2603:10b6:a03:d4::19) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|LV3PR10MB7820:EE_ X-MS-Office365-Filtering-Correlation-Id: b782763a-503a-4e44-7d75-08db7808dc2c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SAnwHv8GjQaq0CrAPppI+2N1dnqG5ENtCqEkeBneH0UjT5ILpFUMEDZZ/KQxoyY2x4gSvwtKsVayLx7gX9t8SlJFx0/kG0Hd9wW9A2cZxDcKqHHk4JCELcecc8a11w+HCDf4bR9ppGKkZlULk22DA/Vga6XZE+eAfIwYloA0obJOgkBi67q3WOEt90ea3iMVu+1iyzzx8G7czF/Q7roO5GCkVnk1txxBqbapmImdjNv20jGohIaKc3oapPC+1ltstPLhovwShBHI/hMLLVhz7niMKKd4hOkfXzA1anhtGTSw7d6WPswH3RZMADizJec3PPOwvnkxcaDl0Xs9mq8sgxNyvkTcbgP3SAyJkaKGSbZifbtDuQc2hdWFKkkRS4+5A7xfGBOelwz7H2gGZwSNzlwISAcTt5pKr15dNtFa88uAmQzUAFgcDgyXaDWUrs4hYShl+PQmV8iBXFMW3YU1xMvjd+u58HeBD4hW5TyuyNrOmnwzESs/QSoYRbz2RxxAfXWw4yqnT8RPuZsbqsVNwWuIxRkpZMoX4WNGc6ChiA8VX6EQo+j5+y/eRHcDO1TavBCjVjxA87Dt/UFD2KfCZlcHxjT/a+MyA6xarD9fnQ8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(2906002)(83380400001)(316002)(26005)(6506007)(6512007)(1076003)(6666004)(6486002)(186003)(478600001)(86362001)(107886003)(921005)(2616005)(66476007)(41300700001)(8936002)(7406005)(7416002)(4326008)(66556008)(66946007)(8676002)(36756003)(38100700002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U/7XCOnGIaFXjDEm+SuMWPwhVnpO/uxGC/eugnOXRdQ9oUGn5e0xmjh0Q7NTFsQfW2nlF+zTiLz5Bn3Vx0yMj3zZFDsx6Gtnmewjok7jt+wQDaLtb+pQfg84aaDERrBh2tpzZc/YkE87O9w7B+dJEhsW4dxlX13HfW6GMOg3wCKtoOo+xccyfx6f58wbq7Obiyz7iIHTXo2Ycc0G6ALZy6kXZ0n99vqLUJqf+kXLrq1TXVvoKJxk0aNYSZoocNLvBbx/qhVUd03jy3829MPtltakSGdT6/PDd9/fg7PZ5ukToa933Kpr0J5+ihIUnAfVCCxOYlcjjqKKeDCbAGcCc+hh/aTHX0SJWXfxcG/NGZeL/FefYiH//7rZsCvzhq+kqi759kdoDU2t61H+iXvJ4NuGIG/wvQxAU4Y+COcAmMn4N8hSJd87djFMRqBf0ztEfvh7DmHWkdutVrGUhdl/JpCvOsfwjMGayQioLiNZi+FajXWVnJN/wuFBfn324GTrlPkg4DxVNies9k1h0jDz5RqRE9vnAFHXY4GzXfH+bsrG3eXX+zFCFKLGa7aSF4dB+nEIva0uvIu02T9JLctxOU61dFnxICnHtBLEu9MMu+31ofL7omP1Vo2HEynRUMRrFsIkDPB4UcwD/QarxiPyWB1CI+E2ZTb7KM9QL0iHtBEnrCvlDBgO8JtNkKfnBogGsIldLShRe9jnJ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HeQAFj/zXICchDTMym6mVcGYCrHlNmcGUTTqFVTQhV0R1IKYbGIl3CPoS8go1ts0qJVXiWzqu7SkolPPSo4FtvmFbDzVNJ1c1xf4bNmhlLJGz7x4eUjk0sPKAUaKPjBQoavMqkVeq7ru8gD+gY3godh1fpA+yJ9T48jVm36RBx/m4z+NCofrq3AESDkWDXIxHQslaC2KDBclRKFOe1Vk+0PPbKzYW5oAp/isRWdoqLL1nL0DtbkfYNdnBpQAjcvTsuy+WqTo7YFRbVDjnaEzR2XrLBrOy0UX8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b782763a-503a-4e44-7d75-08db7808dc2c X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2023 18:52:45.3290 (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: VPUexnmufsGi+qg85rP3ZAb6VWknIJSZPsLbHsURWf99qKZwxOux4y9q5SisLXuBNbSRLrWXdDCXoO1NnSTktlX+xnIJEtSe7GAxmXeSnGU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7820 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_13,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280168 X-Proofpoint-ORIG-GUID: 1iKA8ihLIlBCk7NfbfbuuCSx3BJTiulX X-Proofpoint-GUID: 1iKA8ihLIlBCk7NfbfbuuCSx3BJTiulX 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?1769973905380845208?= X-GMAIL-MSGID: =?utf-8?q?1769973905380845208?= When CPU or memory is hot un/plugged, or off/onlined, the crash elfcorehdr, which describes the CPUs and memory in the system, must also be updated. A new elfcorehdr is generated from the available CPUs and memory and replaces the existing elfcorehdr. The segment containing the elfcorehdr is identified at run-time in crash_core:crash_handle_hotplug_event(). No modifications to purgatory (see 'kexec: exclude elfcorehdr from the segment digest') or boot_params (as the elfcorehdr= capture kernel command line parameter pointer remains unchanged and correct) are needed, just elfcorehdr. For kexec_file_load(), the elfcorehdr segment size is based on NR_CPUS and CRASH_MAX_MEMORY_RANGES in order to accommodate a growing number of CPU and memory resources. For kexec_load(), the userspace kexec utility needs to size the elfcorehdr segment in the same/similar manner. To accommodate kexec_load() syscall in the absence of kexec_file_load() syscall support, prepare_elf_headers() and dependents are moved outside of CONFIG_KEXEC_FILE. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- arch/x86/Kconfig | 3 + arch/x86/include/asm/kexec.h | 15 +++++ arch/x86/kernel/crash.c | 103 ++++++++++++++++++++++++++++++++--- 3 files changed, 114 insertions(+), 7 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 06a4472d0fc0..42c083da7ce4 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2058,6 +2058,9 @@ config ARCH_SUPPORTS_KEXEC_JUMP config ARCH_SUPPORTS_CRASH_DUMP def_bool X86_64 || (X86_32 && HIGHMEM) +config ARCH_SUPPORTS_CRASH_HOTPLUG + def_bool y + config PHYSICAL_START hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP) default "0x1000000" diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index 5b77bbc28f96..9143100ea3ea 100644 --- a/arch/x86/include/asm/kexec.h +++ b/arch/x86/include/asm/kexec.h @@ -209,6 +209,21 @@ typedef void crash_vmclear_fn(void); extern crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss; extern void kdump_nmi_shootdown_cpus(void); +#ifdef CONFIG_CRASH_HOTPLUG +void arch_crash_handle_hotplug_event(struct kimage *image); +#define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event + +#ifdef CONFIG_HOTPLUG_CPU +static inline int crash_hotplug_cpu_support(void) { return 1; } +#define crash_hotplug_cpu_support crash_hotplug_cpu_support +#endif + +#ifdef CONFIG_MEMORY_HOTPLUG +static inline int crash_hotplug_memory_support(void) { return 1; } +#define crash_hotplug_memory_support crash_hotplug_memory_support +#endif +#endif + #endif /* __ASSEMBLY__ */ #endif /* _ASM_X86_KEXEC_H */ diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index cdd92ab43cda..c70a111c44fa 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -158,8 +158,6 @@ void native_machine_crash_shutdown(struct pt_regs *regs) crash_save_cpu(regs, safe_smp_processor_id()); } -#ifdef CONFIG_KEXEC_FILE - static int get_nr_ram_ranges_callback(struct resource *res, void *arg) { unsigned int *nr_ranges = arg; @@ -231,7 +229,7 @@ static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg) /* Prepare elf headers. Return addr and size */ static int prepare_elf_headers(struct kimage *image, void **addr, - unsigned long *sz) + unsigned long *sz, unsigned long *nr_mem_ranges) { struct crash_mem *cmem; int ret; @@ -249,6 +247,9 @@ static int prepare_elf_headers(struct kimage *image, void **addr, if (ret) goto out; + /* Return the computed number of memory ranges, for hotplug usage */ + *nr_mem_ranges = cmem->nr_ranges; + /* By default prepare 64bit headers */ ret = crash_prepare_elf64_headers(cmem, IS_ENABLED(CONFIG_X86_64), addr, sz); @@ -257,6 +258,7 @@ static int prepare_elf_headers(struct kimage *image, void **addr, return ret; } +#ifdef CONFIG_KEXEC_FILE static int add_e820_entry(struct boot_params *params, struct e820_entry *entry) { unsigned int nr_e820_entries; @@ -371,18 +373,42 @@ int crash_setup_memmap_entries(struct kimage *image, struct boot_params *params) int crash_load_segments(struct kimage *image) { int ret; + unsigned long pnum = 0; struct kexec_buf kbuf = { .image = image, .buf_min = 0, .buf_max = ULONG_MAX, .top_down = false }; /* Prepare elf headers and add a segment */ - ret = prepare_elf_headers(image, &kbuf.buffer, &kbuf.bufsz); + ret = prepare_elf_headers(image, &kbuf.buffer, &kbuf.bufsz, &pnum); if (ret) return ret; - image->elf_headers = kbuf.buffer; - image->elf_headers_sz = kbuf.bufsz; + image->elf_headers = kbuf.buffer; + image->elf_headers_sz = kbuf.bufsz; + kbuf.memsz = kbuf.bufsz; + +#ifdef CONFIG_CRASH_HOTPLUG + /* + * The elfcorehdr segment size accounts for VMCOREINFO, kernel_map, + * maximum CPUs and maximum memory ranges. + */ + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + pnum = 2 + CONFIG_NR_CPUS_DEFAULT + CONFIG_CRASH_MAX_MEMORY_RANGES; + else + pnum += 2 + CONFIG_NR_CPUS_DEFAULT; + + if (pnum < (unsigned long)PN_XNUM) { + kbuf.memsz = pnum * sizeof(Elf64_Phdr); + kbuf.memsz += sizeof(Elf64_Ehdr); + + image->elfcorehdr_index = image->nr_segments; + + /* Mark as usable to crash kernel, else crash kernel fails on boot */ + image->elf_headers_sz = kbuf.memsz; + } else { + pr_err("number of Phdrs %lu exceeds max\n", pnum); + } +#endif - kbuf.memsz = kbuf.bufsz; kbuf.buf_align = ELF_CORE_HEADER_ALIGN; kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; ret = kexec_add_buffer(&kbuf); @@ -395,3 +421,66 @@ int crash_load_segments(struct kimage *image) return ret; } #endif /* CONFIG_KEXEC_FILE */ + +#ifdef CONFIG_CRASH_HOTPLUG + +#undef pr_fmt +#define pr_fmt(fmt) "crash hp: " fmt + +/** + * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes + * @image: a pointer to kexec_crash_image + * + * Prepare the new elfcorehdr and replace the existing elfcorehdr. + */ +void arch_crash_handle_hotplug_event(struct kimage *image) +{ + void *elfbuf = NULL, *old_elfcorehdr; + unsigned long nr_mem_ranges; + unsigned long mem, memsz; + unsigned long elfsz = 0; + + /* + * Create the new elfcorehdr reflecting the changes to CPU and/or + * memory resources. + */ + if (prepare_elf_headers(image, &elfbuf, &elfsz, &nr_mem_ranges)) { + pr_err("unable to create new elfcorehdr"); + goto out; + } + + /* + * Obtain address and size of the elfcorehdr segment, and + * check it against the new elfcorehdr buffer. + */ + mem = image->segment[image->elfcorehdr_index].mem; + memsz = image->segment[image->elfcorehdr_index].memsz; + if (elfsz > memsz) { + pr_err("update elfcorehdr elfsz %lu > memsz %lu", + elfsz, memsz); + goto out; + } + + /* + * Copy new elfcorehdr over the old elfcorehdr at destination. + */ + old_elfcorehdr = kmap_local_page(pfn_to_page(mem >> PAGE_SHIFT)); + if (!old_elfcorehdr) { + pr_err("mapping elfcorehdr segment failed\n"); + goto out; + } + + /* + * Temporarily invalidate the crash image while the + * elfcorehdr is updated. + */ + xchg(&kexec_crash_image, NULL); + memcpy_flushcache(old_elfcorehdr, elfbuf, elfsz); + xchg(&kexec_crash_image, image); + kunmap_local(old_elfcorehdr); + pr_debug("updated elfcorehdr\n"); + +out: + vfree(elfbuf); +} +#endif From patchwork Wed Jun 28 18:52:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 114004 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9139775vqr; Wed, 28 Jun 2023 11:56:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Pnb/mPPe2DXgRqfh2J3vQkhspgUAw+PRANdYzLMZ+bza+tq1t19eeH7yoDrGgqmp2o+4a X-Received: by 2002:a17:90a:885:b0:262:c2a1:c029 with SMTP id v5-20020a17090a088500b00262c2a1c029mr15538591pjc.2.1687978619321; Wed, 28 Jun 2023 11:56:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687978619; cv=pass; d=google.com; s=arc-20160816; b=qlwexG5VMkxfoCbMKbtC9Xw1T1SG8RSMgdVgt7sf3lT7ZuXlgaVYJiY6ZYjI9bpfrq OLcSC5Gsi/2zI/dsxqYZvIZ29/SJP3RE0YfeeB7I7vM0YUbfsuWqvKDdoNgcrsQnOL+i pDyHlQ0JSycVxMK4Ch1BPbM/gUK7hzYG8gM0S+FOFVhW3X6aemVCK3kxy4hFinDXuNBk iKpbO4mAlw/r2RpKR2VoLPtP4nhfuaMxmqGQgagQKCf7B9+XA/gu7Qh6FBjcXrTc6tkw MBUYIsUbK9kFkz4GYuBwmleS86xTn5SzKK+9jZRpFdQ4Y4VB6s6v5mcTE0DQHfxdZJoJ yAEQ== 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=K+AA+kYbNK2C8VbAVOrXqomOnTOwqL7DHRi/gDse0kY=; fh=j+K5GuuLTbxxisV+wJRNZBqbr6zhGMwAghI8ANXi4rw=; b=NlMjbuhB/ywJffKZhPsD/FN5GvHnNrZFQIlz0rTtYH3BTnO8g7/IvEPsYRUB+6/ziA OXNwlPDarBDJfrmqIs1R5qmikqdRtyQq6U6d/YEk/AnnBxu5+9ELH8jrAC5jwSzBDe3t N9cmOdzwzP1Wnoef3XONHcq2rOlxWv3f9LUBBK+ZlLLI06UlRupbbfmsuVTDahXycypA JUXbnCyBp31dP975HnKo440tZfp7oGPpOve4+oYL7spb7XYPsZIBzmQFPqcTi6WOVOov AP+C0uq86GgMEX6RxNuwlPTbZ/qMAlCc++jPanYqBMQiC+UWL89V72qa+hCC4htb/kK0 NSdw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=oNMMB2wq; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Y2bn9dkQ; 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 gf7-20020a17090ac7c700b0026305080a6fsi4980563pjb.63.2023.06.28.11.56.45; Wed, 28 Jun 2023 11:56:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=oNMMB2wq; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Y2bn9dkQ; 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 S232245AbjF1Sxs (ORCPT + 99 others); Wed, 28 Jun 2023 14:53:48 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:44202 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231185AbjF1SxT (ORCPT ); Wed, 28 Jun 2023 14:53:19 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35SGwv53019748; Wed, 28 Jun 2023 18:52:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=K+AA+kYbNK2C8VbAVOrXqomOnTOwqL7DHRi/gDse0kY=; b=oNMMB2wqdsWthy3UL+qaumkXQNV0ed+uAL0MY5oMz+iwQG9rm0wdWDGvOZfQWPeqhB1i bsAIMo+tI1c94O1v5/paLmTNjMJcrFWKM0P1/Stjgygd36Wrub/7JY+CgCcQQfo5JJv/ Rowpq1pUiWBf9XbfrAlakdIBjvky7+49xTr+IuKT2v7ksH/uAm8sz/7QfRw4oKiZYtaN dvHNghsMi0Rf63h/oIy31ykzWFKAcQo7VDpC7HYXKbu+b/QLOlalDHfTR+a+LW96tALb QCcywlof3Ihc++5Z5XywkKltIaEyvLnMSQVTcVh3pWCD5mc2xUsVESZCBN0fTt3l9MKB 3A== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdpwdgjwc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:52 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35SHaNjK013088; Wed, 28 Jun 2023 18:52:51 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpx6n2wd-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z8GXQC3vrH2rbq09lM1BqcChX+nVwk94WjCqKn9bhnv2UZ+I4zHOwm97jieKQVAgRlkBV62ECZ1kc+6FeTht8K9cd5H8qOJ1lblKizUldESFOZnxjEgO5vbNBk4UpE8bbp+sMSO4VcyNHBaN8uf+qOj3YEwZelWBTwBz0uUuTAvQqyaWHlNa+OtShYyZsk3bfpi2CovBuK15uJ7VI/ksorCx4MC/KHmIsk9T7U4pYFNQ3KXdrlaGpeUSll7rmGetY1c5TC2Q2+Brxmo/eTG72kMdc+3C6w80MD97yHVZ3/Px/gu/ZZAd8sFgsFNu4UogO1ekGi9aSkSZhEaxyxHlpQ== 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=K+AA+kYbNK2C8VbAVOrXqomOnTOwqL7DHRi/gDse0kY=; b=R0fdBzqJOvtGShFpugEA2N+tHgjPAxPHwzKC2usAqZ+KD1GwvGRgUGtJFYpI3M87/NsdBXdp/GMQPRiWHMptC+v0xmevIvPUhomRkjBUe9Pt/pZ3kXF31I9uDkW/LzVDuuwcJIUTCcGKUkydlYiNp2i2w3qCjcYVUQxXEvWWmNbarIuDfif70ee+d5XASOqIa0xGWrTSHnzEpBcKopL1ZOvSYnNVN+blxcWj3VGBj3nVN6BsgoGkLhNBycX0mdvrvw8CC+VQHMdRSt7MkvnVxkNCwQYaGKkr8Q0t3zLNipi+BZaN6cXsIreYJHZOylDWz+84SEB1+iqejcKzktFIEA== 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=K+AA+kYbNK2C8VbAVOrXqomOnTOwqL7DHRi/gDse0kY=; b=Y2bn9dkQsqk8Kmh/AM9ytwLCc5g//3X+AUsKgxDNv3GqE33nfo9ngltW9YpCtOqpQu+Uk+YjnLxL9yQev2v/ew4fkSyEn25g+LEKulye4i3v/Vjb8Vwwr6XYn0VXKcN0XB6xzaCIyJUuR/OC5gUiOlb4bpt70PNPV8uA4H0APQg= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by LV3PR10MB7820.namprd10.prod.outlook.com (2603:10b6:408:1b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 28 Jun 2023 18:52:48 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6521.024; Wed, 28 Jun 2023 18:52:48 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v24 08/10] crash: hotplug support for kexec_load() Date: Wed, 28 Jun 2023 14:52:13 -0400 Message-Id: <20230628185215.40707-9-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230628185215.40707-1-eric.devolder@oracle.com> References: <20230628185215.40707-1-eric.devolder@oracle.com> X-ClientProxiedBy: SJ0PR03CA0050.namprd03.prod.outlook.com (2603:10b6:a03:33e::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_|LV3PR10MB7820:EE_ X-MS-Office365-Filtering-Correlation-Id: f32b46f7-2006-4e83-5792-08db7808ddbf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /l0M4CV7VgRzVCfpzNoW6LdtuGs6k2vQme6TRtX1P6/giIdNeiKquzw/WheAiUpHklMP6u1r1YhnrS2J0xx27g0iQ1FXRP5IbZneRSoFm73chqMgFpzcl81Q5Vrq7EdYognF9Bo3v6/EXqztjnqqtHzRk5u2a6miODQHMo8Si4+ptahhgIXb7NG3VnmAVPq9lZk6b7rTzBUN64GbnKjv9cOHdF+DQYdq4pxzrwTOFeZqEl5u4zLbA075gHk25LBM8eJAEt10FvVRqDWFnoYECoFMGW4GIwRTWL1Alpnme6n6658xNGs8fj3cW01dfl5eFNHeYjTCGQrB/Z8jPblxeA5FYlCrFmwepHQZP2hDdnJfu3kZdWJGrZBRUethBQCzraUUJ0uurWUoBQs5EPF1YI+gVWYE0PrQ1K53yrUd2FYjoPWmnu2NPUGZTewZoVTo3WdUb6BQYhSpDIhG33JXSp3HgPOv98vhgQnBRl5U2otfPcA3TOZXBTeBkVDF7PTDTzAJfw0X8JoRM02HaM+rtBlhjOxZWyfE48Ukj0qdypC1Rg88k7GiNpcrDLU20NXW7WM80DKJzWyaH2tgu0ppEbJv+RXtXuPrquIFQf+LtdQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(2906002)(83380400001)(316002)(30864003)(26005)(6506007)(6512007)(1076003)(6666004)(6486002)(186003)(478600001)(86362001)(107886003)(921005)(2616005)(66476007)(41300700001)(8936002)(7406005)(7416002)(4326008)(66556008)(66946007)(8676002)(36756003)(38100700002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nK+gZPPL1ASswyUZn7UswpYYvCbA/Hup6a3J4fiB5nwA/gR+LEbuMCQUawpE/WGGuvAE+BIPBqhJzVEnRIWQQFtLmzrefDjj3RH8iXM5UGwZaOJL9bUx2ihfxLu9SYzqEe70LxrnYKOPHnAcZM1PcP1zLIijpM0x8ghzu/+8Db0ApT8AHMGK0GgYwU2p4O5REmayzsOvcXz2PF8qPpe3vjYhkIyBknHVAFn+Jd6Sn6hEe8zQ8NFriwZpKpXqfQCcWTpH95LpcbiYmdYpPQ9C+O+jh9riz6EH+ZF65qcBAYJY6FFWZVHjATO9yX49yRaiSmikqEGTadTELiEFphJbVeOeuA+A7oBXHJzfqUvfPl+nkuhLAT0xtMByBudbSbbu6yUcl1pKRiWEJyUP3kgSUXVImkRz+I0HZYD/o6bZe8Jnax7YhnfgeJMblheUrFN+9/Bb8xW2XeEHqVeXkbQflyOV6lr+7VP3f4YAF/XHa8UNp8oc/kDa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ZpPBIi3npQFcqA3ymr3VaebEostheibBr8E6tTphsweynSPjPCP19qL1Rk7wHm/lXL0GqeBE2kqBj/kbNyARu9uIqJgKtjiXvPl24jWp2J09KEV079Pnp4lHrXNZ4/MIQJ5zeSTTJt3cmZa/KImDOdx12aNBXsBhWqPtD1JhOkDFjJv2jfg+bLeOCNJBD2IVquAIMbdebK5qLXXCFNUt8PnGQOAe8Hyc86t/QPy7BvDB9JjWuoKVeAhbBKq7eH8sPaq6wHkKlb4XaU/P1Zd6U/PjRFtoHbYJD7md431TqF6sCgMFNFg1woMyXUHmyuJ+uC8B1zJ/GXN9LUvieYSFk4dXbxGv7CxKwQX3hLPv3jDzcmKZNbWh44rX5M1AS1VgEcIciZjlKNpednf+qcvxppWC9KxQXFSRbN4HV00Wc2g2DwrIhFQjunTW+hwCFYag9oyl6JwTnufrqbW7Zkv6F7XbutHhfrhR2+oRFiq8jcP5TbWeos8SUV0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f32b46f7-2006-4e83-5792-08db7808ddbf X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2023 18:52:48.1396 (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: buQ82kh7nptB+cR8Bad5CfgKFwG0tdKlaqITvyPutrbzXgjRbOEHk07AFdp4xWblGz68AithYbjIS1j8hghzI3zPEq/4DAR1a1LGu3ORw9U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7820 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_13,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 mlxscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280168 X-Proofpoint-GUID: GqseLKS8eIVBm_HvSl0UYkg-imuAHoJZ X-Proofpoint-ORIG-GUID: GqseLKS8eIVBm_HvSl0UYkg-imuAHoJZ 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?1769973868358792727?= X-GMAIL-MSGID: =?utf-8?q?1769973868358792727?= The hotplug support for kexec_load() requires changes to the userspace kexec-tools and a little extra help from the kernel. Given a kdump capture kernel loaded via kexec_load(), and a subsequent hotplug event, the crash hotplug handler finds the elfcorehdr and rewrites it to reflect the hotplug change. That is the desired outcome, however, at kernel panic time, the purgatory integrity check fails (because the elfcorehdr changed), and the capture kernel does not boot and no vmcore is generated. Therefore, the userspace kexec-tools/kexec must indicate to the kernel that the elfcorehdr can be modified (because the kexec excluded the elfcorehdr from the digest, and sized the elfcorehdr memory buffer appropriately). To facilitate hotplug support with kexec_load(): - a new kexec flag KEXEC_UPATE_ELFCOREHDR indicates that it is safe for the kernel to modify the kexec_load()'d elfcorehdr - the /sys/kernel/crash_elfcorehdr_size node communicates the preferred size of the elfcorehdr memory buffer - The sysfs crash_hotplug nodes (ie. /sys/devices/system/[cpu|memory]/crash_hotplug) dynamically take into account kexec_file_load() vs kexec_load() and KEXEC_UPDATE_ELFCOREHDR. This is critical so that the udev rule processing of crash_hotplug is all that is needed to determine if the userspace unload-then-load of the kdump image is to be skipped, or not. The proposed udev rule change looks like: # The kernel updates the crash elfcorehdr for CPU and memory changes SUBSYSTEM=="cpu", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" SUBSYSTEM=="memory", ATTRS{crash_hotplug}=="1", GOTO="kdump_reload_end" The table below indicates the behavior of kexec_load()'d kdump image updates (with the new udev crash_hotplug rule in place): Kernel |Kexec -------+-----+---- Old |Old |New | a | a -------+-----+---- New | a | b -------+-----+---- where kexec 'old' and 'new' delineate kexec-tools has the needed modifications for the crash hotplug feature, and kernel 'old' and 'new' delineate the kernel supports this crash hotplug feature. Behavior 'a' indicates the unload-then-reload of the entire kdump image. For the kexec 'old' column, the unload-then-reload occurs due to the missing flag KEXEC_UPDATE_ELFCOREHDR. An 'old' kernel (with 'new' kexec) does not present the crash_hotplug sysfs node, which leads to the unload-then-reload of the kdump image. Behavior 'b' indicates the desired optimized behavior of the kernel directly modifying the elfcorehdr and avoiding the unload-then-reload of the kdump image. If the udev rule is not updated with crash_hotplug node check, then no matter any combination of kernel or kexec is new or old, the kdump image continues to be unload-then-reload on hotplug changes. To fully support crash hotplug feature, there needs to be a rollout of kernel, kexec-tools and udev rule changes. However, the order of the rollout of these pieces does not matter; kexec_load()'d kdump images still function for hotplug as-is. Suggested-by: Hari Bathini Signed-off-by: Eric DeVolder Acked-by: Hari Bathini Acked-by: Baoquan He --- arch/x86/include/asm/kexec.h | 11 +++++++---- arch/x86/kernel/crash.c | 27 +++++++++++++++++++++++++++ include/linux/kexec.h | 14 ++++++++++++-- include/uapi/linux/kexec.h | 1 + kernel/Kconfig.kexec | 4 ++++ kernel/crash_core.c | 31 +++++++++++++++++++++++++++++++ kernel/kexec.c | 5 +++++ kernel/ksysfs.c | 15 +++++++++++++++ 8 files changed, 102 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index 9143100ea3ea..3be6a98751f0 100644 --- a/arch/x86/include/asm/kexec.h +++ b/arch/x86/include/asm/kexec.h @@ -214,14 +214,17 @@ void arch_crash_handle_hotplug_event(struct kimage *image); #define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event #ifdef CONFIG_HOTPLUG_CPU -static inline int crash_hotplug_cpu_support(void) { return 1; } -#define crash_hotplug_cpu_support crash_hotplug_cpu_support +int arch_crash_hotplug_cpu_support(void); +#define crash_hotplug_cpu_support arch_crash_hotplug_cpu_support #endif #ifdef CONFIG_MEMORY_HOTPLUG -static inline int crash_hotplug_memory_support(void) { return 1; } -#define crash_hotplug_memory_support crash_hotplug_memory_support +int arch_crash_hotplug_memory_support(void); +#define crash_hotplug_memory_support arch_crash_hotplug_memory_support #endif + +unsigned int arch_crash_get_elfcorehdr_size(void); +#define crash_get_elfcorehdr_size arch_crash_get_elfcorehdr_size #endif #endif /* __ASSEMBLY__ */ diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index c70a111c44fa..caf22bcb61af 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -427,6 +427,33 @@ int crash_load_segments(struct kimage *image) #undef pr_fmt #define pr_fmt(fmt) "crash hp: " fmt +/* These functions provide the value for the sysfs crash_hotplug nodes */ +#ifdef CONFIG_HOTPLUG_CPU +int arch_crash_hotplug_cpu_support(void) +{ + return crash_check_update_elfcorehdr(); +} +#endif + +#ifdef CONFIG_MEMORY_HOTPLUG +int arch_crash_hotplug_memory_support(void) +{ + return crash_check_update_elfcorehdr(); +} +#endif + +unsigned int arch_crash_get_elfcorehdr_size(void) +{ + unsigned int sz; + + /* kernel_map, VMCOREINFO and maximum CPUs */ + sz = 2 + CONFIG_NR_CPUS_DEFAULT; + if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) + sz += CONFIG_CRASH_MAX_MEMORY_RANGES; + sz *= sizeof(Elf64_Phdr); + return sz; +} + /** * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes * @image: a pointer to kexec_crash_image diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 6a8a724ac638..bb0e614f2a05 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -335,6 +335,10 @@ struct kimage { unsigned int preserve_context : 1; /* If set, we are using file mode kexec syscall */ unsigned int file_mode:1; +#ifdef CONFIG_CRASH_HOTPLUG + /* If set, allow changes to elfcorehdr of kexec_load'd image */ + unsigned int update_elfcorehdr:1; +#endif #ifdef ARCH_HAS_KIMAGE_ARCH struct kimage_arch arch; @@ -411,9 +415,9 @@ bool kexec_load_permitted(int kexec_image_type); /* List of defined/legal kexec flags */ #ifndef CONFIG_KEXEC_JUMP -#define KEXEC_FLAGS KEXEC_ON_CRASH +#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_UPDATE_ELFCOREHDR) #else -#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT) +#define KEXEC_FLAGS (KEXEC_ON_CRASH | KEXEC_PRESERVE_CONTEXT | KEXEC_UPDATE_ELFCOREHDR) #endif /* List of defined/legal kexec file flags */ @@ -501,6 +505,8 @@ static inline void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages) { static inline void arch_crash_handle_hotplug_event(struct kimage *image) { } #endif +int crash_check_update_elfcorehdr(void); + #ifndef crash_hotplug_cpu_support static inline int crash_hotplug_cpu_support(void) { return 0; } #endif @@ -509,6 +515,10 @@ static inline int crash_hotplug_cpu_support(void) { return 0; } static inline int crash_hotplug_memory_support(void) { return 0; } #endif +#ifndef crash_get_elfcorehdr_size +static inline unsigned int crash_get_elfcorehdr_size(void) { return 0; } +#endif + #else /* !CONFIG_KEXEC_CORE */ struct pt_regs; struct task_struct; diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h index 981016e05cfa..01766dd839b0 100644 --- a/include/uapi/linux/kexec.h +++ b/include/uapi/linux/kexec.h @@ -12,6 +12,7 @@ /* kexec flags for different usage scenarios */ #define KEXEC_ON_CRASH 0x00000001 #define KEXEC_PRESERVE_CONTEXT 0x00000002 +#define KEXEC_UPDATE_ELFCOREHDR 0x00000004 #define KEXEC_ARCH_MASK 0xffff0000 /* diff --git a/kernel/Kconfig.kexec b/kernel/Kconfig.kexec index 7eb42a795176..8a524b8ff6a2 100644 --- a/kernel/Kconfig.kexec +++ b/kernel/Kconfig.kexec @@ -138,4 +138,8 @@ config CRASH_MAX_MEMORY_RANGES memory buffer/segment size under 1MiB. This represents a sane choice to accommodate both baremetal and virtual machine configurations. + For the kexec_load() syscall path, CRASH_MAX_MEMORY_RANGES is part of + the computation behind the value provided through the + /sys/kernel/crash_elfcorehdr_size attribute. + endmenu diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 53d211c690a1..fa918176d46d 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -704,6 +704,33 @@ subsys_initcall(crash_save_vmcoreinfo_init); #ifdef CONFIG_CRASH_HOTPLUG #undef pr_fmt #define pr_fmt(fmt) "crash hp: " fmt + +/* + * This routine utilized when the crash_hotplug sysfs node is read. + * It reflects the kernel's ability/permission to update the crash + * elfcorehdr directly. + */ +int crash_check_update_elfcorehdr(void) +{ + int rc = 0; + + /* Obtain lock while reading crash information */ + if (!kexec_trylock()) { + pr_info("kexec_trylock() failed, elfcorehdr may be inaccurate\n"); + return 0; + } + if (kexec_crash_image) { + if (kexec_crash_image->file_mode) + rc = 1; + else + rc = kexec_crash_image->update_elfcorehdr; + } + /* Release lock now that update complete */ + kexec_unlock(); + + return rc; +} + /* * To accurately reflect hot un/plug changes of cpu and memory resources * (including onling and offlining of those resources), the elfcorehdr @@ -734,6 +761,10 @@ static void crash_handle_hotplug_event(unsigned int hp_action, unsigned int cpu) image = kexec_crash_image; + /* Check that updating elfcorehdr is permitted */ + if (!(image->file_mode || image->update_elfcorehdr)) + goto out; + if (hp_action == KEXEC_CRASH_HP_ADD_CPU || hp_action == KEXEC_CRASH_HP_REMOVE_CPU) pr_debug("hp_action %u, cpu %u\n", hp_action, cpu); diff --git a/kernel/kexec.c b/kernel/kexec.c index 92d301f98776..107f355eac10 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -129,6 +129,11 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments, if (flags & KEXEC_PRESERVE_CONTEXT) image->preserve_context = 1; +#ifdef CONFIG_CRASH_HOTPLUG + if (flags & KEXEC_UPDATE_ELFCOREHDR) + image->update_elfcorehdr = 1; +#endif + ret = machine_kexec_prepare(image); if (ret) goto out; diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index aad7a3bfd846..1d4bc493b2f4 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c @@ -165,6 +165,18 @@ static ssize_t vmcoreinfo_show(struct kobject *kobj, } KERNEL_ATTR_RO(vmcoreinfo); +#ifdef CONFIG_CRASH_HOTPLUG +static ssize_t crash_elfcorehdr_size_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + unsigned int sz = crash_get_elfcorehdr_size(); + + return sysfs_emit(buf, "%u\n", sz); +} +KERNEL_ATTR_RO(crash_elfcorehdr_size); + +#endif + #endif /* CONFIG_CRASH_CORE */ /* whether file capabilities are enabled */ @@ -255,6 +267,9 @@ static struct attribute * kernel_attrs[] = { #endif #ifdef CONFIG_CRASH_CORE &vmcoreinfo_attr.attr, +#ifdef CONFIG_CRASH_HOTPLUG + &crash_elfcorehdr_size_attr.attr, +#endif #endif #ifndef CONFIG_TINY_RCU &rcu_expedited_attr.attr, From patchwork Wed Jun 28 18:52:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 114011 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9140314vqr; Wed, 28 Jun 2023 11:58:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7FuOLs1LeriX8bW/NC8hcKK2JdF2hQ+l2f1F8fqctd8Zcg53Czf1TJ4d+fStU+NIkn12BY X-Received: by 2002:a17:90a:9e2:b0:263:25f9:65b2 with SMTP id 89-20020a17090a09e200b0026325f965b2mr4760344pjo.4.1687978683399; Wed, 28 Jun 2023 11:58:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687978683; cv=pass; d=google.com; s=arc-20160816; b=AAQE1UaxdPUid4zA95WthY14PGd4uqYQRQG3bV1B1nnYls8IJ91dyXWSlOuKhjiMO0 7Tg1ABY1bHQ5coMvW8bewjkcoJ8kOVNr9JhzOKfbZNYbmHZbo/UjnlZ4/fymmNFMVII0 0yYqu/sh4YWAYofkKqNtZPtE+c30G+RaAyYC+Xd8smYBrxN/HyE8QT6b5RpltTsQJvMb HbRanSZxcSxxtFet4nRLnUf5iLDT5m+NzGlGlG045ovsvwGH8VwMN5VBtH+giABqqpdL hWw3KDiZwGN+X8y4aKyeXBPaO86M4xn3d/69P1umCIo2xz+o+pesJvgMm6m1qPP6j1kZ q18w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=kqZzUcUI7g9GrNNQb568EFpHtig8R3NmjYR2Lpu3gEg=; fh=j+K5GuuLTbxxisV+wJRNZBqbr6zhGMwAghI8ANXi4rw=; b=wWiuWd2gSg1T5DNZnCW9g4CYHKyAikHagsBgNVmJL5krBJ0No6bxT7wbDZYlNAVpgj /csjzDQ6qKkezYQJr8k2bwP/rzrnGssKR7xlz+ENnyQZYIXkJTUBO36ILg/EyilWSj2y Mmq/nyQLEJYhN6Xm7hOdarxSFgpBgBGQ5gzD0p0hvDoyjIKWYm83EYmIk49URo0AWAFJ HlrScoWhrwXKAa3FjPSWzazIvQqwvx/83H1+ySF0efgP6KB4CYJbjj+cwED2AnSLCjg+ 6sxHXO9zEtZHHYQ9hpkumvBUKaUSA+MJtpen6tr4BrjexxQmdyUbNhiuhJ3gIBwMvYEY mByg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=PEHdWS8b; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZM9Z1L3l; 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 r12-20020a17090a690c00b002634a8e3220si695415pjj.65.2023.06.28.11.57.49; Wed, 28 Jun 2023 11:58:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=PEHdWS8b; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZM9Z1L3l; 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 S232084AbjF1Sxm (ORCPT + 99 others); Wed, 28 Jun 2023 14:53:42 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:42128 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232064AbjF1SxS (ORCPT ); Wed, 28 Jun 2023 14:53:18 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35SGwm76002041; Wed, 28 Jun 2023 18:52:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=kqZzUcUI7g9GrNNQb568EFpHtig8R3NmjYR2Lpu3gEg=; b=PEHdWS8bLy+bP0M31qQ/8kf/fWEZqoFKO3T7IpW7AU5YESzpLMI4a6HBMqyxINpdxAl3 eWMXq3CYIeKcOFs8QFhV+DKVafZpG+BVnhDZGoVteDwA/Ixf+gFPLTYD9jpSJpGXjA6Z aY2wFL903BB825lRQ10CEQx+YrprkeGdW8q/waRC2YmMzeITt7abmPGj56NsfNRMOX2R JAudDwSg9TFL9+Vz9UEllOjtlDQWYvYAv7wGW6gd6cIgzKU1OJFSo0XUAR5N/zB7sGKs MElXLWg1pV9TgWZt2Tkj3g7MVFKlFpKnGvJcRrSlDIue/V404n0gRHXxZ/1RjbB4ufJk Kg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rf40e6uww-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:54 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35SHeXd1019984; Wed, 28 Jun 2023 18:52:53 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2104.outbound.protection.outlook.com [104.47.58.104]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxc6d44-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cbW4I5JUQnMteEKhIIbRVoBG4i528sh6E4By+ZG6J2hskDy/R92T83uOH2F3pVa8NflpRAQr1N108xVkm3jEi9TVixaNrRSts1CnbQJpZUWm9zD3QzZJ76yMq3vd6gxkjMpmYhS8XLhcCXSTZ8NHlgLnUMqk2wp6wc4RwrLn5AJATzB8znpiYAku4AKZ6ny/LOvHvdUHOqkdq8KwYqlRNUIW+fV+aCzxqoI4VM4kT/DCdd/zzvutC4H7H3Wu5laMcZLu4V2BvAJp2lNyJiDB3z/dkOn07jiRi+m0fIw+9D7QrTkpSqw76uk3+xHYbWTEmsSYZN7XIlBRzzNGngAy/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kqZzUcUI7g9GrNNQb568EFpHtig8R3NmjYR2Lpu3gEg=; b=OCAvY9yciT8nTKYZYJcVkrLc3NCWmZsrXSQTcML6jaaG6yDfe2o061sktMjKXCm42FQ3qPY6oqixM4oCV9jT2s9+HD2gXbMA92AZ6BTNwqXR4GQr4/KY7uOuc+mNVm3xnkBRzhb2iuTe2O1DeJr+mnJbHG9J7dBAtiqtpPBq0GoevfckGLANXvqONCqxn34Nu9DVMUg9Pq3zl3L7CTriEGDN5gD1L+XU1YucltiLoSFwL8BaSdrbgU7YpIcfCOBQtXmFKc+d+4ubS9M0Xsfopciaz9KHXJuKTCw77glDqmOPs5GFG4HsHRmu0Mh5LYYHlPfbv5ON8EI37PeSglYVNw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kqZzUcUI7g9GrNNQb568EFpHtig8R3NmjYR2Lpu3gEg=; b=ZM9Z1L3lLEGwV3w1839+OkOi3Y4l/dl0J0mYeoNYvTRsOAo1rrNO6Q7M4mMKxERwBp8ZAG9OuKr2Z7xW08V2rNNnJz9LM93G4t0VjJLkhQih6TunHVYckjlcurxCgjxmBiDFtTLSxgmhEOR1snXX4ayx3BfL/SL5/55rPDS/HMU= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by LV3PR10MB7820.namprd10.prod.outlook.com (2603:10b6:408:1b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 28 Jun 2023 18:52:50 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6521.024; Wed, 28 Jun 2023 18:52:50 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v24 09/10] crash: change crash_prepare_elf64_headers() to for_each_possible_cpu() Date: Wed, 28 Jun 2023 14:52:14 -0400 Message-Id: <20230628185215.40707-10-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230628185215.40707-1-eric.devolder@oracle.com> References: <20230628185215.40707-1-eric.devolder@oracle.com> X-ClientProxiedBy: SJ0PR03CA0224.namprd03.prod.outlook.com (2603:10b6:a03:39f::19) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|LV3PR10MB7820:EE_ X-MS-Office365-Filtering-Correlation-Id: ba26dda1-3456-4c8c-bad3-08db7808df7a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CNK4r3qODmyE5LvK1S4wwb6b5bLbTNeeFI7H5miyK82Lx6vGQ2qQQAlSvXHc8D7oZ7Dnft3msfhhNVIaaEyNO2g4GL5ICfHerh5LTtG8vprkwEBfSdcGvpeKXw2fGKH1qt+dvk6mgGL8EgQhPUshrgqEKZ+Pj+sBhT8iyG+DcqjU6SbwS/xmGNd9w7rzqCBgO+jzZCpzgbomF10ywpCENyVmvx+Efv1xYsgPWxfTYHtA98F78lrpGNNw2NcBwaQoqfyu5geTyxPo/dlPiAjHxJ153DaioVVdMAZnfgjx3y4xOrHsM1EBX81YThGVJWkFf6+71imuIvFF8/EFoEtVWMHRr0xK66iV+tk5erFDex/xg68tMcnI/Q1LDvGAoHAcDPDfPCtDTZWvdoyQPxJ3UXF2q5ZbuWtQIOH/7lu7WLHK9GwTZGOyR1sGDewC+QMJkq/PmzFajEVKs5iP4m2nLzhR+xpLMSxFRI5NdVlGdBrKYy3+BTY04CF5e7KrmBVbcAvSJpXOwUKAYuBcFuqcNk3LgCqPsvdS8fEnjODHyWRb5MdcA4HaXvr24yXL0aj4l76kEMx//jjh315gmje/7BV5w0J5x7nws68+NeSz9Q8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(2906002)(83380400001)(316002)(26005)(6506007)(6512007)(1076003)(6666004)(6486002)(186003)(478600001)(86362001)(107886003)(921005)(2616005)(66476007)(41300700001)(8936002)(7406005)(7416002)(4326008)(66556008)(66946007)(8676002)(36756003)(38100700002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6MDEkhzcXiH/T+h27rmYp4YS/2wdrhDnxw1uwoOsVSmr8EheuACjCsYqjv0s11BDgOCh+HJobw5PzpoTkoc1eYahmPCSWM4hJRSoQl/pCIEEa7sQY01uV0lkbBNPqW6gWFmLmWgXvlStcHVVXJuQNlJ4zynRmWHCaeHPXhBFaSzOTHU5X9sep/CigzYBa8+sj66RKtBfFvtIDZpXMi6ja/kyqRWdXV43ksCzcUbhqxrNRHKgUUkBecoC0lYQgf9LcBtb7mUhjyWKYF9Z1v23yr/w1PJDoyV2uBPrz/6mqPpmgBrCloIB18zv1Pc7c0EJdK03xii8oM4MyxpAMtat0GAguPu3G43UvHF19iDRKbeX884rJaCj9xvuCB/Ew6KOPVehug1Kc3VSyHkWPTLD7wPLOOFZguqgpII6tcLFW5TBR1Vi7XvqwrZrUKd8EnU94FJhH+NXtm9xzo5T49/p9UlGaLKgxsRTId8G16rgQ9VepJB9yZQyZAF5GYEob3y9eNvc5uCDVnuOMWQz+3uBYYxzs1UHayrN7VARc0wOUn1J/A6dmlKt66kCKbEIgJYmtEjhSm0ZeOTyBoZi8PL9MUXys5tDaWwGIRP6+ZJnP9ilEsQV9nChPEnDJpZ8nmiHVzVE2P8pFiEjA8Z/z4NcI0eFGcGWAEB833DPYMby3PJRobodoGt/j9aPk+22lurxrqCsqErwMK2XjYFtkTz81mwDyTtS49T3VYZg3Bc2bkiPIzAwuqYYeXDef9bfN4WODCr3wQPke8ktRWgLeOrl2CXinAIU3CdrSYFJg4TMy5SwXGe0V2mCXQzrw9p4j9k8wcyPwFBvKGjgD6Xx+h16Zu0n4Y6COpHk5jsFNBMkiFtilo+0i2lx83EBgSpS0BI0Leam4lZ2jcFm1b82vRKevSNI53ezMKTa11fbL8GW2zoCXSQQmCnsBYhak9HysK8G0sFTJEboY6ecWUiyqikD1BoALrwCcYrqx9GjicIa+QRQRHMnnhY4ZChq9O5ItRk9rLawFguZ6hW3jN5ql5jfVT3x0IB23UrfOgr41E6E/77iVlxUM378KM+T7Id1EbssMlwO1XDjVzDB9kfhBlMAbpKuJHgdczLh0vZqty/9X5k9GdDrjlKNqZXMLLMwsuRQR+FtVjUo19ZX5mFWE2d8eqmlcgYsW7XU7/0txGGPHNvOrGIbPF1JIRqlWtHtJ+WOgxFC/XLUwetcruahT3Bk5mEUEIDuW4tWlrf4dQ5xesyqRepG0yMDJajOTJidN2vng1ZaotQs8patr9ghigGP/169MXtD427kDEK/hnCYpq6JD5e+i6xJgy7TcVnXN6qo2H77tDasjr9rHhmrnQTRQq6x9H7s6ud70CyyUbKQ4ALAFbyhqGLmEujrC9qEw9xSgsU1GuGHAIT+sunMAmgjLczjOhi601jLz1hkGRuqhpN4NopUynHhh+BXxnODNNt3uJOvfnAcWSZPoliTvMXpYjrzwaWHYKmSedlrgnDtajwm4sdH9YpJnMdzp6oRiQ9922SxXDlsdb74RbQu7wzo+wFmwJ26h+oIccZvcZ5fUADMILxMnTSL+l8f7aHR4PqzCzOvIphn7VQjUOT8M8JaZQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Y8T6ZkKHHVSUUHMKz9fjrCFv5ZaL4sJwEb04MKhY8ZmhJWKMzOAOJvfZ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Zg0Jy1xE1mlR6rd8L9yMh+AiWQ2MXZXUzp8EEa351O2HEQv0hT9dr5U7Pjg5GgbTJJjBaAwU9og9dbrNbAOLjYxkG1/AwdGF2Mv9lpNnUbQM/I6IkbjebqgECc/OjSsSIpw3h/HMhligMH3ca+uFR+iaB3D3GoPrBJ6tkGt3SpAV94OI6cfSIwZCU5/JY3rCBlQl7FNX6MQ9ulBMAYRGWE5xenoJFtsirfrFmWHsb2wiN7+WHI0MzqRkfAUZOJ4I1y0re54XaMLDfMgqoYPC7GtdGpSMrHQ/KJLHh05jKiOK7IRaJDIcAvGxhH059w+rud8YzI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba26dda1-3456-4c8c-bad3-08db7808df7a X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2023 18:52:50.8418 (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: IaHb7SReA4dEq6xdH00xeWWBZTu0PxhGBjdrfrjtYU4uK8pA1TXMJZXc1ogRIFla+48xWUHL2JR4Py5LLQuzmZxA/E4Wv8NsatT9Rc8Y+hg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7820 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_13,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280168 X-Proofpoint-GUID: 0gxgbTEiHel7Q1fbdSDmLFOxBFxQPQis X-Proofpoint-ORIG-GUID: 0gxgbTEiHel7Q1fbdSDmLFOxBFxQPQis 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?1769973935779135217?= X-GMAIL-MSGID: =?utf-8?q?1769973935779135217?= The function crash_prepare_elf64_headers() generates the elfcorehdr which describes the CPUs and memory in the system for the crash kernel. In particular, it writes out ELF PT_NOTEs for memory regions and the CPUs in the system. With respect to the CPUs, the current implementation utilizes for_each_present_cpu() which means that as CPUs are added and removed, the elfcorehdr must again be updated to reflect the new set of CPUs. The reasoning behind the move to use for_each_possible_cpu(), is: - At kernel boot time, all percpu crash_notes are allocated for all possible CPUs; that is, crash_notes are not allocated dynamically when CPUs are plugged/unplugged. Thus the crash_notes for each possible CPU are always available. - The crash_prepare_elf64_headers() creates an ELF PT_NOTE per CPU. Changing to for_each_possible_cpu() is valid as the crash_notes pointed to by each CPU PT_NOTE are present and always valid. Furthermore, examining a common crash processing path of: kernel panic -> crash kernel -> makedumpfile -> 'crash' analyzer elfcorehdr /proc/vmcore vmcore reveals how the ELF CPU PT_NOTEs are utilized: - Upon panic, each CPU is sent an IPI and shuts itself down, recording its state in its crash_notes. When all CPUs are shutdown, the crash kernel is launched with a pointer to the elfcorehdr. - The crash kernel via linux/fs/proc/vmcore.c does not examine or use the contents of the PT_NOTEs, it exposes them via /proc/vmcore. - The makedumpfile utility uses /proc/vmcore and reads the CPU PT_NOTEs to craft a nr_cpus variable, which is reported in a header but otherwise generally unused. Makedumpfile creates the vmcore. - The 'crash' dump analyzer does not appear to reference the CPU PT_NOTEs. Instead it looks-up the cpu_[possible|present|onlin]_mask symbols and directly examines those structure contents from vmcore memory. From that information it is able to determine which CPUs are present and online, and locate the corresponding crash_notes. Said differently, it appears that 'crash' analyzer does not rely on the ELF PT_NOTEs for CPUs; rather it obtains the information directly via kernel symbols and the memory within the vmcore. (There maybe other vmcore generating and analysis tools that do use these PT_NOTEs, but 'makedumpfile' and 'crash' seems to be the most common solution.) This results in the benefit of having all CPUs described in the elfcorehdr, and therefore reducing the need to re-generate the elfcorehdr on CPU changes, at the small expense of an additional 56 bytes per PT_NOTE for not-present-but-possible CPUs. On systems where kexec_file_load() syscall is utilized, all the above is valid. On systems where kexec_load() syscall is utilized, there may be the need for the elfcorehdr to be regenerated once. The reason being that some archs only populate the 'present' CPUs from the /sys/devices/system/cpus entries, which the userspace 'kexec' utility uses to generate the userspace-supplied elfcorehdr. In this situation, one memory or CPU change will rewrite the elfcorehdr via the crash_prepare_elf64_headers() function and now all possible CPUs will be described, just as with kexec_file_load() syscall. Suggested-by: Sourabh Jain Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- kernel/crash_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/crash_core.c b/kernel/crash_core.c index fa918176d46d..7378b501fada 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -364,8 +364,8 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map, ehdr->e_ehsize = sizeof(Elf64_Ehdr); ehdr->e_phentsize = sizeof(Elf64_Phdr); - /* Prepare one phdr of type PT_NOTE for each present CPU */ - for_each_present_cpu(cpu) { + /* Prepare one phdr of type PT_NOTE for each possible CPU */ + for_each_possible_cpu(cpu) { phdr->p_type = PT_NOTE; notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu)); phdr->p_offset = phdr->p_paddr = notes_addr; From patchwork Wed Jun 28 18:52:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 114007 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9140013vqr; Wed, 28 Jun 2023 11:57:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4FWKku05fZQiexqNQs4qv4UUk1l+Gee+dxiaJE3GXcoapQfLjqmPKNH8nNaW2oim5ZQoLD X-Received: by 2002:a17:902:b788:b0:1b7:f3e6:5727 with SMTP id e8-20020a170902b78800b001b7f3e65727mr13777277pls.2.1687978643978; Wed, 28 Jun 2023 11:57:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687978643; cv=pass; d=google.com; s=arc-20160816; b=glXUlbn++4WquuwFT5okF/qjmOnVLzjwMWIM0+Pm0qiVaZ/ze9Z8RJ9l9fD9sS76w6 7zOaYTnKcacJNaNW0bgXtGzsWyUmdFZZdy+sgaS1Yz19A80LQNxuNg2KUafkdD8TP5Ni xeEBqULPFsTpGT9Z5G1M9yrHauAN8Ku7oFWqys8us3CSMfSrIURYMek+Q9Fm8gIVRGto fxLKtK8KODyy7pdlAzX9NOcWP0D9JuLswJHaoD4q6k1bdo/cUQzklJVAf9zk/jn3S4pj 4zYMao0BWaMIogEm+MqBiYW3GlDqH6kcxjxy2kGjStcHKFhc/VQ4eGA5hlO2CWCj5V13 eu0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=o+McSM2gKtujfwRfyeOsaE02Y4bKTLqqTyQF/lTUOqg=; fh=j+K5GuuLTbxxisV+wJRNZBqbr6zhGMwAghI8ANXi4rw=; b=zXzlTtgd6FTiSwiwmyKr7V+3KV4p+mzM1dPk6YLdancS/aZl/+h/3onOrO1lXupdvy AGlDrXmsR3As3iCNgI/ICJAMatDUxWpwxtB22nBtTUjaiNibYVkREcLBSqpqZFehghA1 jMw1Axwsfyv+HXsayUMq/qn/EW+B44bLl+eWgi9zvZM/9jfRgIP9Cr+6Ig8Yqv5BtVyk eXWnykPLmZvt+uWe+RSg9PdIRJRFT3G1SThH+vTur6XF/z2UR21B8zjhzKFD87lUnwdJ /JE2BjA4qZOHnBs2zxXM8ZAf+H4GOoCD+SFEKZqzWi/H1IXaF7FogwMMFWsJciS0qIg0 iMqg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=UH13J6Xg; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Y5vLPveY; 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 jc13-20020a17090325cd00b001b8052bdd3esi5987731plb.631.2023.06.28.11.57.11; Wed, 28 Jun 2023 11:57:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=UH13J6Xg; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Y5vLPveY; 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 S233037AbjF1Syp (ORCPT + 99 others); Wed, 28 Jun 2023 14:54:45 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:6328 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231835AbjF1Sxg (ORCPT ); Wed, 28 Jun 2023 14:53:36 -0400 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 35SGx4EC000647; Wed, 28 Jun 2023 18:52:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=o+McSM2gKtujfwRfyeOsaE02Y4bKTLqqTyQF/lTUOqg=; b=UH13J6XgCVSJZdDvEd712RT4XBu0/jCLHfsA42mmFNUh9dOyb8x3vUwF5Zt2fpPg0JHm Qz08NxwT9ibcPBLgFeKhijatvri4R3VzQSwgeZH77cb9HRrMj/idqi4pZ1cgICIZ5nk3 wRWz1CT/7neumMnmRSykQT6+bfdt/63ks7vQjiW4v8+UdkZQBtcn6RMOwyAZZ35u+wgv vMT2FiHOOifEnnJ6U9xFP8Dts6FS4DxZORUJ3nJ1+D7NUzHUhpydLEEcuEKfuFIhdJ+g ALnLOZNd+jRUTWkhyBorEqlZqmvTnXlCh6ioGuptS+3mk4EDKxVAjE/WaVCjdYKJU80J Uw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rds1u8gmj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:58 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35SHbpmi003961; Wed, 28 Jun 2023 18:52:56 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxce51n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bKkMBfWCYHZZl18ZJhXaZVeQzDj3JVTKdY5DcqXFSZ2k2vW/M4r7bqgCsX7wOJgOX2chbXTLMaQUi/faznXEHktcd4b/9LIp1oXaiuLPu/202k1dqEP8vLJEtwEeO7YAE/ctPLNLhMnWMez9xZo+5Yl1i7/t0nOAPpt5WUfMftLl5VkjC2nw9GvLN/QXVfuExNyvJof9LZHh9ka/QYwkeGkfuGZdoIKH+6/4d3Lks9e+M20o/N1/mXa+i5Bl1tI8KrD88FE6NtqiE+bVgBwm6bTPbsQEu84CiadkXB2WW1gtdPBdPwrzqZN4EI20JUvAw7IMuYLJ4PijMjdkHSXPQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o+McSM2gKtujfwRfyeOsaE02Y4bKTLqqTyQF/lTUOqg=; b=doxrrkOKoav2oz3h8M1+QE3bM8PfSws2rEMBcPFsTa0qV7qViPH2U6wIPAq5f5aRRXBXemkuOfHBmHNWtyuWkMt5CvJpjFz8SXIq5LTyHaJpg+y5WsoFtzX9cl2wzwffk5HyARELeoYrOXYixbbF4/NOZoRp1Yj9OAMm4rA8lRQmZ1TbBUc+8Mk/l5eOwjEwmQnSmLovDlcHq4/M148HcLcnsgErXU98jA+kRw//tQ6dR7VMi6kprU46rP1hFIGihyslopzayrFU9DlIQY+J6c7gJw5hFDlpFhJjWIAyEwC4XCUUrFQ9A3okJ/HVgyz5xJSSTgluCLVjXN6yQ5eehw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o+McSM2gKtujfwRfyeOsaE02Y4bKTLqqTyQF/lTUOqg=; b=Y5vLPveY2QUDx6KfKBhflOtt+Oz8RyeacYFYLdpIzW+8+btIshN5+lX5ezGw8mN9mH+lgH1Oxbx3ZTxOj4QWXMZNiovZOFhVtg7rEycCm8fAvL63Wqwnd8AJpWEWmfd5GIdZsetxwZd4pxRCm2PxraAel1HraUBtd3UCHXknjj4= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by LV3PR10MB7820.namprd10.prod.outlook.com (2603:10b6:408:1b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 28 Jun 2023 18:52:54 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6521.024; Wed, 28 Jun 2023 18:52:53 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v24 10/10] x86/crash: optimize CPU changes Date: Wed, 28 Jun 2023 14:52:15 -0400 Message-Id: <20230628185215.40707-11-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230628185215.40707-1-eric.devolder@oracle.com> References: <20230628185215.40707-1-eric.devolder@oracle.com> X-ClientProxiedBy: SJ2PR07CA0019.namprd07.prod.outlook.com (2603:10b6:a03:505::21) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|LV3PR10MB7820:EE_ X-MS-Office365-Filtering-Correlation-Id: e85c2bcc-b5f7-4902-dde9-08db7808e13a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ImAFtW6JXEJr9uTwQOfkGTHfkj2SSzV+S5ZXBCJoC+y/92l7kAaF4ZeAEkJxll1DRt7AgSsGCgOwI4D1oaugcEKxZk0mP2NR33BUuz+/nKQVektqN286aVCe3DH5pvzDguk0v7NNyDK1+paRQn9iB/v+8ywAH5/Yp9Fdf9zpN89/jPecYQtT89pNmr+Yt6LlpEPdM6AY/tACuUqGIqHi+R+vdBK84lYlfuqav4tB0IORdb2kxGuQBpszPoBTezjXq3d8SxMO5pMaoc/MsZQfBBaKADvCSHXA141qjDYfSqYGernHWhpBtWKGLGsI97DIqUWHAGiOw8U3+4DLlrgWh8OlC+wxgMsvoytxnB/wWPHh7PY77wRYDqokRn+nBhghzjIxjYd1O1MqinlkG5EPyU7Y8IXa5JyZYxWpcKu1uWr6mIAvaQx9wtEw26yzHS8VBXte/spidjHT93jojAYhnmGWo/QCMRqVU/eU+Dcrw1bNhGvvHIER2eOR+OxLR7zMODstUU7SdQH7yGxxFKtmvyhtCKIviVmAb2oX9WqKEEwyYMYlrDikP/1l1x0d8vUt/iQbs/rEjn/+0NTsBOOtlP9diYf92O1QKwqZaOVd1+E= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(2906002)(83380400001)(316002)(26005)(6506007)(6512007)(1076003)(6666004)(6486002)(186003)(478600001)(86362001)(107886003)(921005)(2616005)(66476007)(41300700001)(8936002)(7406005)(7416002)(4326008)(66556008)(66946007)(8676002)(36756003)(38100700002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LJerea/3+BNz5KRRpLhJyeQrNcl095YWDm6BfQthYXVnNBdewKdI4UYKQYNolHU/r8DzdlK2iIJt0AgKfwOw1gdPswCMx0tbbXmJTNy453kv1ZRU/gXl9pIyXQm1/rj9/tUDCqUllv/rzHZVYXKbobi2Hnno9RN7XVVi2+9tqYcdNE+vdcxdrReTPszdDWUaXMeFOfWlvTN1wEe0jAiw+zFn76A/0vTbY2TvAAw9NOeWXCCSxsu5QKN4VUeUd5mJdGBfiv0p18RBgXO1TGmawarGYQ5Q7LAmJi7wkeWUoB6O5zHCzQMJMHSlNwwSepnb0oY2NfJzdAgXKKgEx6oiPwphYUaivEz+9Q4n9jIJXt/Alrg/1T0lvcuAQsiCYvA9G+AG6szRXl6l9nqVv9nYj8eU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RbiUPBehinf98PYtUw5p/2CJlgqAFiBago9S4jGBdzYDlVw+ViyPbeu2nj3LEcOSwFK5H7mi7rc8vtUES0pPVFDoiq94WP/z7bEG5Nh0jtGJRXTHJRGgM4iPKSYOVvEoOF+oL4vQ8uZiFrpcU5YVUxlVIjcfDAMZ/v+eSfhSiZCgbRM28utGkuRtxB32DcwJUqytLEXyP8fy0DtaUPECkWHJQMUa2oRRXa5vpOb8mU8hdx7zbM0qdSg6Nc5xiyvBKBIBbtz4tzTFtOauBus16z/tv0t0B4joIZ89ZNz/WIVUaoftAeFysdI16609RpqfxacuaOju03BW4fiv+8UD7MdytFhMC7QqUTknnZiOT5gxJm1J6NfCq3jqXTpSqCqwfV6F0GV6AKrAImXUlzqbmtFC/4+XUT8rKJQhaAmAxw3+hKtgbh4cdzFB5tDa+QvHf6ewQjUEBo6C4bqX1kQBFGRGvD80LA9z4pcwCs3fCWlPkqFX/jhpKEi91rhTs7bDDBps4K0rUthlUgXCbU1INXyjRRIyKhUfaWBh/cgTcgoXlIxgwx97QM9ayw6caI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e85c2bcc-b5f7-4902-dde9-08db7808e13a X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2023 18:52:53.8648 (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: Xku8gPtmRl+UAboMmG/ZI+rtftAEaLZh0FeeV7K48K0IsrWZKdgHSSqpxC0p7B+Tz9qG7nZDAuJeM2Zel+NdTmzzawT1nkMdiqlHGTQeD/o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7820 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_13,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280168 X-Proofpoint-GUID: YeSnm4XcdNd5j4J4e_3Dd3VpNl7vUEaY X-Proofpoint-ORIG-GUID: YeSnm4XcdNd5j4J4e_3Dd3VpNl7vUEaY 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?1769973894364086708?= X-GMAIL-MSGID: =?utf-8?q?1769973894364086708?= crash_prepare_elf64_headers() writes into the elfcorehdr an ELF PT_NOTE for all possible CPUs. As such, subsequent changes to CPUs (ie. hot un/plug, online/offline) do not need to rewrite the elfcorehdr. The kimage->file_mode term covers kdump images loaded via the kexec_file_load() syscall. Since crash_prepare_elf64_headers() wrote the initial elfcorehdr, no update to the elfcorehdr is needed for CPU changes. The kimage->elfcorehdr_updated term covers kdump images loaded via the kexec_load() syscall. At least one memory or CPU change must occur to cause crash_prepare_elf64_headers() to rewrite the elfcorehdr. Afterwards, no update to the elfcorehdr is needed for CPU changes. This code is intentionally *NOT* hoisted into crash_handle_hotplug_event() as it would prevent the arch-specific handler from running for CPU changes. This would break PPC, for example, which needs to update other information besides the elfcorehdr, on CPU changes. Signed-off-by: Eric DeVolder Reviewed-by: Sourabh Jain Acked-by: Hari Bathini Acked-by: Baoquan He --- arch/x86/kernel/crash.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index caf22bcb61af..18d2a18d1073 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -467,6 +467,16 @@ void arch_crash_handle_hotplug_event(struct kimage *image) unsigned long mem, memsz; unsigned long elfsz = 0; + /* + * As crash_prepare_elf64_headers() has already described all + * possible CPUs, there is no need to update the elfcorehdr + * for additional CPU changes. + */ + if ((image->file_mode || image->elfcorehdr_updated) && + ((image->hp_action == KEXEC_CRASH_HP_ADD_CPU) || + (image->hp_action == KEXEC_CRASH_HP_REMOVE_CPU))) + return; + /* * Create the new elfcorehdr reflecting the changes to CPU and/or * memory resources.