• Ryan Roberts's avatar
    arm64/mm: wire up PTE_CONT for user mappings · 4602e575
    Ryan Roberts authored
    With the ptep API sufficiently refactored, we can now introduce a new
    "contpte" API layer, which transparently manages the PTE_CONT bit for user
    mappings.
    
    In this initial implementation, only suitable batches of PTEs, set via
    set_ptes(), are mapped with the PTE_CONT bit.  Any subsequent modification
    of individual PTEs will cause an "unfold" operation to repaint the contpte
    block as individual PTEs before performing the requested operation. 
    While, a modification of a single PTE could cause the block of PTEs to
    which it belongs to become eligible for "folding" into a contpte entry,
    "folding" is not performed in this initial implementation due to the costs
    of checking the requirements are met.  Due to this, contpte mappings will
    degrade back to normal pte mappings over time if/when protections are
    changed.  This will be solved in a future patch.
    
    Since a contpte block only has a single access and dirty bit, the semantic
    here changes slightly; when getting a pte (e.g.  ptep_get()) that is part
    of a contpte mapping, the access and dirty information are pulled from the
    block (so all ptes in the block return the same access/dirty info).  When
    changing the access/dirty info on a pte (e.g.  ptep_set_access_flags())
    that is part of a contpte mapping, this change will affect the whole
    contpte block.  This is works fine in practice since we guarantee that
    only a single folio is mapped by a contpte block, and the core-mm tracks
    access/dirty information per folio.
    
    In order for the public functions, which used to be pure inline, to
    continue to be callable by modules, export all the contpte_* symbols that
    are now called by those public inline functions.
    
    The feature is enabled/disabled with the ARM64_CONTPTE Kconfig parameter
    at build time.  It defaults to enabled as long as its dependency,
    TRANSPARENT_HUGEPAGE is also enabled.  The core-mm depends upon
    TRANSPARENT_HUGEPAGE to be able to allocate large folios, so if its not
    enabled, then there is no chance of meeting the physical contiguity
    requirement for contpte mappings.
    
    Link: https://lkml.kernel.org/r/20240215103205.2607016-13-ryan.roberts@arm.comSigned-off-by: default avatarRyan Roberts <ryan.roberts@arm.com>
    Acked-by: default avatarArd Biesheuvel <ardb@kernel.org>
    Tested-by: default avatarJohn Hubbard <jhubbard@nvidia.com>
    Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
    Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
    Cc: Alistair Popple <apopple@nvidia.com>
    Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
    Cc: Barry Song <21cnbao@gmail.com>
    Cc: Borislav Petkov (AMD) <bp@alien8.de>
    Cc: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: James Morse <james.morse@arm.com>
    Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
    Cc: Marc Zyngier <maz@kernel.org>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Will Deacon <will@kernel.org>
    Cc: Yang Shi <shy828301@gmail.com>
    Cc: Zi Yan <ziy@nvidia.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    4602e575
Makefile 646 Bytes