From patchwork Thu Nov 17 13:24:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13046883 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 B6517C4332F for ; Thu, 17 Nov 2022 13:25:51 +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=ChKY439D3K1Parpkk7Tau8JOnsRdhacDXYa+t960rP8=; b=wW9Yw/rlOveYKd 5HucPHiIEHZuIx9moRZshRuxB/dKpqkYYPGXoTCgKTpdjZ1DhwYsBv26ya+z/wPEw2laURoq5yWdM kABsZgM9Czk5v34jO0J6oaa1YSwty9o/N0DBw4WSUbcL2BDnr+FIDInksvRhxw1X6thHGcgoDFr4v RVVoSQpJXKqm4BCH6vxIVhoFHm4eqwUy2H4zh/5Khc0IE1PsNCbNOuJmrPMHfVcQEnkfP/SsX4YBt yKtmvVTx//QTinXxocMiA21g3JwQUIUcSoRftHnSskL+7D81RrU1BZ7hZpQdhYfVSeBcQqWH4Nrmp x9I1qNCpmPr0SWpjxlTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovesi-00EENo-6t; Thu, 17 Nov 2022 13:24:40 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ovesY-00EEFt-Rv for linux-arm-kernel@lists.infradead.org; Thu, 17 Nov 2022 13:24:32 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 6786161E0B; Thu, 17 Nov 2022 13:24:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2B44C433D6; Thu, 17 Nov 2022 13:24:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668691469; bh=g+8lxvl/zXOd/3IBAW8dKOgucz3Bbn9HautzDr2TX04=; h=From:To:Cc:Subject:Date:From; b=Jk5ZPrjJ4ezy0SIYbeg/Dn82VG9GKY+yOQi2KevVrANw1/KL9a23Uu+xsfk9HgXMn nJIqvNkohKaqz45wNopVkSZjXJS44VDNrzhZRm/GOvcEJ6FTsgElb4wRYZ/bOxu0ku upjffIPDSU6V3CuXoMGDyShPBb5PWmXg/IqRAhs5to5k8+qbTMgB61Bck0VOE0KcRF 5pXFsUEhoF5xm7UEVsioUdO684rb0NmLlqwRSa07bmhVDAI54PmRpUtmsFszquePut XKZ+sGIKXvKBUxkmC4QExdz6f7kIPia0LWT4HgGw+u5dwwAViq8n5kNkYYdul7LPP6 uVHA6JreY+Cpw== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Marc Zyngier , Will Deacon , Mark Rutland , Kees Cook , Catalin Marinas , Mark Brown , Anshuman Khandual , Richard Henderson Subject: [RFC PATCH 0/7] arm64: Enable LPA2 support for 16k pages Date: Thu, 17 Nov 2022 14:24:16 +0100 Message-Id: <20221117132423.1252942-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=3255; i=ardb@kernel.org; h=from:subject; bh=g+8lxvl/zXOd/3IBAW8dKOgucz3Bbn9HautzDr2TX04=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjdjX6sbRVrPw0kw7d72l0vwtU3sY4IiPPjHLBHeGS AfvzHsqJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY3Y1+gAKCRDDTyI5ktmPJESKDA Clwu9WdaTu5q3VMKiQe7vS+oMfSbTlQLXNw38K+pl9nGNscrkrNiLzLHf4cKFNqrXcZ+qNUvmefXmH WwrRowXG62wrcoGsJ8rgxfwQFuQMG8+E/uL4Xn82xrBXww38RnlFxSDNOFDfq7KYX+vNSa2uuxejgU nbqHp1xSuzuTLMJ41dwcue5czeNe5zJtMzV2N/rHihxcFkfBE/yL4Aey5X833vSLDh8Fby3CK1t5rl 0oHYCxCKF/6GWNv5X4atOoolovsks+xDbDZS0rfLJTspAcwUvOTKgYHgTrSr+umW5oNkXdeE9cvs8Z wXLMht0DBiy8DPti1GL/UBaFW1XxRP9pkyjy0dxwZzQXf4447O0pW8Ob+QHdm8IKT/bfXYYvfu7mDW At1BzgRr/qdsRxOmVwhM3+rQp4Mq+dxoFDB4NReiAZhc3eg5+35TbiEl7+Od10DiBwNsOTkA8lYjad k8NWG3PEoychgJZUtWU2Im+HLkYZCocRgxI48CZkzZYT4= 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-20221117_052431_019414_9F1FAAB3 X-CRM114-Status: GOOD ( 19.98 ) 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 Enable support for LPA2 when running with 16k pages. Unlike with 4k pages, this does not require adding support for 5 level paging, but beyond that, there is no fundamental difference between LPA2 support on 4k or 16k pages. There are a few rough edges that make this less straight-forward than it was to enable LVA on 64k pages: even though also in this case, we can rely on statically sized root level page tables, we cannot advance the TTBR1 pointer to the pgdir entry that covers the start of the 48-bit addressable like we do on LVA, as the resulting address is not 64 byte aligned, which is a requirement for TTBR registers. Another slight complication is that the repurposed physical address bits in the page table descriptors were not RES0 before, and so there is now a big global switch (called TCR.DS) which controls how all page table descriptors are interpreted. This requires some extra care in the PTE conversion helpers, and additional handling in the boot code to ensure that we set TCR.DS safely if supported (and not overridden) This series applies onto some of my previous work that is still in flight, so these patches will not apply in isolation. Complete branch can be found here: https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=arm64-16k-lpa2 Tested on QEMU with -cpu max and lpa2 both off and on, as well as using the arm64.nolva override kernel command line parameter. Note that this requires a QEMU patch that has not been merged yet: https://lore.kernel.org/qemu-devel/20221116170316.259695-1-ardb@kernel.org/ Cc: Marc Zyngier Cc: Will Deacon Cc: Mark Rutland Cc: Kees Cook Cc: Catalin Marinas Cc: Mark Brown Cc: Anshuman Khandual Cc: Richard Henderson Ard Biesheuvel (7): arm64: ptdump: Disregard unaddressable VA space arm64: mm: Disable all 52-bit virtual addressing support with arm64.nolva arm64: mm: Wire up TCR.DS bit to PTE shareability fields arm64: mm: Support use of 52-bit pgdirs on 48-bit/16k systems arm64: mm: Add LPA2 support to phys<->pte conversion routines arm64: Enable LPA2 at boot if supported by the system arm64: Enable 52-bit virtual addressing for 16k granule configs arch/arm64/Kconfig | 6 +- arch/arm64/include/asm/assembler.h | 33 ++----- arch/arm64/include/asm/cpufeature.h | 1 + arch/arm64/include/asm/mmu.h | 18 ++++ arch/arm64/include/asm/pgtable-hwdef.h | 11 ++- arch/arm64/include/asm/pgtable-prot.h | 18 +++- arch/arm64/include/asm/pgtable.h | 5 +- arch/arm64/kernel/cpufeature.c | 27 ++++- arch/arm64/kernel/image-vars.h | 3 + arch/arm64/kernel/pi/idreg-override.c | 26 +++++ arch/arm64/kernel/pi/map_kernel.c | 103 +++++++++++++++++++- arch/arm64/mm/mmap.c | 4 + arch/arm64/mm/mmu.c | 2 + arch/arm64/mm/proc.S | 13 +++ arch/arm64/mm/ptdump.c | 4 +- 15 files changed, 229 insertions(+), 45 deletions(-)