From: Cornelia Huck <cohuck@redhat.com>
To: Peter Collingbourne <pcc@google.com>,
linux-arm-kernel@lists.infradead.org,
kvmarm@lists.cs.columbia.edu
Cc: kvm@vger.kernel.org, Peter Collingbourne <pcc@google.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Steven Price <steven.price@arm.com>,
Marc Zyngier <maz@kernel.org>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Will Deacon <will@kernel.org>,
Evgenii Stepanov <eugenis@google.com>
Subject: Re: [PATCH v5 5/8] arm64: mte: Lock a page for MTE tag initialisation
Date: Mon, 07 Nov 2022 18:16:32 +0100 [thread overview]
Message-ID: <87iljq3csv.fsf@redhat.com> (raw)
In-Reply-To: <20221104011041.290951-6-pcc@google.com>
On Thu, Nov 03 2022, Peter Collingbourne <pcc@google.com> wrote:
> From: Catalin Marinas <catalin.marinas@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@arm.com>
> Signed-off-by: Peter Collingbourne <pcc@google.com>
> Reviewed-by: Steven Price <steven.price@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Peter Collingbourne <pcc@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@redhat.com>
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
WARNING: multiple messages have this Message-ID (diff)
From: Cornelia Huck <cohuck@redhat.com>
To: Peter Collingbourne <pcc@google.com>,
linux-arm-kernel@lists.infradead.org,
kvmarm@lists.cs.columbia.edu
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>,
Evgenii Stepanov <eugenis@google.com>,
kvm@vger.kernel.org, Steven Price <steven.price@arm.com>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Peter Collingbourne <pcc@google.com>
Subject: Re: [PATCH v5 5/8] arm64: mte: Lock a page for MTE tag initialisation
Date: Mon, 07 Nov 2022 18:16:32 +0100 [thread overview]
Message-ID: <87iljq3csv.fsf@redhat.com> (raw)
In-Reply-To: <20221104011041.290951-6-pcc@google.com>
On Thu, Nov 03 2022, Peter Collingbourne <pcc@google.com> wrote:
> From: Catalin Marinas <catalin.marinas@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@arm.com>
> Signed-off-by: Peter Collingbourne <pcc@google.com>
> Reviewed-by: Steven Price <steven.price@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Peter Collingbourne <pcc@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@redhat.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Cornelia Huck <cohuck@redhat.com>
To: Peter Collingbourne <pcc@google.com>,
linux-arm-kernel@lists.infradead.org,
kvmarm@lists.cs.columbia.edu
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>,
Evgenii Stepanov <eugenis@google.com>,
kvm@vger.kernel.org, Steven Price <steven.price@arm.com>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Peter Collingbourne <pcc@google.com>
Subject: Re: [PATCH v5 5/8] arm64: mte: Lock a page for MTE tag initialisation
Date: Mon, 07 Nov 2022 18:16:32 +0100 [thread overview]
Message-ID: <87iljq3csv.fsf@redhat.com> (raw)
In-Reply-To: <20221104011041.290951-6-pcc@google.com>
On Thu, Nov 03 2022, Peter Collingbourne <pcc@google.com> wrote:
> From: Catalin Marinas <catalin.marinas@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@arm.com>
> Signed-off-by: Peter Collingbourne <pcc@google.com>
> Reviewed-by: Steven Price <steven.price@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Peter Collingbourne <pcc@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@redhat.com>
next prev parent reply other threads:[~2022-11-07 17:16 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-04 1:10 [PATCH v5 0/8] KVM: arm64: permit MAP_SHARED mappings with MTE enabled Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-04 1:10 ` [PATCH v5 1/8] mm: Do not enable PG_arch_2 for all 64-bit architectures Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-04 1:10 ` [PATCH v5 2/8] arm64: mte: Fix/clarify the PG_mte_tagged semantics Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-04 1:10 ` [PATCH v5 3/8] KVM: arm64: Simplify the sanitise_mte_tags() logic Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-07 17:10 ` Cornelia Huck
2022-11-07 17:10 ` Cornelia Huck
2022-11-07 17:10 ` Cornelia Huck
2022-11-04 1:10 ` [PATCH v5 4/8] mm: Add PG_arch_3 page flag Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-04 1:10 ` [PATCH v5 5/8] arm64: mte: Lock a page for MTE tag initialisation Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-07 17:16 ` Cornelia Huck [this message]
2022-11-07 17:16 ` Cornelia Huck
2022-11-07 17:16 ` Cornelia Huck
2022-11-04 1:10 ` [PATCH v5 6/8] KVM: arm64: unify the tests for VMAs in memslots when MTE is enabled Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-07 17:17 ` Cornelia Huck
2022-11-07 17:17 ` Cornelia Huck
2022-11-07 17:17 ` Cornelia Huck
2022-11-04 1:10 ` [PATCH v5 7/8] KVM: arm64: permit all VM_MTE_ALLOWED mappings with MTE enabled Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-07 17:19 ` Cornelia Huck
2022-11-07 17:19 ` Cornelia Huck
2022-11-07 17:19 ` Cornelia Huck
2022-11-04 1:10 ` [PATCH v5 8/8] Documentation: document the ABI changes for KVM_CAP_ARM_MTE Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-04 1:10 ` Peter Collingbourne
2022-11-07 17:20 ` Cornelia Huck
2022-11-07 17:20 ` Cornelia Huck
2022-11-07 17:20 ` Cornelia Huck
2022-11-04 16:23 ` [PATCH v5 0/8] KVM: arm64: permit MAP_SHARED mappings with MTE enabled Marc Zyngier
2022-11-04 16:23 ` Marc Zyngier
2022-11-04 16:23 ` Marc Zyngier
2022-11-04 17:42 ` Peter Collingbourne
2022-11-04 17:42 ` Peter Collingbourne
2022-11-04 17:42 ` Peter Collingbourne
2022-11-24 10:39 ` Marc Zyngier
2022-11-24 10:39 ` Marc Zyngier
2022-11-24 10:39 ` Marc Zyngier
2022-11-29 9:33 ` Marc Zyngier
2022-11-29 9:33 ` Marc Zyngier
2022-11-29 9:33 ` Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87iljq3csv.fsf@redhat.com \
--to=cohuck@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=eugenis@google.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=pcc@google.com \
--cc=steven.price@arm.com \
--cc=vincenzo.frascino@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.