[PATCH v5 5/8] arm64: mte: Lock a page for MTE tag initialisation
Cornelia Huck
cohuck at redhat.com
Mon Nov 7 09:16:32 PST 2022
On Thu, Nov 03 2022, Peter Collingbourne <pcc at google.com> wrote:
> From: Catalin Marinas <catalin.marinas at arm.com>
>
> Initialising the tags and setting PG_mte_tagged flag for a page can race
> between multiple set_pte_at() on shared pages or setting the stage 2 pte
> via user_mem_abort(). Introduce a new PG_mte_lock flag as PG_arch_3 and
> set it before attempting page initialisation. Given that PG_mte_tagged
> is never cleared for a page, consider setting this flag to mean page
> unlocked and wait on this bit with acquire semantics if the page is
> locked:
>
> - try_page_mte_tagging() - lock the page for tagging, return true if it
> can be tagged, false if already tagged. No acquire semantics if it
> returns true (PG_mte_tagged not set) as there is no serialisation with
> a previous set_page_mte_tagged().
>
> - set_page_mte_tagged() - set PG_mte_tagged with release semantics.
>
> The two-bit locking is based on Peter Collingbourne's idea.
>
> Signed-off-by: Catalin Marinas <catalin.marinas at arm.com>
> Signed-off-by: Peter Collingbourne <pcc at google.com>
> Reviewed-by: Steven Price <steven.price at arm.com>
> Cc: Will Deacon <will at kernel.org>
> Cc: Marc Zyngier <maz at kernel.org>
> Cc: Peter Collingbourne <pcc at google.com>
> ---
> arch/arm64/include/asm/mte.h | 35 +++++++++++++++++++++++++++++++-
> arch/arm64/include/asm/pgtable.h | 4 ++--
> arch/arm64/kernel/cpufeature.c | 2 +-
> arch/arm64/kernel/mte.c | 12 +++--------
> arch/arm64/kvm/guest.c | 16 +++++++++------
> arch/arm64/kvm/mmu.c | 2 +-
> arch/arm64/mm/copypage.c | 2 ++
> arch/arm64/mm/fault.c | 2 ++
> arch/arm64/mm/mteswap.c | 14 +++++--------
> 9 files changed, 60 insertions(+), 29 deletions(-)
Reviewed-by: Cornelia Huck <cohuck at redhat.com>
More information about the linux-arm-kernel
mailing list