From: Arseny Solokha <asolokha@kb.kras.ru>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linux-kernel@vger.kernel.org, Paul Mackerras <paulus@samba.org>,
Scott Wood <scottwood@freescale.com>,
Arseny Solokha <asolokha@kb.kras.ru>,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH] powerpc/mm: warn on flushing tlb page in kernel context
Date: Mon, 2 Feb 2015 12:28:16 +0700 [thread overview]
Message-ID: <1422854896-4746-1-git-send-email-asolokha@kb.kras.ru> (raw)
In-Reply-To: <1422619707-30864-1-git-send-email-asolokha@kb.kras.ru>
Function __flush_tlb_page() must only be called for user contexts, so
put in extra hardening to warn on calling it for kernel context.
Signed-off-by: Arseny Solokha <asolokha@kb.kras.ru>
---
arch/powerpc/mm/tlb_nohash.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/mm/tlb_nohash.c b/arch/powerpc/mm/tlb_nohash.c
index f38ea4d..cbd3d06 100644
--- a/arch/powerpc/mm/tlb_nohash.c
+++ b/arch/powerpc/mm/tlb_nohash.c
@@ -284,8 +284,15 @@ void __flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
struct cpumask *cpu_mask;
unsigned int pid;
+ /*
+ * This function as well as __local_flush_tlb_page() must only be called
+ * for user contexts.
+ */
+ if (unlikely(WARN_ON(!mm)))
+ return;
+
preempt_disable();
- pid = mm ? mm->context.id : 0;
+ pid = mm->context.id;
if (unlikely(pid == MMU_NO_CONTEXT))
goto bail;
cpu_mask = mm_cpumask(mm);
--
2.2.2
prev parent reply other threads:[~2015-02-02 5:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-30 12:08 [PATCH] powerpc/mm: bail out early when flushing TLB page Arseny Solokha
2015-01-30 21:53 ` Scott Wood
2015-01-31 4:18 ` Arseny Solokha
2015-01-31 20:27 ` Benjamin Herrenschmidt
2015-02-02 5:07 ` Arseny Solokha
2015-02-02 5:28 ` Arseny Solokha [this message]
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=1422854896-4746-1-git-send-email-asolokha@kb.kras.ru \
--to=asolokha@kb.kras.ru \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@samba.org \
--cc=scottwood@freescale.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 NNTP newsgroup(s).