From patchwork Thu Jun 29 19:21: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: 114423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9890786vqr; Thu, 29 Jun 2023 13:20:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ43N14h1yiy9NTPfMWWHyripzUPuu6QKDtK56ToMlseG/x8xlY5dAx3dK/IQuMp9jZtluFl X-Received: by 2002:a17:902:e5cd:b0:1b8:2c2a:9629 with SMTP id u13-20020a170902e5cd00b001b82c2a9629mr7035990plf.19.1688070054014; Thu, 29 Jun 2023 13:20:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688070053; cv=pass; d=google.com; s=arc-20160816; b=Wt9q8uMNZwyj8bemqQbZ72ixLrlZFDw/LnLTt3Mj53tW3PgsSAZL7OaV0W5kPRhzNZ xPvH1BXbtccxVs/k+vuMYibt3dNasWsQZEk4Y3ctmE137liR7lvv6qJedD8QT2wavEUl zkJ3llxArUo8X0gmdiDER95l4baRh36EGEc6Aa95Brv4oWNwCOIhi/8Hsheo0vmSFYXt 6nZbmLw0iyrsk1Zqunna0OV/IxuDTx7z3KbSTxhLPyqjIL7SFSyx+gUl3NH1NOLa9Bo0 wTYDhF9L2jX0aKcllxVf+mf3+9FREiDU4kKT1RINjD5dSklT5/vYLS94fNHJIKAA5tIu R1dg== 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=urxPOYUpKOMkti7IfS40b4Ht/WYOtVRmEjh+rUcS9T4=; fh=j+K5GuuLTbxxisV+wJRNZBqbr6zhGMwAghI8ANXi4rw=; b=rcix5EcQ8Vd/PaGycG84e99uFBloH5j5D2k6fIgH6gmjReOth0OVBNfb3b03L0v2wW uNOddmLaqJkDpKTH+chAGjGv93LF5/IT3JqGVma9NiWl42h1hXQBBDIluB0Wq6VQy3Id PuC/HauFgCIS+CCBoW8E7QaAO8uxjjjTS2QlrJv5gfgTlz1TijqCiaIA4S7yuEFFSwNe 2ndHbqrjhwS2IM+TF030YyeUEwE0B/CpKn8LMGvCaNfpmlqoNqAd9V9zmEDZgr8KTPdH nZ/2YR82BiRZN8feKn79HYPhQXTyEVFU1Pvu6ZygbX4ujYP95josVUKUVzEdIcU64Vtd gpLQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=ZNMyRp9q; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YDZDQMDR; 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 k13-20020a170902ce0d00b001b23d4573b2si11781247plg.27.2023.06.29.13.20.31; Thu, 29 Jun 2023 13:20:53 -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=ZNMyRp9q; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=YDZDQMDR; 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 S231857AbjF2TXo (ORCPT + 99 others); Thu, 29 Jun 2023 15:23:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232101AbjF2TWs (ORCPT ); Thu, 29 Jun 2023 15:22:48 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53AC21FE4; Thu, 29 Jun 2023 12:22:43 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35TJ3vBT020435; Thu, 29 Jun 2023 19:21:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=urxPOYUpKOMkti7IfS40b4Ht/WYOtVRmEjh+rUcS9T4=; b=ZNMyRp9q/8gDTzO4v8/4vIvAZOWWZUMbFcALTzgfbxzRZ82SNxO50TYZFS8+89jEXIR9 QAkwPRMvU7ZeeWP8nrwMyCSLc304ksoS8eNAFuwX2yHS1GNZJ+/m9wwYPH8QgyawWT1p 1g046aJJi+tlxe+S+fzH3+pOQ4N5WdaKc1b0OAqIFjSLE/QNqqAYZuOjlA4jNCYNdoAM PAiPj9Nb8AYx5CxhbhX3+S8dOyUEy1vaWSTVUNDQRS2YCrmew4URMJRO5TxvWi8epFJR BaZgL2FKp/5BT/ydIlBs52PBqzgzoAP45Yt8fJuoTCJns9CGXz3u6GvP1U27r+g+BpY6 fA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdq93dp8v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:33 +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 35TJEaIf038200; Thu, 29 Jun 2023 19:21:32 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxebtdr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RUwjT/zbZPCupgWcwRawcYhIY363hb7DhROYktrjeZ69gNlfbwYrDW5nxD6jLDOf/zL6LhJXJ2IqCGc9wkyixb1052LkO7WBhbHC/f7pt9N5rIkMPCLXMcLCqkF6l/ELcUCQ2bW4w2niLanMG6bzgrcefhVQD/GjJfbMHa8XI5tan8jOsl/KonKh26LE6ODL0/ezN56u2TfnlYzxAUHgWxSjMXiS+lwlWnd1EHQ5mYNkMBD4aN1bMvpMlHe8YiBE7AwTn4ttigkJd/uMOaLD0shUaHY+iASr9XBhUJZt/eOfpC4/+H4KY8CUVUE6jPfhHgRTC6cTYQ19LH8k8r/y6g== 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=urxPOYUpKOMkti7IfS40b4Ht/WYOtVRmEjh+rUcS9T4=; b=OYcHZK8/j6Wm1SX+Cc6AWUP5BoMw/P7TP9SIbbF2+pGOmcUHYUmNGuIVex7qab9RGok7a2UZI3fDEc1JQyPkwKPvacwl7G2P0tFMtpuwR4WF1gszlpvAXhS/y7FqbtUS6yMpJw/+VIcIpexH92qU4ovLB6/T5e+KVURi2WCUKUXWlymsi5EpJEAA9c9vNeJY6Dus88Yv1jDXZHQhpPPKGrdoxhYiOiT5kF/xIlpbqPGjBQ8vQ2vrl4uh246w1QeHmEErOyUDY+DwKsTQ90GiTP67cyYxlpLTeOvvJspdA4RuHGTqeU+5LovEEGxI82R6aGjdG5Pan5tzac5iAD+9lA== 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=urxPOYUpKOMkti7IfS40b4Ht/WYOtVRmEjh+rUcS9T4=; b=YDZDQMDRsnZJFYm130OuXsX/f6DZ7FeKAE1TszUtLzgYmHVx0DrSNQByJE0Gb3VJPTjre70YdYlBuUCKiFyzdr9R4moAHKx7274/Va39lDvc5y8fq9XmpKJL8W43dlof7MGERYJ6WCFOAByxWkKsSc26aP8xcf4Wp1ufn0MVS6E= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by IA1PR10MB7200.namprd10.prod.outlook.com (2603:10b6:208:3f7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Thu, 29 Jun 2023 19:21:29 +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; Thu, 29 Jun 2023 19:21:29 +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 v25 01/10] drivers/base: refactor cpu.c to use .is_visible() Date: Thu, 29 Jun 2023 15:21:10 -0400 Message-Id: <20230629192119.6613-2-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230629192119.6613-1-eric.devolder@oracle.com> References: <20230629192119.6613-1-eric.devolder@oracle.com> X-ClientProxiedBy: SJ0PR03CA0180.namprd03.prod.outlook.com (2603:10b6:a03:338::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_|IA1PR10MB7200:EE_ X-MS-Office365-Filtering-Correlation-Id: b9b946e2-4b0d-4c1c-8a9c-08db78d60a39 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JkZGzm7x/AFc6nlOCJhwDWWtl9fLwGEHMBaFtZdxbt67T9Yz6I87PA677Q2jWdSw9k8qdqPpHn+2pPOf57CwiICpy+BHUVIPomaMSZAYmHnps9NDiobdqgkwtOdcJWZxlxExBNgKIF5KXCho8TeLFxPH+pLuD9N34BlcnS1x/I8kAB3hScnPaHQi64mwdkmqgggdQnrT/1C7E07dGRLYPik0rawBNx0jr4e+NJ7AsuB3Pv9MxGc9gJvZWPrFN+meXi81rSn1xu9fUPVHMMLnrSgBHo9W0TkWq3WphTRGuIbb9no8GEPKDAeB0oysISjfbYcz849eO9ykhO59SgLMikzhDbkc00iVSh3T1ye/rBsqYjijLyYrpx0j1CNkr11IOc0JLOq8xeI0K87TMQYcbBYRHZnz0cVVCVhd+vI5bvZPcjMrHSDptLC4OS/sM58Fjq0ICFT1dAaWBvDaADF8NRCDELEvbg9P1I2kFcoa3wBErhQwH6yZuoJa39Hzw01+rxdhl2/of8re6tnOkg7Zfgoo/OlrGXKWLcQ72RPyhmQUe5ZPZl8woFnY1yZOq956Z2XfjFyMIIK55E+r4Z3THQzhbpshhXauBjyxkNWfKZ7Hab8rmrrnmrUK1qXn8ImV 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)(136003)(376002)(39860400002)(366004)(396003)(346002)(451199021)(83380400001)(316002)(6666004)(8676002)(4326008)(8936002)(6486002)(41300700001)(36756003)(86362001)(38100700002)(921005)(2616005)(7416002)(7406005)(66556008)(6512007)(5660300002)(66946007)(66476007)(478600001)(2906002)(186003)(26005)(1076003)(107886003)(6506007)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IDm+CkZaKzbIqI/jIyDImGy1teqsUAfgzXlTQ0hCPQzUv9ZS7w07lOaOsdNxDbd0m50Wk36V+GJScdqXCY7MtXwb4raF0PDKgpVsEAY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mh5/ox5QBnAY/lI2UnrbrxuRAcHlHdZJE7RCGerw2yS3iZqoqt0Y/3ripFTRHly2LlJlVa4keGyPuQtx7JObGY/E9PxJZ076YvbVZ0+bbc6+o99qw4kyKYrqT5uLjw7/uk7WOQJgI1xpHfKjBG3OjUlFLXUChAXCYpOdVvinhB9zh8DZe8EdHwvs2ya3SJfMxJRe+hDOWRdvvv8FCLBqEN0mNFl1p9Vi1n6kJP/KBbBC+tfR2J8oh+6o4RX0RohOnfTw3VdJAWhDX3cmN/lST/EUxdmqMLvXeArHts6I7Y0e0bAg43atA2zOwORm7vb+RBDhS3KPpHLLXRnwhk8Pj1dJfdSZwFniQLiggR/RXZ7DYm/hLhO4TovF1CAyeFrAzsTyLkzi1QbVEt3e0uogI5uSib0bmieeXdB2FowNuVqFbKiwh8qHnru+C7ytmznmk4vZdQTBPPBfXep08QsE+xc9dtb1pf1XkNZVUogVrxEma6bOEykio6njxS2DuriWfKQmtAQEPAU0N6LLvjJWQTWd9kt+/tHKAz98+03PUcijohJFaMn6oSVdXlaI7tz0etEJ0gs6/ojfx19ot9Z4vUxmI4NvLuxLPmsQ3RWKHFH9ipjCukuXSUHnLbMuBXToisYy85Fpk4tUtmiPNdA3SF2aQjbbYYX6QqzhGe3EW2DSECvqDTLtccoirMOmDx/2KIZl32RBtW0vcY2CQ096Dwu8i635XueA6L7rPqQU0guWpkKzi/zwWpSXUib5IXC3cLDoox0KXGtGI2JfdatlP6GNudfZmGOiIfWzbrjxUHPZIK067K6C79vAKr6YD4T3raOthvhHciNHMz7zjrvNqU+sAM639qmkBgg9ToZv3jBjoZL9zpuCeQajpfSrXLqno3aXsuNXlOzdkxtvHo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b9b946e2-4b0d-4c1c-8a9c-08db78d60a39 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2023 19:21:29.3988 (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: lomf7q1lbeS+029FjTUf8qhPRfh9W+En2qmsby28qcVEtUWjTw/QHtz7cf+xnuISEj+2uGAK0iqo1OqWNY11SqyxWGl2ty6osSGqhKM6g1o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7200 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-29_06,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-2306290174 X-Proofpoint-ORIG-GUID: 61ICmdlgMU9EblougI-RUJy8afwawlQx X-Proofpoint-GUID: 61ICmdlgMU9EblougI-RUJy8afwawlQx X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770069745073499114?= X-GMAIL-MSGID: =?utf-8?q?1770069745073499114?= 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 function body of the callback functions are now wrapped with IS_ENABLED(); 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 | 125 +++++++++++++++++++++++++++---------------- include/linux/tick.h | 2 +- 2 files changed, 81 insertions(+), 46 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index c1815b9dae68..2455cbcebc87 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -82,24 +82,27 @@ 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) { - ssize_t cnt; - int ret; + if (IS_ENABLED(CONFIG_ARCH_CPU_PROBE_RELEASE)) { + ssize_t cnt; + int ret; - ret = lock_device_hotplug_sysfs(); - if (ret) - return ret; + ret = lock_device_hotplug_sysfs(); + if (ret) + return ret; - cnt = arch_cpu_probe(buf, count); + cnt = arch_cpu_probe(buf, count); - unlock_device_hotplug(); - return cnt; + unlock_device_hotplug(); + return cnt; + } + return 0; } static ssize_t cpu_release_store(struct device *dev, @@ -107,23 +110,24 @@ static ssize_t cpu_release_store(struct device *dev, const char *buf, size_t count) { - ssize_t cnt; - int ret; + if (IS_ENABLED(CONFIG_ARCH_CPU_PROBE_RELEASE)) { + ssize_t cnt; + int ret; - ret = lock_device_hotplug_sysfs(); - if (ret) - return ret; + ret = lock_device_hotplug_sysfs(); + if (ret) + return ret; - cnt = arch_cpu_release(buf, count); + cnt = arch_cpu_release(buf, count); - unlock_device_hotplug(); - return cnt; + unlock_device_hotplug(); + return cnt; + } + return 0; } 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 +277,14 @@ 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) { - return sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(tick_nohz_full_mask)); + if (IS_ENABLED(CONFIG_NO_HZ_FULL)) + return sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(tick_nohz_full_mask)); + return 0; } static DEVICE_ATTR(nohz_full, 0444, print_cpus_nohz_full, NULL); -#endif static void cpu_device_release(struct device *dev) { @@ -301,30 +305,32 @@ 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; - u32 i; - - len += sysfs_emit_at(buf, len, - "cpu:type:" CPU_FEATURE_TYPEFMT ":feature:", - CPU_FEATURE_TYPEVAL); - - for (i = 0; i < MAX_CPU_FEATURES; i++) - if (cpu_have_feature(i)) { - if (len + sizeof(",XXXX\n") >= PAGE_SIZE) { - WARN(1, "CPU features overflow page\n"); - break; + if (IS_ENABLED(CONFIG_GENERIC_CPU_AUTOPROBE)) { + u32 i; + + len += sysfs_emit_at(buf, len, + "cpu:type:" CPU_FEATURE_TYPEFMT ":feature:", + CPU_FEATURE_TYPEVAL); + + for (i = 0; i < MAX_CPU_FEATURES; i++) + if (cpu_have_feature(i)) { + if (len + sizeof(",XXXX\n") >= PAGE_SIZE) { + WARN(1, "CPU features overflow page\n"); + break; + } + len += sysfs_emit_at(buf, len, ",%04X", i); } - len += sysfs_emit_at(buf, len, ",%04X", i); - } - len += sysfs_emit_at(buf, len, "\n"); + len += sysfs_emit_at(buf, len, "\n"); + } 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 +457,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[] = { diff --git a/include/linux/tick.h b/include/linux/tick.h index 9459fef5b857..a05fdd4b21f4 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -174,9 +174,9 @@ static inline u64 get_cpu_iowait_time_us(int cpu, u64 *unused) { return -1; } static inline void tick_nohz_idle_stop_tick_protected(void) { } #endif /* !CONFIG_NO_HZ_COMMON */ +extern cpumask_var_t tick_nohz_full_mask; #ifdef CONFIG_NO_HZ_FULL extern bool tick_nohz_full_running; -extern cpumask_var_t tick_nohz_full_mask; static inline bool tick_nohz_full_enabled(void) { From patchwork Thu Jun 29 19:21: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: 114430 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9898489vqr; Thu, 29 Jun 2023 13:36:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ61OxGsM0chbCGZ8O3X2LoHldMhiAZSz/GfueS12h5sXpisjuIe4Gy71v0xBh8AyjOdr06I X-Received: by 2002:a05:6808:13ca:b0:3a3:6acc:2306 with SMTP id d10-20020a05680813ca00b003a36acc2306mr496363oiw.55.1688070997132; Thu, 29 Jun 2023 13:36:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688070997; cv=pass; d=google.com; s=arc-20160816; b=Rj0JytGOwoC2XSvIyvt9uETk0JlteqFxOCs3AOHqM4D0UkZnVEJuIYdWd63kWpeW0Z dXhtHE63U4jLKN9p8ilhXINX8XdykuusTqcAbirNnBdOqYTP1aWsQZjz0g69nw38hlcN I23/zhheSXQXr6Xvj1ORo7xJtCgWaxHvWkDRHCHfIhxlCVMRyUL28Q+d/0Kh/JY6kqYa PWElVF7HTuJnM+GVUVH4cd98RxKZIGG7RioOqyLiRBAURYijW95pXP7u3MnOg3cfR4p/ EL/N2Vd7uKUD7fArYZyarGRaTPe2E1l0j5RJqY49HBvhiLBSGaUxltnW38rScjYtIkeP tlNA== 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=5HPLDEQyUQVH4MISxpkHDadsyBn3mLXsaqlvlMMJCmo=; fh=j+K5GuuLTbxxisV+wJRNZBqbr6zhGMwAghI8ANXi4rw=; b=cagwM2QKvRKg7gB7fhdG+nO4lbZ4s5y8Gr+a0V3lTOjEX54nm151SQYDrFtL+KBGFN E/svRGJq8SMk6ExwnUy1hVG87PrQ/tgR5V4PRkF8x7dJLiQL34LKrLVwUAXu4ct3nc0P wbFE5r7F+NzrCBdiAj8d6Jsg1rUq0fQ+9Im+vaecgpr2XK/GLrDZ29OVUOHuWQxv6UuU Qgc0ya9J6j1nULLt9Q0TRpesXFdDa42G7zoVcxtqbHAzBuZrcu3CUfSxjkLRw7HCHH+H B0ZlvfnuOPadyFwEp0mcoUONiRgKFKt0jVCPokbgvFRgX1HlmD4SEGNBq9KF6x2tTz0j roLQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b="Lz3Yxu/z"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=UKcyKfnQ; 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 p38-20020a634f66000000b0053ef158b0c3si11164935pgl.25.2023.06.29.13.36.24; Thu, 29 Jun 2023 13:36:37 -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="Lz3Yxu/z"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=UKcyKfnQ; 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 S232029AbjF2TXr (ORCPT + 99 others); Thu, 29 Jun 2023 15:23:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbjF2TWt (ORCPT ); Thu, 29 Jun 2023 15:22:49 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90EB73AAB; Thu, 29 Jun 2023 12:22:44 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35TJ415D028772; Thu, 29 Jun 2023 19:21: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=5HPLDEQyUQVH4MISxpkHDadsyBn3mLXsaqlvlMMJCmo=; b=Lz3Yxu/z0T5iQN8Za9qCLQ+J9Va8io78qvvUvP4PajenGudaVOz5zQzq7fPy0FD6G+5N IPoJBimQVKRZMiSXcIIBT256+2Hfa6e6QVzhqDD7N25GksUSCGt0bvAAuaIIQm3plH9E zgvoTf4MBIAckmvnf6Kii2p8hPhL0EGoZPsGYobgK7dnTZPfvQqJWaqCCPq4fPeOdL/T RdAXyWrHUpcvcMh/kQWvB+zm22jddXfXgtHLdnB6yN6p9++778nzcjdvlfVkvHBh+e5/ +BFaNiyV2oYcocCvkKNdjJgxFnzYqpZz4ANZjpyP6IpINTjdaz3H9pEGOH09grFvPo9l dQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdpwdngg0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:36 +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 35TIm6nl013083; Thu, 29 Jun 2023 19:21:35 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpx82gjb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JQENek1CcgTVJRRQKy7e2dB5eTCUpeRaETHm6BZAVNQfoW+zEZJ6errdqzYexpP2+zlI5x82eZaPMBuUnOQybwKagpn/8H/kp/e0CjnAWcn5bTxYm5Oe01J7NQX+FVa3vc7qjD2BrpcNKo80i64G1ole+A2Hul/cL3g45XJIe/RwLFABbs+9zlnr9Ze2HKr8yGuswVxR7+hQ1JXqiaFbTvr8LN4VkgvZ3+E4+4gpMBPPsTp5sYz8w+4cD8i6l98fRc0pRX9JeCX0qpUVvbeoGERFxtKxR8uIA9UrxA9+r8BTFCvRgBW9LJuUGvdqPVnVgP9/9FikeorC8BHh8NvYbQ== 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=5HPLDEQyUQVH4MISxpkHDadsyBn3mLXsaqlvlMMJCmo=; b=FVrt5TP0gO12Tq0M9phF6w9w0DotniIQ8J/mDg6sg6PnQBc9ORrojxDOdHpKlY+jch8PTJ3YswFtMA4kvcWDdo8RetBwrETLHbvPiRhQdzY653XAF34gYfGS62y6KlNlqJPc0aFSLstRt5VmJwDuNkHEvWn/gcUrIey2FUpSw6tQgNVqYqg4l54t9AGEWZ1owgTKaFa/R2BKm7rDoPrj3qVj8BBi9dO/njUT9d5QoJDtKgDVfLW/noFb5kKaYD6y/WWOqNRYO7cBXnx5RsdWq7Fe5B/vk5zqToD+sFlbKzP6uDHs7vXgZkiBVvtO576QTV2cv2ctYe5UtK9h1UEMOQ== 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=5HPLDEQyUQVH4MISxpkHDadsyBn3mLXsaqlvlMMJCmo=; b=UKcyKfnQTjApzbCnEw4VofenhxVf2QZlkZAQFGVLUHmPB519fvT+BrygpPawl7avhK5qNaEYr1Q48iRvsTLplQzX5HXXvBIuVBOaVECMcx45RikRAQ3dguAPthr5Pv8nboFtvy4xPykrb5PAH/7lx+PXeqz8wj2INo9fvbKaQJ4= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by IA1PR10MB7200.namprd10.prod.outlook.com (2603:10b6:208:3f7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Thu, 29 Jun 2023 19:21:32 +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; Thu, 29 Jun 2023 19:21: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 v25 02/10] drivers/base: refactor memory.c to use .is_visible() Date: Thu, 29 Jun 2023 15:21:11 -0400 Message-Id: <20230629192119.6613-3-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230629192119.6613-1-eric.devolder@oracle.com> References: <20230629192119.6613-1-eric.devolder@oracle.com> X-ClientProxiedBy: BYAPR02CA0005.namprd02.prod.outlook.com (2603:10b6:a02:ee::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_|IA1PR10MB7200:EE_ X-MS-Office365-Filtering-Correlation-Id: 071495a1-1f43-4192-2631-08db78d60bf0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Em2g9y8Y6XyPjKVU6kGihsdXPoOGW4gjtvhv7XD2THxwlFwGf2PEEX0THkUzsongzl0+4VgFpReyHReDiQJsSU41w07rfEn4xCQfb+erePVgNWwt4EM/KdaJsMn4Vft1VEhtnbz8vOM7qNnmaf9ValnT31CtLiusqAoSkj/dv4jNsI+9bQHYEmbq1X9O9bwyvPw+efJXpK0JhSRVlSP1SGrgmsqYLjdNX5gnednVNy9dSfEjViXv5bSvhEUbuylm2USgBdcZLqKLo1mXO5Q+SPFoZuyVpf1Clj6rKdFNn7VcmVqLe8aWWhwuVcQdd0hbP5N0X2ZSasscUNi789TNmoF8FsPwBdGpxvwaq3ANrJLa9qn1Qb+toLTSK/76GkiFDQO8BgmityQTKG9sXgsUJbh1ApuBFY/cOgl9qzgCDd2PpsPfagMD05ohleo45VlUKFdxJyzSUD6nrcyyBWtltknBcWaC0/VxRvaM5b6zAck1QjWJYHhKai80pUcfyfhyz0mAmBaqXaRzN69sI5Bs8mabi6q+S1iPGfqIS+Dayqwie1JhYG+aYbHZJnbAqnquitJce9L5/bdQSXGk0Ie7DVC8gcQ7T7TXirVWhlfAOhKSBa1UNzlEUtp4k/sgfDDL 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)(136003)(376002)(39860400002)(366004)(396003)(346002)(451199021)(83380400001)(316002)(6666004)(8676002)(4326008)(8936002)(6486002)(41300700001)(36756003)(86362001)(38100700002)(921005)(2616005)(7416002)(7406005)(66556008)(6512007)(5660300002)(66946007)(66476007)(478600001)(2906002)(186003)(26005)(1076003)(107886003)(30864003)(6506007)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aS9GNWfssVWzq5gLP66fydEKW2ntT26eyuA5QzsxqZ1mjjGKE/xSpHhz9fho3qHyV5XjwhwkcFL0FoYvBIHiHiZIBdLZfsW3OAsYWlnjGKVRVbwBpzj+L1uBNQhnbuC3fWklEwaJzklfKx6if2P3rHZmy0rf6zzOeL1oH0blbJGxg/OVYbRDXstKT7+ih2tiGMk09kJqI8mrWrVlev6YsnmXpUAdn30At7BkK6ThRBavVLzt7Ktx3ClcEqnLWBNqqzTW6vWANsnxDBiHsvcshx3Ypekzx28HGDblfu6aPMR+ueSZJteg4Vg8aMlHjOtUec61naUv0av0FTnAw/wyLajLB8B2n6CpU4/g69xyP6U2QHuDOOHYMn/kewSJXheZZuSPuLxBHUvDYkCnYwNqtHp262j2H4AyqqZ50ly/CQXep9y/FeyfAI75Wvf7SRYFvPI8pK+WEk7v8ty05LdchgUobALT30jDJSunIYXpW8avooe9VKaTKX/7kMj9u4LsqCyL+QMMCILKjoHtqLgDikS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t09bBnY+WXnfq/xtNt8x3mqMXHedYYFyHHSV/KVEOa6iOFtYhy1ddGaz/5WmD9AcvKhEqvIjpuL3CRqMPbNRGRJY+NiDg9tTY7kplJoLWg45IPNfxrmjg4dAlhhCCQnb7itYV41KYfHu29nl74ZVAn2ejq8oAZGqJGZRFZQmXm4sMuk34yP96Zqlce8xem2IaxUVwm+smHhBlLoggVc5WCdUi25B7EaJQ+dgzgHmANkIN0u9FTpy5uGM8FZC2Fryp7tHGs6NRJh9doZ0JyXoCLiTPuYQYOiBnwPrceCahjvKeL3oOmSWpKskJzvR2VxGG2djYCw8L6APawX1LhyzvHDr23RBKKmEIq/lh+ZgH9aZQgfGWUyZp4ft0niwt7D+f/RGfL08Ju6Us2wIanzo9lSCvubdMqMnwQEl/OVjSpGeczmnZr/MtQKuNEi0IDlbDpKrrdDe7EEgk4z+CxDNKDtc0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 071495a1-1f43-4192-2631-08db78d60bf0 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2023 19:21:32.2992 (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: i4aO71fR7C5qMlAw18bmhEXmGd35y7/EAjMiDw0Yw/qxhBwPbDBSmtJFcZeMN54hMn4jHtEEPglSp2j9wLKemdgdSzcPlCry5uktTVRLa3Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7200 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-29_06,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-2306290174 X-Proofpoint-GUID: u9xq_TZmDa0hFM2955WD_UIqxuLpwMLT X-Proofpoint-ORIG-GUID: u9xq_TZmDa0hFM2955WD_UIqxuLpwMLT X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770070733797962547?= X-GMAIL-MSGID: =?utf-8?q?1770070733797962547?= 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 function body of the callback functions are now wrapped with IS_ENABLED(); 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 | 229 ++++++++++++++++++++++++++---------------- 1 file changed, 140 insertions(+), 89 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index b456ac213610..7294112fe646 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -391,62 +391,66 @@ static ssize_t phys_device_show(struct device *dev, arch_get_memory_phys_device(start_pfn)); } -#ifdef CONFIG_MEMORY_HOTREMOVE static int print_allowed_zone(char *buf, int len, int nid, struct memory_group *group, unsigned long start_pfn, unsigned long nr_pages, int online_type, struct zone *default_zone) { - struct zone *zone; + if (IS_ENABLED(CONFIG_MEMORY_HOTREMOVE)) { + struct zone *zone; - zone = zone_for_pfn_range(online_type, nid, group, start_pfn, nr_pages); - if (zone == default_zone) - return 0; + zone = zone_for_pfn_range(online_type, nid, group, start_pfn, nr_pages); + if (zone == default_zone) + return 0; - return sysfs_emit_at(buf, len, " %s", zone->name); + return sysfs_emit_at(buf, len, " %s", zone->name); + } + return 0; } static ssize_t valid_zones_show(struct device *dev, struct device_attribute *attr, char *buf) { - 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; - struct memory_group *group = mem->group; - struct zone *default_zone; - int nid = mem->nid; - int len = 0; + if (IS_ENABLED(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; + struct memory_group *group = mem->group; + struct zone *default_zone; + int nid = mem->nid; + int len = 0; - /* - * Check the existing zone. Make sure that we do that only on the - * online nodes otherwise the page_zone is not reliable - */ - if (mem->state == MEM_ONLINE) { /* - * If !mem->zone, the memory block spans multiple zones and - * cannot get offlined. - */ - default_zone = mem->zone; - if (!default_zone) - return sysfs_emit(buf, "%s\n", "none"); - len += sysfs_emit_at(buf, len, "%s", default_zone->name); - goto out; - } + * Check the existing zone. Make sure that we do that only on the + * online nodes otherwise the page_zone is not reliable + */ + if (mem->state == MEM_ONLINE) { + /* + * If !mem->zone, the memory block spans multiple zones and + * cannot get offlined. + */ + default_zone = mem->zone; + if (!default_zone) + return sysfs_emit(buf, "%s\n", "none"); + len += sysfs_emit_at(buf, len, "%s", default_zone->name); + goto out; + } - default_zone = zone_for_pfn_range(MMOP_ONLINE, nid, group, - start_pfn, nr_pages); + default_zone = zone_for_pfn_range(MMOP_ONLINE, nid, group, + start_pfn, nr_pages); - len += sysfs_emit_at(buf, len, "%s", default_zone->name); - len += print_allowed_zone(buf, len, nid, group, start_pfn, nr_pages, - MMOP_ONLINE_KERNEL, default_zone); - len += print_allowed_zone(buf, len, nid, group, start_pfn, nr_pages, - MMOP_ONLINE_MOVABLE, default_zone); + len += sysfs_emit_at(buf, len, "%s", default_zone->name); + len += print_allowed_zone(buf, len, nid, group, start_pfn, nr_pages, + MMOP_ONLINE_KERNEL, default_zone); + len += print_allowed_zone(buf, len, nid, group, start_pfn, nr_pages, + MMOP_ONLINE_MOVABLE, default_zone); out: - len += sysfs_emit_at(buf, len, "\n"); - return len; + len += sysfs_emit_at(buf, len, "\n"); + return len; + } + return 0; } static DEVICE_ATTR_RO(valid_zones); -#endif static DEVICE_ATTR_RO(phys_index); static DEVICE_ATTR_RW(state); @@ -496,43 +500,43 @@ 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) { - u64 phys_addr; - int nid, ret; - unsigned long pages_per_block = PAGES_PER_SECTION * sections_per_block; + if (IS_ENABLED(CONFIG_ARCH_MEMORY_PROBE)) { + u64 phys_addr; + int nid, ret; + unsigned long pages_per_block = PAGES_PER_SECTION * sections_per_block; - ret = kstrtoull(buf, 0, &phys_addr); - if (ret) - return ret; + ret = kstrtoull(buf, 0, &phys_addr); + if (ret) + return ret; - if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1)) - return -EINVAL; + if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1)) + return -EINVAL; - ret = lock_device_hotplug_sysfs(); - if (ret) - return ret; + ret = lock_device_hotplug_sysfs(); + if (ret) + return ret; - nid = memory_add_physaddr_to_nid(phys_addr); - ret = __add_memory(nid, phys_addr, - MIN_MEMORY_BLOCK_SIZE * sections_per_block, - MHP_NONE); + nid = memory_add_physaddr_to_nid(phys_addr); + ret = __add_memory(nid, phys_addr, + MIN_MEMORY_BLOCK_SIZE * sections_per_block, + MHP_NONE); - if (ret) - goto out; + if (ret) + goto out; - ret = count; + ret = count; out: - unlock_device_hotplug(); - return ret; + unlock_device_hotplug(); + return ret; + } + return 0; } static DEVICE_ATTR_WO(probe); -#endif -#ifdef CONFIG_MEMORY_FAILURE /* * Support for offlining pages of memory */ @@ -542,15 +546,19 @@ static ssize_t soft_offline_page_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int ret; - u64 pfn; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (kstrtoull(buf, 0, &pfn) < 0) - return -EINVAL; - pfn >>= PAGE_SHIFT; - ret = soft_offline_page(pfn, 0); - return ret == 0 ? count : ret; + if (IS_ENABLED(CONFIG_MEMORY_FAILURE)) { + int ret; + u64 pfn; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + if (kstrtoull(buf, 0, &pfn) < 0) + return -EINVAL; + pfn >>= PAGE_SHIFT; + ret = soft_offline_page(pfn, 0); + return ret == 0 ? count : ret; + } + return 0; } /* Forcibly offline a page, including killing processes. */ @@ -558,22 +566,25 @@ static ssize_t hard_offline_page_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int ret; - u64 pfn; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (kstrtoull(buf, 0, &pfn) < 0) - return -EINVAL; - pfn >>= PAGE_SHIFT; - ret = memory_failure(pfn, MF_SW_SIMULATED); - if (ret == -EOPNOTSUPP) - ret = 0; - return ret ? ret : count; + if (IS_ENABLED(CONFIG_MEMORY_FAILURE)) { + int ret; + u64 pfn; + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + if (kstrtoull(buf, 0, &pfn) < 0) + return -EINVAL; + pfn >>= PAGE_SHIFT; + ret = memory_failure(pfn, MF_SW_SIMULATED); + if (ret == -EOPNOTSUPP) + ret = 0; + return ret ? ret : count; + } + return 0; } 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 +622,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 +910,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 Thu Jun 29 19:21: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: 114412 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9877342vqr; Thu, 29 Jun 2023 12:58:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlHBJ5SGeEp38QOfNwxktBJsWhxgyHrvSCD/aGvFS6Hyzfk6VULZX/fOH0A/MsCSJ7lPEWNi X-Received: by 2002:a17:903:44a:b0:1b0:49e1:6dc4 with SMTP id iw10-20020a170903044a00b001b049e16dc4mr128439plb.56.1688068735127; Thu, 29 Jun 2023 12:58:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688068735; cv=pass; d=google.com; s=arc-20160816; b=y5iMNCE2BMgGjIbn2UMMPEm8RKiywOAdqBR/k6ppgal4HmcxFUe1rru+PuKC3YUcDv DgGmdqmUFmIjJqb0M9gIZRpd5uVDPDpwXXSjBUi7GOX7/R2RtY6YTcNxvQWeHgAH3H9E zGuIumvngDLkHVd3eEO+j+EMiU1fA1Nj6E/I7C6LnH4IyG+QJClVut2QEtYtwrtp+W0R fdsKIJ0JeCx5s8rfJh2qegATzT1a9zmUMUhUy0oaIhBLUstSlIUtXayJL5Hv62OPM3fZ UNMH4v/QNLqHgBe1Xt21sY15iHuxPasINLvjurOYLZaMdicAO1rYeG9Yjisqa90W+CPI 0aCQ== 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=y2AH2pRzwy0Ok6HkIY+gleixk0V2iGY+zLOq9DEvUoaMVvnoEPhs2Y4TbLMIMLIuqB YUEMxwoZk53VabLI7cKZeq8NbyvLkkNJa1gnSPsG4HdIwKntD+ufP3fPBHUsHroWTohH ScJ578//6qRYS6Z3ZAOe2scEc8dqy5vHbkgvn+Cc1zJ36Ul0eP8xor8i1tOzQ7xwG82Q 8BJhLnaFKtDNIyO/S1ablDFd/RyThcEtSDVaLBI5D4N2l++y7zwQDEi93RSc1EIRGDCQ PKLYPefaD/CghQVBi4V3aElJ6cmUkGW5wyK+aWjZAa0jDaeYs3tfa4RcPdpJPtebgZTs qVIw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=eJi0D4Qu; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=awwonEUG; 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 t3-20020a170902bc4300b001b6c462acbdsi10519168plz.15.2023.06.29.12.58.42; Thu, 29 Jun 2023 12:58:55 -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=eJi0D4Qu; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=awwonEUG; 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 S231545AbjF2TXk (ORCPT + 99 others); Thu, 29 Jun 2023 15:23:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232125AbjF2TWs (ORCPT ); Thu, 29 Jun 2023 15:22:48 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C7633A99; Thu, 29 Jun 2023 12:22:43 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35TJ3phG002877; Thu, 29 Jun 2023 19:21:39 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=eJi0D4QuTIoRZmM7jqyI0eDH2TXWKFeTGelzFeIwelJ+Ri0ePixugp09nN4WR0GitP0c JHKh3aJk/Zd4IwkeB3rFFddqaYD1JfSyOkZ81CnD71XIUiTkcrG7cV4XIVTp87IgLTOk Ep+bpaYmrfPhf55Pnk++5b/aU8rE+cPp/et+0/DRaym8IAc3GblgKrC+Y80VOYSDkWI4 sQcpnojmev/AlTeKTlW3ATo683W1Jq0xuf/ywt8YE6aJmUCTgZU/+wQGCCNh57GZWR0p J3TUpYy+lM0D95PBIFfB3Tlf69iiBc6a48A62RYfa/3YEyYAyZsz3kiug91oW0acOfkN zg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rf40ebwfp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:39 +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 35TI5a7v003989; Thu, 29 Jun 2023 19:21:38 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxdur4f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gwP6ZJLrcQJbSADMSP30Tbl0+BehCmmI6xrDTYDki6b33DJOtgJ2/feHlCBnb6BXhySNK9elzbx88y9XKwj9XFqAFCFFpyJUnrNoTyV/Fz06/PojTx0v0mpr/kbwD2p/CBgurKkeF6Jp/zu2zhUXCI6f//wkdz3Vz7VoZBYTzdZGTbzlXCKQMqH1f1kxBgOEtMsQ9soFWTSjQ2xw9l4jycDzx1e4CTZPOlenldqx/qZaOZSLTIBt/KwWB2bK3Lgo7Soxta+b1YXYludUBwus/YiOC56EbMLkWDtuQ/Xlc17BJdcGUhk7L9NyEpqaa9M28W0KtpZJhEKlOllzUf7YTw== 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=RJ9oN8RKERuwcTxg7vDOVqW+DqTgIHerhsiE5ylhOQtds2B3+EtY6vRjYqHgMY683OV0eYwEEQz89TH0Hu/1sZeDiNQJ/k0YXJuhPgJedUPkh018vZekeZ3lSnExmZz0OuYN16PZmTfxafTgZ9xYUXH+ecE7926hIhhUHMdGHjGuRi9dw+FJ4qOWqZw0W05tLxvEzAbmEok6dcPVe9nWQ4TPYLZ54hHZkzpLXJ+EENT5mRGKHWlEEo6y4QD1PfT6cNf5tsiEOI2yCGwaVNGZxGAJ9gNrf/h/yVDfGNakJIsoq/4rSxOHpmum6IdU4ZxWOHDWOJ87zg4rcY8C/oEG5w== 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=awwonEUG2R21cJ9nfFoQup7uFXL0CTGTtavIT1iKVk6zeRKKfcqkjBoGEGAcHTEIVeww3vn+HJ2B2shUr+l3Kg17HcoKZZJ4ALT09Ip9pAGNXUI75/091Oz3bXI5p2RDLZae5eT/8xacPRLXw9ttpVeUMsCiY0vT4CMEKN/QI/w= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by IA1PR10MB7200.namprd10.prod.outlook.com (2603:10b6:208:3f7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Thu, 29 Jun 2023 19:21: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; Thu, 29 Jun 2023 19:21: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 v25 03/10] crash: move a few code bits to setup support of crash hotplug Date: Thu, 29 Jun 2023 15:21:12 -0400 Message-Id: <20230629192119.6613-4-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230629192119.6613-1-eric.devolder@oracle.com> References: <20230629192119.6613-1-eric.devolder@oracle.com> X-ClientProxiedBy: BYAPR21CA0002.namprd21.prod.outlook.com (2603:10b6:a03:114::12) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|IA1PR10MB7200:EE_ X-MS-Office365-Filtering-Correlation-Id: 57f71007-2819-4ad1-f786-08db78d60ddf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g1BVAdT3rJSe1WccO/IoIJ8S2xrN0J85TwRCG4v2mD6mATiyyqShkXfj8L2G1CMHCCV77RXXO5gpvHKtekTZMA8KUR5obvT7M8JA0qWZJHTIUgK1fwYs9P18i/IdOMtaU0voAFI+I653YnEYQ2ANy235ijMRyt4Y4zTd07wf9r4FUXLCbcfVUHfPEp2n8OywbUisLF+LXzqtIyWItJ0znHyggDmV5OqljB4EPH6EB+79BlK53f6+waBpfUcfoAcxDt1o021tFxsc9MVB1fJzrVJ/Vmc+5Wor8/3JlIBK9AEj6mpxnzxtV5CC/Jj2RHEFtvQuV5+87lOhTmi3nqHFQVxP1Oh+cKztcf6YWSr9eSluDww6rHxc7N/VD6LVFL8vkGqIR5oDQP32ZAaLBBsevRc1SZitSLWmXWrrXSVm6PUDEmNqixL3EkVndNLLqPYztR/xH4gtJ8kD7ls7LIddOA4v8nf77I9Jxut52nuX4jpP3G0w8COZDkHYfrPm9QvwkFhlHSKpK8QLg7XU0nYnhBY3B5XltUDVljFO3157UpJfT9UttkJWDy92fEQM/ffANQZt0bcGLFW4j5+dLFxOJ060B35p5KNIPZ9/bDUwx04= 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)(136003)(376002)(39860400002)(366004)(396003)(346002)(451199021)(83380400001)(316002)(6666004)(8676002)(4326008)(8936002)(6486002)(41300700001)(36756003)(86362001)(38100700002)(921005)(2616005)(7416002)(7406005)(66556008)(6512007)(5660300002)(66946007)(66476007)(478600001)(2906002)(186003)(26005)(1076003)(107886003)(30864003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 12FykM6jMXvgjHs6l12faFOKAgCQEOKABHZdvi6+Q/ofwShI4q+1ywxnunA1rGsab5lysdm4ARYBzQlBQAQBPp+1Vg1EhX8WbxpESd4D0Qd/NYv7WmTjGh/1vJITentO+tB4CLAgqy50BLuInSjdV2RfW71Jy/4OXFPrkTf1LMQuWRxxfvm3YXzrsKUwlrOz6El1ajYB9ca4a7VCitHZe1nhnNiWZ0NA2EiED4JXnY6yIayDPa5r8o+wLrb2VBvQ0EeUC1v7hJE0AfrXmfSI1wXp9frKxLq931tOfmPEIfXRcEu52XR3VVLfcGMaCCkAbVbEvzfgHWS+RDCXMtDA4IJycp2XYdzKQr4LeB7gAzIM4EqpmxEGwBUDsy6QLnTTvtisuObLYc878QbHx+zB1vSTzQKaZk/9qij69HGkPDR8p5vAscLodZvQL23jWBV26vJXo7PY6k3NOVSe36mx98esFuVj5+hlw5M4G+q86mKoeN7a4jbqMjJLlo0BV/jFggrv7Bz3HZmGdAKjnLEUrhZdmU96l/U9hUyvsb5jF90P0Znmb76CADizqGjh/5i0sg0MOcmyN3KEnUcagvYTg8cQmHAMjZH/guwjIhQX2cNtMTKBWbCqwy7WfJN/eMQRQtjXJ5p5CTDHdUNGeeUHYxfO49nRFtE+Z6uyuI1d7MrN5wKUeM+z7Q38n+OXGhgJwcDM8EQNQ3acY7sQMM8kDLTzNhHuaeKIz4x4MN2kxeSM0GT0A2tN0Eh20GdNhDlf/lUFgaIAc8WxTBhz8ZarCjR0QfOFeXVR4kTIxlPg0RWNMSOibfl0suyVnHIlqJHT+UzXWCdjSCiVvRDi4/xpgZTens/OhE5PfEIa1oR+ri4kaulpxN3YZ6RQpajpu19bl47myNyqV40GVAXdgir1sbyjgAAltLzQJggDInRvZpc0S7qMMGKb0nSSXCWUJSnrOhy1HFnQeyL842CGkcUudIwgIGwD4/JwSM6kZMOsAwJgd1Y9uAejcNkFXqsRj4WrqaafhEB7C4LRpIYm29YSi4vPK2mpiT6MEXTuU4wcpByYivz4i0mVK51ht/O6Wx/SPpK32R1Wr6WBk4UwH2reKGY190BOZ0A60cRlVchd+2VTGdlHiKKfeuUSsHcDtvP8KF5WyNJH9v0CWY3Pvq4OlBlTuSBH5n9PCaEUbaJz2Y/UxIPvklHR093RYlddR69YTxvkbVqqeD66biELl2qGHpW8S10W6TEo8iAYC3oz16Uz/FjMWMfUxhBZnehLWs5CAwBlwoIOcE0vfej1msVN71PTxKLWkuaEsF8F+adUntCGbv3msn58FEZU4Zod8c3d9qsZ9M2fWdPpPSmeOW90j48s+C9zBzDcaIw+KLGUX6c3dcDNrxESwKL3hudgjXTpJBFDd/Qtf2ZKULVH82Rqbifg0MHiA0XFUyTPSHhBqYhMb76DwYbaRbrmkiHXZND/JUic/oOYVl96qmlPVR8gI4M1j63PWdY98nQbW3hlrU9encdhqNBQ+kGTqRE5FToweRAqv42Hw0T7HsCSmtdvz4QTVoUwAxmkXjTFEJyaFzc+kX+am+hmusPzcOPeHsDA+umIw7jlEvYz35xOYGuL1Q== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: pO+/3HCsNVPK240gvDuUyLVo8e0tEEwzxisAJIhH02uvedIWQGtFq28wji2g1tnCiM7O29qKlownBn0tX9LNBQYpWxDe2W+gaKfGXDZxXpmchU3mQrW/TJYw1Wxv3SMjXK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EnMUlbJ10YbNaszWLJNT5RPd7rfh6aP+3muRbdp381K8IKgR1esYfu8bYaY/Ta4SjVyBuNk3qkHaC3aQD9s1SLNr+ZCj44tYY4M5JWQPj6i4/4rRZnFXpb79XmNGJz+5WSUgYzezfIewo+cvk3mAPcolXo7vfwUOhVzw9MURHMP61jYb4wN9xFZTcsg602lWO1v8NfFv/3U0TvwTq0kNi1BDFLdIEIFhq2YjQakR1LSWtj4kDnhPvk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57f71007-2819-4ad1-f786-08db78d60ddf X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2023 19:21:35.5962 (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: LElDIAJHKXuBJtjEUnQpQ8SIE15KP+d9bh7Vu81XtEUcTzy07jNt6ZEkeQb4fuxWnzwBdrb+rOg9e2LFo7m0rLaKEz942qCpTW/ykDEQjc4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7200 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-29_06,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-2306290174 X-Proofpoint-GUID: PLfGWo6Ere8vZHQPw-baLrFz2LB6sBy- X-Proofpoint-ORIG-GUID: PLfGWo6Ere8vZHQPw-baLrFz2LB6sBy- X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770068361987223326?= X-GMAIL-MSGID: =?utf-8?q?1770068361987223326?= 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 Thu Jun 29 19:21: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: 114408 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9876951vqr; Thu, 29 Jun 2023 12:58:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4rvQtWHKY/BOTDTs+W6rMAU9dYNttJ2Bsk/9Y0q14Rbm5QSoU0A3BoCSJojJ4UIHRu4lyS X-Received: by 2002:a05:6808:1382:b0:3a0:b5c2:7c21 with SMTP id c2-20020a056808138200b003a0b5c27c21mr409235oiw.48.1688068681163; Thu, 29 Jun 2023 12:58:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688068681; cv=pass; d=google.com; s=arc-20160816; b=jrQXmuBHDPvphloYv0KLQDfIlsdyUvO1q8RqVjLh14hU272oMX9RBRwxL7lQ260vcU kbZLzyPL3poH6s1vhoOrVSdCa9LRfNgyoKTei3TenRHq/Kuax5e9NSqrZcL1tXS8z5m7 OZxLM/x0EQbYen/nGlz1U/UXkj5RFGieC7Kge/X3ezYLNqyIJT+q2Ev1cfTr2tbm1vLc g01TYEJOK64efLGyYV5kiHlBKD9Szp/Cof+p7biiGO8Du2TA8RynVPHP25XdSVIxay3J FIfX5GdWvi1V7OxSc/1mgGAmK2FuX9XkyPoBnfZqxZtasdOeSxDfzlN6I044GhKwSi+H Y9WA== 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=wM7tpdzEHsDGQEfNq0XTPDwleUdC/4uv1XQlDZ88I39rCOvgATQo3Ekp7N7sdmod3C +Yz3ZbSMMIMS5JQnbwJErCnzOnGk2OT6NxGNYsAHKpFuf009woz2ev8byoNDAUyIFeFv gd8ZZoBJZztCTLg86eKWfeIt+Eh4lmepNdTFvS96LpXizvyxPEgHZjZe7x4N1o3Bv/9+ Gf02FQdKUnTM9WnPDH5KZQIRe/DSbrXAw0gjGDTfVnd3EO3r+bu3o7faN5vuwFsk70Iz WNJI353F5LX3EQ2B8DAKfsYqJRpUFTyCSPFRfDYgFJIW3L8EmkCkKp5JSzhMETaEPGS7 1W/A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b="Y/bMKxnk"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Fhfr4Aq9; 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 q11-20020a635c0b000000b00553ebb05d13si11349632pgb.65.2023.06.29.12.57.48; Thu, 29 Jun 2023 12:58:01 -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="Y/bMKxnk"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Fhfr4Aq9; 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 S231979AbjF2TYV (ORCPT + 99 others); Thu, 29 Jun 2023 15:24:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232103AbjF2TWs (ORCPT ); Thu, 29 Jun 2023 15:22:48 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED7733A97; Thu, 29 Jun 2023 12:22:41 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35TJ3phH002877; Thu, 29 Jun 2023 19:21:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=rAap41MLGGcantWJmWHHzuP2VyBfpqCHGeczaU2RdgM=; b=Y/bMKxnkrEeRyP5OSF7sHA9O2xUhqn/rn640Y6ZEvZONJIAWYiON431mzGdVZjcRmisE vZzIXLB/RkYb9J/SSYtq5fjgmdL1N5uzv/Az22mln1K/9R6tecQ/kTCUQQ1W8eR9z7Ss ANy6cuMqL1hl8MqODYf1Tnp8DA/OhfHaRTplidQN3wNnCtErbNAHcyidpgdecl1jDNZ3 +qWrdsoZnfwWHZpyxspdI6IgNn3WTdi+QD4nFc/ONLxD/fAtE8cvbda3kOOm7gt5/3Pk Vr9dE2FsWDWY9Gda3KuorpmNXuxfOdTUFAMeGDyIiFsSujvKmbI4KOCdVMjmLpTYhLso jA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rf40ebwfw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:42 +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 35TJ0IVn038174; Thu, 29 Jun 2023 19:21:42 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxebtjm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PefLr5DDKVAAk4uXFwxJk6nixqc94CX+Jz5PeptKrw0rZRNInqr/kF78TjdIP3r8ubhr4BmTQHyfk46aNbC8q/rjkPXzC+K0hvkfFsO5TsC2mOaNQlu1khB3R7kzlmyYbFD2SK/hqVGqT2f29Y+nYzD0Evu2Q946P/pQuE241Dc0/6vbUMJELjnJd+QcoR3V+O6KYHcru8Kudv5ViiLNHTSDCe/OMh4AXphxJAeq0U0Iiha9y7+kN2BzeOZlqkQotxGH5bSP+IDKyn1PZe0jfj0Vn0FW0HgvFErD6SjC+vTiLqC4Iyje1d5icRqHQTI6hekZQDE5aO2w0SZ4u3pgoA== 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=Lz/i3LgVHhykNJPbDerc3ImHA6cgjv5V8KK4MYHTdoXx3naFvnyKHRbOewQf/N79tiQ7NYydNjSofPwHgfBdhaAF7BCJPPzTEM1zpF+eElVasUcizW2s8OFuaFTW81D80TeI6f+bwyJh9jS+Ef7v9WyPsSwPJxlbAnhvctMgQGRy6v4P5oWvtQH3EXYo6HA0j/9oqONAIU8nOmgQ0UO1qvyHxTnNe8g50kw6B+jpkuHZTkiKHgHcZOr8ActDoAGlZmaFu32AGq6GPrv4fiJkhhR7rLXzjftlGMqPdJoFqLJYs+ghfYOc4qkh2Yvl+TiAM8baU1njp1uywxaxi6lN9Q== 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=Fhfr4Aq9RXS9B0qjIZGKHhgeYIc6mSYddc40bxGZpJRXi7sxGmTPQxmNqdoE65NUCGv5+cV2SXr7ROKpLPAGHNxN/BpA7ZrwV2GE0zw5lJx8bxXboFJQV2X1xfwVO4weNkFDs9hABZ8UYcLStZkBN9gSroOocXmTMrGRBabiZwg= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by IA1PR10MB7200.namprd10.prod.outlook.com (2603:10b6:208:3f7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Thu, 29 Jun 2023 19:21:38 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6521.024; Thu, 29 Jun 2023 19:21:38 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v25 04/10] crash: add generic infrastructure for crash hotplug support Date: Thu, 29 Jun 2023 15:21:13 -0400 Message-Id: <20230629192119.6613-5-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230629192119.6613-1-eric.devolder@oracle.com> References: <20230629192119.6613-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR13CA0027.namprd13.prod.outlook.com (2603:10b6:5:bc::40) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|IA1PR10MB7200:EE_ X-MS-Office365-Filtering-Correlation-Id: 99c0d19d-faab-4e9c-bfa2-08db78d60f5f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x1rDBtccBHxguOWTRtEk7cgj3MDwAvvHu07XnC0o4knj9gDdLW0UWLL0FdDfTnHtYFXZ7FW0kbMZTCDuijEHzdObH+fESCZje+jmgIq90GMjpgyoTPurskRPwJOQwBOpXy04lEkzx2jha2fFx5Uu1sERheVu3hAWLkWKbj29osswpNlRFvJsc2wD8NikE9/S/BxeDjaHTVO86jvrI6Ki0FRUr2uz0wzdBKFItN2r3sy3DuPXa/u+BaQPIQYnzucLMJ+Fsei8FPEhk125+FoeDZdhv/h2iAD3PbME5ejoXrydRHfJKry+A4bclmb5mxneSgZu6NjTK4IXm3WpAcx306EssiD1Sqh/JoqobOYw4zFvt/V5+S10KvV29XKrHb2DAT7KdqCKJEbk0p0LOXNBXLGep/gtpbtBVv49v+2ynjqwJvkP7aR3UWxIEZJXHz4540ei6yy/2bM2UiNc/ik+8n9+j5tktnLBXSQZw0jQ80WT93yWQxE1j/dt4FKCAegpJWc8Sq5vC+C4/BwrrBG2fClDt+9u2cAmnSmQIk2EnyedeGivdMyNZyWFYo0XE7PTLZvtzVb6FvmaLddVg4hUO05VUM0UPrXpJZfuaCP3PMkn5WXqoExAYuNZt0lTmOjq 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)(136003)(376002)(39860400002)(366004)(396003)(346002)(451199021)(83380400001)(316002)(6666004)(8676002)(4326008)(8936002)(6486002)(41300700001)(36756003)(86362001)(38100700002)(921005)(2616005)(7416002)(7406005)(66556008)(6512007)(5660300002)(66946007)(66476007)(478600001)(2906002)(186003)(26005)(1076003)(107886003)(30864003)(6506007)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +IuMyAaJ5NjHi40q9DXhqzQrZqYKS1p8YmispKDhBS/UBDx0kjCQdSeoztq4SiduKXppF8DUOGhyH2uDEejdWISdqMUhkU7QdnFRxdecwOp9fH8hYRrjJpu1kuckHoM9YylK/Qi4x8cKngbSeYDRsAIIERjDvTv2ZQHxIhoQviNEhIUUZ+msIjyRu6cE3f4N9FQOyHo4m27TC9Mv/lwxxWHY9MYsXjSZoiZJ2e9puZDRE81lTRgaF/i3bSDYmkkgIg+JhIM4fj7u4Ceo3hw+H338jSuLboxtr7BcF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qWYDiJ6AY2IlbJC7Jc8syNIhpyZU7so+verHFJIzct0MSOmaZc6vyt2vHj1ODOUPVYFuTgW4cXg33rW4Rb3ExTOpjuyRFVtGjCcJtHoFvGtupFmQfnQGvm7kyWwwRF58YI7+pD1GqsqWdFBTx/3j3V2bIO+L67jlx7BsH9vfiLyFf+kzEaGK0EAGPdmgDX7PTJKNT4v4Q+t3dVv9iazgbvFvfk3UVpM4RNKkCcLGNhFc0uCa4iZ0RCeGs4F9BV0faXPmkHOr4JbyWTc0RUha4GOsa7+rP9TuG097p7LLcYqBDAsFeGmnUiKOlLqnBQeodHU0+RS7IiAIeuCbmw1MBdNGRdVsON6YGjNbG9yERhnO6DjDPQ8WQ1gwZhkuYM7OEx2Di3v4Npxy1R63rWSvu0Gsu57R8RBUMXEEcKzXrgbvZG2iXbhdYr7xpHy+zjq+3P36oRGun4AM4BbYx27s+fy/k2x7eppBsgjHv0GEX4SwCH+iQx700pbKDx7bMfEbQqzM1Et0Qr3+nQ2D9X16bsCrBRoDbYUF/sPR68wnq7f4AiwXPH2QRqjDe2NJW7MoiIxdRLPLRFlCdv4aG5Hq0n5uGIF7yi7nlADdbh5FOGDFmeNn87HBm2d3HhswHnoKm0dQ8G3CHgOoOXMqDJj2aWGMufX9NtUtEEpjyQkQkmZiQiuWybk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99c0d19d-faab-4e9c-bfa2-08db78d60f5f X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2023 19:21:38.1072 (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: bRQhxgL4UZDSQ+pT1ZvtxjH4Lz/SCkOei42V0xGXKJR0GM6YzQDp25ulJp4dKl0qDg1RI/syOL246G3QgUG0BMYqeZRRXK+vCNdM8IwTxqw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7200 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-29_06,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-2306290174 X-Proofpoint-GUID: swe956Mwxm-7FrNZFp0g2g3UW-5HUC0D X-Proofpoint-ORIG-GUID: swe956Mwxm-7FrNZFp0g2g3UW-5HUC0D X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770068305286167962?= X-GMAIL-MSGID: =?utf-8?q?1770068305286167962?= 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 Thu Jun 29 19:21: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: 114399 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9870785vqr; Thu, 29 Jun 2023 12:44:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlHmkg4XWGAYByD56OrjDJbOMEhEeUNFT8mxOt9Iu30AggTx6KO+6LsWEcZy9jn5+TVEw2Da X-Received: by 2002:a17:90a:db87:b0:262:e2a9:bcf with SMTP id h7-20020a17090adb8700b00262e2a90bcfmr234042pjv.49.1688067866047; Thu, 29 Jun 2023 12:44:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688067866; cv=pass; d=google.com; s=arc-20160816; b=Ip5X4TsKaTBjwvguVKKyPQ7C8rEk3Fnc5CXPZDYXYib92BNlXxWSRPrTxax3f8RUcy 68Cto9EA7kyYLlxJTp5d5VPyPHhjQbFqQ7RINn+jf7kTgV4eTFTLgpyaf5olLNYEVVYl Jx7p7tqRIi7mRetVwLO0In5XIYahwCU0Efk564I3bXXJO3891eNdIn9UfN9GUmsTx+vd AWwr9tGiBa2bFF6d1LH1JHvgtBDzitEGZ2f8/Bvdx0KErV6QVgu4A5377j88X1ZtX0RS pIEuLFsGmf7fl1vsr4Ww1VNYHb/mOSnEKLRXvXpQw8akeb6JY9tkE4G1oT3PaOGAA6XP XjFw== 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=EgT4sGh2YI5hIHQu5JOSH2QPmVNygncousg6lCGt+aEgj7ghcKvI9G6sfBemtsVeGv jbTjWkXwWgHz8O5zKOmhNKFTIKf7jdxX3MkHnFc2Wc40anx3GB0v4mjzVcoL/FfcDY0U ZEn7GVVXfjZgYNd4K7HfTeUVnylGBkcfdL5DzAh+YOB5S+68Eaakzx3BMtANuHmupxAt 3Ul3CcdH4Aqz9My3TDK322PmgDT3P3p0ddSWsQFUTWqJ6UYiHvrvhEQ+NuXIJhSMMPEM o7XDUh+/aPIGzZ0YVVKZRsbr3H8IUwVGl1JBA2j3D7v0YOs+J3KYRScCEzfd5ZxzM1Tc INQw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=L+IkdWZF; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qqJe0mhd; 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 my17-20020a17090b4c9100b0024769a264fcsi14008047pjb.10.2023.06.29.12.44.11; Thu, 29 Jun 2023 12:44:26 -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=L+IkdWZF; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qqJe0mhd; 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 S232314AbjF2TX4 (ORCPT + 99 others); Thu, 29 Jun 2023 15:23:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232037AbjF2TWs (ORCPT ); Thu, 29 Jun 2023 15:22:48 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8DEB3A96; Thu, 29 Jun 2023 12:22:41 -0700 (PDT) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35TJ3pJ3002889; Thu, 29 Jun 2023 19:21:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=W8iEv38eAoUWiIac6DamuSVNXvMP78ssEHCbdxW608k=; b=L+IkdWZFNFEhwpn1VLX7tgAEM1FW9IXfAo25OMs7pW7FAWPWGIM1F6JeVD3X11UHhpjH hkAbZGm3QxV/PVtWmjR9DG488f/IM93sCKjmxvLBkVU8fiJnt/OD1sKk21nXKhJ3Kr7x +ouWBLxsPhXSya8O6Lyyc/ZpXwj/hRfKCQh8tnNpvZOuoKWSvuU7ODnV0d/X6hHcEZi+ 7trT16l63g6Rc7MawAONP/I6AHaBcGQgI4ek8VnfsICnfiO0lZ7E6bq6xwYlyef/cWDZ RZ5+hkYZZ2upfnoD4eZ5b7HCvnJfxilbOGSM2s1J9Ydt3Q8FoIaHaOnS7EmTtQy+dNuc yw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rf40ebwfy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:43 +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 35TJ0IVo038174; Thu, 29 Jun 2023 19:21:43 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxebtjm-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JX9GCD8BR518yEpK4iUT+2rZg+fL0n8oxgD9lytEL8g8iXK5kxOCa4Aoh3kGvehupEdffAjUsBXYyJJ+USJUlPjsZ2p+EA0DefG7tEtBPH9ULgtisBFNKEol1QDsuKFXQOc20b75LMqo99WApbCvK4E+rpTlxKov21irJddyGg+8+3umypS1tMTX5jF3sbmvdHbFwD1f6Dd36mzhd9Dg7aFq9fvqvlaMWj0exbuKeJPRXv2OJabNukQqm+IOIM/PlEK37iBZe7TTYsHbIEeJf7fYQIVNKbSu6kdNLGnQUi00qoIGW5pGaN+8BX7OlIG+WQXP7mA7Cx5T1EYbX4UzdQ== 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=Mgu4+MAmBmtjvYP5Ng3XJUf2QIawtbFcpNMEzHNpZRJ8NEK++tzA58RdUDcYhIc/N+tbJYf4OVkKhiiRgiEw7KNZv9z4Msicc2jlKsd21+3VZfY/XS7C+rhlNgJ6kFevn+v+BIFS29z2GF7478vrXfw46OxSpCD+VOIajlJwMjo1D9PvRu/JxTcB9eKm0q4FndBQ1B5rdoLE7sLX6x8q8/cGVIDlMLUm7fHiozrhjG2vu+xQiMxh1Br2+HD60Rczc6aVuHuO2s5Zbpz45JaSbpMEhEbqk+fOENWLow7FkuP6gwR0kAq+d39YAm2E7NU2UZO+2ESllPhBkD1gxB4Iew== 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=qqJe0mhdUhAQpnOpFxzwnQ6Ilx6eUAHTExafUWtKgiYYT5aCRqOQs7y75RHALHE6RM08CsFOx54KWyRZ0xDsEkFD8rZ8PrGoqQ9s8mp85khA4AX50vslGuqHZas+GxHyWWm550oxsCGJMk4/+2VE/ehieqQ4hmMnBIqBriVriuk= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by IA1PR10MB7200.namprd10.prod.outlook.com (2603:10b6:208:3f7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Thu, 29 Jun 2023 19:21:41 +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; Thu, 29 Jun 2023 19:21:41 +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 v25 05/10] kexec: exclude elfcorehdr from the segment digest Date: Thu, 29 Jun 2023 15:21:14 -0400 Message-Id: <20230629192119.6613-6-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230629192119.6613-1-eric.devolder@oracle.com> References: <20230629192119.6613-1-eric.devolder@oracle.com> X-ClientProxiedBy: DS7PR06CA0019.namprd06.prod.outlook.com (2603:10b6:8:2a::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_|IA1PR10MB7200:EE_ X-MS-Office365-Filtering-Correlation-Id: 24462888-195f-4289-baa7-08db78d61137 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M+hr1M1PebPIYWESt1s2eIZHjFQWNlV1I77JOqoErmkNGI4x/qvA8GL1dpgAMbRK04YFHtR3vRrzX9sH8P4BtgtlLPhc0WfzvMc1T4SXf4B6/hx5iB7UhIrKFsFF21GJ83OnunbU4sSKB9dfC0j9XxbDJYKWBWmi/Dt1LZY21iMwGvNxyjRN6VQGDnNpMwzKgVtSvp7DFugp7VSiNUnoGcsZQWpjRutCqjNiRsdoqKWzmPFCv9Q/S1qmc1FYok0JHO++Wj6SUaSMdIF9hWtBNObLBDeHbojNYNmys3MQxcMHD9uHwpMPK0QCh2qSHVabJXv5YPhxcyI6ddor7jCxp+P87GXBDuQCBFkmWX87Eo2JdwFG/w3T1fcJTnDY4PlnyjoXFJWV1UePwEBHHahXG4AEgRuv0FSnSjgi+9S5QC8QKuIechMEtLrA9bpJQtfwowGdENClHQuthIiEvv5f/M00+GLLNFbX6AmMlXxWCJFJyEenyIibAg7UZDtG6dhHpAlHnYa6sbu+n18TL24CPED+w6dUkCLcE9TBxHV45YXb94EyQHbZ0wZ9j4NSBmCPRMPwr/wqlr1kfvStoNLG/V0HrmF7JW42piFNRTPqsK0= 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)(136003)(376002)(39860400002)(366004)(396003)(346002)(451199021)(83380400001)(316002)(6666004)(8676002)(4326008)(8936002)(6486002)(41300700001)(36756003)(86362001)(38100700002)(921005)(2616005)(7416002)(7406005)(66556008)(6512007)(5660300002)(66946007)(66476007)(478600001)(2906002)(186003)(26005)(1076003)(107886003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TM0sx6/Xq9XotUX9l2vrr19DS6QeD9xsUMmgh4XZrEhZccnPjCHmmzMZV9Vw8BmIBrJgNcSWRa8HrouvSUCG7oWnIFbBuo8dpqMmwsrOLmSMLMb41gXpYzoEO6vVdTuvPUCpkbCSvFuFS/sYfnbpffogoe7dq82tD5+xDlnxViry3Csvk/sZlmK6cr0FBcGySTn8gI26dYYX3sb5bte5rj3vh74sd8xTKBN8OEAOcZmcxH/WYkh2TADVUd3SfV0em6S3OJ/bTFtNv6JDeIRi+UtiISaeOtnjbfeItxocJrtGHmSc3k8wPEjm7PG34SM0+5OuOb2t4iFJCDJu8C6K3L0grqZMFo8/y9sD4PZygcmJ9mYd2b2ROgZzU/iJb+tX615iRsTbvrWOQyZPn0lqz16ln6m8T7uM42AF/njMei35Z8lHlINp4+xNn7ElRnAyfkjJHwnye4V+8cO2k3nVv/oMu1ILf0u/HEE2nijojRhIIuJ5ok52B1mYCNQzZtzloqb4LEAb5CZd3Cso93V2nqzC/2r+bxikvcuQSWKgX22LFnVPflarMonVit4BckCh0tG20FUGCB65w7EOEC7X8BoX6eSzgNtLawOcwT85NX0xL2gPvYRKG41UaEAOORtuBFAU0uFWb92CC0dJtfRJHeMeF+LKuKY3FzjusJ33cvQG1lAV5PoC/UNoL+O58kHngr28xJtypxPI0oMjiZm3ZnTH8SIWw+ImuW54txeQCTqPFZsSd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w9g49EivuV8fStxREAnQrpG4l+Ev0eM+cBcfgUK0sj9ZFB2YRZO6Cgoy10KP47vb0O+aKTrI/yE3a7udwK2K1V25K8tquqhLmxVDrux6H+brMRWTQM+ewwcC93fcocDgYBU+MhJ+uDobogCaaXvMiHvYM7rqDXMr5gDT4ShhFsB4ULlxLm5Di0qZcfFBZ3C1/KLr7PcHHG8RB6oyLgLBn388szQG97muN1bqFu0P2lVBfctVC/wo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24462888-195f-4289-baa7-08db78d61137 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2023 19:21:41.1857 (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: c8s0JWoJ1aRCiTXx8C6norwnWarzFx5XsAJFksgdE8jQNaf6vRILGxga2LDKgAlBQPPMEF6XtQz/zyKMlwlbgHEvE/C6qDy54Gxhj65iHuc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7200 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-29_06,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-2306290174 X-Proofpoint-GUID: BxNcQgntbmbUMwcnHXGKW08s1B19OfVS X-Proofpoint-ORIG-GUID: BxNcQgntbmbUMwcnHXGKW08s1B19OfVS X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770067450447828108?= X-GMAIL-MSGID: =?utf-8?q?1770067450447828108?= 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 Thu Jun 29 19:21: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: 114409 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9876958vqr; Thu, 29 Jun 2023 12:58:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlFMThr6qHPCP+GBWPATYfjaYaaCGDS61JLDJVR1B3iBDHzGo8jwhLwgyWNVnyaj3P+Gho1q X-Received: by 2002:a17:90a:db45:b0:246:634d:a89c with SMTP id u5-20020a17090adb4500b00246634da89cmr300141pjx.41.1688068681744; Thu, 29 Jun 2023 12:58:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688068681; cv=pass; d=google.com; s=arc-20160816; b=Lh/POyDQajPwF2ePFOILtAyBVUTjgcnLEAHv12v3c+FOXg7xSTA04INtn87+wZm8AE KKM+FIyHAAJTDT3C+RnYLZ2yd0oQxbuavv8LaQecmP9oeRwKQ7DgdAI246BmN9Bl5zmn 76JloswCGHj1RQoVyg0Vn5VWNqUkMWOXhoizJuTBVJq6g0zMGDLyW4UI/IZVbk7+h/yP MfTQuurszPu6tVOS+iUX+nl7UGvWoM1YsaHJ8hj/koTudoVJCcPXD5NRe9KTKnr/Ftb+ mx3mYprGRksqXX4T/GP9xOXKCSCftqwjWzOABs6sH9HmONJMF1rgMo8c7E9Qkw+KJYyG C7gQ== 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=wvktzrp4ADI2Sb1KaXQf3XL32mNVn5LLn1H+a7D4wH4=; fh=j+K5GuuLTbxxisV+wJRNZBqbr6zhGMwAghI8ANXi4rw=; b=W9thkaqDQawNYGcHG84w5CWhHvGY6tzNebbwDrGgXA7+J3PAdFZrRZxC5Ip3zR9GFq mGCBE9UhTel880E+0C9xJfPh8x3DtBQjkhZguPihH8KN1kNhAPR5KtgtxKVx48vBNc2T vrwgcD0kRyHjES6Qo/K/mXTZlUDWHXdsLtjFdVHahLmh2vdMzauUVDpzSM1BJuMTwPDM 2KwMsS4TjRLGGBs3QjHreDv0nTFAleFcmApjhvarfTxlAsUNTzGDoX3UJFOO0q0/giAw BCOd5ZUbjEC0M7p9Q645fIQL0S2NZEj5tAgBhu6d/2JxU2wTy8DxKTEIbofZngncW5Vi cRHw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b="EkFt/LLh"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=sGLWvVUl; 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 29-20020a17090a1a5d00b0025be125bda9si11087373pjl.38.2023.06.29.12.57.48; Thu, 29 Jun 2023 12:58:01 -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="EkFt/LLh"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=sGLWvVUl; 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 S230436AbjF2TXf (ORCPT + 99 others); Thu, 29 Jun 2023 15:23:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232234AbjF2TWs (ORCPT ); Thu, 29 Jun 2023 15:22:48 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8D2A3A94; Thu, 29 Jun 2023 12:22:41 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35TJ47hX020741; Thu, 29 Jun 2023 19:21:48 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=wvktzrp4ADI2Sb1KaXQf3XL32mNVn5LLn1H+a7D4wH4=; b=EkFt/LLhmhQbiCJSYJas34RWBsdy7cFGLGOPhmSur7d4xSGrjyLAS13dsJlIr/MGSWNM lhRG0g/XmVgBQ32S1ExHBhDNADyVT4YN/EdB8WewptmLZoVkEEkod2MIAlijWsHHkq1q fZpNbsSPgZc2koI8c2czCvKRg1iQwktHuM+MwMhJMH6aoFuzMlwiQqW9kfCjPgNRWl/Z LTu2GxKg/GUw50EnF1i9+pEuSQUk2cWnrVNgaTKG1eW1BRuSeg6P3gCHA1WTSUDRvEEv D9GJ1sJ3drx64x0X52zEl0/vHiIyOUfh2yfXrFoXoYRqE60AlgnyLZ3DJfAGJZU6oj7O xg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdq93dp9h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:48 +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 35TI3MbU013057; Thu, 29 Jun 2023 19:21:47 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2049.outbound.protection.outlook.com [104.47.66.49]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpx82gqt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FNgJ/bFvO18ME2IcwSgANxwfD1bn6+AzgGEybHTnUcimqigIvjzV+lJ9B7tPKPj/ttPbpz+P7cEkUN00XncW1Yb5EPv8HpADuqfmL6xpzT/eMr+rjhTcKhU6MLzmicli4eiAtXdYxLej2juEMH0NRMVTTlOnHH19WB7dpffitvSP8NNqRaIbRe+nKVyFumK7HIGSp1EG+JPrevbOnRpqeV/ab3MGU2IC08yQV4jaCIuSwN488BkGj7xqGiDZSUg2CmFCKG4sT4uIHwEZLwR23z5d+iE9UjPqtMI+lSTf05cedlTfsL2urPG3rUYnaRLpEhkdICI3qlCb5H9G/TFXfw== 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=wvktzrp4ADI2Sb1KaXQf3XL32mNVn5LLn1H+a7D4wH4=; b=Q8NOIvBy2ooVelOtzP5pgtnKcMk7XwI5ryVQdZyfS+CBok12JAa8ygsJJ96li20VGL0Pt88hupqG5llayjVvz4+hNdMds5xQqj5YABe++OwrSfsGxyNt5VIFIf3XMQ2QjvYAgb+vXpFPXMFrYxlXFk+9TKwTS/Ew7kIjvIxTv1I8is96eIzNMO3R5RbMa//3Q8ejmDHvcMcdEgvirfbpxWbq0SL9IwUv7XaynUAW/EQWbYcicOCpAUA17U3ROB6vv0HoGLGyWGgWI2ZMx2UVQYPbKnqZhHbcy2Juq1ImVVzPcXMAAUFklDIP7m3SyYiIGnrUBomuw05+ay6eWUn9PA== 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=wvktzrp4ADI2Sb1KaXQf3XL32mNVn5LLn1H+a7D4wH4=; b=sGLWvVUlmmxhSNx8lokZffMTK+zIlR9YRV4EPMw9AFvNqV6becUCJgnBrnBOcJhvOqiyEXCDkXyufDlS8X1gCwjR1lOKyp3op43HB8Nov0sMcQ4G7b9pZQ+vnv1B3PWqE8X+v5fFXbhPoweFQGAxwLE8Afsu0bYxNcn+Zi8VLdw= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by IA1PR10MB7200.namprd10.prod.outlook.com (2603:10b6:208:3f7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Thu, 29 Jun 2023 19:21:44 +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; Thu, 29 Jun 2023 19:21:43 +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 v25 06/10] crash: memory and CPU hotplug sysfs attributes Date: Thu, 29 Jun 2023 15:21:15 -0400 Message-Id: <20230629192119.6613-7-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230629192119.6613-1-eric.devolder@oracle.com> References: <20230629192119.6613-1-eric.devolder@oracle.com> X-ClientProxiedBy: DS7PR06CA0019.namprd06.prod.outlook.com (2603:10b6:8:2a::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_|IA1PR10MB7200:EE_ X-MS-Office365-Filtering-Correlation-Id: ff73759c-e872-4650-94a1-08db78d612ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8NOb2P5+yylh4zNq/EvaknSi3i/IebOieKonb3tdVC24bHea4N5B+hmp5OiupqDOrMRJy6kub4L2Dk6XdDQuQ/ObuMK/2ypKj0FD28auYnt3KkaG0eliV97r1srIaQFKDFtHrp10Il+17byEWR3Y4HwXXBAp1LlC7YfO+p3LO16E7rlzIp3sk7WL+X4jzkdtnX6GO3agAmZ02CSwQa1lecmIlHjL2F3mUKv24v6tF0Eog59Yuno0GnkkbOYcp3bQl4uh/dR1z609Wyse6cTnmvZwj+2Rmnli7tpSi2sPLRwdqMg0qlf2e6Ql3CP60Fw1eKO6JEmQAzIYRbx5QtwMM8r8smvN8CwrZ/L70RS20mhBYHfJgC6J1gQsF2GalLk2EBxXTd/4Ijc2vHP29843QKJ8udGnRL6+PUQ3b994p/t1m3n9OEDzwUm3c3KsfC6WyLkSmGNcwQw8EkdvtSXWDjcIJKRm9LrUS1zhgeHe7qFBlBDmKdLf3g8nm5QUZVDuQ2gwukX6DWYcDCSNSUa58qclwXC3JHob88EHJdHigIiRl/WS8yB4ZaxMBVx5u6J4FeiTYr+Tx9piLALezQKKCo6Jv5CIo0i88C3ewY5VzEE= 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)(136003)(376002)(39860400002)(366004)(396003)(346002)(451199021)(83380400001)(316002)(6666004)(8676002)(4326008)(8936002)(6486002)(41300700001)(36756003)(86362001)(38100700002)(921005)(2616005)(7416002)(7406005)(66556008)(6512007)(5660300002)(66946007)(66476007)(478600001)(2906002)(186003)(26005)(1076003)(107886003)(30864003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /6ZHZMnDwCxEB2DZ2SeQMHWMTPZ/EkoVA81z3breZb4GFLb31JlXnNENEPZ1/bp22hJX+j73d/69QTryYzwNjt4QnwDKJP1g725Ro/REsqnwYkLL6d03xW8kC5HtWrZ7LPV4H+rIlVvpZD4t/OYuu1uSE/gQAUJuK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ZjeXn+qKYdmuZhp3DCm9GXxDtDDcexI9a86LXAf4wamwU9zkumNUT/sgklANdCO3rj9/WbYFHVsfCyC8A9JO6ScemrllkULwo4rOlIyu+6CUrF+huaV3SkHnD6crUKoyDH8DQbWLR9CQPMrTSDTAsj1wD1AB8cyYmxWvTiFhlu0pFqO0C+WJevjsUiC7xMBjulYLfjGrXBMFlol1j44cMiE4LMRd6nnZk9X5nVgbv6YPWMlodmSGbKbqCSPkkkpHMbWO/LOHGeNNFFD6NX0Q6jwrEUX4dN3vdj9UWkWfrd0q2XzTFtmBZdV5qMABPDzHsalMZCKdDD1JhUzWreUF7dkHASEJYOC+jWshNes7pfcSR75fIS8LbfVaUB4N5qETD9caGHdihyv3SdGOJR38U4PuGGuZn6C48lFqrA2slpSqTOQd9IE755OeL1TkodUbQZu02TantHsfcvFU9QGZUuh0JZauNdBEKkkiLhp8zC1MoXNQtSux6cqCc5Bfdt49muBD6Z2rL4g9vRg0qBGTVWSe8nEwze4+WvKtOXlrIkrbTM7QmvuOldzzi82CRLnuY3ujSW5PcYGmZ+unR2SVm+muv7sYEFOA7nAoOHopKr3tpfD4nKQf5Geq3ctuQc9e9MxSHjk5nuYoNV1AQNM0qcx9bOSP92m/FaS2z8cb9bg9Q1qaG+MHiOQfGA3frOCya5NwH6u6Rc2ML/1xdIlx1/XOYxj3TZXXZOsiskYsCZCvzOd0CdqMzOg/ePRtI+GPKgHQrbnF0eZtcgEQ5uYwFJcWPZj2qWrSUQ7XFYeLlkMQQy5mMsNGAmoNK7KM1w8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff73759c-e872-4650-94a1-08db78d612ca X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2023 19:21:43.8548 (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: tNP0nPLpXwAEYZM9N2AwKWG1A42vbAsDkxHYaTwbOot9oKOYD0VPRZZpDaowKgGQBIrYdEsjprqpHKvicLST93LWo+t0B0miNoo3fIF+mqU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7200 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-29_06,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-2306290174 X-Proofpoint-ORIG-GUID: mGDalQwyYpfaMvd1a9YR0hICtum942GP X-Proofpoint-GUID: mGDalQwyYpfaMvd1a9YR0hICtum942GP X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770068305914051927?= X-GMAIL-MSGID: =?utf-8?q?1770068305914051927?= 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 2455cbcebc87..7637cd1dd480 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "base.h" @@ -130,8 +131,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) @@ -286,6 +285,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) { /* @@ -470,6 +477,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 }; @@ -505,6 +513,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 7294112fe646..a0b0862871ef 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 @@ -915,6 +923,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 }; @@ -938,6 +947,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 Thu Jun 29 19:21:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 114403 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9875943vqr; Thu, 29 Jun 2023 12:55:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlGmL70Be4SV7lPaOOiPw8wMKXa9HDry+6AbpmmJpBMF/jXYVOEU7IIUDwQAKewyBnzUReNy X-Received: by 2002:a17:902:e74a:b0:1b8:560a:aa16 with SMTP id p10-20020a170902e74a00b001b8560aaa16mr270713plf.10.1688068551667; Thu, 29 Jun 2023 12:55:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688068551; cv=pass; d=google.com; s=arc-20160816; b=w/C293qfdhcBmY/7u+RtDL6bAkJXNKEMLPFoUjiqX9NmkcsxyjMcbpcnrrFl0MaqS0 E1N+4btvRFlmRTDaVCBqX6aWvr3H3HxOOh8y8Yio9xxSb04HXyeNL8xWw8dVj3nYQjLJ GUm38RsexIF64QuYmT55MYAAU2dqrZjDCb7iM567MAZ1B0SWweNFHcdjlNWUOs4snWbN toS+LWDykLexRFbfuIkToq7xP5nkZm9Z7jwafGEBa1GBLQwcMfh2s3QaY5bPDlFczLIu Nb/sHos0TIJHPhwzDkQe+DEyG+RxMYlOAyRS2vCpyoHwISGdK0/udpUFtWTaO1uVJtcF 8lew== 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=CAWuiKWz8vfETymcBO7tuYWFLozD8WR/t6bpL0xa3ihW5GC1s2JFdRwRBkNzXNBF2F HCcoehroBrQC/KtYrmXBNGsrd+70C6wjqUe4nOTLnhl1RtuRV1HJU1nPiJVi9ej4VQsU Y6h/JIrT+EU8R/7cEw1KU8bM5nY5SY6Z6GLnP81mF9NWNbxY7CuP99V9h3zFPCYUDaiM MJJ0pbJ40aBExP3axAM2ykdl66Eb0dDNanxAdCaACN0VOJAmJNYl5PYBUVgegGRENjRw 18/qJfys0+do/Ak1w0ABb9WqEtwSj7AZaKt4qtAI66J6GWs1lLePQMSR8RSqypc2G70/ 8MOg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=ZGMxP+vT; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=NAYTXuyw; 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 m3-20020a170902bb8300b001b80643d64dsi7300624pls.145.2023.06.29.12.55.36; Thu, 29 Jun 2023 12:55:51 -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=ZGMxP+vT; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=NAYTXuyw; 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 S232279AbjF2TXx (ORCPT + 99 others); Thu, 29 Jun 2023 15:23:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232048AbjF2TWx (ORCPT ); Thu, 29 Jun 2023 15:22:53 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90E243AA8; Thu, 29 Jun 2023 12:22:44 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35TJ41L7028737; Thu, 29 Jun 2023 19:21:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=OCr5zrFqhJdkDnvbZF8hy5NfQnLo1d6CmVojxbAKj4s=; b=ZGMxP+vTZsdYZdmeybOmL9iQqSXJJIz0DKguLZ3EYTC3Yz2F8VhdejUaASvQ4j29pKF9 wruc2JBrCp2NKxHtzIFT4IGM1I9PVP7B2Qm/dKcf3/HYFdIYmlusb9TVwPdKDLBT/hH2 uS/7Mk2KbbYZA+L0w/N4kcV1Aa6mvnSC2inWh9AFQ3Nd89BFC32H5LLkBAxM/byEOOn/ j/rLscN7alALW6smrUEe2fWNuBpGrPUAqH5vgKfAmHahb+KOlNkyD7//zGQTqXptxZzV XkTU9sziHi8PMHWOWaWlUePjUu78ak1cHhJUWPH03X77xXK2kjVfSpKti1juzw7QioKB 6Q== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdpwdnggj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:50 +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 35THcaI3029658; Thu, 29 Jun 2023 19:21:49 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpx7tspd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nUWrZdAfjOBGz/GeQvct7tDxJzYCWO7VJscRb/RXXCMRRt0IMH5cZiVZCTtCZiLziw5ssJmX6i9hium5M6h83xTYLbJlOCGyH/g+8DsqEPMK1ucpowpuvZQYSkKOVilNSvDKBrGsJLp0JdPYIQJi6EItNf0pM0a4RymSxMgmTuegTYJ5y9MgHh7rdjg4+jbRLaqSGrAdTZqI/CKibYz0ommd5VkjVwwuNlJ/3TmI98qFTTEIiBpEq4ecl7QxDMAF7zfQqffZfbNZJKSopC7LyzcCnOsivl49Q+KoIfurkP1vAMLluTw0TE5WeWHTJe/KGaJcDJipuxzNUXeaweovzw== 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=VCFr7VgeiXmsVADNNg34zU2FUal/dWBaB2TjZg/6K4Yg2gx8ZpbSzi0RycB6OHkxn6xXDOrWKkn69e/9k1G42pSUPAyHMlzqPUSSGhusD3a3XykHWka8oCpO4jNRBz5twE2YpL2PJXuhVjN09r2aiTTD8exn06mGRi11kwsqJxG5LNLCqKFvF2KQcHnvKkt/K44m8ijOIEZXhXMB4LnY4pX4iuB5OeHY8AMSVtu8fk3O42HAUUhGtboHw5+BDyYrzU+UG8P4tBrSHEUuOF5SsJcSDcfkEs0UtCUVMXdA78xej5Ir5ZpBWWT696skM00x2Muz0pJB6jWHDeWg+FPkvA== 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=NAYTXuywcIXZ6TMYVwaqDlWDNwTPttPmAf9o/ArOkin+6aHiNSdf3PxUhQu9XKyNeV274Eb3F+DOkgf7Jh0WcGR0iNYemPpgHjgbQ1PvekRwAWQpL+NIziOjBjT1KXxa5aRPviSd6OMa3M5c9CIG32aWezd+5z27T9bR+P0Zxp4= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by IA1PR10MB7200.namprd10.prod.outlook.com (2603:10b6:208:3f7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Thu, 29 Jun 2023 19:21:46 +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; Thu, 29 Jun 2023 19:21:46 +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 v25 07/10] x86/crash: add x86 crash hotplug support Date: Thu, 29 Jun 2023 15:21:16 -0400 Message-Id: <20230629192119.6613-8-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230629192119.6613-1-eric.devolder@oracle.com> References: <20230629192119.6613-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR03CA0055.namprd03.prod.outlook.com (2603:10b6:5:100::32) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|IA1PR10MB7200:EE_ X-MS-Office365-Filtering-Correlation-Id: a386ef27-224f-4cf8-1e58-08db78d6146e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SLu83oT9AqshE6vv0tCtRfqMleANcZRqFJYJcnXR5R+kPuekLcZlcJVRfwCp3mnvaM++YBfmoS/QvJeWca4jQs0QQNqkRrbT+2NfP8HQDG2DsQpdkLXH/YKJU6fyUJr79CTxSIFCTo/9zdAS9ExsfIIv0U7waAJwDHOzVlR7D1qhEAwzhbSEHoJv3v3NCNr5Qs/rUHHv5jGk46kZsl2Fm+rkUqDqRD3gRBnhA3u/E5I7qpFD1u7BZ2cO2m9MlERnebSyLe8me3/OGtSdQ7mafv/Gq0eUl9L8cKQYLDRLu3P7YVkzjqf38R0N4k+HJtgXa8U+d+DOkSqgm2I9WyBb9XK8dYlZPWAaUNIAqeVz0hC0/n1hMgWeACqyeboqQSbA7Aw/ZjfOkX8fMpiEXjKnL4CV7yVs4C58d36h1UQ8je5PkqWacCTibe/sNrPfOHtk76BFhsZpVm16Gf0Q4Hj6Q6oV+AqBNcvfOhqxuco2ivzdL489a1lbeaNzI6UI155GKOoS0VKesZl+PyyU1N2y1Z5zl7Ly4k3oVk2yJ+C6GRGBNqJfQQZwbHVeP3xZy5BR5BNleYOueOhnDeTo+617s4iXA7YQlyvEpJeKR92/6yU= 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)(136003)(376002)(39860400002)(366004)(396003)(346002)(451199021)(83380400001)(316002)(6666004)(8676002)(4326008)(8936002)(6486002)(41300700001)(36756003)(86362001)(38100700002)(921005)(2616005)(7416002)(7406005)(66556008)(6512007)(5660300002)(66946007)(66476007)(478600001)(2906002)(186003)(26005)(1076003)(107886003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6e5u/x/khUBh0RHl64T/vAY52RTw8h7K9jI97tZ0tv7H1AeghCuj5CJHQvFG+5dqFfp8Cxtjx0nip/+0ERngv/CIkorYwPa4mSzqga7Ku54Ly/28Iu+wgrgPUEhWAR+HFkp2z+u7Zp1NcdfkMDS8Mr0iOgNXGTdOQccQEF70bZ0VH221faC58lQS20hCg+1/cxSXs6uhdkFn/tL8xAuQmq+hV8DA6qgMNDhLXpBI4f84iuIiB/LwzECf1mOJn+Ur2aZO8CjWXw88Tde1eCxhPyFIYm2TRy+vLFAEE5kerIF793anSN1zmrN8BN2jz79+KHhkmR2hs1/kY9/CgujUwY08E7WkQcZEE2i5IvFrrH/aRQmH463zkH9L4mWZBo8bNsDtUQa1CVKc2w8lEbzdkeJQ1KZjVvi8V6lGDU3M/8uFqfScIDB4j65b1Anb4qag/QeVVbVW8GofrOIOnVwJ6O1POKG2tz2w+oVfOPUNzhcI8KQYcHafudlVDSrZgcIKqvNnTEDumg1c+B/hyGWc63CSxX/f6KLFooHSq2mFOZnBzPxTb+NRY0qw5xWEAjkeqhrSzLcQOjXTgSzhr2Kq69tmCU+WunJR3iRhdsKBk7ZEEYQySlXOjHaBypm9vdjz+XTXv1BobtiZPY/kJUruCMpn3+VO55pdd2mNu1CeOOo8JhrczCidc1jDhH0GhbXy0vpN/TLQOX+T79TflIJQkM3w/12AegCbDrxuQc+B6V07wBE7vHIFXbUONBShHcvNyn1y8VH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l0s1DG6gmcOmcm1iItG68UKpwC/zMGIdcCxxWtof9PyphNWHTSV6w3OUANyuA4MchXLGq/c19dH+P/3C3voSu3h0OphXH99qqWsY4KNc9nyaNVMIxTFZWCn/tUd7XXVNGsrR61GZSzcPy3e79oTSlgaw5EDH0aTyV3pGALggbsC/Jb94LVZJ8ly2cVMJOQLab4OXU26MQ= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a386ef27-224f-4cf8-1e58-08db78d6146e X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2023 19:21:46.5856 (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: TZVQUDaNi43piufRDXbJMH0UsxkJIghEtC6Kse8GkBHR3gdKjuR4B/+WFJhRIyVcLIgJ+O+B5JM79hm1MBYBjPvoQygE76r3P5THouYvw2U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7200 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-29_06,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-2306290174 X-Proofpoint-GUID: ei0G87BwGhVzQ84_a_0wrQLqI5_N0OKH X-Proofpoint-ORIG-GUID: ei0G87BwGhVzQ84_a_0wrQLqI5_N0OKH X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770068169563325658?= X-GMAIL-MSGID: =?utf-8?q?1770068169563325658?= 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 Thu Jun 29 19:21:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 114415 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9877850vqr; Thu, 29 Jun 2023 13:00:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlFzF/PQlz8oXlCCJ8QiMTUo6Bs11STxtUwStRZ0gkHbp6e+89Q2M5h8HWQo0uwUXjeawSLf X-Received: by 2002:a17:903:234c:b0:1b6:c229:c352 with SMTP id c12-20020a170903234c00b001b6c229c352mr229640plh.14.1688068802167; Thu, 29 Jun 2023 13:00:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688068802; cv=pass; d=google.com; s=arc-20160816; b=lP+geKudTREMg2sDIOcVD+jWz9r1PCreuf/AYkLudJXg1wOddEo2Go0GlLLx6AeEBk oyV7Ej2Nq+0Z92JuuRCjTZGMnGESijZpLbNvTWnY4bbKrhSZC0D9PkEhBea51odYAbrj g/sK376E96hHH4Q0eoizZiLj/+y8X3HsJSWbi046z8okTRKUC1G3uM5WwRw3DGdhFH24 FZQ5rDilR6hRySbQuPbMs7/eq4uWXs9HPINsE4CQV3LZfgR48vX78j/X4ib7ByLRQV21 osk+s1dgVcigHWwryV7pE1j83CvmGda/HQE7wpw87PySuz99eaPLFWj8oqlId8WekC8Z QiXg== 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=yvaPRl8JCMeSvCCgLhAoiV3R2TqE7FWeWU1N4zPM+pGj3oVVPAqt63viMaiPTWrzQW q9W4gM6SNXl6nuQ1lUU4gYHq2WzvSIQwfHTQznBW33wPKet+whNg04gV2OyDR6X0M2HC WHy5AUKbN5ND2NH27AxxdiPGAxf5/iy0LFyaPwTUUbCUd/2z+M7vsSmrcx+anEvGtIrP XvjH4L/OUWzStkTjVYpH5/7MT2VYNBtYqLM7StXKiK1WUL36XBzISO84Ae2EUZOp2BsM T5M20x3pOeQrbxchsmpPQPbgiGGaWRKi46ObX9aTvvuO0DDtxQ12hAbxP8wnsikdTeMC PUhQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=4DAAeEj8; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=W0MDl3jp; 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 q14-20020a170902bd8e00b001ab1279d418si10188567pls.474.2023.06.29.12.59.49; Thu, 29 Jun 2023 13:00: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=4DAAeEj8; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=W0MDl3jp; 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 S232421AbjF2TX7 (ORCPT + 99 others); Thu, 29 Jun 2023 15:23:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231422AbjF2TW5 (ORCPT ); Thu, 29 Jun 2023 15:22:57 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE8453AB1; Thu, 29 Jun 2023 12:22:46 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35TJ4GQN004726; Thu, 29 Jun 2023 19:21: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=K+AA+kYbNK2C8VbAVOrXqomOnTOwqL7DHRi/gDse0kY=; b=4DAAeEj8GPV794LkqHkXf/Iv3AEXfCF1oAdKoiU3tUuj9V54N7x11UVko7T8iMpbPJGu rNvaaSUceiIPww3T0qIeRW6LErw+TS3EDYzWGo2MAW2TmkIReubVGxGgr7OxJO+QRTQy FMmOlQPumbTuHIm6t2js8AkircffzOtw0DP6/R8Sx1gQ+E5DnxwiiHR2sMljC6K+Jkow CL7rNuDm1fFT1UEQw1Mo/JgFtqeODFJWpspHpfCCB+4h1ccpB52kfVSws4yNESs5z3lS u6IhXuvIv6dhPvPo1GZlLmt3YMTRQLkqXewAEQyMgtpo2ZOdgXKFrJPT5kATZ1jH37IJ ag== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rds1udpur-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:54 +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 35TJ7pe9004003; Thu, 29 Jun 2023 19:21:52 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2049.outbound.protection.outlook.com [104.47.66.49]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxduraq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BnHP9R0DcqyidTkhqgzkYBu8WBhNtrTBwPhK0Rc+K7M65TG9ejcgjMrsmRxIByY25YdSq6Fno5D3id77KKasEBYPgZZTjWilGe7z4HFjGKC2p67G8M6KY3VO2n6s71JzBasega2rKmcFwz6tRRCQomnx5L7KwZYI6j8ba7eUSHRNaBjd85dX8GS9Z5BS60zYGyzUfKxpY3g7l/YOZGTSZeQXsWbWi8YQ105EGHU9BGJOmLq3/Gr5Pu0oS/miqDCrihrrpgaDtzU5WvDyw6fUrJ9i3Z8LeDJOVGmwzODRLNRgTGpIhIliTvP8Cucre2WbrDq0oU6y5hN+fem+s+OKnA== 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=lYa+cwARIK0dZ/R0yMRTkXhWlVjNg1cf/+o/6zsdLorCvjUy/D6Dqigk1o2OcnQFxYxxsgBq5jXq56p1VtkT0IhEg3iyqk/6E1jUvscovYbJJCC7U2iJeWpu+MfnMkKOCpHdfhAdutUkaPrm4lS3P7L40Cvup0F/aXXn68PDI3fVNR0O8Ew0lAJeRebeO03E4xDd/ZDPbtx+bqz2L943GDXJNWIYAoY2B6A/YbnC2cz3wisQwKZql8mko6guLVneHaBoujeaueMZWTkks44Mg/ixXYhUYbK0dRGUOBi46KcdHbg/dsnUs1oARbcqmvOkLrlytbpmNhILunaVbfPvFg== 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=W0MDl3jpPtjgKybbph6n7SKuG3gSYvp+O++pWIKT1U6K/DArA0NF/b0UNxyXli/iJh3F5c6TduNgYeexF7IaPMSJQ6H7yJvlmFaioDpNitRjBX3cCy7RgXNbfk6gRD/yA0pAwUVW/cKLj8Uy0LGXS0c6L9iaELNn+ZD8gKvYxZE= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by IA1PR10MB7200.namprd10.prod.outlook.com (2603:10b6:208:3f7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Thu, 29 Jun 2023 19:21:49 +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; Thu, 29 Jun 2023 19:21:49 +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 v25 08/10] crash: hotplug support for kexec_load() Date: Thu, 29 Jun 2023 15:21:17 -0400 Message-Id: <20230629192119.6613-9-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230629192119.6613-1-eric.devolder@oracle.com> References: <20230629192119.6613-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR03CA0060.namprd03.prod.outlook.com (2603:10b6:5:100::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_|IA1PR10MB7200:EE_ X-MS-Office365-Filtering-Correlation-Id: 5711ea19-670c-4443-f86a-08db78d61600 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8/LnCzWyww84Oa4FrIyrtmpVg4ZGIqbCebYQRvrZ+L7deNMqIzKT+j5eMnd0TIKTfKxJ6UH/BuRO+PvcXV4rWl6xuDd0brGeynI3o9S0Her4UGga0KV9yDMO5A7y2qLsJXOP35DmvhVFmD0IxsJ/0KSfUaIINobxhTBZ3xIDLbNQknu0HcS9J4MehKK/dYv33qpkWsBY8Cu6eabK4i2H7JiYq0WWEb+voOvvkHBmNv9KxxAH7wO7ELpgdUz28NTOEIuTeW0olHa1rHnvwsWG/N6Xv3VMZLSehlSjpJMQPp62/xC1YG7XvB9kLesWrHQrY4gAKREh46mPI2Lkyb5qpc7jBMmDNBB//e0d3hYHjhpOKwSOR7ytFhJAW5G+Tds31S0zt9M/JczTFQyhfb6ByMjjyHISEpJiIHDsICCq5bMmywlwPngBeooXIUYKhgAItINFGAoqCq1F92eQ16Mkga5VsR8RYGvJZ3PD3JsgcFf496+oz2a/Y4HtocTi2VR+rvLU/3rPVcJfEFnehSD2UmT4mjll0yctokDJ/d3ZLtajvMCPnXfrbpbOBS5VTLN95jb+5QBSFgPSHrGyOQgWbrrZvFQW8nz3HwAFIOoxMJA= 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)(136003)(376002)(39860400002)(366004)(396003)(346002)(451199021)(83380400001)(316002)(6666004)(8676002)(4326008)(8936002)(6486002)(41300700001)(36756003)(86362001)(38100700002)(921005)(2616005)(7416002)(7406005)(66556008)(6512007)(5660300002)(66946007)(66476007)(478600001)(2906002)(186003)(26005)(1076003)(107886003)(30864003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9f6eWfkDOaju8GLdCtyHli8kEq2crKnFcgyg//9l4RQ0Y+UhnraOHjRKhtYY7u3FgONzsd5MJKCzx1y2/s5NWIsirLYBan9MxN/G85KIrw35dDmS0GUWdM6OPR1PcIyPVCqedTw04qW+X+a/hqcsr09Dpu1v2IrIy0ufdpFN0K3/QG18EPQCKpZqTzneD6S7d9/VAYLy4aM0UgrFa21mAikEeOqYi4RZk0jZVdCxcJ/Xyl8WgWfalHgh7X+aXD0rxlYs9dnMO6mQaSI5wECGo4XcZ2uc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C82Dvo4WVX4h+Xx4HUw7w4f6tVZZMVb8IBPdxzkR4ljYMn21AWlCdQ/vRoD1JcAc0IjaUkdxKqLxlpYxfuAXO2BYFN70YeQHURm7ZyS5slHou2mG3Y7AXvowTwXT/2Khk8w43EegaJ8GuhGkvYAeDmFYR3YX6MhXF7JO+w3fTC7H5vJ7HAZPEtJdZARcRwV+MhMFVIyIkmZObsUhT9tADR4tS13efTeAX8e51VPFwdkTL3GqmxnP08DOFGuMEhl8JZsnSYblpEC4NqYYzHUzgSF4M88Phr2Y/BOi29dTuTBt7t3RwEGjHq2aa88OF1FGBoHnQEPk/7PM5XsbESOfiXVUVp8baRg30PnzGKK37RIfbe5HhFr0cfX05Wx8IjcFnfPAkEIrsa5iBDFw4RCzhVTObql7R65HrdzcezdEl4w76Tcx0qjD/ME2HIlxLCQvwmlhBE7BryC9OmnlV0/0fZRpD0DU2G0lGxYw/MCsdbx3CxFdTQHq/2BIiUxRvC7PqEDSFWVR6n7T/dz1D8DTNcdaNJqX8ko9ekD9hrCzlxkufU58QwcP/9wKFzw1+fy2mo5FtOAARUxBwGqudg8J0ej2rykTJI+CzCb1sGBeh5sNny9dHm5WdBnm0ESNJS/anLqRNz1l/zmGmN93NE9Pt2bmZqzfIPa9n9pgC/htVrsjZoqv4stDarKHPsIOB9MiMGQXrtwsYCQ0WqGulCN6I= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5711ea19-670c-4443-f86a-08db78d61600 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2023 19:21:49.2025 (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: 6CysDTJ7NqKTBc/NT+7JgZEd5+Nrq4G+UsKqCXYvtm0KnvWkzIphVcZCzt1UdoycRKjCJPVwMJTqBkhOtCSo6BAXnhAeN/VYQDeJPncKNUM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7200 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-29_06,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-2306290174 X-Proofpoint-GUID: -AR5v2zFV3hhmlcc-cOuWN5Ao7fsE8J9 X-Proofpoint-ORIG-GUID: -AR5v2zFV3hhmlcc-cOuWN5Ao7fsE8J9 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770068432307137447?= X-GMAIL-MSGID: =?utf-8?q?1770068432307137447?= 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 Thu Jun 29 19:21:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 114431 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9898572vqr; Thu, 29 Jun 2023 13:36:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6VyEfplJ+XWCB0TLs4ka1KNqCfREjILr6U0CUXfAQnr7XKWiFeIYfMvShxapvO9dODA7hp X-Received: by 2002:a17:90a:c906:b0:263:7d8:4a with SMTP id v6-20020a17090ac90600b0026307d8004amr6832534pjt.18.1688071006611; Thu, 29 Jun 2023 13:36:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688071006; cv=pass; d=google.com; s=arc-20160816; b=Jund+CvuTgaVbV6PUTH6vgLwDS0b3owJRmKEqWXrclqwvBnMCiXFZcnPPmyOtMxDba gfFLEftJRyX8EVAARv0n1A9oD3pdF+gf8iP80IurcwNg/+KvKViHnzTx/+Yc0UzDvIQe TBktfVu8SdktX03VftggBzE9DnJOhIeaJLL9lp/XSuJZuQnlxOjTmfJZYBMGPvzSdaQM MB+3g6wXmCmmLBHmnJA+Xl8JXlgC4N4wWzmJWYy5wSNBJReUS8sHnJgh4lF8vbVAIDT9 JBWWA94XICN19F6V/lSXf0skeMSf+DvkLhQG21kgrm1i0biSfOxtEWl7s4iQto1GHXIr Ygtg== 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=jbq/zW/kpJ5Asd2m6bkP8TwpRMJPlYlfWp+H1GJFf7IXkGn8BHqGIhLx+YtJAk68/l zwJmu9m4G2WWDTg4DEYeeccVyAE1ru7UqpjZiRrVKcuHKx2s4G0BmcZzDIyxhRnLJ+Pq cv/YGZ7lyayHp/Ipq/DzVvzNJWd7+9cwEiTmRm+1JQ0MSeOiCCVSJuRkjC+h+VOZG1gT O1Trcp6T/332teZfJrVspwGjSAst3iPl0IZO40pt41vuGeYzhQlcYZKh1xhY+P/6QZ3E d0AZHg4cmSAEWubOS81Z7289rOXkMl3/AkXV4tCIAuT8ucNe2tB9VxHPmYZPu9dpYNfk VOjg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=lDYKfkRE; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=R7xJt5Hs; 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 rj6-20020a17090b3e8600b00260f28b14e4si14815579pjb.4.2023.06.29.13.36.32; Thu, 29 Jun 2023 13:36:46 -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=lDYKfkRE; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=R7xJt5Hs; 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 S232234AbjF2TXu (ORCPT + 99 others); Thu, 29 Jun 2023 15:23:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232287AbjF2TWz (ORCPT ); Thu, 29 Jun 2023 15:22:55 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 272A73AAE; Thu, 29 Jun 2023 12:22:45 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35TJ429I028819; Thu, 29 Jun 2023 19:21:57 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=lDYKfkREByz7jvq19kj93wpHDJC+zhrt+rEZQxH0MSHVpzhgIRQhGDptEnnKU58KAr5E 1/ROhdb7ka0H9OZwi7sBFLK6lT51tU5VHKyIzRx7dTzoxlInKPzCmhpi3Gven2PVbqwD xxfjL7poJYidX5LFdG4z4O2XAZs5y5P5hvbuTseLixjlfPKo7PSNV00eDkWc6nImq8yS UfQN4Rfpy6adnf/mCzh0d4VDV/cttf2hRZ1HTtb97XWM65jVglP0OIqtMSHFZDgVLiNK 62nFwF4Qo6B8X8Zdx4Y6JaJz+iNXd7QVN5WSTfZQKW3Q8rGauMJF0rHnj8Ksb2CfnZ8J fg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdpwdnggv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:56 +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 35TIM87c008573; Thu, 29 Jun 2023 19:21:56 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpx7tsc8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PCvhzIWSIEtVpZanbVu6ozyz/6YRSIsBZpzASuk9sJ1gOgyiO9M2T5ejsvEcG+90HoBLp9WpfGRvD4gIa8xmjgb8K5bqyfAd96tC78c8jlNm/m0sGSrBsoV2zr6mrUY8nXwRNr9FQKNtoVtUfIhdcd7HNeGra2RWRqgL+0N6REYstXkNs3Zt6UTzmKPjnYrFMII2aJbeVwxdFBEMGjVxhRa2IfS38IG/fqncAjz5lUZNRnbjweLTM7fIfiUQtrhMwuP3lgJZ8k879JB8qoiQUxnVGVa1gutrC+8NkQVn4QQZ2FFksWmevrwf1bFeaPqxXV35tuTuBPJXb4iOM2sedw== 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=BMzqGucjDBLgvsRi1FmdzEmszSBXxxG2M6479o30HZwpR2gI/RzataqgLFfZ0Ajra0Xopcfm/M8TMC+3TatcHk0agu6lgZjvGyu8Y4AxzYUl8kDdo26CFZ89AfrxGqebcR62aSuUkGnW00asZ4VqhTOif+OjtPJypsPeUN/JP1xcJHdpipcru4B6MNo4ohNKCHK+AiqJe25GHvbVD8gmvLZelDBdfGp7m3txCMbQaYSMxElVYnSxST+qYrbb+hYHOoxi6poVowOEMeLu+ba3UKBVlqmDy6+5cLVGFvfJuM+N8B3GKGFKefBBLWPfkMCD86YHgmFZcFVrmDP4Ws87yw== 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=R7xJt5HsiOlYYth60yX2JXyJN2cys8L80knO5+Ikxu/ZJJPR0+CLzdFOwBfsBWuExWpdq27pryGTPeGOPUQE0wiU2GZIvKlq31Iqu9d3Z/ub9ynfb+fxmPvyuFb0QAOw0lbtmpyeD7Va++WK5+opnv+8enzj/w3FexVuUJIBksE= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by IA1PR10MB7200.namprd10.prod.outlook.com (2603:10b6:208:3f7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Thu, 29 Jun 2023 19:21:53 +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; Thu, 29 Jun 2023 19:21: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 v25 09/10] crash: change crash_prepare_elf64_headers() to for_each_possible_cpu() Date: Thu, 29 Jun 2023 15:21:18 -0400 Message-Id: <20230629192119.6613-10-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230629192119.6613-1-eric.devolder@oracle.com> References: <20230629192119.6613-1-eric.devolder@oracle.com> X-ClientProxiedBy: DS7PR06CA0007.namprd06.prod.outlook.com (2603:10b6:8:2a::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_|IA1PR10MB7200:EE_ X-MS-Office365-Filtering-Correlation-Id: 697c5db2-d34c-4785-7243-08db78d6185e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pBsg1SRdsVswbdyvYROTwYP2Z0ko80zyZgFIUxRhGatHU/njUoOCWf+WTr137JasXizkPpPOij5qgDBhFCrnV6cG2vGO3AWxRI/cO5v4IvPRMqBWdIwffuo99lSMys15+MeCOlw+TcpWQAb+zrDk/vJb00QIz2Y+c5p9O6vrjikBxiMzG4OkLixvFEtlRISaT4o3EpkEo/t8wXzuYdmR4zWh9tPICh8zRP8fa1Fb1dG/Zqc9pnzQPckYekse698G/KERfQXuFOA8hVS7pCmg8BgTYl7qtxN/b8ga6LBRDWiOSGMHbYOrKf08UQhtmE4bbdkRzv7mHY/UAgwqRVqLQIG5IBK+R8GAWDlZK8RD5OT+SqzNnUz1JFjz5VEBIVHWi+aJwMyst+y1LHzJ3/ME9PZicplyPMu55OZE8M7RLUt+R7huiLpXzd18EFjCutAwlSQuI/Vyb1zTDF5qQUPmzvuffBO2OSul0gyQRTWcUhLghJN/SF3DPSktnn6JJAKfTG/G+VcvdRTgrjVaaFPyUP+n+cPMyyvlnmuhdx/H7LLq5H6sKmZnYo3oHliSsrCEo81bR1tSLFiCvfU2ISnOADwv4tzhwyKbo9Ha7WDRF4o= 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)(136003)(376002)(39860400002)(366004)(396003)(346002)(451199021)(83380400001)(316002)(6666004)(8676002)(4326008)(8936002)(6486002)(41300700001)(36756003)(86362001)(38100700002)(921005)(2616005)(7416002)(7406005)(66556008)(6512007)(5660300002)(66946007)(66476007)(478600001)(2906002)(186003)(26005)(1076003)(107886003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ms/nawuuebVQ9giEJge8PvLS8OX1tFSToq7X6DNU1q3A5lB/UqA1SVSzAhdvPxKrzWzf8QPNlr5wK6RUIR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BncWZ/3lIe69+71e+c1/o/2joWt3hTZH++MU7oQ3dwqWD/vJh2JXTpb1DI1Ktp2kwwSLlHdzTy8U5cyInfK4kMt8SMVyFDdmn/ndAVabtWDR3SUEwfXkvz52U6gTa8EuqsidnZtoO6Nl4FLU1I5T4rnDxxP/kbadJTnOpWpRBlzWplloMa03ZPqNeuYeMpfwU54s9jj/rCd2ZM4lHCF1oVxYmMmKOTjreptIg/k3kBqVHU5AV035ttsw/oLgUCIs8vsCsCwR01UJrJ/36KNZMzEbBuc3idkv2yGx16M7bwHIB0VXpN4p0ZHIRaw42t+V+vANkOBqhfZJfidvOo28ftERGxkJyuICfpv5j84/I6gE/CzkrUl+6vD0Wc3j2h7FDB32wB3d0heUzNBnkMPadsh6U2KEgllQcZkCbKpliTLBGH9nizDvS0ynbhmAJhOjUzBJMN3SklO/JluNXJcmY6QJyH149nDXO0k1/OuqKiaqafsCKVBY2udK8i8z/pAYMZeXha+svYSBIe+oWvCapyq8YpuO9Mk222bzjjoEOBPpH+9aDiA3aIDMR7rT02JGPe/r2PznbmSOhf0fek9Z3Qqk5alSYP+mDIsuEvmUs9MhxCmJ5L24/ZDsr5j39ZYBl9dKwLHNS1FYqKJujRDTKcSFCm6Fedx/hRLqSKHepFF0eV1Lk3HReR5yrMBvCuJ50BkNzcuQ8lz2n7vJhkjbScShyMi2Gn4Tz+7NZ17PF1DmtrCzK2/01O+vF+O7iffH2qzgiqVN3XzCstiNZ7fBAI/S+FZSdHcQxqsLcbiE0JjmV4et8JrekuieoofvFTaPvCObIEMTM3HKGqxCFa9+ZZcSqTvNGY8tXMScxKMCYUs+2V4sxfmI35/2F2RBy6Jx5ZrcoipgUtC7Mh5Gvc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 697c5db2-d34c-4785-7243-08db78d6185e X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2023 19:21:53.1633 (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: ZMihUjeqjSDh96U8nwbZjLiNXy6bThxgFui8VSr1GwZet77krLnfTOt6k075l1nI5IlKKc5d2TdyT/f/XGTaZ20ojucwMZ1vHbM1CCMavRQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7200 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-29_06,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-2306290174 X-Proofpoint-GUID: FWUaFHBYwk3hRjxwqAaWeVtSQ5qKVbRy X-Proofpoint-ORIG-GUID: FWUaFHBYwk3hRjxwqAaWeVtSQ5qKVbRy X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770070743591954045?= X-GMAIL-MSGID: =?utf-8?q?1770070743591954045?= 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 Thu Jun 29 19:21:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 114407 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9876881vqr; Thu, 29 Jun 2023 12:57:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlHkw0OQjEW9HF72CDnobvi4yydCsE/qj+z81H2U6Ehlo275gDmxZFExoRO2jZ3j/rR5sMVS X-Received: by 2002:a05:6a00:1253:b0:67a:6af6:5171 with SMTP id u19-20020a056a00125300b0067a6af65171mr842147pfi.13.1688068674200; Thu, 29 Jun 2023 12:57:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688068674; cv=pass; d=google.com; s=arc-20160816; b=sxqiDm3jo08mMvlo4qJxui1OibkT5nY5dQ4xxQyOUUmoD1mpC4GIQPRHzloAgMrpWw +Yn4quuG8o2nhVgwjGmT47L2f+ik2vphNbtOpGGWJ8usrWCvaxUlkpey0RmEPrXWpPUZ TvWzhnwkAn0YA8P6CZEEDSs8bhQgfR1BmxJJ8bh0PgTPtFasjLVRCweKG114RLGGpmX9 Yf5h7ft5YjayK4yHof1PppgzI0azgqeFomoTTrRpjOeJmGAhtZ6YenNq5YjhDEQ9xsEb dxCu4QHrZAuzoyzf+iVG8RZMGuAEtnMfhi2fVqvR3sFtNeKfN8WPCwC2QHkE4NMTqVPL 0kqg== 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=qetZw9udVjo4zUtNoYWtYO8yhp7UtqvrI99L3x5NWlE5vLbn+hiLHupIj+HHP0J0PG ZQ2S+K6kQ2zFMAw/2F5JE7FKu22Uidzyte3s4kH4MRCROInAkY0ComeQF3c24XjoTNJT mvUcFFbjmUft7ijosNO1cNly9cVOAc1TLT4tfrbI3jZ57Fh/26bFBIujEjtfMFZZiwRA EoaiNmR5H23QnJHb+A9pIq5PFAI5iu8ttaHinmI4RRPF7z09gKqT4jWsgTvnxilP0lb9 HyNpTrOM8DtA/szJpmazDbB+zRWkVUZOc4Ds+986gJT1qkOcYaYgK7x3q0Tg5eR3RgFd 8YJw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=SXCD6SIq; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=gh1vk7W6; 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 cj22-20020a056a00299600b006634db9e11dsi6303281pfb.313.2023.06.29.12.57.41; Thu, 29 Jun 2023 12:57:54 -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=SXCD6SIq; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=gh1vk7W6; 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 S230209AbjF2TYK (ORCPT + 99 others); Thu, 29 Jun 2023 15:24:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230364AbjF2TWz (ORCPT ); Thu, 29 Jun 2023 15:22:55 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD9683AAF; Thu, 29 Jun 2023 12:22:46 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35TJ4N7P028140; Thu, 29 Jun 2023 19:21:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=o+McSM2gKtujfwRfyeOsaE02Y4bKTLqqTyQF/lTUOqg=; b=SXCD6SIq+GC5Wr3QCCnnUJfuWRpBHBEE124BRTipuigwD6U3vr+4WmCTgdtb/e3x1KmF 2Ekn26yCN677tUxyCWSbLYW3YtHaFPtMvFp+89SPuh101z1OGNKpug3xfQgGgbT5CG9x TN34jd+PNEmeIaf9V6pUlKnhIayJHknNXZNj6DTqNyW1NFWqf4pXM1xOp1Cq7JvvfbmD ctvhcFyzor0BNlcHVVT5TgQ2y1hDt1uaFP/mAT/sUeeCX8Z8GzaiojsiwJ6+m6GjDivg M7+wPjQjrMZFQWKCxQS7LshlfFs7+1NJN/7XcUmjnTjj5JA1mHxvYomJguKm/6682htE cw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdrcadbd9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:59 +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 35TIUW08008581; Thu, 29 Jun 2023 19:21:58 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpx7tsdp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jun 2023 19:21:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b39mfrWsiyBoKgUZTow4lAd/lfb+m5FCLxxoM9EdlauS4Au6FVUBOZRM/O+zdkWSdOqoXy8e12uF3PjSMVuAeoLF2QxgX22VVFubO0lTtUm7RP1FRW77L+0TjF5q4At33OedY7PiJQLR7nFoS2kHT7ul8cc4ZC35rR2NQsHY4xsdC28uRTKMnBsSRmR3cIUUN7eZBWzn7CPVUcSiDBXjKvxirkZRe0P3llLPx0z1pxLwgCk5BB1GflyHODCFFdZZTSfM/y5SzBfMFJL4JbCLps08tAA5/NJFobH3qH4H+IZWK9CVL6etgI1PEp1ZHTzNu37ny3TlB0Wd3yUdHsNkZw== 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=I4iuXGiAS8wpdBkH99iqJdT9su2jtkjFgXd4on4uoQA/I/CDUy852+w57xvWdNM2Dq/AifZmM1yAkEumLkJKZgEHvyjGBeYdfr+LXn0An3SPi8CO5eU7XSmkrBIR5HRsShGJAXp8MgXdNS87PpZqaZTymHiR4HBfXLwn9ZUM/uW3QYPZ5bdIXikgMrWYNxm59ZWApuZkdUzihG4kRBWs4Ny5eRWXs3j8TYcQAv9Sql+kNSz0d+3VG9VSmkqb/k27StAF9xmXlrBC+7qg+F82pGIkg4oEbcLE21u1f+/Ijzsh6Vu+a0jgiXdQjlHXb8qjXymfY8aSrT1Z5GyA2uRKtw== 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=gh1vk7W6y9Y6McyqW5P4ULrlGHyri64jA/uIIWowIH7ffws1VK8S7KWIKHPSKvBIVNQz0t6837/Ppkqd/wMU+u1BRW2irMwNt9nFxUrfB+hbtsbVOSH7r3DfLHJDfA3FjkOtWwcrKoVkf85IHu3IPuvVrTyD9x1w3gDwzoUyS7c= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by IA1PR10MB7200.namprd10.prod.outlook.com (2603:10b6:208:3f7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Thu, 29 Jun 2023 19:21:55 +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; Thu, 29 Jun 2023 19:21:55 +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 v25 10/10] x86/crash: optimize CPU changes Date: Thu, 29 Jun 2023 15:21:19 -0400 Message-Id: <20230629192119.6613-11-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230629192119.6613-1-eric.devolder@oracle.com> References: <20230629192119.6613-1-eric.devolder@oracle.com> X-ClientProxiedBy: DM6PR03CA0091.namprd03.prod.outlook.com (2603:10b6:5:333::24) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|IA1PR10MB7200:EE_ X-MS-Office365-Filtering-Correlation-Id: 50ef87ca-37fa-40e7-4c46-08db78d619f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6gHXghPFYH/Xd8ZqPLcYbtXtFN4ag0z6id76cKNqClEfatOGeMP4U0yvxzxVnT8la4LoanTxKetfXWSLti5VYssD+Nk0sOqPOC5hmX/DN7u+lTjB+AoNpz7Xs4qCL3iuwdlMNrBJu9Hwsz0hBQ1HhHP1QdrToLg4Jr/xbc0ZIjVyGDWkE2PL7ASLZr01k9raB1dNtBommCJnl7ANIPBgopXW7oZu/aGq+9G8vIUy344lHl2n9xMpqDv155Vkm4NIPYFWJanCkmCoe1LnvtElq/jp1pJkjAZTy4WSRWTBeqa/abmYgox1BypyQYmgy/2XVIqsHqikVSPF+vPbJiIPJWfBirCBubtLieqR3unn8SA2mhkhS/XHKpJMwXy1Asxow3+ebtL2fbNQgoxUzSsONoiEq144wtf3qZM8WIq+jT9g1+fuUTAbZE+loM/TWJ0I08H+5lpVzzQnCMZKjiWD5weL0cKyGW0CQq/ENPnstTA4JjsNWvvysh6MXr9e29G2bVDOP39wCtVxqMnYqqeqSmr14xn+OXoUAL6UCwPRYaMXiy5MjwsA50pcKk7ERGd+mJo62pOYbLbq48eiPbZVJfWmNICfv55qSjuz/AQ4YZg= 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)(136003)(376002)(39860400002)(366004)(396003)(346002)(451199021)(83380400001)(316002)(6666004)(8676002)(4326008)(8936002)(6486002)(41300700001)(36756003)(86362001)(38100700002)(921005)(2616005)(7416002)(7406005)(66556008)(6512007)(5660300002)(66946007)(66476007)(478600001)(2906002)(186003)(26005)(1076003)(107886003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ElkLGFe+myynGuJMWXC/KJK4/vhLF0NQhLnvhyEGb2JSJGgWjF0cDTtBW4Q5yIA10xJRWDRx4CB6QuRr1M1ORSoGyd8JoQpgnHa90HBN4BQS2Se8oFRSBM5vFgpnji3dUrCcxKcwsphDNd7ImL5UKeaUG1ogLz0BI90jHofdmTFJdXxxxcJeJNlWOzxepuXR6EJf695+aSTHLwpdPpf1yKSgo3Gf3xaRW0TR3LcQlJQcAuHkg0kvHnyPHnv9keXtOOJWorbtOaSaigXRfifqwOs2QUsOMbC9JogW3DgxRwQT1p0HR6vHMCJM/1mjUdk9BamyF50vUlBboPmjSB31Cj7LoDOV6ZghNR9acS1tzqLHM3kK3W07RvqcnmgGrAs2+pF6DbQYJtpmDs79U6qV1yCc47Ho+jRKSQbrGE+AsXl3auf2x74ZMhAI4Xb/mXzQ0+6BDQi9fv1qYpGm5jZUk8h/ACIQyGLbH0ttyQq44WIBMCzuWor95VYkFr0MZO0aGmgvlEw9J3O7PHkkJJS7VrPw+AK5WJrlQ1nWvhP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2TmVO3xUYJDllBCfDwmg+601EZJqhFAfg76cpC40A/7EOmAQIRPBrPgaFlf8TJJ5p/am1/AeNo8+c4XZ1RmxJezkJXbWEmLA7PRAC2EvchDtN1HZ/x1fGhRt0zSjDR/WHgEAokZ3EMQi4D+bmRtkKl1ONw/VWdLsQYcDK2pLaPaI+MBHkKoq+6u8ZC7b03R+xGsm2tTfpscanQM6U9gI0q/K8R5t3e2yMmSBr0T2o4yPU9//LQNGlMnuMBnlmiOckb6wdDD08ak6u/7X36TgF8ewjKKfJBbuOjAUPjQcolmypJwI3oX/CEwo6fQVWJY32qlxVtZ19Jafj0V57gcmhwdBdZUqPWGi6d196SlGGq9sROqZPVDvzEfYpcGwzAeE4X6m0Kc6aY8kfu9RCMNREGPBEnX7Vx2Z//3r5mW+mmt+zMAARs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50ef87ca-37fa-40e7-4c46-08db78d619f1 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2023 19:21:55.8211 (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: 88eaouyZHVU5G5qb1Y8PG5qklwlqUH8X9hhdllYsqUr2h4EyPYIo3CVf1HI/2PPBSNz6l9PKW/nN7zEsnHo7XvhEcIROLeb1nkYsUwRlaZY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB7200 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-29_06,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-2306290174 X-Proofpoint-ORIG-GUID: oOwg7Q2ABizDAnmR-RvLuLaFm7hZSKuf X-Proofpoint-GUID: oOwg7Q2ABizDAnmR-RvLuLaFm7hZSKuf X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770068298279864671?= X-GMAIL-MSGID: =?utf-8?q?1770068298279864671?= 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.