From: Stafford Horne <shorne@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Jonas Bonn <jonas@southpole.se>,
openrisc@lists.librecores.org,
Steven Price <steven.price@arm.com>, Jann Horn <jannh@google.com>
Subject: Re: [PATCH] openrisc: Fix pagewalk usage in arch_dma_{clear, set}_uncached
Date: Sat, 8 Oct 2022 05:26:49 +0000 [thread overview]
Message-ID: <Y0EKGV38rvbbXZF6@oscomms1> (raw)
In-Reply-To: <20221008052422.29695-1-shorne@gmail.com>
Sorry, meant to tag this as v2. But I missed the command line option as I am on
a new system and was working on getting aliases and other things setup to send
this mail.
-Stafford
On Sat, Oct 08, 2022 at 06:24:21AM +0100, Stafford Horne wrote:
> From: Jann Horn <jannh@google.com>
>
> Since commit 8782fb61cc848 ("mm: pagewalk: Fix race between unmap and page
> walker"), walk_page_range() on kernel ranges won't work anymore,
> walk_page_range_novma() must be used instead.
>
> Note: I don't have an openrisc development setup, so this is completely
> untested.
>
> Fixes: 8782fb61cc848 ("mm: pagewalk: Fix race between unmap and page walker")
> Signed-off-by: Jann Horn <jannh@google.com>
> Signed-off-by: Stafford Horne <shorne@gmail.com>
> ---
> Since v1:
> - Repost to include LKML.
> - Added my SOB
> - I tested this by booking this on the qemu virt platform and it works fine.
>
> arch/openrisc/kernel/dma.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/arch/openrisc/kernel/dma.c b/arch/openrisc/kernel/dma.c
> index a82b2caaa560..b3edbb33b621 100644
> --- a/arch/openrisc/kernel/dma.c
> +++ b/arch/openrisc/kernel/dma.c
> @@ -74,10 +74,10 @@ void *arch_dma_set_uncached(void *cpu_addr, size_t size)
> * We need to iterate through the pages, clearing the dcache for
> * them and setting the cache-inhibit bit.
> */
> - mmap_read_lock(&init_mm);
> - error = walk_page_range(&init_mm, va, va + size, &set_nocache_walk_ops,
> - NULL);
> - mmap_read_unlock(&init_mm);
> + mmap_write_lock(&init_mm);
> + error = walk_page_range_novma(&init_mm, va, va + size,
> + &set_nocache_walk_ops, NULL, NULL);
> + mmap_write_unlock(&init_mm);
>
> if (error)
> return ERR_PTR(error);
> @@ -88,11 +88,11 @@ void arch_dma_clear_uncached(void *cpu_addr, size_t size)
> {
> unsigned long va = (unsigned long)cpu_addr;
>
> - mmap_read_lock(&init_mm);
> + mmap_write_lock(&init_mm);
> /* walk_page_range shouldn't be able to fail here */
> - WARN_ON(walk_page_range(&init_mm, va, va + size,
> - &clear_nocache_walk_ops, NULL));
> - mmap_read_unlock(&init_mm);
> + WARN_ON(walk_page_range_novma(&init_mm, va, va + size,
> + &clear_nocache_walk_ops, NULL, NULL));
> + mmap_write_unlock(&init_mm);
> }
>
> void arch_sync_dma_for_device(phys_addr_t addr, size_t size,
> --
> 2.37.2
>
next prev parent reply other threads:[~2022-10-08 5:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-08 5:24 [PATCH] openrisc: Fix pagewalk usage in arch_dma_{clear, set}_uncached Stafford Horne
2022-10-08 5:26 ` Stafford Horne [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-10-06 18:33 Jann Horn
2022-10-08 5:07 ` [PATCH] openrisc: Fix pagewalk usage in arch_dma_{clear,set}_uncached Stafford Horne
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=Y0EKGV38rvbbXZF6@oscomms1 \
--to=shorne@gmail.com \
--cc=jannh@google.com \
--cc=jonas@southpole.se \
--cc=linux-kernel@vger.kernel.org \
--cc=openrisc@lists.librecores.org \
--cc=steven.price@arm.com \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).