From nobody Sun Dec 14 19:12:13 2025 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11023090.outbound.protection.outlook.com [40.107.201.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3330D20C48B for ; Thu, 12 Dec 2024 08:25:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.201.90 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733991909; cv=fail; b=UphnQGALxp6gFt7YoAILziuC5aI5i2vl5ByeQkrOOas3Fk5Pg76V0RCu0LNlx8IO1mIHhgxaeqFr3mMiAn4sjkZnCuySsVxw5vG+F2JG73D9fZZzd+CGqYrRYnbMXDtwAGSPlaXuxaYrdLavRp7sueoYoKccGOxWjtOoHusdJ+8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733991909; c=relaxed/simple; bh=EYnS9uOEd6dzXMo+uncnCUmduMS+ehFTzgDBMF3tzEs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=FuCVwN/dKFhKJj9uu/UrIZMrebICcqsMAnWA4eV77PGtja2+q9oejFs4kw/Jyp8lyas/NVrbb0Gh014a5IWiBWRHXU67eKK/zbr5J9oLtC8+VnoR+f053xTYnVXAvlhEKgYf1s48BtGbQlhZ6pV9nfvfSsPK3nputwbhVutUL0U= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com; spf=pass smtp.mailfrom=os.amperecomputing.com; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b=QOqUfqwu; arc=fail smtp.client-ip=40.107.201.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=os.amperecomputing.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=os.amperecomputing.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=os.amperecomputing.com header.i=@os.amperecomputing.com header.b="QOqUfqwu" 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> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: MA0P287CA0003.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:d9::20) To PH0PR01MB7975.prod.exchangelabs.com (2603:10b6:510:26d::15) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: =?us-ascii?Q?Q3/x0CJ+B5ObhjlBpy1AUox4lHDWL+ft7qncQfawbJSnCqw0zQgWNw50BsWJ?= =?us-ascii?Q?7ELf5eu5AJStdM8C4oz6kVHBE/DnFWU4XFlEpSujKfcCLjI1RreFwM3ngLLS?= =?us-ascii?Q?AV60jvGWNbEQbYO5Bwnb5auf4QQ3JopGgiIz4cqySqFU1F6jQVNjPDIHrDmv?= =?us-ascii?Q?Htn6D2tHfiKEBRWRdkTUUjmmzbo7JR55aVBFalFITOPE3d4U64e+T3yTTEUL?= =?us-ascii?Q?rojzc6EqgQ1pOQ6FwZF1kWY9lu3raYaxQFUfyhno8Z7XRtg/jQGrgfFbgAQT?= =?us-ascii?Q?oNiXI7QkY4GYH3HrEpgQcdizYNQjEqVcQkgvMZBF/E53NBhFPhxY4qFKz7zw?= =?us-ascii?Q?Sb0y3n1ZNVAYZphs3ImAqNqOAttj+tPn17jOW6sW6RcYhkfBTLJvT1ZzI3/x?= =?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FiYofmOBGkDJOqtADWle0AlWzhi/ma1/?= =?us-ascii?Q?Cv14Jv6/H6LmrauZr0eqPEbOl/Mi+yEmBpbLdWC/VKxWE1PpKVMslAIgSjVm?= =?us-ascii?Q?8X6t3djRUI4kFfkkczS7yKJvxK+1wIzJFadx+Z6+zekelo1xag=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR01MB7975.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(376014)(7416014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?KX1W9ZM6Qf8Xovk/Z167tGYpCoEdw+tgpemUPPEfKIq+scImw3UZ61iIli8W?= =?us-ascii?Q?ACk4F/kbSwfnNdfo6pSiX7p+rgLWNLNlVEJ+h+MEL2R/bRJuwQZAUHeR7irG?= =?us-ascii?Q?Ko8Wkmpo+vo9kP7bCwAdJjzx4UytOXkGLgEjsAtn5yxGk51fH4snVsKLKjpE?= =?us-ascii?Q?Bj/o98EjvWeEREuC2FzM84uIEFh1OAQZ6fDr3LPSTFpF94W8bEoGgSYsqjKA?= =?us-ascii?Q?k2+aOlYB60ndzeDDThLhstrwVRcECkN3XTIi61NdOGXtggNX1Yfoey1OUMGl?= =?us-ascii?Q?DzoKVI2XxFoxAZRbwqvcz4LiElnVg0WYI/7CL82cbUaww1AXHAQ9beW+2IJj?= =?us-ascii?Q?Kx6UuJDvSWskUJPL1nLk+Q9KJ+yWlsHi9rNkd9DZUtv0U123uCoCfHaRMZQF?= =?us-ascii?Q?S8lecPeBcT9jUpI23afVtFQEr0XJl8CE1c5zUzbc7olu0ah2fnHcQ00dqgdV?= =?us-ascii?Q?Cqd0mw72ZtQM+sgWc88ry+W1Dn0W+4zj7xaTe4WQVa6vVzB4s9zNPhdc8FOC?= =?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nrXiqdSb/XLJHE1oiN4NKl+RB9X?= =?us-ascii?Q?/JUD2jLkR7LoAG3SHUWoFknuZbDwMRKMyMNqZMSliN8bo1qfLM5Df+cN6F0f?= =?us-ascii?Q?tJ9L59UOKGqg3deHks+zWCYspvXue8867Oncx+exOWcX2xO6Xsxgh/8k/Mmi?= =?us-ascii?Q?NzZVmpTSbgS8gc20fN42m1DNKBFOfu2GN2emaXuKS/a8o/7koFhlC3mKLxl+?= =?us-ascii?Q?0O32dMpmQ4b8xtHX0duI1hY=3D?= 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 Content-Type: text/plain; charset="utf-8" As per admin guide documentation, "rodata=3Don" should be the default on platforms. Documentation/admin-guide/kernel-parameters.txt describes these options as rodata=3D [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=3Dfull" is the default instead. This patch implements the following changes. - Make "rodata=3Don" behaviour same as the original "rodata=3Dfull" - Make "rodata=3Dnoalias" (new) behaviour same as the original "rodata=3Do= n" - Drop the original "rodata=3Dfull" - Add comment for arch_parse_debug_rodata() - Update kernel-parameters.txt as required After this patch, the "rodata=3Don" 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/Documentatio= n/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=3D [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] =20 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]; =20 +/* + * rodata=3Don (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=3Doff + * + * 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=3Dnoalias + * + * 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; =20 - if (!strcmp(arg, "full")) { + if (!strcmp(arg, "on")) { rodata_enabled =3D rodata_full =3D true; return true; } @@ -31,7 +53,7 @@ static inline bool arch_parse_debug_rodata(char *arg) return true; } =20 - if (!strcmp(arg, "on")) { + if (!strcmp(arg, "noalias")) { rodata_enabled =3D true; rodata_full =3D false; return true; --=20 2.40.1