From: David Hildenbrand <david@redhat.com>
To: Barry Song <21cnbao@gmail.com>,
akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org,
linux-mm@kvack.org
Cc: ardb@kernel.org, catalin.marinas@arm.com, jhubbard@nvidia.com,
mark.rutland@arm.com, v-songbaohua@oppo.com, will@kernel.org,
Ryan Roberts <ryan.roberts@arm.com>
Subject: Re: [PATCH v2] mm: arm64: document why pte is not advanced in contpte_ptep_set_access_flags()
Date: Thu, 5 Sep 2024 10:15:30 +0200 [thread overview]
Message-ID: <f24cd80b-3bc5-429a-bbef-591a17ecc1bc@redhat.com> (raw)
In-Reply-To: <20240905081124.9576-1-21cnbao@gmail.com>
On 05.09.24 10:11, Barry Song wrote:
> From: Barry Song <v-songbaohua@oppo.com>
>
> According to David and Ryan, there isn't a bug here, even though we
> don't advance the PTE entry, because __ptep_set_access_flags() only
> uses the access flags from the entry.
>
> However, we always check pte_same(pte, entry) using the first entry
> in __ptep_set_access_flags(). This means that the checks from 1 to
> nr - 1 are not comparing the same PTE indexes (thus, they always
> return false), which can be a bit confusing. To clarify the code, let's
> add some comments.
>
> Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>
> Signed-off-by: Barry Song <v-songbaohua@oppo.com>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: John Hubbard <jhubbard@nvidia.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Will Deacon <will@kernel.org>
> ---
> -v2:
> * collect Ryan's rb, thanks!
> * doc why but not advance entry
> * refine changelog and subject
>
> -v1:
> https://lore.kernel.org/linux-mm/20240831083537.62111-1-21cnbao@gmail.com/
>
> arch/arm64/mm/contpte.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/arm64/mm/contpte.c b/arch/arm64/mm/contpte.c
> index a3edced29ac1..55107d27d3f8 100644
> --- a/arch/arm64/mm/contpte.c
> +++ b/arch/arm64/mm/contpte.c
> @@ -421,6 +421,12 @@ int contpte_ptep_set_access_flags(struct vm_area_struct *vma,
> ptep = contpte_align_down(ptep);
> start_addr = addr = ALIGN_DOWN(addr, CONT_PTE_SIZE);
>
> + /*
> + * We are not advancing entry because __ptep_set_access_flags()
> + * only consumes access flags from entry. And since we have checked
> + * for the whole contpte block and returned early, pte_same()
> + * within __ptep_set_access_flags() is likely false.
> + */
> for (i = 0; i < CONT_PTES; i++, ptep++, addr += PAGE_SIZE)
> __ptep_set_access_flags(vma, addr, ptep, entry, 0);
>
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-09-05 8:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 8:11 [PATCH v2] mm: arm64: document why pte is not advanced in contpte_ptep_set_access_flags() Barry Song
2024-09-05 8:15 ` David Hildenbrand [this message]
2024-09-06 12:29 ` Will Deacon
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=f24cd80b-3bc5-429a-bbef-591a17ecc1bc@redhat.com \
--to=david@redhat.com \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=jhubbard@nvidia.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=mark.rutland@arm.com \
--cc=ryan.roberts@arm.com \
--cc=v-songbaohua@oppo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).