From patchwork Thu Sep 5 06:30:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qixiang Xu X-Patchwork-Id: 13791780 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 93627CD4F54 for ; Thu, 5 Sep 2024 06:33:21 +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=M6AOQTFQXZ3aIQJt/Ag7MYJ3ZWwVnhD5AKw59fQxJxs=; b=rCgm8Xp8cUQtUE5R7i7apHnfrX QD6Gar/Paqj4ey1AC3niRFVBG2ofy4FuwBIZTQeH4y0U3thePLRzCptBtHO/RM1Gc96K0+ug2Bzny he+VDKZlTTmBV8K9DEc+Otbn9ki42PSTKKU2OoUsEcaK6u4uO3ubajfCDZVP1kbROHilsbFwnXGPD pb6nhYLvvr/6Dm7gJiFKXJuRCijDTKpmaR//9BNfdhXtK7RnYAHemxH6JmBwVFSKgyPe/xkrpqGrQ sj8+352M2OdgRKVCUL/pt/cT9KtzEdB/7bihrcxc63CW11q9UEyCdbvPZrj7uZuUKhr1MjNAgs+QQ uxgciniQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm63K-00000007Bns-23cL; Thu, 05 Sep 2024 06:33:10 +0000 Received: from mail-tyzapc01olkn20800.outbound.protection.outlook.com ([2a01:111:f403:280c::800] helo=APC01-TYZ-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm61S-00000007BRB-49ij for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 06:31:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ywbUeE7m4VbGccwtebDwsvovfPzbepU6Qoq9RnrgwONgsiAlaTkVJKYziCqqCE0stnL5iQ0I1O67y4KmeoaxbM43A3qTNcV6wqSA8vSNxZhYzKqvQg/19/+m7dHg25QEkYB2RVVPKbKjUwsXEezeh2VyRqUR0Ztl6UvhaF0/f3Poj79mStLrt2GtDlPnyiThQNeI/Wzf/bNl1EHgS8rMht4EezUtQw5svrBTxtYETawfgQuKWwOReg9B7Wwe4rNq8YM7pqfmqhrSdCDkOSDcbcVWu2djjkDwIR96xDdtdpn71/zy+FkqVOusHkCQlGPDZ8nAQLg4+hdQ+XUe2owGOQ== 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=M6AOQTFQXZ3aIQJt/Ag7MYJ3ZWwVnhD5AKw59fQxJxs=; b=gpgl44VGr6aW4gtmOd6Z8IK0/5600sT9FvK0S25AHU5+2OkN+bAxcMxXd/UGu6s1MveaUMbj/5nUA8uQdliF5R2vV75eBwI4GM7sJB4Lwq50wGvmfJVM6IllBphUsYCWJjJcg4aIqdbT26cRqAeykbdttPCS4H2Z1VI+k8UKUDnRtjs5Q7//02v4DMLVLf4ZH3R2hL1zG2XoRtV5M0/Z+brM36UsA9jJ2RYJfD3bqNiJNztUUqVsqCwJwdRPwdMhWp3iQ/37Se8D/2bGRxOeyIUTwbwJBF6O0YYDvKYSbTn1YUu3l5FO7H5bie5h9mWzusMZDJN9tUq1F0MoT17p4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M6AOQTFQXZ3aIQJt/Ag7MYJ3ZWwVnhD5AKw59fQxJxs=; b=PQ1jW5L93mLQjT+k6WHIihL6V9mNbuvM95cTe2oe3tqgxstQIVP8xvJ+jn0+LUoDoVN6JMKpCiEN7Z1vAyU6QLr/jZ9WmOQGt7iQGVlgyRECHDlcQpkjQox4aHIC3afeNasyAazgBufVO8rNPdEypZ2nH9M9NjDEfo7GGN7ojdfP9cNO3Cee9E/HMarJNwDykiSG345vcOA4YqSoMXMZ3fQkHmPRVpJYt0VVaiwpZD042/N+gi70Y0hTzoVJdX3oHYb9vBug0MytY0d0zJnRHcRNvJHwQDXUiFW7+Aj9391YrSJVIWQCz81j23+eF165swMSTa1G8hD/Jim+0gsctA== Received: from SEZPR04MB6319.apcprd04.prod.outlook.com (2603:1096:101:a6::7) by SEYPR04MB5737.apcprd04.prod.outlook.com (2603:1096:101:8b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27; Thu, 5 Sep 2024 06:31:09 +0000 Received: from SEZPR04MB6319.apcprd04.prod.outlook.com ([fe80::8a6:22f0:5560:f3b4]) by SEZPR04MB6319.apcprd04.prod.outlook.com ([fe80::8a6:22f0:5560:f3b4%4]) with mapi id 15.20.7918.024; Thu, 5 Sep 2024 06:31:09 +0000 From: qixiang.xu@outlook.com To: maz@kernel.org, oliver.upton@linux.dev, will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Qxiang Xu Subject: [PATCH 1/1] KVM: arm64: Make nVHE ASLR conditional on nokaslr Date: Thu, 5 Sep 2024 14:30:26 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240905063026.3411766-1-qixiang.xu@outlook.com> References: <20240905061659.3410362-1-qixiang.xu@outlook.com> <20240905063026.3411766-1-qixiang.xu@outlook.com> X-TMN: [+c0HwO8i7Omk7GuaiYAD9MACED5BJ5bf] X-ClientProxiedBy: SG2P153CA0003.APCP153.PROD.OUTLOOK.COM (2603:1096::13) To SEZPR04MB6319.apcprd04.prod.outlook.com (2603:1096:101:a6::7) X-Microsoft-Original-Message-ID: <20240905063026.3411766-2-qixiang.xu@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR04MB6319:EE_|SEYPR04MB5737:EE_ X-MS-Office365-Filtering-Correlation-Id: ed93d2e6-4edf-4dda-3ec2-08dccd7453dd X-Microsoft-Antispam: BCL:0;ARA:14566002|461199028|5072599009|8060799006|15080799006|19110799003|3430499032|4302099013|440099028|3412199025|1602099012|1710799026; X-Microsoft-Antispam-Message-Info: CFJvn9h3UVR5z5jVwNC/Mmt62vM5hIbHhNcSPNb4CoJUDSLONvAF2eVC0/qtShC7q6ArkEbHDJUexL2N2YHrxb3/ecpMHcW3axvmbK1xoizK6uNSjxAVqdHjCg49hAr01qKqZU4kW0Vx5W3A5KGb15Y9uysj72+QKybPfubwkJjMlkKgvfsZUwfTwmckGtXYhGa0n5ArQycm/ROSnO5yfseqollRsYNC4ldqavh5tGAMt/SIvF+cFpLJDUiJdbX8gn95eUgc9wXxUc/lmhi0g8uZ05RAg21wE35REItnLjwhEpT5Z9C7LCa6CdLpZw+lgaw1o63Xv2EXNJgQKeEcSAGm0oAmJqx57aentZKP0DXQpCIqQ97GdlvV9UgQhUB/dgB4CUKNdZNflMebCGPHaob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nW+m39/K3IU8aD9YoKwCEqhrarcP3+69COyDXLEAPwA9jExTFxrlDAYLKQ/W90BriLteGIOQBNTJrlGuwO78yOIom5tXcAhnx9W+cgU/AkK4MXA1rJVNMEa+Cbs8xfoMhlnLXIemPFg9oIn09WKPXThKsbIsGpvQrdknO1YoFbZt6dF6q3QTWMMAKrQOODLCAscB9A+nzNf2j8IBW6CGlLTJgHkBao8jX0/9xz1R3q4ifzYyKwNHgOTX/nFBLadCujKeivzhkuJ6mNvLJdpy9yqu4rjzMcLd0DQBnknXZOqr2BoQ4RILQRtGLfqI9Kg5tN5VI93zf1gJdJ80/EJBEicXUp7AAXpyPhERqdZ1n9PW5lAv/JEi0/1A/ukvj6cCFxnXjthIjRNZ9l6f9e49c9XdCblDB4ljyErF9fJwYb+UAEpf9v7eesHvGhOmv9Uf1yzX2iAOsHC2hY5hr5cpFuRgnlAE/HKXX4wBMtUg2XT6lRz2OHfkceyCk3MFeiujGdp9ip8XfnIAMY0bGOdHe7UQUTRtnztdnpko2+waUcIGoEervvkY2ZP+iqiLD6jlu3SSXE5xe+gXjioLBVBRZAjOpz3In/0hQD/oP7P+GxYK6XjkKPhJbrJFrX3zPIe4EMGimNNuS6gjl/WOuMf597mvV0AYwiB2GABKuZpwehbpjbEF0E+Tcl+AN86O8PffqRGuYcaUwEH04G/6darfevafE8GRg7DNLCDl3XlSDY= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed93d2e6-4edf-4dda-3ec2-08dccd7453dd X-MS-Exchange-CrossTenant-AuthSource: SEZPR04MB6319.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2024 06:31:08.9315 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR04MB5737 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240904_233115_103392_3E4D6CCD X-CRM114-Status: GOOD ( 10.79 ) 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 From: Qxiang Xu The random tag of hyp VA is determined by the `CONFIG_RANDOMIZE_BASE` option, so even if `nokaslr` is set in the cmdline, KASLR cannot be disabled for hyp VA. To align with kernel behavior, disable KASLR if the kernel cmdline includes `nokaslr`. Link: https://lore.kernel.org/r/20240905061659.3410362-1-qixiang.xu@outlook.com Signed-off-by: Qxiang Xu --- arch/arm64/kvm/va_layout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/va_layout.c b/arch/arm64/kvm/va_layout.c index 91b22a014610..bebb4b1ddc82 100644 --- a/arch/arm64/kvm/va_layout.c +++ b/arch/arm64/kvm/va_layout.c @@ -72,7 +72,7 @@ __init void kvm_compute_layout(void) va_mask = GENMASK_ULL(tag_lsb - 1, 0); tag_val = hyp_va_msb; - if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && tag_lsb != (vabits_actual - 1)) { + if (kaslr_enabled() && tag_lsb != (vabits_actual - 1)) { /* We have some free bits to insert a random tag. */ tag_val |= get_random_long() & GENMASK_ULL(vabits_actual - 2, tag_lsb); }