From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: race between kmap shootdown and cache maintenance
Date: Sun, 7 Feb 2010 15:30:45 +0000 [thread overview]
Message-ID: <20100207153045.GA30457@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <A0A1E7539300DF49AA383E614C7827BC048DB1096B@HQMAIL01.nvidia.com>
On Fri, Feb 05, 2010 at 10:13:03AM -0800, Gary King wrote:
> for highmem pages, flush_dcache_page must pin the kmap mapping in-place
> using kmap_high_get, to ensure that the cache maintenance does not race
> with another context calling kunmap_high on the same page and causing the
> PTE to be zapped.
You need to sign off on patches you send.
> ---
> arch/arm/mm/flush.c | 18 +++++++++++++++---
> 1 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
> index 6f3a4b7..69ee285 100644
> --- a/arch/arm/mm/flush.c
> +++ b/arch/arm/mm/flush.c
> @@ -117,7 +117,7 @@ void flush_ptrace_access(struct vm_area_struct *vma, struct page *page,
>
> void __flush_dcache_page(struct address_space *mapping, struct page *page)
> {
> - void *addr = page_address(page);
> + void *addr = NULL;
You shouldn't need an initializer here - the address will always be
initialized, either by kmap_high_get() or page_address().
>
> /*
> * Writeback any data associated with the kernel mapping of this
> @@ -127,10 +127,17 @@ void __flush_dcache_page(struct address_space *mapping, struct page *page)
> #ifdef CONFIG_HIGHMEM
> /*
> * kmap_atomic() doesn't set the page virtual address, and
> - * kunmap_atomic() takes care of cache flushing already.
> + * kunmap_atomic() takes care of cache flushing already; however,
> + * the kmap must be pinned locally to ensure that no other context
> + * unmaps it during the cache maintenance
> */
> - if (addr)
> + if (PageHighMem(page))
> + addr = kmap_high_get(page);
> + else
> #endif
> + addr = page_address(page);
> +
> + if (addr)
> __cpuc_flush_dcache_area(addr, PAGE_SIZE);
>
> /*
> @@ -141,6 +148,11 @@ void __flush_dcache_page(struct address_space *mapping, struct page *page)
> if (mapping && cache_is_vipt_aliasing())
> flush_pfn_alias(page_to_pfn(page),
> page->index << PAGE_CACHE_SHIFT);
> +
> +#ifdef CONFIG_HIGHMEM
> + if (PageHighMem(page) && addr)
> + kunmap_high(page);
> +#endif
You don't need to hold on to the highmem kmap this long - the only thing
that it'd matter for is the __cpuc_flush_dcache_area() call. You can
combine this conditional with the test for __cpuc_flush_dcache_area()
as well.
next prev parent reply other threads:[~2010-02-07 15:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-05 18:13 race between kmap shootdown and cache maintenance Gary King
2010-02-07 15:30 ` Russell King - ARM Linux [this message]
2010-02-08 21:57 ` Gary King
2010-02-09 3:35 ` Nicolas Pitre
2010-02-09 4:00 ` Gary King
2010-02-09 4:40 ` Nicolas Pitre
2010-02-13 1:08 ` Gary King
2010-02-18 2:00 ` Arve Hjønnevåg
2010-02-18 4:18 ` Nicolas Pitre
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=20100207153045.GA30457@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.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).