From patchwork Thu Jan 27 11:27:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12726608 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 C3F89C4332F for ; Thu, 27 Jan 2022 11:28:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EFF26B0072; Thu, 27 Jan 2022 06:28:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 677B96B0073; Thu, 27 Jan 2022 06:28:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F0F26B0075; Thu, 27 Jan 2022 06:28:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id 3FAFC6B0072 for ; Thu, 27 Jan 2022 06:28:00 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F0E84901BD for ; Thu, 27 Jan 2022 11:27:59 +0000 (UTC) X-FDA: 79075842678.29.ADBF671 Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90057.outbound.protection.outlook.com [40.107.9.57]) by imf19.hostedemail.com (Postfix) with ESMTP id 7DBA11A000D for ; Thu, 27 Jan 2022 11:27:59 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kOLkGziZeuma7k5n2HPX0dwtoqgwH2MSdy0OWv4OKEhbK0O/jveUSXb5B9MKxdh6QhTdrVSC5o7lpv/ASQA6+x2Dwu9KYYRltYlTFxy8zaXSWkntPn0Yg1qjYSPI12bzThJ1FGtVt2s0XwRaM5JKdtzf0Rq1kLMktQbWTsd5NZMrWsew8WKWYjJ4RwEHw3Rs85TMu9pMt0+KG/dVBbbKPIEnjitCj/nboXr5IJ/U8JfzH5k29eNbZeuhey6vPNejdmbzxdKXFWhwA0Ldmc0p+S34c6ZyKVMxAOSPzCbLica7ghAt3eNyZ4xtMD9f3q8viMgWKdO4QCio9f0Ks6mHlQ== 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=EuoAcwdro5/8HcduMJqG9w864tNel6knvYxF7+65CzM=; b=B4S6oHFymRTSap4c/p08QLB/kmiC2qoQUP+MsEyPob9NXQYn5iNm1PN4/mYdrn6cnt/nVpphaDer2YAa1bGniaX29QrRE3UON9oKuzOemAh/pvepEq/03iVTTuvxkRFEFNnRq2MjmHJ9BZfjZhYg0m2rU42IZuhIwEjY98wo4f3DGVBKRkhuwvp3mGFMwF6ADNSI7MrYwwe8f9L1NfbcYH6N2oA1Eg0rYQwc9hqGlwx9VOUihPTUAoBrHgb/Phs15XdupGRBeWPvymVrlOzWcTbNcyfSth8Z9/dxXoujLUKEF35eWuY0lIB6uoXR3YJBenAchhuoPRPsDgJ6ZxmePA== 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 MRZP264MB3227.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:30::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 11:27:57 +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.017; Thu, 27 Jan 2022 11:27:57 +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 v2 1/5] modules: Always have struct mod_tree_root Thread-Topic: [PATCH v2 1/5] modules: Always have struct mod_tree_root Thread-Index: AQHYE3Dv9+i+4LBYlku5GPEgOH7pTg== Date: Thu, 27 Jan 2022 11:27:57 +0000 Message-ID: <51394dd54e861e723645940a191f7d54dcd2abbb.1643282353.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: d088cbc0-7156-40db-0676-08d9e18811af x-ms-traffictypediagnostic: MRZP264MB3227:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 9oN2bWKFpRPJcdSztL4I/tyhDmdejaQolh/DY+yqv8gFnUYDQX8QjHrg3KZTJMC3tKDbMUX66oCzi2NPaFKsLaxUkqd8vHfXwg9zwZv6olQ1QBagnwiGzQEY8bF6y5kWtqRF1lCDND8K2NeLAZ797uoDihzQdipngTO1iNjhzZ01eZ+ymWdh2VLk4H8ZHok0EnMyPZPxRW87ZXXAjHG28OFE194Q71kW/5PMf+kaM9YnrrfCF9Zrd918fWz0rNLOZAxFrBSlmSlHWA8DuMTm5sskY5uqQgZGl6uML/RWY7BqifZHYyNcMZoyMQTafveglnVwxpaFbhC08cUnfTQS/gn8ZIR6+3CJG51N7eyhuCM2LNqUecJ0JZ5lb3T3TuZ0LLS8NRAG8wp8Ikr0J9xZiU8JM2V8gX2eGSGTFOev464ImLcd52eW73B32fKTLLm0GOe57AIGlCtzJThBRey8dyDtMiou5TTyKBwpkpTLMOo9M8SlHbY8XowIfK12gNsugX3YxG9QPTfvH4WgLnOOSM1k/bQkAUy5Wu6XXRHmZh0KOoO2kYPla7tp9h4CO2kRy0pnP7GedhrzHdTYpsp4bZyLR5szUB2Jp8zN047Y4nYSVrZhVVbp0FE1aSrqVSFNICd0/0fiv5YAPSLqb7Ku+rSdwxkXkUuOozR3M3hQPvgSzOp/HRmzz+jpEGmgZvuh87pPX2GTDCRe8MYhNZUAzg== 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)(86362001)(316002)(66946007)(6506007)(6512007)(76116006)(508600001)(66476007)(5660300002)(66446008)(66556008)(91956017)(44832011)(4326008)(64756008)(8936002)(8676002)(2616005)(36756003)(6486002)(71200400001)(38070700005)(2906002)(83380400001)(122000001)(26005)(186003)(38100700002)(110136005)(54906003)(20210929001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?fD56qYGhwLuaiLUTlHZzZQh?= =?iso-8859-1?q?Mz+1+d9d9ZJL/rVM2oGeUVSI4QGjlmWRQC1Lpv2Ct0iVAAaQT5+gBaSRjQQY?= =?iso-8859-1?q?bpquv2DdtOWIJgx9dSq2zgzh/zN8k032Lp1BbunStz9eHzZ8o7V0mnNWErTU?= =?iso-8859-1?q?h9W2x2hKBh/m8BFaOdvaDbzwpVV9Tz/YyH3kINpeGZjXtpbDgcl+bi8cX6f/?= =?iso-8859-1?q?GtH3aMM339kuUCV1ofTNQ1UGtIbNhywStk6jskOkdrIp93FEd4aqK4Lejjrw?= =?iso-8859-1?q?+a9qlrSl2WY6PYpC8y/5VU03v0i56aHyCeF1CS4lZb+0fodhRTy9JTsEd1YN?= =?iso-8859-1?q?dkY+9J5zNxTOt0j4LHZnJRa/AVBUdRnUrxwp6H+ww83GpLiskZILL7dIPcxp?= =?iso-8859-1?q?3sfm0w382ubTgP8vobu4vvmplbmaeTzlGOBjH8w5GxEVLB8YvNK/uveQf7Mb?= =?iso-8859-1?q?+gizUKLm42bRv4QAGP702ufE2cOlDwPct6vP0v5bP3LtKcJW4YT+DextjTh6?= =?iso-8859-1?q?yY8dPcW9NW2UqRUExvKivlx415GV9O6FchxYCqWJfnbNaAsqGRwp7SUUObFV?= =?iso-8859-1?q?AonTiD6++iaW4+pnXqAZTVH5fKAvGLYIi3pDj+UaTZ0y7H4dCf2ZKGcv287b?= =?iso-8859-1?q?6y63ASXOFL0fkQl/ZPECUtY9wihw5LHk0MDuJJtN/jWSJFpDHXVnw6D/MHBW?= =?iso-8859-1?q?BPUSTsl6egaYxBB+RH8ga/qem/+s72cKvmJ0Pe1FEqQr2cBTjgmEhktyxKJJ?= =?iso-8859-1?q?Bve12OLFid3B2JyjQQPsKr5nylmkhtSDqnSBMJOTRvvpXTIAkkLEM9xnLCEL?= =?iso-8859-1?q?cvGC9Kw2C5EJUohmJgzeUnc6ceOksrMqNTFcSGHyC67I+oHmGLYkvLfrGDAZ?= =?iso-8859-1?q?hEEXafrj+IlNaAD56x1qjyNnOVVeVBx2KfGTmC6Pwd1z409KLEA8FElBFscE?= =?iso-8859-1?q?0SfCvE5QcZuUpdsb+UpRrS70//nxxvlG0ki34PnybzKK0PA8myyUSem59yLn?= =?iso-8859-1?q?qSnCfXYO76lOXPArqN8nj8YZKQ1m6PJs8cNfWeC/3fAun0VCc6YnvZ/6YX+I?= =?iso-8859-1?q?C694MQunl7+aC9Et0DnlbLLRKHMkSh/tkZD6/wZduiJXhkXYYZETqxukHNc9?= =?iso-8859-1?q?J+bn2oGX/Z6Tr5zmGGULmxMsreaoKZ3GtPOZgBIfaVK2YvBrtVjdHKda5cPO?= =?iso-8859-1?q?WKPJVQFmSPuxwuR+Am6WZnYWgjK9xRdVXtppUkFDeqDTwkV1oltky2kf5+2M?= =?iso-8859-1?q?6qO2fd0y7nOJNWQwq4El1faRBVHqfxzR9RtTqyigTSaTsQ757iaBSYJfQOKU?= =?iso-8859-1?q?neTgrlMJm5LFg5FkUTl6/usMivPBVJVu24TjSw08MjhbIxIgb3zI867i5jIT?= =?iso-8859-1?q?yVHX2BP9c1YvBbRpf5Y0TBl8T5uMtI6YSaCrzhA7v88YWw9G7bx7+AKhWJn0?= =?iso-8859-1?q?F5Sp+dyg0Kh+8b0QtDYcvNPjNxfhOrP2+NiV0GLFQ5Z8RSad0T3GG+IWLMUB?= =?iso-8859-1?q?udgpY21A1pwr/l4KCU+7Wy3JepL/PdRc5em0ia9MHvi5urPXcgzbEgYIYn5S?= =?iso-8859-1?q?DmRCefadlPA9BmKINkfMFlDScgaxnf6oyLq7N1B2DAyR+qsgj86qS9W3tyZA?= =?iso-8859-1?q?Dmpqm8Yo5tJGIsq/7QQ5t+l2kzR4qHsHBJDAOt6fsUNJ7fcMsJKcucqDfTSe?= =?iso-8859-1?q?EHHe0z7mzKk1kty63Ob3/xjg6nJBO0lrXwJFt2tcSocRufd2nQp+TKFBeDLS?= =?iso-8859-1?q?ib8k=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: d088cbc0-7156-40db-0676-08d9e18811af X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jan 2022 11:27:57.7808 (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: oB6sgKYi0SLQFVvkfSRcCOz9/fIaeVLrwxbjUn/5iUU7PC9je9Z1y0ClLkhudPeEaSbj0uxCHLCcFdrUjQB6uDQqqQ7/wLVUQEBf2zJRaTU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRZP264MB3227 X-Stat-Signature: 7m9rbicff3wucyhwkg1tcucdssy91sc6 X-Rspam-User: nil Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf19.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.9.57 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 7DBA11A000D X-HE-Tag: 1643282879-90265 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 separate text and data, we need to setup two rb trees. This also means that struct mod_tree_root is required even without MODULES_TREE_LOOKUP. Also remove module_addr_min and module_addr_max as there will be one min and one max for each tree. Signed-off-by: Christophe Leroy --- kernel/module.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 24dab046e16c..c0f9d63d3f05 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -85,7 +85,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); @@ -96,6 +96,16 @@ 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, +}; + #ifdef CONFIG_MODULES_TREE_LOOKUP /* @@ -149,17 +159,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 +208,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) { } @@ -239,10 +236,10 @@ static void __mod_update_bounds(void *base, unsigned int size) 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 < mod_tree.addr_min) + mod_tree.addr_min = min; + if (max > mod_tree.addr_max) + mod_tree.addr_max = max; } static void mod_update_bounds(struct module *mod) @@ -4546,14 +4543,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 } @@ -4737,7 +4734,7 @@ struct module *__module_address(unsigned long addr) { struct module *mod; - if (addr < module_addr_min || addr > module_addr_max) + if (addr < mod_tree.addr_min || addr > mod_tree.addr_max) return NULL; module_assert_mutex_or_preempt(); From patchwork Thu Jan 27 11:28:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12726609 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 A1F3BC433F5 for ; Thu, 27 Jan 2022 11:28:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 409856B0073; Thu, 27 Jan 2022 06:28:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3446E6B0075; Thu, 27 Jan 2022 06:28:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BE9E6B0078; Thu, 27 Jan 2022 06:28:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0031.hostedemail.com [216.40.44.31]) by kanga.kvack.org (Postfix) with ESMTP id 0BF056B0073 for ; Thu, 27 Jan 2022 06:28:05 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 80065181CCCA0 for ; Thu, 27 Jan 2022 11:28:04 +0000 (UTC) X-FDA: 79075842888.16.FB6A6C9 Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90047.outbound.protection.outlook.com [40.107.9.47]) by imf09.hostedemail.com (Postfix) with ESMTP id F1124140008 for ; Thu, 27 Jan 2022 11:28:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M+cOta/AdEQmjDLtQcmgwPHdwJDZGSvwYLM7mhfahM3mT/logBpquoFR6YcYj55NnwXDfrriK18oHOn74f2YnHmdMo/Ba+ymT/WpfOZkgWA4tyrehu8UwX+jlWuaDltA7rANpJOBoNY/Uz9KquJ4ta+PDXxWZOrhJBMBNnq2QXOCKqTb1etuJotcEu1MvNf5yseNUAR4TO5wYE0de08tPSuijV5temlb04fro+AcWXaOFpIeS94ftoOvXxpqCZNOYgSbgOS7nWzBF/LubJt4KjEMptKoxJpyg0jvKVK+lJwp1H+fmnOQrocynA1mEMr2uenzxcmbSpCUU/pYIoP4IA== 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=s9nOWJ2p8JO3cNb1x0dPdEgMBG0k4rQWeltrEXRW9PE=; b=Z+6IxgiJbyodTC39snyEaflMr9NfQ71xnNRjF94eg6fQ3WKRAI6XLyfnvbWf5XHmK5yXR45yHWlHPEbcP3kAbFtriLgcGMdUMioT0CgjrWrRJbn5PkFaS6EsJcecdkYpfLFFvXxmHQMU/mkSzeAveeC/lRDObjBtoL3ozstEofF1FrOjxysDkGB8YoZfcv3JiiSKfk0hJg5bbNmVenAJbXI5LOBNAtTCbaPzRlHmigRhOvFkgtZG+5P+bMottzHvspCewLlDgcvLy9PDBwRSXlXCo2tvsDf6mxcyjtYkka4wlNrVRW8k5W+8nYO3xW4VrTAe1gD9PJ7FLOyglY/KMw== 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 MRZP264MB3227.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:30::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 11:28:02 +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.017; Thu, 27 Jan 2022 11:28:02 +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 v2 2/5] modules: Prepare for handling several RB trees Thread-Topic: [PATCH v2 2/5] modules: Prepare for handling several RB trees Thread-Index: AQHYE3DyBqcLvucNM06Xc/qiNZ0+aw== Date: Thu, 27 Jan 2022 11:28:02 +0000 Message-ID: <62ba4349b97f2e52be2bdcad4474e244ca2a83d6.1643282353.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: 803532f9-02c7-4bfd-6a46-08d9e1881484 x-ms-traffictypediagnostic: MRZP264MB3227: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: HLtHWkobq758/HvDnrom7w9fCAgIEMeXED7g5WKFF3kCxGZaOoSQHoT5zhqx6XfS7vLbh1U+d1SqQioUH+UWvJF6eOgzBj1kSvyVDc5dN4hH9CgtUbbZjtKUnJ/Kddd1kl+maRGyST/XzEtUqJsD62lj4JCvm1WArOwO7iyTRlhPSQ5MhSGqsBnKVSwm/fXeDZgRCJ3JDlGEJpE7WZiZujLJ42s2Jf20vxx5aiOb9FN7R3VQlNs4x1kbWynWhhAWTsxdXefwbZycPLYwZZ0Y2k04jHnv3ZLt+fBCo2qJ5gdjfBEtdFC2x+IQNq56vM4mS7gZvEiPE7DlKH+IJrP13gH4riCOSio66p7BLgdc/sriKTthV2onsvrv0DUjxhyphUxyoJxNleh/830WLEFN8klTntlE4lAGrYWDSvQJuGSLck0FqeR7ir7EXBz72fnr/7q+V9DN5cyRH71dDhD9VRodquIfcJQ3kt4uTyw97KLNKJd/rP8Y7wBm6HfSG52hr0LiBuMxvVHMjAXjjaLEoibTUtk3EHlhHppAd1/7d7+y0u4Px3TWZg5mBp5ubFXJHgBCFBlPqORcXDuHKDXvExeY7glqB+iXURviHlTf8WOcwojQDpWftw//5/f3nL6EfPoSNAqgQSu0WI1V9BXXCa5Ay21Pw+CTHQaP+UzODOTAtRVl/k14GINBI2wsp1b1m3iCAB82y6tIY2xa+Zor8Q== 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)(86362001)(316002)(66946007)(6506007)(6512007)(76116006)(508600001)(66476007)(5660300002)(66446008)(66556008)(91956017)(44832011)(4326008)(64756008)(8936002)(8676002)(2616005)(36756003)(6486002)(71200400001)(38070700005)(2906002)(83380400001)(122000001)(26005)(186003)(38100700002)(110136005)(54906003)(20210929001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?xPkmDEGvJRVxpEipNxx2YOs?= =?iso-8859-1?q?JQAmit3g2pApBpmhnMIw3lxAdcLF9KxEd9rgGTFIfvVhdmdWtSTmjBbUjxyX?= =?iso-8859-1?q?5ZEjnLhP/O7NqyNO6Tlcoe3bEQ5Pv53M1+E+ia93ka5/bzPLJnc/opFf0LKp?= =?iso-8859-1?q?VySDB9Bk1n2I45GB3legBjMwR7f6vhUbuRdTaiXX/cWLlq0oYm/VjpqeJ/Xs?= =?iso-8859-1?q?6S4qHt9afw6dg4vJZda1z2Yt5jMbI3q9piYd1aqskCXG9nPhmgKiWb7szW+z?= =?iso-8859-1?q?BWj+yVD1IVRc6m9KvM57Bf3prITO+wToayh1WkppM+P/OEnfa2pyJPHx4I1X?= =?iso-8859-1?q?T+xHAyhFAKRpsu+QGCRMh23k53rJfwCfBccyeHqFcgbt32fp0WsfKit7QGUK?= =?iso-8859-1?q?Y4q9MZws9ugeh7og6GHt2OY7jPdNeicUJ+l6IuzogF9UqfG41TjhmxsIxzFQ?= =?iso-8859-1?q?LzMAqo4KXh6eAeIWarNK0xEh/g1uDjyQK7hKE91bhspc//QwxEWPzZ33syG+?= =?iso-8859-1?q?+fT1flobJChaAXmBMN99kj3qkwSgn5oMSRyEkjVS7LkoDmxTQsPozb5cFNpy?= =?iso-8859-1?q?G82S/dJXbY4x4M39m/ulkR2n1TxNlCW2bGtNlkJhXDdNANHv1xp9fyeY6v6N?= =?iso-8859-1?q?3kfWuPgv72azFN5e1kljUAa9B4w6GnyPjxHc3QHbPIM5/QED3J0wBEI4RsER?= =?iso-8859-1?q?Bo2wrlRqIVJhy5KReukA89GnEA9NUoebbjXNYk3Vd5mxFINEgDJnaI14Xq4i?= =?iso-8859-1?q?G/P6aLEY0hKfMh+3F6SE+nb7whRPiF7V7tCTH7TLcAAqg1eT/cCulHUcros8?= =?iso-8859-1?q?Dy+Zq296058DQwzipFlFv0bdxGMJ1X8VYFjiFpuvxNGKWOjtgygkoXOKuMcH?= =?iso-8859-1?q?RoyIEuRCxJk8W+Z6fw5GdSLKTcGzkpX7nfxfb3+87I5Sb958F+jb/Y+Z1XVx?= =?iso-8859-1?q?WkKZ55enPRJdn5l7aR71DqbAybTY9iiQg4uVwOEyRvGMwPmNRJ7hoZMSermd?= =?iso-8859-1?q?zmPHGy3qHsbD1ya356JolmWT34kM2eqUkS4W1HxbgqToYxHmBrjDHvZwLG/g?= =?iso-8859-1?q?n+QlVMOAWIMXZe04qvF1vhmBSJ7qC6PqYrsB9odyWkZzmGJ6tBWhb93Dn3lw?= =?iso-8859-1?q?XO2YhfDEuArfkiKGL1K7HnRP86082t80JHbyOL5dcTHbL0t1euYi5cthNgA9?= =?iso-8859-1?q?xWkww/TqBf4Wzy6Xpyr+RfYRF8VZ/edrOdGuipWf2RDSNKb83iCIaPUS8IwP?= =?iso-8859-1?q?HOXccIlLg/Ft1hke6sgkR5n3HjBb2xi7+oKgc/ahsaOPhL3Lf65SyWoBcNJh?= =?iso-8859-1?q?H4SPw8q3GTc6RD2N1unreqJmrnoFK4ZjDtqcDsFE8Eab4JcEGKklejIHOGnZ?= =?iso-8859-1?q?JjH1NuGZuuxOk2K1LbIa3g2Pn6gIHYr191uiTBpC6kKy4ARfxFla3nqWMhlx?= =?iso-8859-1?q?v885geM4SZRpVRT3zTzS15Dmv3ULrpJGADRLhsnaEKpB47Hpb7Xkf1BIKinv?= =?iso-8859-1?q?x0xvdN6qbSqhHO+aohi869wdSrbCaRG0BV5csY85NM5Dr19tcyYrUX55KEH6?= =?iso-8859-1?q?fGy5Cz9EiAvKf2NJfu5HLwQ0dTLd8i4n9/0MaRlAyPvX1d2LVwo8PKCGwGAH?= =?iso-8859-1?q?Ho+LP6HQbUNcUXxO82bk4eVQ0qzloaJDnCqB84mqmDgVO9Fx9P7JGdik6erK?= =?iso-8859-1?q?4cihqXVtipLDz/fDLpsgq/Roh5Krjjj74BHY9O613zKJq8GicLe+7O4ptHsU?= =?iso-8859-1?q?pX70=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: 803532f9-02c7-4bfd-6a46-08d9e1881484 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jan 2022 11:28:02.5191 (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: Dp7W8NYyMpbN4tQ10HNYOgKv9wArmy7G6QN1lGuU7MxDVO0uOhQMI8C1NL7qUSqaDcJK3uvOHqokfIrH4hSdbYaNg6h+5OS2LT/pqnX2Cqc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRZP264MB3227 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: F1124140008 X-Stat-Signature: oo1tcyga1tj61jt9z4d59zp4zqg1k17d X-Rspam-User: nil Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.9.47 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-HE-Tag: 1643282883-854096 X-Bogosity: Ham, tests=bogofilter, spamicity=0.002708, 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. So 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 c0f9d63d3f05..2b9a3d9d3c0d 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -159,14 +159,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); } /* @@ -178,28 +178,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; @@ -212,7 +212,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; @@ -231,22 +231,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 < mod_tree.addr_min) - mod_tree.addr_min = min; - if (max > mod_tree.addr_max) - mod_tree.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 @@ -4739,7 +4739,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 Thu Jan 27 11:28:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12726610 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 3B9ACC433F5 for ; Thu, 27 Jan 2022 11:28:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CBB6D6B0075; Thu, 27 Jan 2022 06:28:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C45186B0078; Thu, 27 Jan 2022 06:28:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A978B6B007B; Thu, 27 Jan 2022 06:28:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0188.hostedemail.com [216.40.44.188]) by kanga.kvack.org (Postfix) with ESMTP id 990956B0075 for ; Thu, 27 Jan 2022 06:28:08 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5F21F181CCCA0 for ; Thu, 27 Jan 2022 11:28:08 +0000 (UTC) X-FDA: 79075843056.14.F72C5F8 Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90080.outbound.protection.outlook.com [40.107.9.80]) by imf10.hostedemail.com (Postfix) with ESMTP id C2058C000F for ; Thu, 27 Jan 2022 11:28:07 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fqlHO7IblNmn2uA0ksQGHTuN3jNbyqSSqlQZ8TTWcp9dSD9Xqo8Q8WrY7Y5rYOFUpXudlNniIyeng30ErL6A9R0KNojjISdI9NdNlNedFh/hrjVBHKJuvpj73BjqfHFzB0Jakj5x7KCXXaN7JGoKnG+J3HchtPMqurRdK73GfMuonFqzMak+Jx4dEqK0SWIfMhyPm2Wjq6hDIKciYD8BgtDTZGBQvmyu0BpPBwWB2rHgwggRhWfbm475qJ8oS7GJ1B9YcYnbbzbs3N/xwr39vq9Tuj1ePeq+28kG7YCyeK4KnrNGqdRKhhKjRW+TLSpL4em2EL1z4m+S/E2B+NFGuw== 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=oUPprGAP1KBC2ZtiRxj1EG8BE+y2WpU/+J274WLJhvU=; b=aRcDLbAZCSsrUHbNSEORs8fB858XiIW6jh76GrS54BOBc4+8muxUl9RbtvRDQmWMcON8Ndnzt3IT4zSRw9K7l6Ag5561bJCHDpPMbFPhNaQY7PlQP+SzI/uCVhgKUfcz5difnEtJwXKtJnbcnX81DNem9iv/Aak5ohNfB9t10IJiXi6HD4pcvb4Utxu5i0Z84Wd0aUj4e8kzHqZLMAOYM5Fx84ZXZxjNC1nI6GIyiDvAPUmrIIVMdS8q1eCH9bp7HFqzRksQI5Q2S74D0zNxEGjAi38n3F1i/YJXGiiO1fKKuclNdEwwjn3zmatxyg+r/BjSCm/gVFYvQqmHLjKBvQ== 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 MRZP264MB3227.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:30::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 11:28:06 +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.017; Thu, 27 Jan 2022 11:28:06 +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 v2 3/5] modules: Introduce data_layout Thread-Topic: [PATCH v2 3/5] modules: Introduce data_layout Thread-Index: AQHYE3D0IIMspQerl0CD9FPcUHWeOg== Date: Thu, 27 Jan 2022 11:28:06 +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: 970c8b1e-51b0-445d-628b-08d9e18816b7 x-ms-traffictypediagnostic: MRZP264MB3227: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: AUk93dzYuySvNNte1V76LLdrl3JGzgEZ0qzkaoF6KGkcd9FAeHc36CTCiZscAi1p6MeRcFLDvP+vQbySNx2O/Ju3wvDu0GXs0S3+CaMKKkPYmYba1lmRhhskoEhJv7d4Ec9+OrM8KGXEA6pBQAsBFQFDWUsZwKs3T5QZXZnaS6udiwo9yKo9GB3PPxOw82FAWMRxQufnNoFmpma88A0MDxM2i64ldkdR0LtDFn7LCHmzOXzRcLY5bMmG01u3N9Dy5ndn532Ry8jz0sTC1OkYjEKkWJjuRDCrH2BwGH6p//CFC1MUBsNH6LbBxdKISWlvu4ppceUE4yUhwvYQ6vtzqy/cdilmWSFRmrVyiM2bNq5r8dQqquplN02mMofZBQgIW0Kd1Q39IJT6yezMtaD2bmsNRPX2fV7bSmIIR6vPQFb6lGpCNlA4yXVaUKqW/ADXqBGxMeWFqI7UTaAQWj2wlhRS92uGDT+eogz1o8rS9AHAIFOUehte1obckH+mKsnl8Ih1+Q8jduVyCvcTLN2LNVdLqa//Q5e7PIfEzX14ntu8Zgln2QxgvbSAybOVdthGeW7aXKafTZLKB2aGSucANswKCCArhBbqaRT1Gkmu4fc0TjaaBbrwnc4p/oYsrTBt/FMZhKgMWoL/qfWQOmxLu69Tryazpl2lcKM5bJ9IaAp/xEdmnukeUzc0WseOdS4KesJ2efRX499F+mQd3kuckA== 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)(86362001)(316002)(66946007)(6506007)(6512007)(76116006)(508600001)(66476007)(5660300002)(66446008)(66556008)(91956017)(44832011)(4326008)(64756008)(8936002)(8676002)(2616005)(36756003)(6486002)(71200400001)(38070700005)(2906002)(83380400001)(122000001)(26005)(186003)(38100700002)(110136005)(54906003)(20210929001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?EKmANtKIYL9G/CI5FQPxp8I?= =?iso-8859-1?q?wlmEjnl4QS4goanl5rIfvnthy8zTiQjPEJB48VjC0/cOmGfROpC+R6YLo+mq?= =?iso-8859-1?q?tcjbp/zWaBVxhsrm1a8XzWuaewU9alLcQPobtmeTA/30dhRVYJ07d484WFGY?= =?iso-8859-1?q?tkJvRzcbE2kueoMvBEKSADQpPDCbOrHk3v3TM2P3TgLbrBCgTH+vVUpEVcSY?= =?iso-8859-1?q?MPsQbwDa/MV2+ntxtOd24kzAFbpLbP9JWLrcPwYv70t7iX3mf/bxRjgEwI52?= =?iso-8859-1?q?uFFwjYTrgmlqJM/3kBNkqsihDpdhtoOxFZId9rNkKufq+psJTFnwN9DPp/vc?= =?iso-8859-1?q?y+qdoMRYgo9569LC/BMXH0FNmKp43jVzA7twv9Z8vxygj+ZeL7t1QwpNvfsU?= =?iso-8859-1?q?UjclP9nTSHJiqAdrJ8fPcVPnQccnjhY7iC6AL2QN+351uNzLV0RlyW9vOw8j?= =?iso-8859-1?q?5StPIO1SM6tQA1yQTsKLDDVxQU02QdDH3zOxj6h4M0Czuu95WwxvgM1DgHXW?= =?iso-8859-1?q?sxl7drgNbkgvgTNRHuy5A5FegEPxNYK3vTfCwdggvEV6j6Mtlh/2rkRJQXut?= =?iso-8859-1?q?qX/JOjnRtovBMNodDCpCH7SxmkjpC7Rj8anD1E3pgEmWj05AL9HfSIx6PAvN?= =?iso-8859-1?q?I9qgcpQb5xBjCBv9RRJMWdXrfqFerFnyAAu5Tq6iYXKJFXoApb5KfccfgoDg?= =?iso-8859-1?q?nBT1c+9xx704MAcEYpznH8vUZjiNmNxCI/AxAj5lCloFp3nKutz65zcyiHM4?= =?iso-8859-1?q?vDgPx0TBIPAtaA+Ae9R1c5ZT01jHk299gDW+JRW1Cf9mIHWijrxeqruyBTOQ?= =?iso-8859-1?q?TS9uqIky4N41hlm1BjKgmwUzX6ow5lqnrdZ7oWRr1BlTblFDWrOVoNkLyCr6?= =?iso-8859-1?q?ikMOlCTfD6QUG5e9OGnhhWpMZSxe7uBlIcRyDsvUt3TDsd/ZYHHwyQImloN4?= =?iso-8859-1?q?5sJAOBOKOsyEzHeXiHoRZltLpOxKoUjgKcgSe35oYUHpLPx5cxRz2sEd/x/X?= =?iso-8859-1?q?oLMuKD4dffTI3lyvxawQW9nVj6s3J4fmWhyJTupCq1+g1hOFpBncxY0aVdZa?= =?iso-8859-1?q?fNKguBfqPlTG3aMKn8/l5GB7KM6xOqj5ZMZw1DAdwBEISRjsqquQuDRwcZyT?= =?iso-8859-1?q?DCcL3KeG6mJsEtvmMmOzrNl5eXUfSeH0Dy3wqJ5qFQYIu5cCBGSZIw17BojR?= =?iso-8859-1?q?2OqBGFrqLb9TriE1rRuRGcRMeLDgX70QVhwxv6r1jA1GBAjTet+7eea/grzw?= =?iso-8859-1?q?ZmgilE4+tI5T5YKBXo/BkFHQvEYPPhwJLb9xHwNIrQY+Go7aR2OqAlnRSh/G?= =?iso-8859-1?q?z4P19wOBKtL6As32WhUNZLT/chbi9FstODUVpzezUf3O1QY7DdLer9EK0uM/?= =?iso-8859-1?q?Tn3I+eOo2ccff3aM/ULlqsbJOe3+byHynkWam8npXVTWksFu7vOcs8zyURQD?= =?iso-8859-1?q?7VuDCmzurSHmPq9aSMWBGw/Rg0H55Tm9X55T1t+t4a40ci3e8cSnMDW76isY?= =?iso-8859-1?q?qqj3/job9/JSbk59KxRCanRKhs16MIyAAIySyITg82OQHy/Zs6csVJ54Lpc9?= =?iso-8859-1?q?LbGZtRIaGA5ag2t2sSSBJhQr3ki4q3vDN2ftGp3H+E7nQLHLiZXijq26bYGc?= =?iso-8859-1?q?Rt+GeYCEZtaXtOnd6mxIn6QzISj8uqLCNFH7KiEY2Es1fsTotSFZOE8NRhnQ?= =?iso-8859-1?q?phxY7kSA7pXuDnB12aQWWJqXY76d47UcTeD+aDP2wvzII9vLWej10znFHEqo?= =?iso-8859-1?q?NZC8=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: 970c8b1e-51b0-445d-628b-08d9e18816b7 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jan 2022 11:28:06.2242 (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: Z/qmunLGKyHUNVe77SEuHTd+HLHJ+UEBx7C0M5EmmGoexIbJsDJJFUL5vbLiJgT2Q9Y5U/dAryH+n+Na8jzOZvIjsL+Sf+WkaZ4YVwj/3Co= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRZP264MB3227 Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.9.80 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=none X-Rspam-User: nil X-Rspamd-Queue-Id: C2058C000F X-Stat-Signature: x71pjh33ngcuy7ear3eyp1xfgfphn745 X-Rspamd-Server: rspam12 X-HE-Tag: 1643282887-175976 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 2b9a3d9d3c0d..2b70b997a36d 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), @@ -2011,19 +2013,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); } @@ -2201,7 +2204,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); @@ -2448,7 +2451,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) { @@ -2457,15 +2463,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; } } @@ -2718,12 +2724,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; @@ -2767,9 +2773,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); @@ -3465,6 +3471,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; @@ -4170,7 +4178,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 Thu Jan 27 11:28: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: 12726611 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 3EF20C4332F for ; Thu, 27 Jan 2022 11:28:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CBC326B0078; Thu, 27 Jan 2022 06:28:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C1F926B007B; Thu, 27 Jan 2022 06:28:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FAAD6B007D; Thu, 27 Jan 2022 06:28:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id 8DE876B0078 for ; Thu, 27 Jan 2022 06:28:11 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 456B0181E7860 for ; Thu, 27 Jan 2022 11:28:11 +0000 (UTC) X-FDA: 79075843182.22.683098D Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90079.outbound.protection.outlook.com [40.107.9.79]) by imf21.hostedemail.com (Postfix) with ESMTP id 9C6331C000B for ; Thu, 27 Jan 2022 11:28:10 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cxTTqcQUfYNDQhOT8fCTdRsyzFbx0i6b2lnIrI5pAAy74+7OJQGK/bloCTtiDgcPan3fS1TlfC2gh0dMJmgraAi6Bt7Um+DfarqMtK7xjWPWrt3/JmRO67qd8wgEH/LTZ2VykCzf9Qd4fQohaHSci9DZ3yjE/Sxw8RE18D61RHj3ta8Gag8nlQMkI7qOGiZ5EDp4PMEIOpS14DF1jSSsVUzuxhB6HvARnRB05IJ2jLNzHb83/t08QwvHU+n/QerAfl0mw9bA5KwHX9rriUvoh63c+H5z+1/Mvn8NDej57vTPQ6Utj+Ge2gqQsTEQ7JOADUzeAk5uPTRlGZ3EIOskfw== 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=ftrm5PnfxSN6TFaYpNBsboVG1Y+OovC2x1ldoaop11Q=; b=To8TaXNqdLcahm465+5ticGSmw2GvZ4VNWr9HyEx7gz7/Hwn8gIUSNqDgus9fhlJ9QgBkrn0384GGn3A//WYpYEEXenlGw0Ti5LYwBpk8QftFvxgF7N+SIjVWoA6/wl8SgGBv6ZO6CbU2Gi4OYZPeKEW+T0Zj2TtqBZXbXWXsHjnKctzxcFbi3n9/8XEY1W3stsGqxLHGhdYI8OqPSakz45rI4kmYQylO7Ib9lRBgUX/7xuiB+2DFm72R/B24jvduZpRRq5H2lxSScB5sfWErETXjuyzVdmmM9Uh3AQ1GlWQB85COciWjeaadzDFAE8dfGZCooLXjTT24hTka931Jw== 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 MRZP264MB3227.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:30::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 11:28:09 +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.017; Thu, 27 Jan 2022 11:28:09 +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 v2 4/5] modules: Add CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC Thread-Topic: [PATCH v2 4/5] modules: Add CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC Thread-Index: AQHYE3D1Z7Rpwj2GuUCO1fMCdk3yhA== Date: Thu, 27 Jan 2022 11:28: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: 5a9629b8-3d6b-48e5-fa16-08d9e188186d x-ms-traffictypediagnostic: MRZP264MB3227: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: jowYzr2s8tmK5SrzXvi7c4METlRlN+yTSnVoRtW1GzN48shyYC90eTfGDAZnQom8WcfJg7GJs1fKRe2SshcGT+sC1jiosa+ZR2eukZhmNIf4DOJzbnQ6cewohqoe+YlXWNIPRA7AfVLbyZw1+2hJXEQ/FuWRpquT34W5h7J0TYnIXiBFAO/BMvZ3YVddf1CVRelgOHYIyw8k/V3LB2a76z7hBEErYwZ5fGFWu5sAsgdGmW+1F9rJMs6Ux88VN9pV5Kb+bZnGv3Qcm8DSmSVwh8TP44Vl3BiI2CBnVWBuKFZiw6NEzR5BX3ZD1af4rwB8877U/3F9nC013wgavQAetXBrskkyAxJ0iaaOuQkUaB5fGVij/18V/1rRA/qj+GJm56FJZJuqGcPJEMhsyX4CkIX6JarLgiLoF7HwI5FUp/2LsL50yQ7ZOFfJYYFa8aXmFEkNPhXgtDBcTCLNGtJY/2Fx7b6LAfNmVLFYn7hqyfQyzi8CLshCiarG5mwZ0aZyMxhG2tF3L+l+1reK8Ik1xYO8lh+4EjPU0IfJJvHgQq3OoDkeDQDZrW89oiCp+jgS4a04SpVO60F0/x8eTuudXvu7LJVz2O7rxYGsdTzfDr6+/uuxPkM0KaKcrsFz3KcJ6HxB2J0XdITBfD27tG/LZfxKo31T8T7DywtvZpelXlcP2YVJctephdUXXuoM7LT6/dGxR2BAoFF+eY0aoPpfjw== 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)(86362001)(316002)(66946007)(6506007)(6512007)(76116006)(508600001)(66476007)(5660300002)(66446008)(66556008)(91956017)(44832011)(4326008)(64756008)(7416002)(8936002)(8676002)(2616005)(36756003)(6486002)(71200400001)(38070700005)(2906002)(83380400001)(122000001)(26005)(186003)(38100700002)(110136005)(54906003)(20210929001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?e/dsWD90LPN8Kj+5rd6KDvw?= =?iso-8859-1?q?hIWanfJcEVjo9X1gC+QMJiRN12CydejPmg7NpeP1lwDsO2I2PsWU92zYuzgt?= =?iso-8859-1?q?cHL31/+zvuTqGBYoYCQxr67deTS1LNHHqz0gz3Gqqgf+WtDPh3Q+RAHINsQY?= =?iso-8859-1?q?cd/gTVcAXzaKK4Z+SifPwU9jIzE3a83keZOgcUvvzJE8PBtQ96ixL9F6CNjk?= =?iso-8859-1?q?yo1HYqdhaXqYI1sMICJRx+Srdjpt8eGhyDaw1+0dHSuPloRAArgGncmd5Ulk?= =?iso-8859-1?q?CWZ7DcSsOSF1vpRvcoDyuG4IDSlM7Uu4M4mMNS4GlC5bjLO6DWM2SXSMiPXh?= =?iso-8859-1?q?Tk+ROzx6BYoeD01hvQSSY2ZRz6AMDeAp5uUiTf3vMZOgvV3fnYkhUIVwFivN?= =?iso-8859-1?q?0CwvsyGEVO8yLbdRm13YPhRMiqe/xN7k2p4LvSii+8crgZh1E7XTMuh6CkbI?= =?iso-8859-1?q?+9BLG8SGeM0DhQRh5nmBEF5WW6MKMnu2WduneaBvCfGw24/jAzw8i36p2Rsx?= =?iso-8859-1?q?pajYEXYCdhnFcKRmnANBNP6YJUo/lweCqQNMkTK1HKmi00jpI+jla5M2yxWG?= =?iso-8859-1?q?M+7y0OpGJ2HnoBTUGNfEsL1lcdwzcd/mJHhPbdQTOXaENuMqvEKrNE/fqvmk?= =?iso-8859-1?q?R8yujfa6SnrcEXcJ/NzIRzry9EW3g+LvGBVS/1nP9X9bjLCtc2QcTK+7uFD1?= =?iso-8859-1?q?VHeMjQdQL9PwZRidGUqqZP0xIWkOH+2xXraXQP7DXr9iuhBdBO3EiptapeFB?= =?iso-8859-1?q?0mbRNWfQtZZpPVDFL5YHCG3R/aGVvJUcImcyxctj45p9bdBtdDCl7y2uNsvG?= =?iso-8859-1?q?6bmU6lCoFwNV2P0SJnDC5Lvi6VdNJeBapFv5qweEHQem25Lyy9jrYdDdD8OT?= =?iso-8859-1?q?pFbnKR0syWKEpgHUtoNJqWZzm1ykjxOyXyQT7K4FXWCPfe8+0LxwjASJM+xP?= =?iso-8859-1?q?hEQHdqisdSQZMNXpsiaOW9ixiOGk1/HDbsbw7Ev1nJcq3hucdgs7wf9QNSJS?= =?iso-8859-1?q?tYaiUfGd3dNX8kVqdmmUmdz/WMxdcUNdWybtACD9krxPWPtmTbTN1/jN23hC?= =?iso-8859-1?q?dbf/zUp6HItIIYfyTjYxR0bSaaUGEwn2NpmIMbXXOGiEpL/jwgQLvEuK2f15?= =?iso-8859-1?q?UU8rb0XYdoZuDigI63x/xWdCeWnAQvqopGVV0MqbtCGEg0jGcvErwbssnOMU?= =?iso-8859-1?q?tEicVyLzeL3C5KWPXMTAZzC3RzIpc52tF2ky9cinVtHF6zKrHNon93bNeZOr?= =?iso-8859-1?q?glpXH6/K0MMVSOqHDQJ0D9P0MjAKbahKdVMy6IfsMK43OR3rYGdb+lYgg0WZ?= =?iso-8859-1?q?fQuRIdq+MoDv/pbeWwybKkneynd1wFtvQyTLDXGOhlW3PZ4nvP5T9CRBFNni?= =?iso-8859-1?q?kxhNCPDIN4tllHTe5mqNv6l2UTWoX1W7ZMo+2uIO+FRPlI1a7IhKyJ+bZk6B?= =?iso-8859-1?q?Ju8m39GanIOxERMaF2ziE8fXCNezdHFjm85j217azPxRz41jx/jyg2G7AS/o?= =?iso-8859-1?q?q3/mPFMZmRdaR0yjzU5dCMKLDsbIpUkXGpTFl4xwGtHjnF1RLctVXcfGrjQt?= =?iso-8859-1?q?PPVfPAbT6pzo8hWlVrdfzfvnDfV+IMDHVP4H4dBXNkkn6SZa7XSCSUOfmwJ/?= =?iso-8859-1?q?pvDPRXJIxzh4o5DmgL3JXkmh0RFRH9rB24uZmQTIT88BxjfzpbArAO5qcbEx?= =?iso-8859-1?q?LmLM8X7wHLfu7JY0+cg6HMAFkmPI88SGJb0XPUbvch82ZCNmsNhdW03TxJuH?= =?iso-8859-1?q?XM1o=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: 5a9629b8-3d6b-48e5-fa16-08d9e188186d X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jan 2022 11:28:09.0829 (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: NdKcHODDUINQJGjyscLlj6MivQQz+MpvUNUDJ7dpbGQgTILLGP2yV6qUM8AwE5ZQUxzTRaaa5GbHjdP3v/i2VYZ8ET49ZeuhUQDcSRNwPfs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRZP264MB3227 X-Stat-Signature: p638p14t1adjy77nyhyxhp5ecyq35q1j X-Rspam-User: nil Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf21.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.9.79 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 9C6331C000B X-HE-Tag: 1643282890-506705 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 Cc: Daniel Thompson Cc: Douglas Anderson Acked-by: Daniel Thompson --- 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 2b70b997a36d..884c9fb11813 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: @@ -108,6 +110,12 @@ static struct mod_tree_root { .addr_min = -1UL, }; +#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 /* @@ -183,6 +191,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) @@ -195,6 +208,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->core_layout.mtn, &mod_data_tree); +#endif } static struct module *mod_find(unsigned long addr, struct mod_tree_root *tree) @@ -249,6 +265,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 @@ -1178,6 +1197,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) { @@ -1206,6 +1236,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 @@ -2208,6 +2241,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) @@ -3459,6 +3495,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++) { @@ -3634,6 +3688,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, @@ -4612,13 +4669,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. */ @@ -4741,13 +4802,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 < mod_tree.addr_min || addr > mod_tree.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 Thu Jan 27 11:28:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 12726612 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 101A1C433FE for ; Thu, 27 Jan 2022 11:28:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 912F46B007D; Thu, 27 Jan 2022 06:28:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 89B826B007E; Thu, 27 Jan 2022 06:28:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 714576B0080; Thu, 27 Jan 2022 06:28:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0043.hostedemail.com [216.40.44.43]) by kanga.kvack.org (Postfix) with ESMTP id 5CEAE6B007D for ; Thu, 27 Jan 2022 06:28:15 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E089E8249980 for ; Thu, 27 Jan 2022 11:28:14 +0000 (UTC) X-FDA: 79075843308.19.D457E13 Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90055.outbound.protection.outlook.com [40.107.9.55]) by imf16.hostedemail.com (Postfix) with ESMTP id 4FF17180009 for ; Thu, 27 Jan 2022 11:28:14 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HONsLZcHH0WoHGXT0+zCH1t2xJvj//2SpjrRmBzgbXv0j5g+IlaHoLHK65TMa7UCYmQsvdbZlc/N0k6akNXmRtC9+qgeafT5NAnpJIvdauJT8ahqxOQn+YLkKrV95qpyMNZ5lhCkqLbDjy5RyEs49C3VCWEAea1W4QxiszVRPB+vqPrlnJjMt1+kKXE9Pfku8H3AyEZSlkF5kzBwK1lyt3ORlPmuKIdNu7jjJE4nzBnQXkaU2zjbBQc8BNxuRBXt///i3HEyFm9g54YYdWhU4oVdTsKjDkY+vxS8aAc/JJoHzJvGphtUaOKNQeS48B7QrcmVuIBPVe5jCtI14dhM2A== 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=PhDFfC15sYA5sS1yfPxZ/4tBEafzLuMimPYpmp9mZF1X6jfbYczFnF312UTOUVA96JFQ9f3sVmKsk2K10v5zIws/kpYuE6oHLpkW9IY15d70WdAgp0wle/AQMGQXZQ9/twx8ZboS7aOenkjsfxCtl/G6Krycio1qI/bOEBJNw3nKgdxC9zum3F1PNQ8fKVHuOLgyYW2aRPGt6OSR1lSvLUddGmAnk9QJNnnw3KzkVuqT2mmwmG8YcR8PmA9JFZ61ejad/BnelRX9PQrsA1CK0G6tHV4OYMkWR3+ABZxDxvOJ+JnLBvtkqt6dCIXH5lQeD/gfjtKabAsQ2twUNt8GDw== 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 MRZP264MB3227.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:30::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 11:28:12 +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.017; Thu, 27 Jan 2022 11:28:12 +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 v2 5/5] powerpc: Select ARCH_WANTS_MODULES_DATA_IN_VMALLOC on book3s/32 and 8xx Thread-Topic: [PATCH v2 5/5] powerpc: Select ARCH_WANTS_MODULES_DATA_IN_VMALLOC on book3s/32 and 8xx Thread-Index: AQHYE3D37kysOO3Vq0mRXtsXlcd4bQ== Date: Thu, 27 Jan 2022 11:28:12 +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: 4585b1ea-b2ce-4c99-123b-08d9e1881a38 x-ms-traffictypediagnostic: MRZP264MB3227: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: 35pcxN+/jFlfzwNgWNHWKW/Q2UU2LHTZ4TO0dk9fUscOlugP7i/hLWo1VXGJU305Qub4W3b2+u8Lv5V4lPxJXV+GwCc9Vw88jgvye4V3QHZm88itjM1w39VAtWXgQQxWTdvBqGog4QTzAyow9REztVaIHcG9OjzqqM7J6u4FwpBkvwbX7oNQOUPgw50c5YA8qsBZxNVojE8yzBGbbBjJRCI69X/idFqnUTJbpK0x9oNIokKhHcLwzceZ9sc1zN1VfTkN3GIbMNBzK4z0MbJeMIopCva7cMqqhnnsJ7QtdJ3LULxZ65qrwEyUoobpZaSf9mBxKtjl4KPKxbIGphx42kUhUk1M29r3b3Sj+4XgxuOQd4O6M9FhPEw1AtUeY4EIZAyMomBB6yr73QpHXhgsYOuYIFhbLad/DLKPleizlAtnIRPAU6RS37qXBg8cndrJ2gu7kbFtpguZRaRgh5Bnw0ghe1yoWnach3bZNLum5YBW4iwBmholLoh+VRnUoFnCOBs7GAGy3nc+fDMUxjiCuKJ535lC8GEDRKTu18FYZ81vjYY/iGBUBZXK5QlQkjxQH9HxDnHUU7OEbKlERnA88hSY7ElBCcgsfwThgrziC9PXHB4SVvaBAPX4dEzoBnW1ZGSyGHYJ1UIVtJb1I9evumbOIfFrgWpfZjCVPbtud+eg3wGiCNFtnuFKfFjFWXvV3TuChWsdiaUCwSxggs5znmfMIDlUTyJ1+0sTjS6AhZk= 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)(86362001)(316002)(66946007)(6506007)(6512007)(76116006)(508600001)(66476007)(5660300002)(66446008)(66556008)(91956017)(44832011)(4326008)(64756008)(7416002)(8936002)(8676002)(2616005)(36756003)(6486002)(71200400001)(38070700005)(2906002)(83380400001)(122000001)(26005)(186003)(38100700002)(110136005)(54906003)(32563001)(20210929001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?r4ylYb/DVh5IEiPzk8bl+g2?= =?iso-8859-1?q?hJaYN2XN0pZJ6EcqpJnU3Q8sfiMUqHfMBjnA+diI2mQnZyydLqHXz7xCK+Es?= =?iso-8859-1?q?p3niwmZ32CPE60GpuV8fy1UXEWNTJFqZxP+CcvyUQpVSvDLJ45r+q7rQSq5k?= =?iso-8859-1?q?b+eRwX38jNkSsuAzeBJmtKUcmvcvJc9xfUv4vohmmUl6dQi95Zev4B3QDWXC?= =?iso-8859-1?q?lraT94pAZn3eQudBRxp0hdNML+vCcbS0v9oOvKrrcyLmr7wszwHi8QJAMql7?= =?iso-8859-1?q?XznR+1tBr7H2e4iyRfBxflFNykDxmcy4GUZPelqfWeQ2UOSLXtPzmxXnMRl1?= =?iso-8859-1?q?FrJa0i+t4AZs/X63LDIhCQabk8NLN0ZP7tUuDfmCvVWkgHbn5+A6JU8qB1DW?= =?iso-8859-1?q?w894aoRYLfvQfJ6gnNC47cH05d6RHYHdT4jO+L/DrHxO6hFHC8CoHGEuTrnr?= =?iso-8859-1?q?uHPFArKtP6VecwUMIuh+ybhNoz+1EVLF9dLev8pzIU10OVfWjPSzU11mexKS?= =?iso-8859-1?q?CPfb0h/V+h62pE7vWUk9Shao1uvUrg5tiRRRyMuO/b10oAJPOlWylCK9OoTf?= =?iso-8859-1?q?qPRw/SKxe6YhUqcrR3ZhiLl2B9QKss6bzO8z1cHzD/PKaDfP/vHfEYjLUN0h?= =?iso-8859-1?q?a+NlAuGv+auW63BJUz5Vj03hdmHBz3tM2WZ9yshI4o/yHSZs38DeQzRgKIaC?= =?iso-8859-1?q?2LsuSpqBD84pqcITvB0ZuLXNUe3SSBLj9Vkb36U2SqB0V8NG+zRO2pxKPMme?= =?iso-8859-1?q?4OebUtTJBJA+uxQTdZLDL6hnItTypQvaSgXXD6hXIZdaLCxGclS1CXKNsG2K?= =?iso-8859-1?q?vOUIBJ7FZ+g8UqckqNKNJty1qlVsgN5i16TGU6ThwjxKBJB9V+Dq0iQapvwq?= =?iso-8859-1?q?CiYJDGFl4X7O4I3XPUWSvii/CYH02HAMkBHzx89BKeuVM/TreUMytuRd4Lsw?= =?iso-8859-1?q?ReMzOYj7ivY3UhebrSgsSOzTgdV8hOLuh0sGn6klu2ZlaAH52hAcOMlWQZK5?= =?iso-8859-1?q?vSWbv31xPsS3WpS8aJvNPtjcvj7byiAaMM8NovvsNwn91KbAmyLB0HjGl+w4?= =?iso-8859-1?q?SWwCJHQvOu7hrtAqKKODRBVnqUr+X6R2RliKU+6Bd3U71OX2JAeDRvKSniYq?= =?iso-8859-1?q?kLOqVc8DbVBa5ryEW4kiprrbAE9uKAQRxN+gYIqdWYHovCvL3O/1pTd11s/u?= =?iso-8859-1?q?ilaDBcS9mmHAPO5ro2fiCzvO7YJyQwuNQvsopIvtD8Wnvp0v+Rk0bCkWCImR?= =?iso-8859-1?q?rDw3cFZNCAVjGxv1cWORov4jkFRfNkp4niBN2kT8Vc/qVm+pgNZwh5ucSV8W?= =?iso-8859-1?q?NqNCmt0e3mIwi6EdzifTqn/8jx5J85frAsw/9AQNgv28+4dwuWgiaD3KhrIS?= =?iso-8859-1?q?o1i/e7iBxQGPJtYlz2p7XNMWzlPbK/jh/PapiQQBgLkJsJ3bpgMxTJGiF/o9?= =?iso-8859-1?q?h54ytrQ1s8XotPGpL1MKmkqtBub9ihD+Jlx2OEC315XN24/pL6mu8boDlQ4N?= =?iso-8859-1?q?MXu50sbYxPkIgGtgI2yK3gfYYfGRt1HI5t91HibudK1TCYO74g+UFvY5vQFr?= =?iso-8859-1?q?oMRHjf9s4i5C6deVqtQ0sLK1ihj9oM1J87wYUMoq7ABu8gl9fZDFjbl5XpZo?= =?iso-8859-1?q?a1TduM8YbiDY0W4LDFr/P+AD9PYibqzd1oiRGxjoTFEtvW8JVRLOjBjkGAVt?= =?iso-8859-1?q?dDKfz8DVyfjREas8Nsh/S5ENUa9pQDc1Y3qvc5jW6v6DbrFQvRMyeRhCLrN3?= =?iso-8859-1?q?mVOk=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: 4585b1ea-b2ce-4c99-123b-08d9e1881a38 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jan 2022 11:28:12.0695 (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: QE2iG1lyjB9puRxP2Hd1tDfbjnaBnOmweFdBgashU8HvUP92dDUohHGQ3rGumku00QDcnqdar4JxoeOtPudlJ76L4s2y5bSEfUoD+mNBhhU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MRZP264MB3227 X-Rspam-User: nil X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 4FF17180009 X-Stat-Signature: 5fizfegwhi4w1izifcugpwi7mzmef5gb Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf16.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 40.107.9.55 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu X-HE-Tag: 1643282894-574334 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000316, 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