From patchwork Tue Nov 15 14:38:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13043774 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 50417C4332F for ; Tue, 15 Nov 2022 14:39:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=1x7ZwBclTT5zkeKDZ5gZNR000n2jClQWw9CfizOfBww=; b=uLmgGmrxek7jgB BZP05r7PKrhJsThWp3ixwTfn8Dp4U6Lce9o3i47NfoL6ANc8QpwnjQK85810mZDqAHrNrmPf2AhmP 5vQ+HDarYOmH5zhs0LpMZt4BiZsS7gBXF28BFnV74+ZIWtZG4cNtCo70DBz61h91PXJlpiCVY9YVi P8oUCPMBZ3ROQVGwSECiOQUTsKCyad1NH7eyyZ847ynpgwz/0Ku3ziXoN4V9AgMC4Vex3FOxzmRjn uXkXqV2VUBNgYkQQNjAWB0lDFk3KRbilG8KlpNMoiGQehvYsZW7DzRRCGXVfDR1FTnISG2lP6qbcX dUNjTb4OIUeEiaDuOeEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oux5C-00BwiL-MS; Tue, 15 Nov 2022 14:38:38 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oux58-00BwfW-Qr for linux-arm-kernel@lists.infradead.org; Tue, 15 Nov 2022 14:38:36 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8CC57B81979; Tue, 15 Nov 2022 14:38:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E0B9C433D6; Tue, 15 Nov 2022 14:38:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668523111; bh=IqH2mHKY9kQj84lK5lWUV0lOuGhXuZzvLmnxzWJIInU=; h=From:To:Cc:Subject:Date:From; b=rc9AwkxRQGhT2RFDiuiLmtcqvE57TuQLKas40Rwdnr6NcCtQrWQCHdHprNeSpsqmG JXpuCSwdyTINpR4MaRnepk7zbYPOVsdEXmC5fsI0GtXva6WR+2UNPYb++wS42wBRWn 1yvuExvvutnvs+1gtS8PWWT3fyR/RZBhPxGCWrCuKbiVVEb8guNu8BgNmKla8jOIrE +HJIWcoz5UeVHCA+1utAu9qc8GjovM9SeEf9Xsf4jOW8KoYxY/c5AvYi2E5BJ2X9TW u7J0RBEvfhQIkvBRfMkNUvW7S4Sj6ZIrVlJkOz/10HJ6jNM9XhflvxPzF+VvF86iYj Q59+2nA6M3Djg== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Catalin Marinas , Will Deacon , Mark Rutland , Anshuman Khandual , Joey Gouly Subject: [PATCH 0/3] arm64: mm: Model LVA support as a CPU feature Date: Tue, 15 Nov 2022 15:38:21 +0100 Message-Id: <20221115143824.2798908-1-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2305; i=ardb@kernel.org; h=from:subject; bh=IqH2mHKY9kQj84lK5lWUV0lOuGhXuZzvLmnxzWJIInU=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjc6RaMOkoQd8rlG8Vz8sS/7k9gUyepcTLuWxbQhQz 0YIsJpKJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY3OkWgAKCRDDTyI5ktmPJPcgC/ 9xfWLgNdhSEm9De9JqMD134FOh7QsvbCMfoFOh1HUVrqXZXQzQ+nQw26qiHD/vgbaHiHcxuXHRTWVl Q0kr60DP5t0B+d6AjCNi6m9MBIrgh3yXDBjNp7xH4D8FrPGT3W1dqTo/CJ54ZIsuNccLX3KOMZNGYv Rlj3HtgWFi0AjbxRYjyw/QiCdPfweNsDBs2ErWAyya/NoK5PHCJEg0rjxZD66Gly6e+CFYMct2vmeH 5VCgrCKrAzh7EJ8cp9HewjJ8gnsSHYWhrHQKL35/Bl4/jgNeURwxwPaNEtdpJestSjBiviP5HwYLTq VePEFhXiA19luuWxbTWZRaEjtx3f34iuxScRJJ/XrrhAuR7jZoj6W3YIs5y8va3kCy/O3T+vYp/81i adfHJ2QSS0Zzci6wUgMv+quXOIDywnM2qkSzv4ihvWTAIbwrZxp7DtmrP0DvjFveLfPmvDV6davHDm BmeMHi+WRdizm6Z7VsqQFoy4qyztD26GMum83qOA6hWBo= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221115_063835_211292_4DE78869 X-CRM114-Status: GOOD ( 15.08 ) 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 Treat LVA support (52-bit virtual addressing) as a CPU feature so we can rely on code patching, reporting and overrides as usual. Currently, we enable LVA really early, and have special treatment of it in the boot paths. However, given that both the ID map and the TTBR1 mapping of the kernel image are guarenteed to require 48 bits at most, we can boot with 48-bit virtual addressing initially, and switch to 52-bit addressing once we are running from C code and have parsed the command line to look for CPU feature overrides. Patch #1 is a drive-by cleanup that can be applied independently. Patch #2 creates the LVA CPU feature and wires it up. Patch #3 introduces the MMFR2 CPU feature override, as well as a arm64.nolva command line option to force 48-bit virtual addressing even if the CPU supports LVA. While at it, E0PD is wired up as an override as well, given that it sits in MMFR2 as well, and that its value is taken into account very early too. Note that this applies onto my series that further refactors the boot code [0], after a previous refactor landed in v6.0. [0] https://lore.kernel.org/all/20221111171201.2088501-1-ardb@kernel.org/ Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: Anshuman Khandual Cc: Joey Gouly Ard Biesheuvel (3): arm64: mm: get rid of kimage_vaddr global variable arm64: mm: Handle LVA support as a CPU feature arm64: mm: Add feature override support for LVA and E0PD arch/arm64/include/asm/assembler.h | 17 +++++++------ arch/arm64/include/asm/cpufeature.h | 1 + arch/arm64/include/asm/memory.h | 10 ++++---- arch/arm64/kernel/cpufeature.c | 19 +++++++++++++- arch/arm64/kernel/head.S | 26 +++----------------- arch/arm64/kernel/image-vars.h | 1 + arch/arm64/kernel/pi/idreg-override.c | 8 +++++- arch/arm64/kernel/pi/map_kernel.c | 16 ++++++++++++ arch/arm64/kernel/sleep.S | 3 --- arch/arm64/mm/mmu.c | 8 ------ arch/arm64/mm/proc.S | 16 ++++++------ arch/arm64/tools/cpucaps | 1 + 12 files changed, 70 insertions(+), 56 deletions(-)