LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Dave Hansen <dave@sr71.net>
To: linux-kernel@vger.kernel.org
Cc: Dave Hansen <dave@sr71.net>,
	dave.hansen@linux.intel.com, stable@vger.kernel.org
Subject: [PATCH 1/2] x86 tlb: fix overflow of flush_end in remote tlb flush
Date: Mon, 08 Dec 2014 11:03:48 -0800	[thread overview]
Message-ID: <20141208190348.BEDDE684@viggo.jf.intel.com> (raw)


From: Dave Hansen <dave.hansen@linux.intel.com>

If flush_end ends up being at or above 1 page before the end of
memory, the following calculation can overflow:

	f->flush_end = f->flush_start + PAGE_SIZE;

x86_64 has a 2MB hole at the end of memory, so we don't expect
this to be possible there.  On i386, I believe this page is in
the fixmap, and we never use this code there.  We only do _local_
tlb flushes.

Either way, just fall back to a full tlb flush and spit out a
warning if we ever run in to this.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: stable@vger.kernel.org
---

 b/arch/x86/mm/tlb.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff -puN arch/x86/mm/tlb.c~x86-tlb-fix-overflow arch/x86/mm/tlb.c
--- a/arch/x86/mm/tlb.c~x86-tlb-fix-overflow	2014-12-08 10:58:21.875765823 -0800
+++ b/arch/x86/mm/tlb.c	2014-12-08 10:58:21.878765959 -0800
@@ -109,8 +109,17 @@ static void flush_tlb_func(void *info)
 
 	if (f->flush_mm != this_cpu_read(cpu_tlbstate.active_mm))
 		return;
-	if (!f->flush_end)
+	if (!f->flush_end) {
 		f->flush_end = f->flush_start + PAGE_SIZE;
+		/*
+		 * Check for an overflow and just flush the whole
+		 * TLB in that case.
+		 */
+		if (f->flush_end < f->flush_start + PAGE_SIZE) {
+			f->flush_end = TLB_FLUSH_ALL;
+			VM_WARN_ON_ONCE(1);
+		}
+	}
 
 	count_vm_tlb_event(NR_TLB_REMOTE_FLUSH_RECEIVED);
 	if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK) {
_

             reply	other threads:[~2014-12-08 19:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-08 19:03 Dave Hansen [this message]
2014-12-08 19:03 ` [PATCH 2/2] x86 tlb: fix tracepoint nr_pages calculation Dave Hansen

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=20141208190348.BEDDE684@viggo.jf.intel.com \
    --to=dave@sr71.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --subject='Re: [PATCH 1/2] x86 tlb: fix overflow of flush_end in remote tlb flush' \
    /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

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).