From patchwork Sat Jan 29 17:02:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12729562 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A607AC4332F for ; Sat, 29 Jan 2022 17:02:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32E586B0087; Sat, 29 Jan 2022 12:02:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DC5C6B0089; Sat, 29 Jan 2022 12:02:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17BD76B008A; Sat, 29 Jan 2022 12:02:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id 058306B0087 for ; Sat, 29 Jan 2022 12:02:08 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B2C9B82F4BF5 for ; Sat, 29 Jan 2022 17:02:07 +0000 (UTC) X-FDA: 79083942294.17.D161B93 Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90059.outbound.protection.outlook.com [40.107.9.59]) by imf30.hostedemail.com (Postfix) with ESMTP id 31C6C80003 for ; Sat, 29 Jan 2022 17:02:07 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lf1RZYhEzuv8B9+5AMHJIePX0nOIUO6IUW+f1BkQKM/tsWtf8a+8CZkpW2WaK3A4dO4Dfq8NSZSV1BJB9pICKQ4s6+JMzAdpPEoX5SyqRGRJDlUd5mWsurYgMplDnYLp1jDep4up8foyNNG5XlpLSsJ5XQcQuBF6Ohpsponyl2I7Qlvnclmdk5VQJXCdi+qzN+kL6QO9xLCd2HLgtvH8PfDHiHJ1WihzPl5qqpdfYseTO8FVlCD8SB2b9kY3dn63JlLfSn0+xsI+7f6bIekvKI7tpdtkQjTazQ7u/0j4jb5tbFuiVYxh3f65X01Ya0stYrgH74cpS5CfgOFQK8PwAQ== 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=VJplCcR9Zkx4G0K2Wjd0QLzNxJNdkoySv2NqjcWI/Ik=; b=EO7teiGeybXqSa3YGeJCpfd9/a7NkjOgx5lx+pTyNYmtzM9JTWcJzdy9wnUhMNKSMVBVNJdpL3AzdXHP1D/CXCxQ1bRJjbXxtHldZJlXZMnVWppZa4yxzrp0S/DlLUpMXUhnjKwieq4VUR1LSm6G2dBDEvgiSOb+f4TIyV+ujlLxEQIqathJ2NVkZnfFwdmIATbwMkDW/Fgv+o5Zc0ugIq6WXJ2fhoN1VgHJqpx1kwBw4BtS44ytEHWevNF/nXHo0ceRzaRFmyx6Vxmtwn1W4oFF5UiZLS7vx2T5Yzt8Hae2vsPzbA7zUF/UUhjR5LfqvA0o3OvjZLap5Zpy1TXH1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB2584.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:1e3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Sat, 29 Jan 2022 17:02:04 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::c9a2:1db0:5469:54e1]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::c9a2:1db0:5469:54e1%6]) with mapi id 15.20.4930.020; Sat, 29 Jan 2022 17:02:04 +0000 From: Christophe Leroy To: Luis Chamberlain , Jessica Yu CC: Christophe Leroy , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "kgdb-bugreport@lists.sourceforge.net" , "linux-mm@kvack.org" , "linux-arch@vger.kernel.org" Subject: [PATCH v3 1/6] modules: Always have struct mod_tree_root Thread-Topic: [PATCH v3 1/6] modules: Always have struct mod_tree_root Thread-Index: AQHYFTHwBkgteju0lUKhtOmDC0OODg== Date: Sat, 29 Jan 2022 17:02:04 +0000 Message-ID: <79a93898cfc4fcab56bdadd06bd9233f78caeb81.1643475473.git.christophe.leroy@csgroup.eu> References: In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5431cea2-0cce-43ff-add0-08d9e3491320 x-ms-traffictypediagnostic: PR0P264MB2584:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:556; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /50+geNmZLhhxp7pF6rvhMNVFH8QLSwZ0LcFAxDc2KYyCsX55kC3ethHp8768UZkPVTdVQRF5cH9w9Edy5ebQEEh3S3EGd+ja+gKtpqX6M9KJBRqJ09tPCSPqo689OxCkPQ2kOWod5hHaapiJEMSAwd+21tlqSr2M0mlNwy2YTaVinU6EKOG6BVYEE5GA4tPYltfAe8Kv7SHCCYPOJEozgOMWTwyA6+NEXcUHQgsNnZy0BJx5oBLtQngjvC6amiQPSyn40pWOz68io2oMC+N+ENzJpafVHuHsiZbwkfpLIrVPIbaT/TxcB9yo6mcQjES2IG1tJUqnUah3TEum7FHJu1Xn2VVT5QS/jmtzI3FiF1qGgNKEqc9GOFQi2ePi3d07WKVhudsJr+P4buo2TJucFzPXjOfBxcuQ7rkN15wprwM3E3+cTLZ23YqE/oGPLfNRU1PXDX2oqh3D7kgCj+PTS2EM9LfslM2G/8/OZp6roCDYqBfCDlY+7vrhN+PCkXMuyX8MjkpZNke2GXTzRyG/DsTEWwrObrrVUZxqbY0a5Z3AH9jd7kg2CiCzmKRfWGKOfXf+RVGWunuQDTRqX9ckdN5rkX8i5a4R4HAZSXS6JKHwnLHrYifeUaaW6B1csj6RLSm/7oQsNDnvWznJg0oouwIqi2EgNzBU6fC2gnaIYCbNYyJPAgf2TgeF9h0ExlMI1j9PN+ARlxhNWsiBCdZhQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(54906003)(110136005)(6512007)(2906002)(86362001)(6486002)(508600001)(4326008)(122000001)(38100700002)(91956017)(316002)(76116006)(26005)(64756008)(6506007)(8936002)(186003)(5660300002)(44832011)(66476007)(66556008)(71200400001)(66946007)(8676002)(66446008)(83380400001)(2616005)(36756003)(38070700005)(20210929001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?914jvIorz8kxfZKlhd3jVND?= =?iso-8859-1?q?2DCYK/x+mTl5Ju4hnvbW0OarUbKlO9B/gKWytJvW6jP5TZMk83LiK1DsKsO9?= =?iso-8859-1?q?fNVaOO4sXnwz4CLY09xSk1hDjHRS61N+DoRPBODodYiLgWdIVXS9ChJRfIYw?= =?iso-8859-1?q?xm4aig6hwunGT+G7d4H8e0tj4Gt+OEyIlBk96ZEJV3piWzBD7X+B4XA9oZXq?= =?iso-8859-1?q?ld0XFrNOXrtguCsdO4J1DoPSYG2b4FY1cQS95P2O2oCnwZPncBZ8+m6G5BOC?= =?iso-8859-1?q?kSkxn8PCFGDGHKUayM41kBY5WLh0TqhsFfbFRJn2RBMA1JVH0p0xpgOV8Wxw?= =?iso-8859-1?q?szD8EGTJbhIbscowCaYBynO4m1ZGoxir25MuwsDpkRo1aAFCC3sAzzCfUn/t?= =?iso-8859-1?q?/gGWxtRD8MLRGXAxkCOoceeEzdV35H4H5ABqhrA37XJ4oUGiTL/Si2CsmUyU?= =?iso-8859-1?q?GawZ45TXOVAC5j7IDb0pWehYNBSV5c8b0pUKI6uwS9CwsjwzVKJcL1YClimM?= =?iso-8859-1?q?MdY9mKSGoIKLuKtxUos2n8AO+rkfmKeClWzj2w1hs9fGXeprDiqVA+UWAO/l?= =?iso-8859-1?q?af7dH8SDbmi5VMc89nZBWrpGKNcZundDRTfzgdmkdlh452Dx5+RKnWtcECxp?= =?iso-8859-1?q?hARfE/gwjqSGGnULRkLl+gr+KtO9v8SzwYIM9cTkHBcDGi87MEbTwfAq1gvM?= =?iso-8859-1?q?3Hrfb9sFx9zM9RMME9C3BWg942zoRu+FTdsClwKhsnNCGntOZ2Pa29CRImxp?= =?iso-8859-1?q?+oQ3moQ84RJo44grY5LxPQaleB15m8gqwymi8jz8TxEKTdsEOY6ie0dnIvui?= =?iso-8859-1?q?S+oCnK4wPZWCd1qnrO1UuNoRsAMdTVTaAlQMNLaXnD3VGFkjkrORiUeGCkYZ?= =?iso-8859-1?q?XcYcOapRmqneY2kn5ZqzS841x7RqqZ9naD0UuYm5s9fv8DSYKaXO1a0awGSF?= =?iso-8859-1?q?r91zjc+V3wGCy6h4gVpT8KmZisHVZUU+J5uSLOAkYRaGj+ayPvtRRBpTSif1?= =?iso-8859-1?q?gLshm8dIa+Li9hNIV4Pp0qq6ovGmyt3a+nqVCZqs/9ygS8KYv6Ykfc8Gnn9Z?= =?iso-8859-1?q?uKziwyi7UddMtQwGcvjpsFk6Y+DS14rISUTPglVmmcBTs6Y2o2dZrs4O1gEd?= =?iso-8859-1?q?zW8OEI6PnA1/QuYrInbPRdECJstr3g1CfMvbhgZl2s7lUHaiZ/AN5D6ooTq+?= =?iso-8859-1?q?YXbsATEvLTrxG/OSTbhksUk3qfReaByJpD/+CZrzMROAMHGViB4/Sl/k1PXN?= =?iso-8859-1?q?/cUQfaAZ6SCntaCZRgiW+oIHoMFX+XGN/cU7qFiy0o3H1UVD/augeUPL5YxK?= =?iso-8859-1?q?G9wg72joIzoleDSrxlSQ04SDISdxIJZHnXCenXw/hPqiLRS3Iw55J1O35tPk?= =?iso-8859-1?q?0ucdPhIGaq8od1e+bjIDXG14Uj4HY8igZ+D9eJcmkbMScH8fJnr/RXMHiKZH?= =?iso-8859-1?q?wA6OSfv3iuC3Kb5HvSN2DyK/Ggt/mX1rq2JJ0UOHr74PidnA9BEpnKRNbjvz?= =?iso-8859-1?q?8ej8B7/FaaMmcNcai6kEkgbYyZuMglgeRueSzNRmkyjEJfM0LkVrojzxsfhV?= =?iso-8859-1?q?XJ5yiblx4ar4TnuRYjDvkT0TKzikUzJ/87G+zUH1/27nx5zBpGVRYILRwInO?= =?iso-8859-1?q?TOg7dr+qz6oTxo+9gSzrXdb1t9nxJVTocPTcOJzj5pLBnfPEidSytrbz+VjI?= =?iso-8859-1?q?06IkswkqwdhTw6cmEnk65HIZ5i352BVjHvpiuN+SH4g+bGSuAA0suGM5w2jZ?= =?iso-8859-1?q?/NcU=3D?= MIME-Version: 1.0 X-OriginatorOrg: csgroup.eu X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 5431cea2-0cce-43ff-add0-08d9e3491320 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jan 2022 17:02:04.1881 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9914def7-b676-4fda-8815-5d49fb3b45c8 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 6j5EVAHKC2Cc9TFaQQWcM+IWDgyGMUvkhKiZ1usUhYEtoLVnUeeU2hYN89gdD95h/lvk33Zau2PskYU37pXLgOYf/Wiex07OvQxqS+G6Ijg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB2584 X-Rspamd-Queue-Id: 31C6C80003 X-Rspam-User: nil Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.9.59 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-Stat-Signature: 7di446pge46n5gfuxejqs7i5z1ucjrg5 X-Rspamd-Server: rspam08 X-HE-Tag: 1643475727-217494 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000643, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In order to separate text and data, we need to setup two rb trees. This means that struct mod_tree_root is required even without MODULES_TREE_LOOKUP. Signed-off-by: Christophe Leroy --- kernel/module.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 24dab046e16c..080193e15d24 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -96,6 +96,19 @@ static void do_free_init(struct work_struct *w); static DECLARE_WORK(init_free_wq, do_free_init); static LLIST_HEAD(init_free_list); +static struct mod_tree_root { +#ifdef CONFIG_MODULES_TREE_LOOKUP + struct latch_tree_root root; +#endif + unsigned long addr_min; + unsigned long addr_max; +} mod_tree __cacheline_aligned = { + .addr_min = -1UL, +}; + +#define module_addr_min mod_tree.addr_min +#define module_addr_max mod_tree.addr_max + #ifdef CONFIG_MODULES_TREE_LOOKUP /* @@ -149,17 +162,6 @@ static const struct latch_tree_ops mod_tree_ops = { .comp = mod_tree_comp, }; -static struct mod_tree_root { - struct latch_tree_root root; - unsigned long addr_min; - unsigned long addr_max; -} mod_tree __cacheline_aligned = { - .addr_min = -1UL, -}; - -#define module_addr_min mod_tree.addr_min -#define module_addr_max mod_tree.addr_max - static noinline void __mod_tree_insert(struct mod_tree_node *node) { latch_tree_insert(&node->node, &mod_tree.root, &mod_tree_ops); @@ -209,8 +211,6 @@ static struct module *mod_find(unsigned long addr) #else /* MODULES_TREE_LOOKUP */ -static unsigned long module_addr_min = -1UL, module_addr_max = 0; - static void mod_tree_insert(struct module *mod) { } static void mod_tree_remove_init(struct module *mod) { } static void mod_tree_remove(struct module *mod) { } From patchwork Sat Jan 29 17:02:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12729563 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DAADC43217 for ; Sat, 29 Jan 2022 17:02:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C7DBF6B0089; Sat, 29 Jan 2022 12:02:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C2B666B008C; Sat, 29 Jan 2022 12:02:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACB1D6B0092; Sat, 29 Jan 2022 12:02:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay031.a.hostedemail.com [64.99.140.31]) by kanga.kvack.org (Postfix) with ESMTP id 9942B6B0089 for ; Sat, 29 Jan 2022 12:02:08 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 6D47D80CBB for ; Sat, 29 Jan 2022 17:02:08 +0000 (UTC) X-FDA: 79083942336.01.6C20250 Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90059.outbound.protection.outlook.com [40.107.9.59]) by imf30.hostedemail.com (Postfix) with ESMTP id CD31F80003 for ; Sat, 29 Jan 2022 17:02:07 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mlIwTWhhzB0KgRw9pNUZU1mGDBOI3kfWgnz4sFQxctjd4up8MgHSDPOgkmuS6za+hM/BOfFtKJWG1sstK9kHpodwv61sPxcVwCAuecQ02qOfTm+oId0MsypLhRAmbuT0ZCl2LCg3tv3vG03HcM6NZPhN5WTqucHWBtPbMfLvimDyu2pkphlKoWp8skiiDHPzpR6HFv5l87yrLVZVpBtmFGyRJjDWUBULx4MrKiQTcfCboUq2DWLTa5joMMihuUIxTCKDitcu+FjftTFEIcS0cVWesytmFf6588bRu/ZVQKc+O0/upv+OHJqwd5dw+ZQ4uZJg+ADMaYquneh/z84ekA== 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=gLPBHDvXBMkQgGlRIh1tkuwHuf0uvhx2Y4O1zkh+ryw=; b=IwtV3Rl0eLpc26MnYR04jDyPdju1+/1pPkmuqAGxBFo81iq94cZobyTwWTtFo6fngzdU7MAQg/t+tlUemeJJcAO4M2ki52Wcp+NzqoBPjFsA4AvrgwELwNnQ+B2FWoUZN31Qsq5IF8iTiergVsKaOWe9fJsiMZ6oxz9beYj7vW4Lc7iJ2sW52AAvTlclNL3Si/hLoi5Gl2HDeFekFFICSR6cw6rCjDaMxTQJ60cVObjTfWa9rrUj1Cv1Lq5pVBRI+vzU/Nh7p4PPf0aLfhxKdJfhGJgJOLp/jcxpqjP0wP+Nc5c6xoka54dtgR53t85Ml+qQpH+KU44A1JGkg6K1nA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB2584.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:1e3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Sat, 29 Jan 2022 17:02:05 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::c9a2:1db0:5469:54e1]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::c9a2:1db0:5469:54e1%6]) with mapi id 15.20.4930.020; Sat, 29 Jan 2022 17:02:05 +0000 From: Christophe Leroy To: Luis Chamberlain , Jessica Yu CC: Christophe Leroy , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "kgdb-bugreport@lists.sourceforge.net" , "linux-mm@kvack.org" , "linux-arch@vger.kernel.org" Subject: [PATCH v3 2/6] modules: Prepare for handling several RB trees Thread-Topic: [PATCH v3 2/6] modules: Prepare for handling several RB trees Thread-Index: AQHYFTHxTvyQXbQLfkCX5PUzwy1VGA== Date: Sat, 29 Jan 2022 17:02:05 +0000 Message-ID: <4332de93cfe4eaaf756825d5f72cc7c9fae13c34.1643475473.git.christophe.leroy@csgroup.eu> References: In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f8beb2b4-6937-4366-c451-08d9e3491418 x-ms-traffictypediagnostic: PR0P264MB2584:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: hWGKN3C4Ej/d4sZlgyU4S3Sd0Ju1XH5zpBai7ucXgvF99VmB+7Ed909QOn0KuZs/6wZPwUqV8aRbPvOhjWwSgWnIGLfvFr9Dl5KQ83sceKllHwEorLvFPUsFduUVw9PKwoDjhsWxH++hMteK8pP/767QbgQyFz/gHEx9hIDQW+hQ7AMIp1omi2Uyr0psNousiqjoviXSjQ0O2Ww4S512Qi0doFRNaBx1PQgi5RWHvy8a4h937oSiPaQ3aFHICnCqeR/swx7mQcMgBw3wz+5bOMkTo0rfW1oKyl650iXIzDA9O3bqL6wtUtUWIWeh02ID8Pih6nbKm71bsMgpfY1B+MZhAFB6L9JURozmB0j04vDvxHfofZLxARII/MeeUmN0GLjgj6oE0Bp7s18gyk+fAvQSkHC2EyVmRVJLjaVKAJkkDYRLU2IbbN1zrtpMvq5qPE7X2wpKs0w3vfxIgbsENbqYiXzv121YYe5KKIXuAR8Aac5ZE2NbRWGW3iwdlRBZZXPF3AkAX3JGVYKD0aizIss+8m8Na1Pijj24QveEPoPoitJCI16x68JCU7iLCLI+HpMId3ngZeFa58uzjvRSFRjYZFhwKQID3WGDc8AuDvF837nfIPNVaOXyIfJC8YrVckQ8kJPFRBQcHRxFYbsNbUmlw6Kupuc7dnmTZMIVD1d8kcsmJPrFC4qyeQpjqSZKChehMxwNM5ELKUsq4WxhrQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(54906003)(110136005)(6512007)(2906002)(86362001)(6486002)(508600001)(4326008)(122000001)(38100700002)(91956017)(316002)(76116006)(26005)(64756008)(6506007)(8936002)(186003)(5660300002)(44832011)(66476007)(66556008)(71200400001)(66946007)(8676002)(66446008)(83380400001)(2616005)(36756003)(38070700005)(20210929001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?JaN9RSDWGBfJlk/b/5Qfr7A?= =?iso-8859-1?q?CyycMar17QOeH+RCzl6lSu41ZgDUVo4cqHY0JwAa92AB5P/ivhEzu/TVtA4v?= =?iso-8859-1?q?6fk7Nxnj3vX/0E5dXtxRzRIm2AVBNpfiYNjTdW/usKK4hyrF2TKJq8NbpjNn?= =?iso-8859-1?q?NYcMu++nfNWk4bJbdzQWmmE83lY1wbCFEjhzTMOlEW/U8q2Oh66h/O7MH9O7?= =?iso-8859-1?q?JNdatcoM0jlAGNBqEWgu+h/CZZzUHyk+WeJ51FN/kQ50Q7ziidbeo2o7YyVb?= =?iso-8859-1?q?Ms3Ao23i2MSPduSuLJD1CxR4MbQ/5R4OKC6KiyymgqOnuhycozI95f/7TpqP?= =?iso-8859-1?q?L6paaXwqzzBwtl7EzCbnk3vQpXlwN7AFd3MJr3BTqc9lQDoQwyHAtskxJNoB?= =?iso-8859-1?q?Fm9vU4IVhw4a8gL9j7I+Ce7vLijNCdoO24WTO6ZnlbVGBZHMwDord6zJldbe?= =?iso-8859-1?q?sbux5FjTQlIkxxeSXz21AFBrtDaTEKy6aaIULrpS1CQ3fKXDybxfGKZ+m1Do?= =?iso-8859-1?q?x5Zs3L0TMFTP7BY2EZ9xUmotPo0hw6VKxkqnwif7VHBXuArtRt2vr8yiuPmb?= =?iso-8859-1?q?S4LqEKj/1NwcYkUdhM4raa35ii38VDXc4TL4SsTwlKq0SxLl0QtG5SkROwJG?= =?iso-8859-1?q?zsnapxDpimDi0tKFAkwzi0cyjTaCfjPmeLu29sXs+IQcnGt5YxWhz5NIbEus?= =?iso-8859-1?q?BDJ3iBN9RrThD4EpiFB8/hpaAf12KVfkA1ikfPtXdhhc8d4oQz5zUy/yrJdP?= =?iso-8859-1?q?l9TqepiSMJUXZ27hbhx1966XE3yXtbj5sEKeL5IDwxqwx0q5uM9tGP5F9t6U?= =?iso-8859-1?q?wsat907hVyg4IZJ6etr3rpGXuNfOnSMoI0UwvrXK5NxWTdldUWS+QXx6VER/?= =?iso-8859-1?q?uz07X96nrV5mVTOWJCMvfFPaQ5tx5p9huQ2I9siKMSE7F1hg9qFHtGbWLwg9?= =?iso-8859-1?q?Z/pYp5hsCdhuLEwibm+aRIcBXVzoEafyfPUozjJkYyXi8BjIhcgT8ePO8oCP?= =?iso-8859-1?q?VlDsP+fELXDmUnWiS0Cx4GejLhAU5UkAssdPWybNymoueRK1q5j5tXip7vKT?= =?iso-8859-1?q?WAZklJ64W2Ra9S++mQi2GNnt5qewGSI92ekMznULxSyK/O194bCkCuYsTYoh?= =?iso-8859-1?q?E5ETIZ734MUH0oJdERepOA6eNtEXNwTo+D4oQkD6PtOZupPHdDs6gvV0jOLI?= =?iso-8859-1?q?tgbRZsRFb22Xd1uTqZ9CwTm8AkZbWw0Q664evllQE6ppq/dqanMuVK9PZNdi?= =?iso-8859-1?q?eAN6PD0WoiXmbt/ezEEFWyHCwaaHE7+J97QW3Bi59FM25Ow7C3IWI003rQIG?= =?iso-8859-1?q?QuYRLMuDJEYrY4vv0hWLCJWlQtPEK/se0XJJMnxm+//8oWwjpcjid5Is5o9D?= =?iso-8859-1?q?HPUYLC6SUyL51faUPb1gEAvQFnfEYLdJvMb/R1x8xx6Nj215I3XPyy8kB7va?= =?iso-8859-1?q?lDGzVxWgoHcCE0Kq8AnpLk/mSyIIau7GBqxHhBbbfcqvrDdBmdwtdLh+OZ2B?= =?iso-8859-1?q?kM89u7tvdJvv29Wh+ehVks+cdlAoSiANevuXqEYMrhM9+7RhnyGv/vB12/OU?= =?iso-8859-1?q?OwT2bPTt41fht+gULDHmvNNObU/+J7z8noTSFjpP4iMk5M0K3CAMGQPtZwuc?= =?iso-8859-1?q?MJAIYIRCJ5OyJmNrYjVXSVgIOyNoD/V/lEXGPAEKNJ/OZMwBSUkY8kWEoBiH?= =?iso-8859-1?q?mpuckwWnhTUXf1D4lIlgT80YbfQwHPrQr1+0y6qsJvVtaMGkfCIWNIJ9UdpC?= =?iso-8859-1?q?l42s=3D?= MIME-Version: 1.0 X-OriginatorOrg: csgroup.eu X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: f8beb2b4-6937-4366-c451-08d9e3491418 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jan 2022 17:02:05.8452 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9914def7-b676-4fda-8815-5d49fb3b45c8 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: LdH7KpXpLR/SPVoBEu5F8ZKXySA9jFWD/oO3FnfyWuPiW9sB0K30qo4RJusuH7jHu9KByUnzLuzMMX7KzbnmhWKLV4Ggy0gEW6HrN7Q2g+0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB2584 X-Rspamd-Queue-Id: CD31F80003 X-Rspam-User: nil Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.9.59 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-Stat-Signature: twhe3ukxj5y4t6bp6xx6o356rmyuhgnd X-Rspamd-Server: rspam08 X-HE-Tag: 1643475727-154670 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000028, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In order to separate text and data, we need to setup two rb trees. Modify functions to give the tree as a parameter. Signed-off-by: Christophe Leroy --- kernel/module.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 080193e15d24..163e32e39064 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -162,14 +162,14 @@ static const struct latch_tree_ops mod_tree_ops = { .comp = mod_tree_comp, }; -static noinline void __mod_tree_insert(struct mod_tree_node *node) +static noinline void __mod_tree_insert(struct mod_tree_node *node, struct mod_tree_root *tree) { - latch_tree_insert(&node->node, &mod_tree.root, &mod_tree_ops); + latch_tree_insert(&node->node, &tree->root, &mod_tree_ops); } -static void __mod_tree_remove(struct mod_tree_node *node) +static void __mod_tree_remove(struct mod_tree_node *node, struct mod_tree_root *tree) { - latch_tree_erase(&node->node, &mod_tree.root, &mod_tree_ops); + latch_tree_erase(&node->node, &tree->root, &mod_tree_ops); } /* @@ -181,28 +181,28 @@ static void mod_tree_insert(struct module *mod) mod->core_layout.mtn.mod = mod; mod->init_layout.mtn.mod = mod; - __mod_tree_insert(&mod->core_layout.mtn); + __mod_tree_insert(&mod->core_layout.mtn, &mod_tree); if (mod->init_layout.size) - __mod_tree_insert(&mod->init_layout.mtn); + __mod_tree_insert(&mod->init_layout.mtn, &mod_tree); } static void mod_tree_remove_init(struct module *mod) { if (mod->init_layout.size) - __mod_tree_remove(&mod->init_layout.mtn); + __mod_tree_remove(&mod->init_layout.mtn, &mod_tree); } static void mod_tree_remove(struct module *mod) { - __mod_tree_remove(&mod->core_layout.mtn); + __mod_tree_remove(&mod->core_layout.mtn, &mod_tree); mod_tree_remove_init(mod); } -static struct module *mod_find(unsigned long addr) +static struct module *mod_find(unsigned long addr, struct mod_tree_root *tree) { struct latch_tree_node *ltn; - ltn = latch_tree_find((void *)addr, &mod_tree.root, &mod_tree_ops); + ltn = latch_tree_find((void *)addr, &tree->root, &mod_tree_ops); if (!ltn) return NULL; @@ -215,7 +215,7 @@ static void mod_tree_insert(struct module *mod) { } static void mod_tree_remove_init(struct module *mod) { } static void mod_tree_remove(struct module *mod) { } -static struct module *mod_find(unsigned long addr) +static struct module *mod_find(unsigned long addr, struct mod_tree_root *tree) { struct module *mod; @@ -234,22 +234,22 @@ static struct module *mod_find(unsigned long addr) * Bounds of module text, for speeding up __module_address. * Protected by module_mutex. */ -static void __mod_update_bounds(void *base, unsigned int size) +static void __mod_update_bounds(void *base, unsigned int size, struct mod_tree_root *tree) { unsigned long min = (unsigned long)base; unsigned long max = min + size; - if (min < module_addr_min) - module_addr_min = min; - if (max > module_addr_max) - module_addr_max = max; + if (min < tree->addr_min) + tree->addr_min = min; + if (max > tree->addr_max) + tree->addr_max = max; } static void mod_update_bounds(struct module *mod) { - __mod_update_bounds(mod->core_layout.base, mod->core_layout.size); + __mod_update_bounds(mod->core_layout.base, mod->core_layout.size, &mod_tree); if (mod->init_layout.size) - __mod_update_bounds(mod->init_layout.base, mod->init_layout.size); + __mod_update_bounds(mod->init_layout.base, mod->init_layout.size, &mod_tree); } #ifdef CONFIG_KGDB_KDB @@ -4742,7 +4742,7 @@ struct module *__module_address(unsigned long addr) module_assert_mutex_or_preempt(); - mod = mod_find(addr); + mod = mod_find(addr, &mod_tree); if (mod) { BUG_ON(!within_module(addr, mod)); if (mod->state == MODULE_STATE_UNFORMED) From patchwork Sat Jan 29 17:02:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12729564 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0C40C433F5 for ; Sat, 29 Jan 2022 17:02:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 10AD76B008C; Sat, 29 Jan 2022 12:02:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 01EEF6B0093; Sat, 29 Jan 2022 12:02:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3DE66B0096; Sat, 29 Jan 2022 12:02:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0218.hostedemail.com [216.40.44.218]) by kanga.kvack.org (Postfix) with ESMTP id BCE066B008C for ; Sat, 29 Jan 2022 12:02:10 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 66BB782EBA19 for ; Sat, 29 Jan 2022 17:02:10 +0000 (UTC) X-FDA: 79083942420.26.968EAA4 Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90052.outbound.protection.outlook.com [40.107.9.52]) by imf29.hostedemail.com (Postfix) with ESMTP id 84FB9120005 for ; Sat, 29 Jan 2022 17:02:09 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hwj5rChqPGMlOGFbzFLQkN4dUem+WT/uqY4ya483X9lX4TnF3fJkVSsW1ruP04/OiA3gTt2p/F2TTXARUb3hYHQBdo/Ni41zvoUgbE1Gr/Vx/z+M/KFHWF6XZ3H9rKVDzy33dvUAXotdJPDpxkqKJ+pr3IXjAoU3bn3eNrKS+zcbmIjGzIJtvLiTM5xt9zOSjQe4Dmba6/GTCs/nRsoIhY8TtfhPfNpBNUXIIjSBkFLZfvoVHPaP0OWxkRK0vP+3ym+UgBuj+aQ3Mb1Z5v4rHvbffMEjBoBuE6nFqS5HM3wVmz1+CQxK8VZ3HTy8PAxc+uRazC+mMjeX70YTflilpA== 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=hTNNVKGZrQ6aWs2Xbf+ccCMIkXy5woQGxkZ8cpu0eKk=; b=bElG2vwO9Gaeq/ViM3jPkXuK20heQptN/DYH+s1rD2bUsjog2P9aku6fFW2JlZW0NMf0bPWdIEuXVuZoKWMtpWj3GNW6rZDlJlJkcvr0BF0EDT7ndqxuQIUosa7pz3Xu3kSpp8WNnBmIntAWiI3lP2h+gYnrbiLPieTrRKC9CZFSgO7l3+hCNeI9vcwl4CthFJPMi3LWVj+yRV6C4ePCd3lu4zIjO8yfl8XSXLRVTHgyMlkFW5RHYmU9Vvjrgp1PUEqoUuEpiQjoafPmg/E0+/FCwBJ1wD4NuCOyHk7jWKmTss5UNV+hFELBzoEE41kz+6eLiT7gunbSpJUHXeYNwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB2584.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:1e3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Sat, 29 Jan 2022 17:02:07 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::c9a2:1db0:5469:54e1]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::c9a2:1db0:5469:54e1%6]) with mapi id 15.20.4930.020; Sat, 29 Jan 2022 17:02:07 +0000 From: Christophe Leroy To: Luis Chamberlain , Jessica Yu CC: Christophe Leroy , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "kgdb-bugreport@lists.sourceforge.net" , "linux-mm@kvack.org" , "linux-arch@vger.kernel.org" Subject: [PATCH v3 3/6] modules: Introduce data_layout Thread-Topic: [PATCH v3 3/6] modules: Introduce data_layout Thread-Index: AQHYFTHy2PWsHrGmbE6uWGTz7rHarg== Date: Sat, 29 Jan 2022 17:02:07 +0000 Message-ID: <230bfd896f24ca7a9281783aaa8c0ebfebd0bc7e.1643475473.git.christophe.leroy@csgroup.eu> References: In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c9907be1-0d72-41fd-9cb9-08d9e3491553 x-ms-traffictypediagnostic: PR0P264MB2584:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2150; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: iq97BXGY3xTjE2pQr3Bv/DGSnbK/EvvQDwaXF0hz/28ju31ugMDHkrG6Zqzu7jhP4oxiPfW8MhyLjNSUSMEM0rBNtS/OYH2ftymealO8rpDR4vv1L4+GaOVcSJfsp1BqpnPi5Qa9yItlfF5qwcfFAqYmeWgvUhk9LHap4sqEzM0DPVrC7bkUSHTvQI7eWxRb2sNTkUut+qjYn03Qqnv3I6IO+Pnr+gpyT7sqwBUdXipbYb6ut5UhH+odk3+liUYAuln66zFfWe/Jxe0HUGmIbCT1ks88TDOcSRMd4Lt3eiQPzwqHwIqUW+7Em8Q/m9UvkitqXm2CyN676dUvQzEEhBwQk0XlDqQEXNo0Hw9c6BXsAr+fii37mGqqqpCXgVk5TYntXE7SgqHMA3+otLXdEMTiA5WAWdVycB6dTDCJRG9nN6vw71ObRjMumTnMcvaktIjN8yxCQbcE1MG4ZKUp+31Ga5LsE8a1eKH9XX6X1okamO3Ko8vWP/M48ZS0FYVB6Cwq27xk5uB2nSC+Ued7Owro8MdAxFiNkj7WE21Sj+lMVB+V74Hja55QlqFriy/o/xDpTVu+PDw4vDeNyuGPoIyMK1XcnM65vXHxRz4++xXqd4WzxmGrYD5hflfCflnudzCB7IUJ1hkmxbU+7lsqnOEDba9kJujxfFCL99wfvZZ7CGqvSnRQRebF1ltUntHXoIFqsUc1dxVRWSl2Fe/Kbg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(54906003)(110136005)(6512007)(2906002)(86362001)(6486002)(508600001)(4326008)(122000001)(38100700002)(91956017)(316002)(76116006)(26005)(64756008)(6506007)(8936002)(186003)(5660300002)(44832011)(66476007)(66556008)(71200400001)(66946007)(8676002)(66446008)(83380400001)(2616005)(36756003)(38070700005)(20210929001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?0v+yEAVCI16SgamjFHO0Z3s?= =?iso-8859-1?q?bSWvruoIdxXXeoJfEMOWDUVyNlqiiVCXGGrzqXlMOkB8VgOGc0vuh51kbPLb?= =?iso-8859-1?q?I9MhsSP0RI1e1v+yFb09oFn9FQHkZk61fwzvM6LlaprgffxUqza9wYlOz5YT?= =?iso-8859-1?q?vwvy60ZI2ZgqQQXeYbmqu5WynrXq0l8XukqaMzxhx8rtaZpDKLdVmW1b6POg?= =?iso-8859-1?q?sfZFWbyaTO12IYoTQZfTw/yiw0I0XWGB8/Z0zxEj92lDGNvIfAsS5cyWfKaU?= =?iso-8859-1?q?rMyBP+LBUMkImkln9XCcqqqehxHUdtYVVkch8EzrTPqd5PmmJLEQm6cnFvV8?= =?iso-8859-1?q?NW1biP6gBZ72oPQYdAGN4LSbYB6YLNdyxb6XLmm8bZLFJXnCN/p/FbVtfHM+?= =?iso-8859-1?q?cF4wsUlL5NG3dANQgQ3QnH3IkULgyyhOPhT2wbaPe5lSrpWBUZSBl7m82YSA?= =?iso-8859-1?q?mQAxajosroc+jUmgz6E4rnhI6NZ9cRRN/+qvxx/KzxTsItrL1ZCA5fTsBjLN?= =?iso-8859-1?q?KwVNu0o2JCB54pCiW7E2NA+pKSLEt+ns5H/iBLpDifmMdyYeXT+BH46YxZez?= =?iso-8859-1?q?t8rq/G1S1MiPv892R51nw5NJH/NMUotFQsZeD5wZfTzzaOM/FZU6KlGT+Jrm?= =?iso-8859-1?q?pnP9E4wIeo60H4tQDZztrlIPnB5sGSZZNQB7yBERhKH1wC3gWuKEoNUXqN2V?= =?iso-8859-1?q?tOILBwQ3pKp7w0qY+ACAQyq5a0xxTZvMzBB+N5Lb8+ZGCfkW3772TCEgFQ4s?= =?iso-8859-1?q?qh6UQl+Rdw/5yNfCKG1sbctk6n2xyRVwTzxOqyx51CrHo32Aw1yG836OnDuP?= =?iso-8859-1?q?WP7+Yoee7ODrWqudaCIHPkFQfpQVxDaygsVs9NGhQwKBeis0i8oD1iQjdwcR?= =?iso-8859-1?q?frnoyi6jqXdlhxp2aUWMyGiW2JyAlEhA+QW4C2Xl1ReMDirnS0ShXf2LbvzT?= =?iso-8859-1?q?CCHHubtxErS2PwOjGnq7oY8iZK8KPt3brPZ0qlUq4bM2Lz52D1GzbcYG0P2R?= =?iso-8859-1?q?lZr4/YvtWyD5iDiUn9cdCS2IoEZ/IuSIqPdYS2nBVLihjFOQBJDw8eP4rIPO?= =?iso-8859-1?q?t0+pxdju4GNU5rxFe/aL0F2MmdYMYvZ090TdbwTqmEMNYM/FZG1CwwL8B56t?= =?iso-8859-1?q?YAkjlYI3HxHYYNt31Hbb91SbIuPhxZ381cD5ySzlZMM1L+m2IQPwvn1MUz0J?= =?iso-8859-1?q?Kr7x4HoAf7SEWRkJVWpU05C/0xqf1sd8tiakf5G3UufzUjs/gEIoxGN7s6F+?= =?iso-8859-1?q?J+RazPPJnWCcK72fFzuc9POU+c/SzPDBtcDjac+AjnYaTFTYPCzMAwitzE8A?= =?iso-8859-1?q?XHK3+kTPF0el+14O8YIju1YEB9d3MPGeI+9dhBPEaEpuAFLZV/RGRwLNqfiA?= =?iso-8859-1?q?FWdRa9N14T8kSyrhiXv8saJwTv1YAuy/FWXAnCYI0fSB6IcyzSTBgOvCdiPp?= =?iso-8859-1?q?Xvq+7xCaal67J6RZ3Vw3D306c1L49dshqG9cbcm+bZqaRwjGccwOfAgWj31h?= =?iso-8859-1?q?VEnxi2wGVqIOPV9jqopKCQRwI68DUclJs+GEz29MdlCQEtuWey+1//7jG6Nh?= =?iso-8859-1?q?pF+JT9gTRKomymW0344FN6fKJB2J7X38saYUOpTJSnUaXWJe60+d6M5rmUBx?= =?iso-8859-1?q?I/FUQDTiBAKArkh14CN6Na/4iNKR8fO+zB0qta4ulnpC9IHh7oNtumVvf8SE?= =?iso-8859-1?q?pVGB6CVcGPS5Gkch0hYpFSTcovPizmbBb2p6u5hVSFSaUIOEqCkTn6d1Jnzm?= =?iso-8859-1?q?rQCI=3D?= MIME-Version: 1.0 X-OriginatorOrg: csgroup.eu X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: c9907be1-0d72-41fd-9cb9-08d9e3491553 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jan 2022 17:02:07.8773 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9914def7-b676-4fda-8815-5d49fb3b45c8 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: HyP7tzVeMg8dYNazcxzKki42tPitgbR/rJB6c4nNvHriB4MJ7VrMUIU8YMwX0aU+X8RzfSW5eodI+mWlmnNssZc4F+6pO+gjZihvr6mVRyg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB2584 X-Rspam-User: nil X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 84FB9120005 X-Stat-Signature: 8qdfeec1pf68itiq4iak4syt3wtxf3zi Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf29.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.9.52 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-HE-Tag: 1643475729-862778 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In order to allow separation of data from text, add another layout, called data_layout. For architectures requesting separation of text and data, only text will go in core_layout and data will go in data_layout. For architectures which keep text and data together, make data_layout an alias of core_layout, that way data_layout can be used for all data manipulations, regardless of whether data is in core_layout or data_layout. Signed-off-by: Christophe Leroy --- kernel/module.c | 52 ++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 163e32e39064..11f51e17fb9f 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -81,6 +81,8 @@ /* If this is set, the section belongs in the init part of the module */ #define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1)) +#define data_layout core_layout + /* * Mutex protects: * 1) List of modules (also safely readable with preempt_disable), @@ -2014,19 +2016,20 @@ static void module_enable_ro(const struct module *mod, bool after_init) set_vm_flush_reset_perms(mod->init_layout.base); frob_text(&mod->core_layout, set_memory_ro); - frob_rodata(&mod->core_layout, set_memory_ro); + frob_rodata(&mod->data_layout, set_memory_ro); + frob_text(&mod->init_layout, set_memory_ro); frob_rodata(&mod->init_layout, set_memory_ro); if (after_init) - frob_ro_after_init(&mod->core_layout, set_memory_ro); + frob_ro_after_init(&mod->data_layout, set_memory_ro); } static void module_enable_nx(const struct module *mod) { - frob_rodata(&mod->core_layout, set_memory_nx); - frob_ro_after_init(&mod->core_layout, set_memory_nx); - frob_writable_data(&mod->core_layout, set_memory_nx); + frob_rodata(&mod->data_layout, set_memory_nx); + frob_ro_after_init(&mod->data_layout, set_memory_nx); + frob_writable_data(&mod->data_layout, set_memory_nx); frob_rodata(&mod->init_layout, set_memory_nx); frob_writable_data(&mod->init_layout, set_memory_nx); } @@ -2204,7 +2207,7 @@ static void free_module(struct module *mod) percpu_modfree(mod); /* Free lock-classes; relies on the preceding sync_rcu(). */ - lockdep_free_key_range(mod->core_layout.base, mod->core_layout.size); + lockdep_free_key_range(mod->data_layout.base, mod->data_layout.size); /* Finally, free the core (containing the module structure) */ module_memfree(mod->core_layout.base); @@ -2451,7 +2454,10 @@ static void layout_sections(struct module *mod, struct load_info *info) || s->sh_entsize != ~0UL || module_init_layout_section(sname)) continue; - s->sh_entsize = get_offset(mod, &mod->core_layout.size, s, i); + if (m) + s->sh_entsize = get_offset(mod, &mod->data_layout.size, s, i); + else + s->sh_entsize = get_offset(mod, &mod->core_layout.size, s, i); pr_debug("\t%s\n", sname); } switch (m) { @@ -2460,15 +2466,15 @@ static void layout_sections(struct module *mod, struct load_info *info) mod->core_layout.text_size = mod->core_layout.size; break; case 1: /* RO: text and ro-data */ - mod->core_layout.size = debug_align(mod->core_layout.size); - mod->core_layout.ro_size = mod->core_layout.size; + mod->data_layout.size = debug_align(mod->data_layout.size); + mod->data_layout.ro_size = mod->data_layout.size; break; case 2: /* RO after init */ - mod->core_layout.size = debug_align(mod->core_layout.size); - mod->core_layout.ro_after_init_size = mod->core_layout.size; + mod->data_layout.size = debug_align(mod->data_layout.size); + mod->data_layout.ro_after_init_size = mod->data_layout.size; break; case 4: /* whole core */ - mod->core_layout.size = debug_align(mod->core_layout.size); + mod->data_layout.size = debug_align(mod->data_layout.size); break; } } @@ -2721,12 +2727,12 @@ static void layout_symtab(struct module *mod, struct load_info *info) } /* Append room for core symbols at end of core part. */ - info->symoffs = ALIGN(mod->core_layout.size, symsect->sh_addralign ?: 1); - info->stroffs = mod->core_layout.size = info->symoffs + ndst * sizeof(Elf_Sym); - mod->core_layout.size += strtab_size; - info->core_typeoffs = mod->core_layout.size; - mod->core_layout.size += ndst * sizeof(char); - mod->core_layout.size = debug_align(mod->core_layout.size); + info->symoffs = ALIGN(mod->data_layout.size, symsect->sh_addralign ?: 1); + info->stroffs = mod->data_layout.size = info->symoffs + ndst * sizeof(Elf_Sym); + mod->data_layout.size += strtab_size; + info->core_typeoffs = mod->data_layout.size; + mod->data_layout.size += ndst * sizeof(char); + mod->data_layout.size = debug_align(mod->data_layout.size); /* Put string table section at end of init part of module. */ strsect->sh_flags |= SHF_ALLOC; @@ -2770,9 +2776,9 @@ static void add_kallsyms(struct module *mod, const struct load_info *info) * Now populate the cut down core kallsyms for after init * and set types up while we still have access to sections. */ - mod->core_kallsyms.symtab = dst = mod->core_layout.base + info->symoffs; - mod->core_kallsyms.strtab = s = mod->core_layout.base + info->stroffs; - mod->core_kallsyms.typetab = mod->core_layout.base + info->core_typeoffs; + mod->core_kallsyms.symtab = dst = mod->data_layout.base + info->symoffs; + mod->core_kallsyms.strtab = s = mod->data_layout.base + info->stroffs; + mod->core_kallsyms.typetab = mod->data_layout.base + info->core_typeoffs; src = mod->kallsyms->symtab; for (ndst = i = 0; i < mod->kallsyms->num_symtab; i++) { mod->kallsyms->typetab[i] = elf_type(src + i, info); @@ -3468,6 +3474,8 @@ static int move_module(struct module *mod, struct load_info *info) if (shdr->sh_entsize & INIT_OFFSET_MASK) dest = mod->init_layout.base + (shdr->sh_entsize & ~INIT_OFFSET_MASK); + else if (!(shdr->sh_flags & SHF_EXECINSTR)) + dest = mod->data_layout.base + shdr->sh_entsize; else dest = mod->core_layout.base + shdr->sh_entsize; @@ -4173,7 +4181,7 @@ static int load_module(struct load_info *info, const char __user *uargs, mutex_unlock(&module_mutex); free_module: /* Free lock-classes; relies on the preceding sync_rcu() */ - lockdep_free_key_range(mod->core_layout.base, mod->core_layout.size); + lockdep_free_key_range(mod->data_layout.base, mod->data_layout.size); module_deallocate(mod, info); free_copy: From patchwork Sat Jan 29 17:02:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12729565 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12EFEC433F5 for ; Sat, 29 Jan 2022 17:02:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 839616B0093; Sat, 29 Jan 2022 12:02:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E5D86B0098; Sat, 29 Jan 2022 12:02:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 615F76B009A; Sat, 29 Jan 2022 12:02:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 480A26B0093 for ; Sat, 29 Jan 2022 12:02:13 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 06D8F96F2E for ; Sat, 29 Jan 2022 17:02:13 +0000 (UTC) X-FDA: 79083942546.28.3EC4591 Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90048.outbound.protection.outlook.com [40.107.9.48]) by imf31.hostedemail.com (Postfix) with ESMTP id 1757720008 for ; Sat, 29 Jan 2022 17:02:11 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B3vmdGU9OT7OB/MYVJaa+tbQvlzwOrT4puKAHnpdn1AiEarF24YZtYxZHXAPCQSFRwhSCaI9GqOkGLDbo/aXvcOEYe0CVEVplZuLTGxp1iHmjHmJIcMoTNlK0FoSeOGEaxcNp9C6mL6GQU3FnHjoaLpNGgmKhv8AIXFIkjuM/qFeyGtRsMGjuXHN1cdXMlQfS2laTY3MWhiju+5EDuOOVVbmJRxh1ynZ3R8Mx7ZVhjAgKG+8XKoZ4FQIgRdLdPYzKtRAyCG9Zm0yIxXPgR+8yRYMqWu39EAp08Tq5re5Z+3OJtCnOzHmsa06V9baN339pOm023dQmVmnTl3nhreSbA== 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=crTqMyovasbkWf6JTa5Z5LTj9nH5kwhkV4dOns1N6Sg=; b=RvmlA8m/kH5k7lFEcqcfqcekTY/ENvTpdSiw2b/MNbVW34fF8/CRNJn9n/2XJwBBgPNmyTnSNhjM9zKaOQMhVFFZ7NRRe3yH49OIH32cy34MzoWTNnemwUExthqvf9Q0e6qPSTZe6XPVdYHpyTMd6In+yD1f41K1tLpFQa9yqVyrrkBW5dmVqzt9o9RkD3GewhgDGTb/s7SonoFt24zIcxqmuNIW8nuwUVGXP3tDGp6C5BE7lUxC6sOK+ITJhonX6C9wrTb7hH+RJktgvLj10t4AZhKYrSeRhJxv7W1Nt8aKlLsOTFcIChR/TcAVt2IN12SRLryLaCuZewdahWx8KA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB2584.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:1e3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Sat, 29 Jan 2022 17:02:10 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::c9a2:1db0:5469:54e1]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::c9a2:1db0:5469:54e1%6]) with mapi id 15.20.4930.020; Sat, 29 Jan 2022 17:02:10 +0000 From: Christophe Leroy To: Luis Chamberlain , Jessica Yu CC: Christophe Leroy , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "kgdb-bugreport@lists.sourceforge.net" , "linux-mm@kvack.org" , "linux-arch@vger.kernel.org" , Jason Wessel , Daniel Thompson , Douglas Anderson Subject: [PATCH v3 4/6] modules: Add CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC Thread-Topic: [PATCH v3 4/6] modules: Add CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC Thread-Index: AQHYFTH0u+jifZZUEUq40HXmKIXLkw== Date: Sat, 29 Jan 2022 17:02:09 +0000 Message-ID: References: In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ddbe221b-971b-47af-40bb-08d9e349168e x-ms-traffictypediagnostic: PR0P264MB2584:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3383; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 81Nogny3zzE33mGpi3yTKAQH4HoJqw+dd7xMQlVBGn78NQBufriYftcyv+o6lTNbI2+9jvHOqJB4bzXrNtd7xJI/dh1H+3rxo4PI12JBto6WqXKcWjOA1ubB/z+mkW8PgTXFVvLSzsbjBbVShmZVQ+FDBKHT4HrfilqPrrFpKQHdRrfKi87S+4F95lWTTewnMDmDBN0wZmuXaBXJIBZRyNoerIHhrhk6dITA4XlNiKP4xZ3LB3hOz85Pe2s19j548yBcLC7NHij2cvBdldxYeUfcjcuaCkybg6EsetAOlecF928CMeuZa7khJq1Z3Y90rLlHoKeypF0UvKCnWXA/tkH444rSgsJLzzOUlf+KRw6OjBddFkqaree9xgcGxU7zBXq/dK3DpIPQKPB+DuqnzQ/4OxIa+3S+BPVMIUJpcIUjy1+yEg/MyjkKLzhdBXdgC2GIhnF05XyOe4yDM3iWUGK9YdQMmr9hJ4ETWmCA6A7snHpvIvuXD+fISQZT/mvkA/tPM3cVvCjVtc4HM7Hm/N86xYgXIjppHrQXscm9Y32k6ScLi4qAd4kMwUUp8/Ik6DzTH3Cc3nGmWr4K5M6VPG7FIe4jS142+P5cfGxUxnf/OEdJN9DHhgyHDAmZ+fTpbubh3NRtWpfzDfzajAO76aS5KJUhmbNsVZD4cxt399r/piJY/Pdpp/AwnKPIj/ET5WU9MB96chmlo1XlUlELAg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(54906003)(110136005)(6512007)(2906002)(86362001)(6486002)(508600001)(4326008)(122000001)(38100700002)(91956017)(316002)(76116006)(26005)(64756008)(6506007)(8936002)(186003)(5660300002)(44832011)(66476007)(66556008)(71200400001)(66946007)(8676002)(66446008)(83380400001)(2616005)(7416002)(36756003)(38070700005)(20210929001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?hPMAGi1c1Tj4eLLUWSODeE4?= =?iso-8859-1?q?5lh04b5tZx4xglgzRiUEY1BAHSyMESF2RzlHeyd7GRzqyagApBOWqSryASrg?= =?iso-8859-1?q?zawSqD2HRJfYAkd0vWE3k7KnU5IxHVVOTrdqr2diBiKyj6llqBF6lQLZ9SGt?= =?iso-8859-1?q?+PE6hzpmXUL7H++X6dH7n81kCAMfUE8XcQcGPb7l8BtX7TTKiSZDNJsPT7YP?= =?iso-8859-1?q?ieu0CwlGKcTJltL/FAh5vn9K6fyPlo+3/URTvt87TQf4lIiS0N3zj0pZfnes?= =?iso-8859-1?q?nMmmm4EliOMgJI7iXwpp8dMbrRw60Vu+dfDdRuuSL2cGb0CJXoN0Q0jUcRDS?= =?iso-8859-1?q?n/un0qhaUt/DpgWblaEwHYgmif/V5HuW38/c1vfQTr/0M0kN3yOtBYf4HI1F?= =?iso-8859-1?q?3UJD878TW6ljoAwHeFOJf1ao99WipA247mEwjTKVzrY2eksbP5zGwy5SuFRh?= =?iso-8859-1?q?8vAL87xSoMQFpJwS3faEId/FUlNisX1+o2ZoLvinHWDFctLYnnHW6XoqsWoD?= =?iso-8859-1?q?djChvpkMfRRBop2ekCgfiA01muIgFnUUv4EIyDVjaeJVR3LvUK8t/KN3U/jO?= =?iso-8859-1?q?eeAd2qS3GfekIWEOQ97djFz0vODCBDpvLlM8P5M5K89PAUVKQRLzU4Gfypcp?= =?iso-8859-1?q?J8BsqIrNedUnfYIt4hfvfqGN552FqTZx8QHXhQxxz7Om5p9QbZYJc7XjuGYX?= =?iso-8859-1?q?E0fEUTnBK2lzsCC9t9b1Tn6JcttUVY53wYNMUTSsalQNeKI9GEKAt0HbGkXy?= =?iso-8859-1?q?HXNSietMNT3Pk5vk10TGQq9HN/wSiGOgovtIi3HLJylpcZChB0vLs/SjimC/?= =?iso-8859-1?q?5XTZQBni34akEGCINURgZoLmFWTIi+jo2U5lsGwzdOdXO/62JLeZYPk+e9XI?= =?iso-8859-1?q?VHDhi1u1Q48SqvgJurCJ9VExxCjX0m+Lv9WYTAY7uYA0f3Z7tam41LtGq7ug?= =?iso-8859-1?q?IvI+5kauxFgr6/V0TgvdYdqY0pYIA6uHFH6E0X7XaYpA55ILRdQY3PmXleON?= =?iso-8859-1?q?dE3FNIkwo7QP+ljeIz8efWyO3NASe4BlEbWc1sODxSTyRmcCZzrlKzUXstuM?= =?iso-8859-1?q?UGyzsSSkh0tmCYEb88zSZgEaDFOxgFx9FStUDGObfikbP5pLocX3q/1ag7uu?= =?iso-8859-1?q?P+HJv4+UmebcfcefoEYcct63h2h3Ufl8CpZGTKiZ0b2p7zKsYf1Wuu8Stxxm?= =?iso-8859-1?q?ikOtfkyPRhdynU93a2olWB4/TLOFt646LVPPC12ACiWKB7Hu5vAfsvo6gEME?= =?iso-8859-1?q?xbdsvMh2lgisBMCiSTwjz9Ac2aiz6tAlytl4/5JISIOw7WYR6ViuSSal5YGx?= =?iso-8859-1?q?p3MSNfJg6284I2hy+opcrwAfxLKi+NQmOAkCUhR8MYL/ZSeGK+ci6eiDdsA+?= =?iso-8859-1?q?3qaJwrYsx5VVO9MY3fro/sCq+cbvPx2V71kGwU/c/jwSqRODZ0EatbXnx6vy?= =?iso-8859-1?q?gqRuO+iLnwfCBbz68hnN6h2VnuOYVuca/IaU9H/hlK9LGI5rjsgntuKB6hBq?= =?iso-8859-1?q?Mdg1FHYA3rZ04PSRTxfpxfvHlObiK2OVaVg3ZDOqTwvf9End+6Vlu9c4RXlS?= =?iso-8859-1?q?CCuHQLw0iWYXujaRLqf5oeVocNhf5jrpvRmSWcR9Aaw3aJIACpg5ey2d+xpB?= =?iso-8859-1?q?opVLLPjYCJSSaFfaHQbkY/N7VW9Khajpp+lXa5sQ2CnrZXfDoR0WBI41Tb2k?= =?iso-8859-1?q?VW+6+k83Mx9e1zd8DLcn8BlNJ517P3lJC7VJm9HA4WCPLTT9sRh/EDTk9URe?= =?iso-8859-1?q?BD9k=3D?= MIME-Version: 1.0 X-OriginatorOrg: csgroup.eu X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: ddbe221b-971b-47af-40bb-08d9e349168e X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jan 2022 17:02:09.9706 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9914def7-b676-4fda-8815-5d49fb3b45c8 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: VT5hpRGjfKO5EqpTKSJ+gYAbAc3k48b+eXU06Vv08gaSjQgUfbcWXPRuN2vQ/DNudUHXvH4CTwGl3HBsWUJRJ0dD/j4APEiusCE7tqkCudc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB2584 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1757720008 X-Stat-Signature: ki69hjyxjbmfrp65surg51o6ykwssc6b X-Rspam-User: nil Authentication-Results: imf31.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf31.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.9.48 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-HE-Tag: 1643475731-822262 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC to allow architectures to request having modules data in vmalloc area instead of module area. This is required on powerpc book3s/32 in order to set data non executable, because it is not possible to set executability on page basis, this is done per 256 Mbytes segments. The module area has exec right, vmalloc area has noexec. This can also be useful on other powerpc/32 in order to maximize the chance of code being close enough to kernel core to avoid branch trampolines. Signed-off-by: Christophe Leroy Cc: Jason Wessel Acked-by: Daniel Thompson Cc: Douglas Anderson --- arch/Kconfig | 6 +++ include/linux/module.h | 8 ++++ kernel/debug/kdb/kdb_main.c | 10 ++++- kernel/module.c | 76 +++++++++++++++++++++++++++++++++++-- 4 files changed, 94 insertions(+), 6 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index 678a80713b21..b5d1f2c19c27 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -882,6 +882,12 @@ config MODULES_USE_ELF_REL Modules only use ELF REL relocations. Modules with ELF RELA relocations will give an error. +config ARCH_WANTS_MODULES_DATA_IN_VMALLOC + bool + help + For architectures like powerpc/32 which have constraints on module + allocation and need to allocate module data outside of module area. + config HAVE_IRQ_EXIT_ON_IRQ_STACK bool help diff --git a/include/linux/module.h b/include/linux/module.h index 1e135fd5c076..3a892bdcbb5f 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -422,6 +422,9 @@ struct module { /* Core layout: rbtree is accessed frequently, so keep together. */ struct module_layout core_layout __module_layout_align; struct module_layout init_layout; +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC + struct module_layout data_layout; +#endif /* Arch-specific module values */ struct mod_arch_specific arch; @@ -569,6 +572,11 @@ bool is_module_text_address(unsigned long addr); static inline bool within_module_core(unsigned long addr, const struct module *mod) { +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC + if ((unsigned long)mod->data_layout.base <= addr && + addr < (unsigned long)mod->data_layout.base + mod->data_layout.size) + return true; +#endif return (unsigned long)mod->core_layout.base <= addr && addr < (unsigned long)mod->core_layout.base + mod->core_layout.size; } diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index 0852a537dad4..85d3fd40b7fe 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c @@ -2022,8 +2022,11 @@ static int kdb_lsmod(int argc, const char **argv) if (mod->state == MODULE_STATE_UNFORMED) continue; - kdb_printf("%-20s%8u 0x%px ", mod->name, - mod->core_layout.size, (void *)mod); + kdb_printf("%-20s%8u", mod->name, mod->core_layout.size); +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC + kdb_printf("/%8u", mod->data_layout.size); +#endif + kdb_printf(" 0x%px ", (void *)mod); #ifdef CONFIG_MODULE_UNLOAD kdb_printf("%4d ", module_refcount(mod)); #endif @@ -2034,6 +2037,9 @@ static int kdb_lsmod(int argc, const char **argv) else kdb_printf(" (Live)"); kdb_printf(" 0x%px", mod->core_layout.base); +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC + kdb_printf("/0x%px", mod->data_layout.base); +#endif #ifdef CONFIG_MODULE_UNLOAD { diff --git a/kernel/module.c b/kernel/module.c index 11f51e17fb9f..f3758115ebaa 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -81,7 +81,9 @@ /* If this is set, the section belongs in the init part of the module */ #define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1)) +#ifndef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC #define data_layout core_layout +#endif /* * Mutex protects: @@ -111,6 +113,12 @@ static struct mod_tree_root { #define module_addr_min mod_tree.addr_min #define module_addr_max mod_tree.addr_max +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC +static struct mod_tree_root mod_data_tree __cacheline_aligned = { + .addr_min = -1UL, +}; +#endif + #ifdef CONFIG_MODULES_TREE_LOOKUP /* @@ -186,6 +194,11 @@ static void mod_tree_insert(struct module *mod) __mod_tree_insert(&mod->core_layout.mtn, &mod_tree); if (mod->init_layout.size) __mod_tree_insert(&mod->init_layout.mtn, &mod_tree); + +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC + mod->data_layout.mtn.mod = mod; + __mod_tree_insert(&mod->data_layout.mtn, &mod_data_tree); +#endif } static void mod_tree_remove_init(struct module *mod) @@ -198,6 +211,9 @@ static void mod_tree_remove(struct module *mod) { __mod_tree_remove(&mod->core_layout.mtn, &mod_tree); mod_tree_remove_init(mod); +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC + __mod_tree_remove(&mod->data_layout.mtn, &mod_data_tree); +#endif } static struct module *mod_find(unsigned long addr, struct mod_tree_root *tree) @@ -252,6 +268,9 @@ static void mod_update_bounds(struct module *mod) __mod_update_bounds(mod->core_layout.base, mod->core_layout.size, &mod_tree); if (mod->init_layout.size) __mod_update_bounds(mod->init_layout.base, mod->init_layout.size, &mod_tree); +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC + __mod_update_bounds(mod->data_layout.base, mod->data_layout.size, &mod_data_tree); +#endif } #ifdef CONFIG_KGDB_KDB @@ -1181,6 +1200,17 @@ static ssize_t show_coresize(struct module_attribute *mattr, static struct module_attribute modinfo_coresize = __ATTR(coresize, 0444, show_coresize, NULL); +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC +static ssize_t show_datasize(struct module_attribute *mattr, + struct module_kobject *mk, char *buffer) +{ + return sprintf(buffer, "%u\n", mk->mod->data_layout.size); +} + +static struct module_attribute modinfo_datasize = + __ATTR(datasize, 0444, show_datasize, NULL); +#endif + static ssize_t show_initsize(struct module_attribute *mattr, struct module_kobject *mk, char *buffer) { @@ -1209,6 +1239,9 @@ static struct module_attribute *modinfo_attrs[] = { &modinfo_srcversion, &modinfo_initstate, &modinfo_coresize, +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC + &modinfo_datasize, +#endif &modinfo_initsize, &modinfo_taint, #ifdef CONFIG_MODULE_UNLOAD @@ -2211,6 +2244,9 @@ static void free_module(struct module *mod) /* Finally, free the core (containing the module structure) */ module_memfree(mod->core_layout.base); +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC + vfree(mod->data_layout.base); +#endif } void *__symbol_get(const char *symbol) @@ -3462,6 +3498,24 @@ static int move_module(struct module *mod, struct load_info *info) } else mod->init_layout.base = NULL; +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC + /* Do the allocs. */ + ptr = vmalloc(mod->data_layout.size); + /* + * The pointer to this block is stored in the module structure + * which is inside the block. Just mark it as not being a + * leak. + */ + kmemleak_not_leak(ptr); + if (!ptr) { + module_memfree(mod->core_layout.base); + module_memfree(mod->init_layout.base); + return -ENOMEM; + } + + memset(ptr, 0, mod->data_layout.size); + mod->data_layout.base = ptr; +#endif /* Transfer each section which specifies SHF_ALLOC */ pr_debug("final section addresses:\n"); for (i = 0; i < info->hdr->e_shnum; i++) { @@ -3637,6 +3691,9 @@ static void module_deallocate(struct module *mod, struct load_info *info) module_arch_freeing_init(mod); module_memfree(mod->init_layout.base); module_memfree(mod->core_layout.base); +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC + vfree(mod->data_layout.base); +#endif } int __weak module_finalize(const Elf_Ehdr *hdr, @@ -4615,13 +4672,17 @@ static int m_show(struct seq_file *m, void *p) struct module *mod = list_entry(p, struct module, list); char buf[MODULE_FLAGS_BUF_SIZE]; void *value; + unsigned int size; /* We always ignore unformed modules. */ if (mod->state == MODULE_STATE_UNFORMED) return 0; - seq_printf(m, "%s %u", - mod->name, mod->init_layout.size + mod->core_layout.size); + size = mod->init_layout.size + mod->core_layout.size; +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC + size += mod->data_layout.size; +#endif + seq_printf(m, "%s %u", mod->name, size); print_unload_info(m, mod); /* Informative for users. */ @@ -4744,13 +4805,20 @@ bool is_module_address(unsigned long addr) struct module *__module_address(unsigned long addr) { struct module *mod; + struct mod_tree_root *tree; - if (addr < module_addr_min || addr > module_addr_max) + if (addr >= mod_tree.addr_min && addr <= mod_tree.addr_max) + tree = &mod_tree; +#ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC + else if (addr >= mod_data_tree.addr_min && addr <= mod_data_tree.addr_max) + tree = &mod_data_tree; +#endif + else return NULL; module_assert_mutex_or_preempt(); - mod = mod_find(addr, &mod_tree); + mod = mod_find(addr, tree); if (mod) { BUG_ON(!within_module(addr, mod)); if (mod->state == MODULE_STATE_UNFORMED) From patchwork Sat Jan 29 17:02:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12729566 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 285D6C4332F for ; Sat, 29 Jan 2022 17:02:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32D686B009C; Sat, 29 Jan 2022 12:02:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B57C6B009B; Sat, 29 Jan 2022 12:02:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0439F6B009C; Sat, 29 Jan 2022 12:02:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0241.hostedemail.com [216.40.44.241]) by kanga.kvack.org (Postfix) with ESMTP id E2CDD6B0098 for ; Sat, 29 Jan 2022 12:02:15 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9DD1F182371AF for ; Sat, 29 Jan 2022 17:02:15 +0000 (UTC) X-FDA: 79083942630.27.3C31B0D Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90048.outbound.protection.outlook.com [40.107.9.48]) by imf31.hostedemail.com (Postfix) with ESMTP id E51682000C for ; Sat, 29 Jan 2022 17:02:12 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kfxnno3faHvx2fwiaznYxZtZy8CTLiUNu2yAfOdgGp1ZUaKP0cJAFCnVw1iOC8WsynOFdMieHkV/0/H/zd0xnHD/2bw9gHpB85GhN30dHZFbkB7Pa6Pq9RQrcWqDYKjnT8h1aF1dFeEviDIybgXfuNe532CwjYeF2yDw2wJ67rtRhM03rbU7oFY2bANDtNagOpok7yfMNZdwL09xsRr02bJhF3TrTbGQf5qv1RG8eeYutNcw88hlC67CIX2i7dZHpkxTs1zluL+bmmiP/oXcIpA+qn658GUTio/4Qbw0HJlO5PM9hZFu/LWM6awNrzLxDSbh6CZm4E5HV5ulCT6lUQ== 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=cSCVxbuJ7b2G/qI76FRabVmCoG6DxICmPOKkKXiqnaE=; b=XDFUgHhTCjrG9AaU2ADWqLJQIEuQkV3TiCvYvw0cGnwZlYw1MI0wkNS2pfNDYCU9APmTMX+92FOYL/12vwILKKpCRiDVMu+OT3UcNjxk2841Jy54zpCYeQAZvbx6Fjpa0re4k9fxOScBshC1lene3bIpa1KpM7HaJId5Z7ImKxtBEBAXNx/dRjglnbfEiPnhAEk41VMC3YZvLRyS7Tz/f2UiwoYpI5IOu2FVXIaNMD3ODyWNiprCt+pTlaXtqnZ6n9dKwlSmZ/S9NBhNTKRBH2K7U7+U/S81v0dP/8XIGOkhkfnW3OgyTs7Y+kuWkEb1v1l+GR4/UMUpeCOqq/gp3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB2584.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:1e3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Sat, 29 Jan 2022 17:02:11 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::c9a2:1db0:5469:54e1]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::c9a2:1db0:5469:54e1%6]) with mapi id 15.20.4930.020; Sat, 29 Jan 2022 17:02:11 +0000 From: Christophe Leroy To: Luis Chamberlain , Jessica Yu CC: Christophe Leroy , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "kgdb-bugreport@lists.sourceforge.net" , "linux-mm@kvack.org" , "linux-arch@vger.kernel.org" Subject: [PATCH v3 5/6] modules: Remove module_addr_min and module_addr_max Thread-Topic: [PATCH v3 5/6] modules: Remove module_addr_min and module_addr_max Thread-Index: AQHYFTH1Li2/03ycxU6FcE0z+2fkwA== Date: Sat, 29 Jan 2022 17:02:11 +0000 Message-ID: <344a86345b2ad9ec5ce69775c914e508b789b197.1643475473.git.christophe.leroy@csgroup.eu> References: In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2b97d94e-295b-4230-011b-08d9e34917b6 x-ms-traffictypediagnostic: PR0P264MB2584:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:324; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: InQqnK9QVAeF9bJywjERHADoIiE8o2cRxckK/XoQTCMwdVTNe9zrDTyLo/pLwXwcV7FTbVfkPWLCEWgAOgts0E/KMzDIdsAuipa14KbD74ttbIX0ZPq5W/Bq/iLhsuSqTqzWOMnD64rFjnDx5ajFhWQKLeLcNx+7HShWWQBcCEBzO7N3sv1nO486gbC01MmSOC4Os5Y3+rU9z9/GX99lHUc3Skky4Zm/HgDBpvmJctUlVvZOEEs0GQPYhnRNPNHy/49wwx2A92dXbcDqCssxWntB9ZUUYAB5XknjRNEwYvFwTDl6+xs6a9C4R/aXc+F3HdowzFpZ8VmEotHTC90hHDzyfJxVRhi6f0RrI1gH5qXSyf1PDqmb1x18XSd5ko26EWWN2TEdclaEpUeMyA11y58/JuFTlLGOLhD2136LQUQit6YymL3DA3l4Gw9IGgW6fl6qkQ7qTZRwXimAG8DEBCH4ROpsnhLpB4iz4T9oomEbP+KqEC1CXchiSIbNKj9n+uFgvswJX5ZdsFsYgcXw7H+Ex9XLywhvfs8MuRlNADHQIIWnZ94kGYy2CEp/kUc16YGREQ241QV4CYoGDH63itmCyjKpVFzYL+LNxSGRvj/rzfyQqoJ5PeFJDc8jmnj8DVnMi96q8IkQ4eyWSbn0RFmdpfl0APoo8n+hMF7fU9x68d2NNlCVqU5Gbj7XH31BYaGcSPE7+xZK291AMy47Gw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(54906003)(110136005)(6512007)(2906002)(86362001)(6486002)(508600001)(4326008)(122000001)(38100700002)(91956017)(316002)(76116006)(26005)(64756008)(6506007)(8936002)(186003)(5660300002)(44832011)(66476007)(66556008)(71200400001)(66946007)(8676002)(66446008)(83380400001)(2616005)(36756003)(38070700005)(20210929001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?NOn5/vUngpqkvWl0LLfOalA?= =?iso-8859-1?q?C82YxB+A+eibdNifl/a6LmzEfI89ZKpAow3miBRGIADCuIjAJy2OzWy83ED2?= =?iso-8859-1?q?Tc9ekvu+fxp+ZXqfhs0FNtwsjtM8TyWFqcvyGSZ768gOg6G6KqoniOLed8mR?= =?iso-8859-1?q?oW3vQABC75JUDIz+/Xpsl7fUqFJ5MugeN7dAjVo+OwQhEZmeW/BB5Q9k3kk+?= =?iso-8859-1?q?J7FX7n8mTDGKW6Uw3pdyNQ7sKOrLItYcUjDSgbnB9OoRGoWu2RNcqPOpspHA?= =?iso-8859-1?q?lFM1px8JFGQ0eEQV+Xvs7My2sHCBbMc0jZ7l7T6ZgS7CH4Udi+To0EfdZWgo?= =?iso-8859-1?q?K7ZAtKJJ7P0PXkNDb3WiYQJ49Z0QTmydcBwSLS+nroSbZ2P2s4mG+yY3HxTH?= =?iso-8859-1?q?Ijx3e9EVwAZEZlo8aMJ1bhoPgbRbGm5niEpjmPp4VHgxdrDQeWhLtmnKsgU1?= =?iso-8859-1?q?MMz1BYYK/h/gZjnFa5jd9Majd+ymoV92s13bzp75oHeVoxZO7B0yRns3a+gU?= =?iso-8859-1?q?JzgxKSkX4m3BlCAWk7I41ruKAigYLi8U72N0jTMjI4daPfKN+eHhnCm/21wZ?= =?iso-8859-1?q?DMF++EOzwLJNu58UIrKJ+s/WfiJ23viF91JbOG034okZV8HVeEOTSix/1oPh?= =?iso-8859-1?q?efrpXvydbwwIjAwvG3CVckVdgYZR7TeswXD8OpO6KFreZsV5JIZJtwYCrChy?= =?iso-8859-1?q?fzNERfmouU+ApeifCZ1Y9iXO+I0wUny85BN9ieZUJH9zuCFjdsUIcUs3a2OZ?= =?iso-8859-1?q?/WOO0dQV7idmB01aXELupHgBhJ/ZeCsEFLsxG0czhhKLD6IsZVpwygfUcQrF?= =?iso-8859-1?q?ursULaT9TEdUBJ4GmlkBmmVqKa4pzdQ3vI5RA0HEAkM9Cct5vfkY8Y3ML1Tc?= =?iso-8859-1?q?FP4clxJ2wiAzh95ldqOI3ctLj4D8BHbjjkVCZ+TWpqTZbFkdKlGl8RL0e3Mu?= =?iso-8859-1?q?DiVjoTqG5mJBFnmOhw5TuXgPC4zUTFTyfSCv+W99si+l1LP1qAhYslpgE4au?= =?iso-8859-1?q?W7fG/GAd92U1c00cgrOOauURVekArvAYgSqjb8tFhlxeQa4DhVgdCrJesjxv?= =?iso-8859-1?q?Y31eJUAI9j7Cx9gynJnvYJuJdjlRb6BDqz165K7J+Vz0uyKEyPRIuz3ATY0U?= =?iso-8859-1?q?PVlOy41I+raar1pm/lN2bY7Cgy4Ut+dtjJYAsBacKTBUxOMQ9zAnkmZBCP+l?= =?iso-8859-1?q?N2b+0AKI5OY5/K/W1hoTXQWPL7VH6iCgyBTg8Kr9/O279tbRJGpNblVJjBEf?= =?iso-8859-1?q?qccCeg/XNa5Y5lXlcr8JmejN8JEf50qLWmjKvaev3PIed80NWmHmgEBoCMwz?= =?iso-8859-1?q?j62m0//UJi5Aug/CgyQXjU3118Xb4J8KWanERMH8sLjZWY5ukjviKdCne6Y3?= =?iso-8859-1?q?/Lgh26Y1MsSd+cxDvQIJwCQBKxTqPuCDY/qbNhyQrIIxBbDxkyAT7boYb0HK?= =?iso-8859-1?q?AHgCWKhCp0t2xp4vot7aV0ndZL1VB5+t5L8B014K50TbJjL6brXWUxrn6zX0?= =?iso-8859-1?q?hQfWbG299O5nkDxFJBP596s9hBWi9LYiinr6FfFYoHPvG6KXIOcaqSkfx918?= =?iso-8859-1?q?o+GedYIDK480+bcZ7P95dDjh/TCkzGSoYVSpi9QDz+JcFgLCE4D3I8Jks7Kc?= =?iso-8859-1?q?Ky8ifNJNdp172PSF1qFgJRb8gGquwf8Gt2i0T1hUiCCrQjI4N2SiHOv+okRy?= =?iso-8859-1?q?V9DtJ5x6o24fnatn0/IM7iNHyvuvRjTP72VLT+6R35f5GjomzZww/Ajt3Q3u?= =?iso-8859-1?q?rb6U=3D?= MIME-Version: 1.0 X-OriginatorOrg: csgroup.eu X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 2b97d94e-295b-4230-011b-08d9e34917b6 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jan 2022 17:02:11.8932 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9914def7-b676-4fda-8815-5d49fb3b45c8 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BHuaWMVkOOayyz0OKKttULsn/RB4/NllPUFVoTG9KNJGl8vpGu+AIKmp8xUV5Q2YnDQQw5kef+QT08zK3nJ8Ti4AqcffDD1HLYF6LlK+iWc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB2584 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E51682000C X-Stat-Signature: tcc54ssbsrauhr9megmp5oa8dcrz8j35 X-Rspam-User: nil Authentication-Results: imf31.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf31.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.9.48 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-HE-Tag: 1643475732-435785 X-Bogosity: Ham, tests=bogofilter, spamicity=0.034543, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Replace module_addr_min and module_addr_max by mod_tree.addr_min and mod_tree.addr_max Signed-off-by: Christophe Leroy --- kernel/module.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index f3758115ebaa..01fdc9c8a5e2 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -89,7 +89,7 @@ * Mutex protects: * 1) List of modules (also safely readable with preempt_disable), * 2) module_use links, - * 3) module_addr_min/module_addr_max. + * 3) mod_tree.addr_min/mod_tree.addr_max. * (delete and add uses RCU list operations). */ static DEFINE_MUTEX(module_mutex); @@ -110,9 +110,6 @@ static struct mod_tree_root { .addr_min = -1UL, }; -#define module_addr_min mod_tree.addr_min -#define module_addr_max mod_tree.addr_max - #ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC static struct mod_tree_root mod_data_tree __cacheline_aligned = { .addr_min = -1UL, @@ -4611,14 +4608,14 @@ static void cfi_init(struct module *mod) mod->exit = *exit; #endif - cfi_module_add(mod, module_addr_min); + cfi_module_add(mod, mod_tree.addr_min); #endif } static void cfi_cleanup(struct module *mod) { #ifdef CONFIG_CFI_CLANG - cfi_module_remove(mod, module_addr_min); + cfi_module_remove(mod, mod_tree.addr_min); #endif } From patchwork Sat Jan 29 17:02:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12729567 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51009C433EF for ; Sat, 29 Jan 2022 17:02:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A86676B0098; Sat, 29 Jan 2022 12:02:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E2816B009B; Sat, 29 Jan 2022 12:02:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BF646B009E; Sat, 29 Jan 2022 12:02:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay037.a.hostedemail.com [64.99.140.37]) by kanga.kvack.org (Postfix) with ESMTP id 5626C6B0098 for ; Sat, 29 Jan 2022 12:02:16 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 14EC822B9B for ; Sat, 29 Jan 2022 17:02:16 +0000 (UTC) X-FDA: 79083942672.02.232295C Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90048.outbound.protection.outlook.com [40.107.9.48]) by imf31.hostedemail.com (Postfix) with ESMTP id 852FF20006 for ; Sat, 29 Jan 2022 17:02:15 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PzdIMkfYAmkDVNuC5iZTEa+JF/y3u6ACtcnoxro3KRT/FsrF5zKNrnMnkzuOFk89GL+uL29u5dH6qvJEG8+RTEbtlIEORha6L3aK9S4sFXoLc5TL+Eyns70Jnm9AYgEiErXcyTW/LulCOcVmZp9GPMtpgxYJOljvMCkmc7346Z3dHefuK03Cup/TpJkT4u5g1CIhrAS10BLmXo5Wz9cr1zpnMq37PMJMQoBGJlSZX8iMhWVBDS7pc0kczRWHbB7Og05pslfZeeJUHPfopaQV8QhfrFNG6WZhK+DL6HOXDenmqRa+86AYl2JCSPh672Ayw9Zup23FFIgHqO8SOWXsmQ== 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=hDmVjj830CtXExXD123euZ+os2WqKPyfIrNuhETOUf0=; b=GmBMH1vQPoffveeJA/PM3mu66uzJI8l3WPBZBVGMB/y/JtmkzqjdbnubmxOcG2djLuuhURUDMFDQoaH7uPCo9Qjh7s2wcxN6QfHc01iJZ9zAvrYYTGe4MonFxfYjP81sqoLM7ZehJ9Go+nXpDgrm+GekIUO/jNJz0c6W8qSnIUcO6EXro+ZduaBzPviQ8QTdDPAwYm50y8Ik7Llht7J6bfQEaMYBPUN43ZbW5pejks9bsG4Iodd4qCX+/N57RJYjszzSNQ4H1tG45nthmh+SbY1c+odwTKyJRGJNrLr4PZiLH+AsFkDQWzAHYh6/LQwboduK4re8mb/D3sG4nMUohw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:31::15) by PR0P264MB2584.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:1e3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Sat, 29 Jan 2022 17:02:14 +0000 Received: from MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::c9a2:1db0:5469:54e1]) by MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM ([fe80::c9a2:1db0:5469:54e1%6]) with mapi id 15.20.4930.020; Sat, 29 Jan 2022 17:02:14 +0000 From: Christophe Leroy To: Luis Chamberlain , Jessica Yu CC: Christophe Leroy , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "kgdb-bugreport@lists.sourceforge.net" , "linux-mm@kvack.org" , "linux-arch@vger.kernel.org" , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras Subject: [PATCH v3 6/6] powerpc: Select ARCH_WANTS_MODULES_DATA_IN_VMALLOC on book3s/32 and 8xx Thread-Topic: [PATCH v3 6/6] powerpc: Select ARCH_WANTS_MODULES_DATA_IN_VMALLOC on book3s/32 and 8xx Thread-Index: AQHYFTH2Z+9BZHr+mkubHJQ6ewTMHg== Date: Sat, 29 Jan 2022 17:02:14 +0000 Message-ID: <04a0d5550f331d68f7eab4b512d50978712f989e.1643475473.git.christophe.leroy@csgroup.eu> References: In-Reply-To: Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c8448cf0-569c-4b8b-c1a8-08d9e3491907 x-ms-traffictypediagnostic: PR0P264MB2584:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: iwv5BXfDzUnohE3Dhxxj3ViUEOzp38nRo/dx/VgebUiBPwRV9YmfDJbKwgK6+r4yiqqWejLAao2JiSi38V40BrAL2jiV36cPOHBxFW7+/lBX5/yriRbsohIMXTfuTN2hzlIqQVKsAHGhp33IioH/W2YkuJtJl9D6ljuhQR7uo7h98qLjk/V/bHiyLyTRuZh4k2ytLgiu90u9DFIe0S3K7ByVv3VFeeSjeV+PNHbdXTJeap3QfOg5bnUXLWfK5kDmcKGz2aduCSu+qHbk+j4GzKfycFqAOVFS+SQ742DNj9NbcI3u5PVW9WMzmn5QUggMgKQnE5w3o1DCE9/+ngAWa2N8cIXonrpvNHytzGUiWcjlPrSjXspJ53xsLAYQEDOmSaaw6Ftq3lJM1s1agvzVINB+I+fENd52KLy0qKVwWbzaoNmEHEIFkf1sajYzqn7GcCF1nbbIWGIHuHsQbkB8UruowWYZuxuu+8iboawcu0AOlIq1hmk/A+PoVUoL0Yg3uzDishAkdhfZi0KrrNtC2VBxHXJ67/pZOgAuQRy6m3tWjLG35cxoMY+2Yy4rYm2/o09kxI7ujAevof/XCR8K9mOAW0glv2leh0Q3tWgZMZH5q1RFwBScWLF5dmhFnu+r0Io4cvHl6GY23JbZudnXxc8V6GFEadJtWkrQNwuyGnm8G+qzV/67a0RCfK1xxsc962Ofb/5VCQzYUCGXolleQwjvXPDS0VwHuLVQcQ9cVOY= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(54906003)(110136005)(6512007)(2906002)(86362001)(6486002)(508600001)(4326008)(122000001)(38100700002)(91956017)(316002)(76116006)(26005)(64756008)(6506007)(8936002)(186003)(5660300002)(44832011)(66476007)(66556008)(71200400001)(66946007)(8676002)(66446008)(83380400001)(2616005)(7416002)(36756003)(38070700005)(32563001)(20210929001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?j73f71ns0JUnRc3p8L3L7g8?= =?iso-8859-1?q?Z4IvNoRIeizCMijE2bSQI4DpV3pUISSxIMvmzb1QiLYfaneeZY6SxfvVc38a?= =?iso-8859-1?q?UbQJ4IG/vBvgeXZnp77QiDlCsY5CzwyiejteFq/OG/nLKmFLKzc0Grz2cQhE?= =?iso-8859-1?q?bQkiwDhmtCHaRCqiLtfuefpZlGqaOMMu/OKkZgwEOcPKatp9+Gf6bENwAUSe?= =?iso-8859-1?q?YMUFx8MksOVwlqGr76wkLEQ4Q84nAIHEBpwM3xF4Cjfnz6z1R9jW96Uwu5WD?= =?iso-8859-1?q?2PJBpbbx29y2PzR2Wgl5STsbRSjAxyfKAq6DsssLpsmtzRmN5L7DWpUAk63G?= =?iso-8859-1?q?C2+aaocPyJVO7JlXAwQqGS5m2Ym5bC0veMAmaRPAZY1wxIh4VDIBqNRHtUSa?= =?iso-8859-1?q?0BZZsyalFKycBwBAVoZWsAPn+0QOcL01AZwkS+mgmiFa7Q9kjdcNYXNDQpaj?= =?iso-8859-1?q?tDYNyzz+tf9JnaqCO4UQUB2WZcfc2Eepa/U5vPwhUert/GMlLz3dBMIhr9Uq?= =?iso-8859-1?q?HK0hITi0BTTOEJid/rqqXQ56ttalTeyXIp08TpJHYTZ+bE9+vrlrX3SHkmmx?= =?iso-8859-1?q?jWUnzMDDsCw7BrF91l2KFsjE276J4nmv/5QpQPB5kNTfruNrjYhR05FnYh6v?= =?iso-8859-1?q?J42QAUCjpsf/eZBp0kv4q/ywLniv6gnF9VryRl255wgY71486gVzn1JbtQ0z?= =?iso-8859-1?q?6be01uot6JB+KI02meSVAp37objuh2K4xdlrKcx+TbpX3mkEwwSNdUwEoWfu?= =?iso-8859-1?q?9mOTp1CHJsc2q3/h4expdtXeYqCKoaF54ab/9GCXsrHV7oT2KyTmCJ7fqpEK?= =?iso-8859-1?q?3w3OHHrD+2mkkeFQWpXPUC/aJIFb9FJiZS5QJYhfCpJvC1RsymC+5u2q+dzm?= =?iso-8859-1?q?6ClQZl04v3Zh0M5fi/UGDUPb5Xk5+hj9bIB5lIq5P8U8Mb1IsxL6p+CNswdY?= =?iso-8859-1?q?obuY1wgovDwcHSMlH8u8O8JF+2NEpN5sjXKi4MO+W4ZSnTEOAHd+CkOw6ET8?= =?iso-8859-1?q?yMsD9eJrYLHf9/ANSycaUa6LOAx621hXxWI6zAZ/ixf3eFCpuBUedX8lPM0w?= =?iso-8859-1?q?ktEK6ZfGDpjABnYSyxaHrvryCfWyyKcnl//DS9dDMmzbGhBnyTASFLOYrpod?= =?iso-8859-1?q?WLXwo4zdR6aq1f4nJAh9z6dMK7GP+CT+tijozU7Ja3gGXTgH88/2h072t8Re?= =?iso-8859-1?q?oWjkVPyV+ExjEVLLOOtD3QGmByXiwvQFENkjDhOftF8WDu+PS5zQ6vrNSs9l?= =?iso-8859-1?q?prBNj5yIynZTo7kK7JSgV+EjLdYyvIhEEkW3qGxy+Xq3yajeWueYAYxXNGl0?= =?iso-8859-1?q?qZT5knwTc4B/4zrChWa1O9Vwe3ePyCkF2VdLhJfFhwwQCYW0U5OOMO9U30s0?= =?iso-8859-1?q?WUxE4CS/IqDOnXt3C9SEzyFaxMt8nnQJqWXFONh9p8pZjr3Lx6EsAzGGs0RR?= =?iso-8859-1?q?8RsfqNegeiPu/+W8HNp3ITtYHNaNX/Ln1ARvEX8F7Ep8q2POGPY2hYc8epSL?= =?iso-8859-1?q?dNhT1jrJHFuSu76l93K0BSXx85uHjY9jpvAtqqeXZRCStlQ7FVMcbxQU3AqW?= =?iso-8859-1?q?4S27niYuqsS/xr+m3NbFAQJQ+voFMma7kfxx+NXPxlCO2tDfDjVzVpQR7L4K?= =?iso-8859-1?q?RMS3qf9T9gj+ManbYnQKsqiZ3covKFzpsHiu5YPhE++E7N8ShMfxyynz+40Q?= =?iso-8859-1?q?XXjDXHsSIACrTukK0iZ/E408g9otiAm/yQL8fQ7x1qHxTsBWsQmrHAFX7Siz?= =?iso-8859-1?q?pTbY=3D?= MIME-Version: 1.0 X-OriginatorOrg: csgroup.eu X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MRZP264MB2988.FRAP264.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: c8448cf0-569c-4b8b-c1a8-08d9e3491907 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jan 2022 17:02:14.0755 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9914def7-b676-4fda-8815-5d49fb3b45c8 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 6djKFQr0cHMhrf6Tp+sNdDrT700aVyYKZ+t5IOoSqzEcz7ADs6/oGc5Y6d9B96S1UVn3cQi5o4s5j6QmgEjsM9VVhqWgKvn1wakt6iQfqC8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB2584 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 852FF20006 X-Stat-Signature: dcsxodi6nzz67meq4jcifpoeba4x53j4 X-Rspam-User: nil Authentication-Results: imf31.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf31.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.9.48 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-HE-Tag: 1643475735-67598 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000539, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: book3s/32 and 8xx have a separate area for allocating modules, defined by MODULES_VADDR / MODULES_END. On book3s/32, it is not possible to protect against execution on a page basis. A full 256M segment is either Exec or NoExec. The module area is in an Exec segment while vmalloc area is in a NoExec segment. In order to protect module data against execution, select ARCH_WANTS_MODULES_DATA_IN_VMALLOC. For the 8xx (and possibly other 32 bits platform in the future), there is no such constraint on Exec/NoExec protection, however there is a critical distance between kernel functions and callers that needs to remain below 32Mbytes in order to avoid costly trampolines. By allocating data outside of module area, we increase the chance for module text to remain within acceptable distance from kernel core text. So select ARCH_WANTS_MODULES_DATA_IN_VMALLOC for 8xx as well. Signed-off-by: Christophe Leroy Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Paul Mackerras --- arch/powerpc/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index b779603978e1..242eed8cedf8 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -152,6 +152,7 @@ config PPC select ARCH_WANT_IPC_PARSE_VERSION select ARCH_WANT_IRQS_OFF_ACTIVATE_MM select ARCH_WANT_LD_ORPHAN_WARN + select ARCH_WANTS_MODULES_DATA_IN_VMALLOC if PPC_BOOK3S_32 || PPC_8xx select ARCH_WEAK_RELEASE_ACQUIRE select BINFMT_ELF select BUILDTIME_TABLE_SORT