Message ID | 20231124101840.944737-41-ardb@google.com (mailing list archive) |
---|---|
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> 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 D2604C61DF4 for <linux-arm-kernel@archiver.kernel.org>; Fri, 24 Nov 2023 10:20:43 +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:Cc:To:From:Subject:Message-ID: Mime-Version:Date: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=0IcDuiBOdEEjdihSkictujwEJxzm762/PaXMMD71qCY=; b=cv5 OHeCjbN8iyFqzsDXFoFJZrSYnpkVMQnT3+Dxa+PPQ3NiIm7T3lD9T1qqgsR8kHK3MQGgDEX5u8YRJ cpQ0nmPHzvirrgQDvsn8rmnn8CSXOLIHGPXEDRJgtj0jFjtMxYK/6JEJoD7CwwlVBHiYUwfrwnOz4 QO3Fcr2JEpM7iIx3PJXRsDsMkt9Hqhiksk6+9xn9fSOKvOPFeWtXvCFp5aSjFjZ6xVJ7BGbA+9S1S bX7sxbliEMulvIQ1oLIoBNCAwh8vMFgQkpOltuAdRy6AI1LuRkjeIDZHQ0svecohUHMN+UaZ/sxrK vgsHhuo4TP4E4YrGbu4TaBnC3YyskSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r6TIJ-006oUU-2P; Fri, 24 Nov 2023 10:20:19 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r6TIG-006oTv-28 for linux-arm-kernel@lists.infradead.org; Fri, 24 Nov 2023 10:20:18 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5ca26c07848so26968127b3.0 for <linux-arm-kernel@lists.infradead.org>; Fri, 24 Nov 2023 02:20:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700821213; x=1701426013; darn=lists.infradead.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=adsMH/v1RZALRDFdbhrlgSzxi4imvm+4tbG488mqO+g=; b=ulXbxpxplg0J/J2ylUlO/rTZUskrPZsW45bULdVB2zippAMIyRuDazpy4v+OZkBVf2 s5SweHJXVB+3OwKl7u+zBiVzxkOl/qIKtnc0Fg/VEsQQY93FX6b79NHCJXm0DxaSrH3K cTUoNs+uq6lOmWE+vRDgg3Qzg2dGTKvQa3Ar2I3wf8r2DqY2Dc1gE7RrTS/8bw7VM9zd aznUyXZrOeVgy8p54H8xZhIGqjHubketSVehtN3g2awFJdmAfUiJl7gK1jh3RTkPwSFg OlaHRnJOWmu4WPJSrPjlAB4ekITvnWV1NAjCgph2g2gzTSAOAfclM6rrUZ9r3x8yLAYy oWSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700821213; x=1701426013; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=adsMH/v1RZALRDFdbhrlgSzxi4imvm+4tbG488mqO+g=; b=YXvln5iucbi7X/mKdAasd0PPQbS55OkOmtolhj3fJ9BMVqFYovntlQUY8UJcCZTWwe pm8RRglBrAK6vPRPRxwgZJCBBtuJXLY81hnaGCB8/4SsGuWBA5yaFosF3r5WcbOvAx/j i4kNz0zXqdF2BHI9+WaxUi+GOqHiMh6K30N24dJ1vm6wcHtCIXrlOLCipt/CA+nNeOWW hqkiIZzdQxC+y1dToquYF5chUy4BbYG5DnVL2ni/tJJrooLlUwlddRPepT508P7r770a QeYdv1TpbHfw+Ef9SMB8Gk5F8+ddzx9qKf52nz1U7+yjMC1qcl3TdZQ+k9kdLR3kuzoj zVSw== X-Gm-Message-State: AOJu0Yzvj7HIGnja5M6LKAbEx9gpCB0XzrvmBUKdoST19Tevv+ZFdHQt olEtFvG7JCVacXu1L/RSL1E/0uta9bjadxsC84/OGXprEiww+5NRWwHY1RKlQW2xx0DCATKvVHW smfUP3XkIyL7fVlPklT4sju0vdHCQChFnuEl5mi24Vs1pXdtF0fYDyh9cal3ZS34MhQ3JJFW/s2 8= X-Google-Smtp-Source: AGHT+IGTg1V6iEmwEB90WwZSx7+hLJaBSLaEk9FWA4Ozdezaqlr4hHhxfXDd7v13kgCpWf7eD+rWmRbg X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a05:690c:2f0d:b0:5cb:e3c9:ca22 with SMTP id ev13-20020a05690c2f0d00b005cbe3c9ca22mr59111ywb.7.1700821212929; Fri, 24 Nov 2023 02:20:12 -0800 (PST) Date: Fri, 24 Nov 2023 11:18:40 +0100 Mime-Version: 1.0 X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=6907; i=ardb@kernel.org; h=from:subject; bh=CA7ejFO9HqurFn4iCcGLNbJOG8jwDk70BNNNZnRjMAc=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JITWhoqEw+zTDou1nH/g/+xOUrxzuljjVImHzrBC/Kp2Mr bPbq350lLIwiHEwyIopsgjM/vtu5+mJUrXOs2Rh5rAygQxh4OIUgIn0GjEyLH71bvKpb5yq+9sy jFRcRBuXz58Sddlju4bS8ofF+2oPrWb478kwV5K1fX7z39szHV1fx368IVa9x2SV2eT35Z8y10S qcAIA X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Message-ID: <20231124101840.944737-41-ardb@google.com> Subject: [PATCH v5 00/39] arm64: Reorganize kernel VA space for LPA2 From: Ard Biesheuvel <ardb@google.com> To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel <ardb@kernel.org>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Ryan Roberts <ryan.roberts@arm.com>, Anshuman Khandual <anshuman.khandual@arm.com>, Kees Cook <keescook@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231124_022016_706135_70A63711 X-CRM114-Status: GOOD ( 22.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
arm64: Reorganize kernel VA space for LPA2
|
expand
|
On Fri, 24 Nov 2023 at 11:20, Ard Biesheuvel <ardb@google.com> wrote: > > From: Ard Biesheuvel <ardb@kernel.org> > > At the request of Catalin, this series was split off from my LPA2 series > [0] in order to make the changes a bit more manageable. > Note: it appears I need another patch from the second batch in order to address a kCFI build issue with this series in some configurations: [PATCH v4 40/61] arm64: mmu: Make cpu_replace_ttbr1() out of line https://lore.kernel.org/all/20230912141549.278777-103-ardb@google.com/
From: Ard Biesheuvel <ardb@kernel.org> At the request of Catalin, this series was split off from my LPA2 series [0] in order to make the changes a bit more manageable. This series reorganizes the kernel VA space, and refactors/replaces the early mapping code so that: - everything is done only once, in the appropriate order; - everything is done with the MMU and caches enabled (*) - everything is done from C code (notably, 100s of lines of incomprehensible asm code are removed from head.S). (*) the initial ID map will be populated with the MMU and caches disabled if that is how we entered from the bootloader. This is important for LPA2, but also for other future extensions to the page table format, as managing this entirely in early asm code as we do today would become intractable. This applies also to things such as copying the KAsan shadow or the fixmap from the early page tables into the permanent ones - this is all being removed by this series. Another notable difference implemented by this series is the fact that the permanent ID map always covers 48 bits of VA space, and is no longer tied to the size of the kernel VA space. This removes awkward logic to add a translation level above PGD level, and will be beneficial for other reasons too (it permits future changes in the EFI logic to get rid of SetVirtualAddressMap() entirely) Changes since v4: - merge a couple of followup tweaks for issues that were reported while the v4 was briefly queued up and pulled into -next - rebase onto v6.7-rc1 - omit LVA/LPA2 and WXN related changes [0] https://lore.kernel.org/all/20230912141549.278777-63-ardb@google.com/ Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> Cc: Marc Zyngier <maz@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Ryan Roberts <ryan.roberts@arm.com> Cc: Anshuman Khandual <anshuman.khandual@arm.com> Cc: Kees Cook <keescook@chromium.org> Ard Biesheuvel (39): arm64: kernel: Disable latent_entropy GCC plugin in early C runtime arm64: mm: Take potential load offset into account when KASLR is off arm64: mm: get rid of kimage_vaddr global variable arm64: mm: Move PCI I/O emulation region above the vmemmap region arm64: mm: Move fixmap region above vmemmap region arm64: ptdump: Allow all region boundaries to be defined at boot time arm64: ptdump: Discover start of vmemmap region at runtime arm64: vmemmap: Avoid base2 order of struct page size to dimension region arm64: mm: Reclaim unused vmemmap region for vmalloc use arm64: kaslr: Adjust randomization range dynamically arm64: kernel: Manage absolute relocations in code built under pi/ arm64: kernel: Don't rely on objcopy to make code under pi/ __init arm64: head: move relocation handling to C code arm64: idreg-override: Omit non-NULL checks for override pointer arm64: idreg-override: Prepare for place relative reloc patching arm64: idreg-override: Avoid parameq() and parameqn() arm64: idreg-override: avoid strlen() to check for empty strings arm64: idreg-override: Avoid sprintf() for simple string concatenation arm64: idreg-override: Avoid kstrtou64() to parse a single hex digit arm64: idreg-override: Move to early mini C runtime arm64: kernel: Remove early fdt remap code arm64: head: Clear BSS and the kernel page tables in one go arm64: Move feature overrides into the BSS section arm64: head: Run feature override detection before mapping the kernel arm64: head: move dynamic shadow call stack patching into early C runtime arm64: kaslr: Use feature override instead of parsing the cmdline again arm64/kernel: Move 'nokaslr' parsing out of early idreg code arm64: idreg-override: Create a pseudo feature for rodata=off arm64: Add helpers to probe local CPU for PAC and BTI support arm64: head: allocate more pages for the kernel mapping arm64: head: move memstart_offset_seed handling to C code arm64: mm: Make kaslr_requires_kpti() a static inline arm64: head: Move early kernel mapping routines into C code arm64: mm: Use 48-bit virtual addressing for the permanent ID map arm64: pgtable: Decouple PGDIR size macros from PGD/PUD/PMD levels arm64: kernel: Create initial ID map from C code arm64: mm: avoid fixmap for early swapper_pg_dir updates arm64: mm: omit redundant remap of kernel image arm64: Revert "mm: provide idmap pointer to cpu_replace_ttbr1()" arch/arm64/include/asm/archrandom.h | 2 - arch/arm64/include/asm/assembler.h | 14 - arch/arm64/include/asm/cpufeature.h | 53 +++ arch/arm64/include/asm/fixmap.h | 1 - arch/arm64/include/asm/kasan.h | 2 - arch/arm64/include/asm/kernel-pgtable.h | 128 +++--- arch/arm64/include/asm/memory.h | 20 +- arch/arm64/include/asm/mmu.h | 40 +- arch/arm64/include/asm/mmu_context.h | 25 +- arch/arm64/include/asm/pgtable.h | 10 +- arch/arm64/include/asm/scs.h | 36 +- arch/arm64/include/asm/setup.h | 3 - arch/arm64/kernel/Makefile | 7 +- arch/arm64/kernel/cpufeature.c | 56 +-- arch/arm64/kernel/head.S | 428 ++------------------ arch/arm64/kernel/image-vars.h | 33 ++ arch/arm64/kernel/kaslr.c | 11 +- arch/arm64/kernel/module.c | 2 +- arch/arm64/kernel/pi/Makefile | 28 +- arch/arm64/kernel/{ => pi}/idreg-override.c | 188 +++++---- arch/arm64/kernel/pi/kaslr_early.c | 78 +--- arch/arm64/kernel/pi/map_kernel.c | 187 +++++++++ arch/arm64/kernel/pi/map_range.c | 100 +++++ arch/arm64/kernel/{ => pi}/patch-scs.c | 36 +- arch/arm64/kernel/pi/pi.h | 32 ++ arch/arm64/kernel/pi/relacheck.c | 130 ++++++ arch/arm64/kernel/pi/relocate.c | 64 +++ arch/arm64/kernel/setup.c | 22 - arch/arm64/kernel/vmlinux.lds.S | 17 +- arch/arm64/kvm/mmu.c | 15 +- arch/arm64/mm/fixmap.c | 34 -- arch/arm64/mm/kasan_init.c | 19 +- arch/arm64/mm/mmu.c | 135 ++---- arch/arm64/mm/proc.S | 13 +- arch/arm64/mm/ptdump.c | 56 ++- 35 files changed, 1017 insertions(+), 1008 deletions(-) rename arch/arm64/kernel/{ => pi}/idreg-override.c (58%) create mode 100644 arch/arm64/kernel/pi/map_kernel.c create mode 100644 arch/arm64/kernel/pi/map_range.c rename arch/arm64/kernel/{ => pi}/patch-scs.c (89%) create mode 100644 arch/arm64/kernel/pi/pi.h create mode 100644 arch/arm64/kernel/pi/relacheck.c create mode 100644 arch/arm64/kernel/pi/relocate.c