From patchwork Thu Dec 12 08:24:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Shijie X-Patchwork-Id: 13904808 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 203FFE7717F for ; Thu, 12 Dec 2024 08:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=aHTLca1a3DMebjt/eDGzKKdZrQWqh1BRI3n2PJX+MxY=; b=I3zZMdssGx5MHyLuZsqp5XFIN5 WDcDp+ywqu6O3kylLcTZZij9Z9tnQ/6ZNlMP9gkZc7vA8O1b1nRYx+jPaxe14iNRN+pzSzfLiGu7h tK7+X1H2ztC++uo3BAtqC1qyAl4Cc1hQ/K92bTkRhjSUFCXhoSq2ql02Vil2N7YI+TI/tbeLn6QRa e6hW53IssvFOflbBuek/VbKtlEvFMd3SFVwwpFPm6hIDbdb1mRktjlk4VtXQp2Yz/lf0hGoW/SYY4 gNCkxn7xBJtt5voOQHHW7VzLyFC6/pwNdoufYrsclBUUEItEE3bc6C76kXQ9GMFpLp5tyjq+jco/0 I2Vd2qUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tLeZY-0000000HJ3c-28PZ; Thu, 12 Dec 2024 08:29:24 +0000 Received: from mail-westcentralusazlp170110003.outbound.protection.outlook.com ([2a01:111:f403:c112::3] helo=CY4PR02CU008.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tLeVT-0000000HI2w-0IyX for linux-arm-kernel@lists.infradead.org; Thu, 12 Dec 2024 08:25:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=S4logDEEB6dgAp5t1PifVbYLqQ8cl5cKZiDWDluKInV060+dB1Oq2P6B7FmY5ckc5wVTXxzVUiOQmwxrgCm/Iz67c/dor7BzaKIcuMZ4S1f3jP22T+fOKrNCq9Dai3nrH0+yg37j9adXhBjL2VWlAtqKGKpslUXLtk1LiQO7fJaNvSytR2MN/DAGdLifEkAMwevb075rI55HxLDrjTj+4+eXVwbzt3pznPUr3wXYXaWDt2P1zhJ+lEIjJvd6NYmMvddS0dk2GmY8WQQhuGkzvdr16orGUQ5Duw3yydhV2OVOEFLTUNCj0yG+iM+zJUV2LeTai990W+mmJ/11F2xs1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=aHTLca1a3DMebjt/eDGzKKdZrQWqh1BRI3n2PJX+MxY=; b=sj8suACzAyA53fD1p66jQe8Yjk2+OWwLHkX9zPvYSEiPwRTVxSC0I67PZqUN8HU9EOMbbxrYgpMF5SeTiWtzIvzybR/oO8rgrzVwWaQs90ij9GQ5N5qnstUB2Pet+NHu7bLbnviKWoh+s0FCSaaE7TAsGUuMBc5i2em86OEwTNOak2JUxvvDgEhAHCfNfzTUeRh1tyR2IwmDGr7TMHcXheVesw6R5Ees+UvzIiEdD9RTtesqmET3HHGUBQX9PvWSXTv9KMh05+Oqn6hL+gFq4qgZMBngOoHMQaEA9NDLY2Dg6VuTAS76kMmOCZMDjCeChk4nPXaHiptu3wMSoWm12g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aHTLca1a3DMebjt/eDGzKKdZrQWqh1BRI3n2PJX+MxY=; b=QOqUfqwufUshNAjCI/AmjBqNTSv1tQWjvXfsuhe1Z+5jPtf35SaP1b5G8WRWpZNqDwHzAB07/HcXnljoUWI4OCTUaTnu3/Zd+ieYwqF7qY/MOziTfo8HTqRhHLql9xWxQ9tSbyFJKgPnLumj8ZMtDpfsGykE/GD5B/4hJ5ysj3w= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from PH0PR01MB7975.prod.exchangelabs.com (2603:10b6:510:26d::15) by SJ2PR01MB8459.prod.exchangelabs.com (2603:10b6:a03:557::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Thu, 12 Dec 2024 08:25:05 +0000 Received: from PH0PR01MB7975.prod.exchangelabs.com ([fe80::6926:a627:118e:8050]) by PH0PR01MB7975.prod.exchangelabs.com ([fe80::6926:a627:118e:8050%3]) with mapi id 15.20.8251.008; Thu, 12 Dec 2024 08:25:05 +0000 From: Huang Shijie To: catalin.marinas@arm.com, will@kernel.org, anshuman.khandual@arm.com, corbet@lwn.net, ardb@kernel.org Cc: patches@amperecomputing.com, cl@linux.com, akpm@linux-foundation.org, thuth@redhat.com, rostedt@goodmis.org, xiongwei.song@windriver.com, inux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Huang Shijie Subject: [PATCH v4 1/2] arm64: refactor the rodata=xxx Date: Thu, 12 Dec 2024 16:24:25 +0800 Message-Id: <20241212082426.4110-2-shijie@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20241212082426.4110-1-shijie@os.amperecomputing.com> References: <20241212082426.4110-1-shijie@os.amperecomputing.com> X-ClientProxiedBy: MA0P287CA0003.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:d9::20) To PH0PR01MB7975.prod.exchangelabs.com (2603:10b6:510:26d::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR01MB7975:EE_|SJ2PR01MB8459:EE_ X-MS-Office365-Filtering-Correlation-Id: 54b6f04c-ea7b-4718-fc88-08dd1a867b7c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|376014|7416014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: Q3/x0CJ+B5ObhjlBpy1AUox4lHDWL+ft7qncQfawbJSnCqw0zQgWNw50BsWJ7ELf5eu5AJStdM8C4oz6kVHBE/DnFWU4XFlEpSujKfcCLjI1RreFwM3ngLLSAV60jvGWNbEQbYO5Bwnb5auf4QQ3JopGgiIz4cqySqFU1F6jQVNjPDIHrDmvHtn6D2tHfiKEBRWRdkTUUjmmzbo7JR55aVBFalFITOPE3d4U64e+T3yTTEULrojzc6EqgQ1pOQ6FwZF1kWY9lu3raYaxQFUfyhno8Z7XRtg/jQGrgfFbgAQToNiXI7QkY4GYH3HrEpgQcdizYNQjEqVcQkgvMZBF/E53NBhFPhxY4qFKz7zwSb0y3n1ZNVAYZphs3ImAqNqOAttj+tPn17jOW6sW6RcYhkfBTLJvT1ZzI3/xVhJPhYiS6SgP/kN1bWBfOuOgRqXRtHgnuiGBTyYlVVg9uEvy/xXtjabXHsNFJH9gb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(376014)(7416014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KX1W9ZM6Qf8Xovk/Z167tGYpCoEdw+tgpemUPPEfKIq+scImw3UZ61iIli8WACk4F/kbSwfnNdfo6pSiX7p+rgLWNLNlVEJ+h+MEL2R/bRJuwQZAUHeR7irGKo8Wkmpo+vo9kP7bCwAdJjzx4UytOXkGLgEjsAtn5yxGk51fH4snVsKLKjpEBj/o98EjvWeEREuC2FzM84uIEFh1OAQZ6fDr3LPSTFpF94W8bEoGgSYsqjKAk2+aOlYB60ndzeDDThLhstrwVRcECkN3XTIi61NdOGXtggNX1Yfoey1OUMGlDzoKVI2XxFoxAZRbwqvcz4LiElnVg0WYI/7CL82cbUaww1AXHAQ9beW+2IJjKx6UuJDvSWskUJPL1nLk+Q9KJ+yWlsHi9rNkd9DZUtv0U123uCoCfHaRMZQFS8lecPeBcT9jUpI23afVtFQEr0XJl8CE1c5zUzbc7olu0ah2fnHcQ00dqgdVCqd0mw72ZtQM+sgWc88ry+W1Dn0W+4zj7xaTe4WQVa6vVzB4s9zNPhdc8FOCrfPYcSNm/v5t1g9WkrIJ3yKIUifPZJ+M2FZTvSMwTi6WZpq81wm37a1et1oPITrs/GxiRxthQ8SCKsxoQbuEVvpNL75sGU/X5BMdI2YLl1bzZO03CgzHWz5hqpYh+u34aOPZw/n7hdy0nDP07G7hX7dA6Ck1HSYUVT+FusXOK+ImfB33fM3B/JVfmf9hB5ksz0SiJRaI5alqWnyXFWXriLkL0+YPJBTHH8MTfdPKKkB1WSQkWBASXPYCy3/Wwuij71SLQ27ipTPx7iJO9N3597U2UD9QwnXE7h8dSPcETyCqZxjdlYLoh2sywvMun6MKpNVTT5ptrpEuSKyNwnjnTu/sDw+ZoYa5TECX+kjhwkKT77XDJ+88KjIulTzf/S6dy55r5DNA9wHa+BjIxYSw2fhwdS9b12iengb6OENwKsqKaF7TpIGr+v1FiVzqPXxL+WopB2oxOorbW4P99XwnNHFrhjI4PGLfaTr+PkAcL/cfrJmywk6TvB+709gCG8WC+H+eHq6u7mTtEEz5bhLUlZLMTEecjzbH/QoYoCvTVp7r2oxDRgXsXfAh99qHv+0Uc2M+JTsYCqIuzxbgXrJpxYebQZ5DzCdANcvbQEn7Reoylzld+AIRffZjEs8h4Ob/iBhuAC/jT3tvcM/BV9TakE0TB1MOzRrtH+9CzS7TirkJMoIWTmq5SHPMPcIlWJdmVHLSfvfw9uVLf2AQb/7E2u7gyC+pYwgF86yULhwCV2y2jOR902TJTNK6vtn24c/5DYNx3Qeu8RcUVqNfPBNAJFGL6wcVBLhCod+kD0BjqiH33uC3PvZt8vX64E+1lqQH9RwhiujNnYge0i9Su4TxILePJ/CaogD6Fb0jV6YjSnrXiqdSb/XLJHE1oiN4NKl+RB9X/JUD2jLkR7LoAG3SHUWoFknuZbDwMRKMyMNqZMSliN8bo1qfLM5Df+cN6F0ftJ9L59UOKGqg3deHks+zWCYspvXue8867Oncx+exOWcX2xO6Xsxgh/8k/MmiNzZVmpTSbgS8gc20fN42m1DNKBFOfu2GN2emaXuKS/a8o/7koFhlC3mKLxl+0O32dMpmQ4b8xtHX0duI1hY= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 54b6f04c-ea7b-4718-fc88-08dd1a867b7c X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7975.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2024 08:25:05.8196 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mLNWrwYeyWRp7MUldgWPeRXfjUDP4BAuRAYy78dodCsYEmJMo85KJXiFftvNSVYCi6thjWaQPWltiGITjC1HmtYd1lpOIXGvEsPCGfIruUxB5md4D9EqWq2qgnqYZN4y X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR01MB8459 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241212_002511_115174_AA93F278 X-CRM114-Status: GOOD ( 14.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As per admin guide documentation, "rodata=on" should be the default on platforms. Documentation/admin-guide/kernel-parameters.txt describes these options as rodata= [KNL,EARLY] on Mark read-only kernel memory as read-only (default). off Leave read-only kernel memory writable for debugging. full Mark read-only kernel memory and aliases as read-only [arm64] But on arm64 platform, "rodata=full" is the default instead. This patch implements the following changes. - Make "rodata=on" behaviour same as the original "rodata=full" - Make "rodata=noalias" (new) behaviour same as the original "rodata=on" - Drop the original "rodata=full" - Add comment for arch_parse_debug_rodata() - Update kernel-parameters.txt as required After this patch, the "rodata=on" will be the default on arm64 platform as well. Signed-off-by: Huang Shijie --- .../admin-guide/kernel-parameters.txt | 2 +- arch/arm64/include/asm/setup.h | 26 +++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index a22b7e621007..51bce7b9d805 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5901,7 +5901,7 @@ rodata= [KNL,EARLY] on Mark read-only kernel memory as read-only (default). off Leave read-only kernel memory writable for debugging. - full Mark read-only kernel memory and aliases as read-only + noalias Use more block mappings,may have better performance. [arm64] rockchip.usb_uart diff --git a/arch/arm64/include/asm/setup.h b/arch/arm64/include/asm/setup.h index ba269a7a3201..37f58a603224 100644 --- a/arch/arm64/include/asm/setup.h +++ b/arch/arm64/include/asm/setup.h @@ -13,6 +13,28 @@ extern phys_addr_t __fdt_pointer __initdata; extern u64 __cacheline_aligned boot_args[4]; +/* + * rodata=on (default) + * + * This applies read-only attributes to VM areas and to the linear + * alias of the backing pages as well. This prevents code or read- + * only data from being modified (inadvertently or intentionally), + * via another mapping for the same memory page. + * + * But this might cause linear map region to be mapped down to base + * pages, which may adversely affect performance in some cases. + * + * rodata=off + * + * This provides more block mappings and contiguous hints for linear + * map region which would minimize TLB footprint. This also leaves + * read-only kernel memory writable for debugging. + * + * rodata=noalias + * + * This provides more block mappings and contiguous hints for linear + * map region which would minimize TLB footprint. + */ static inline bool arch_parse_debug_rodata(char *arg) { extern bool rodata_enabled; @@ -21,7 +43,7 @@ static inline bool arch_parse_debug_rodata(char *arg) if (!arg) return false; - if (!strcmp(arg, "full")) { + if (!strcmp(arg, "on")) { rodata_enabled = rodata_full = true; return true; } @@ -31,7 +53,7 @@ static inline bool arch_parse_debug_rodata(char *arg) return true; } - if (!strcmp(arg, "on")) { + if (!strcmp(arg, "noalias")) { rodata_enabled = true; rodata_full = false; return true;