LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/2] x86 tlb: fix overflow of flush_end in remote tlb flush
@ 2014-12-08 19:03 Dave Hansen
  2014-12-08 19:03 ` [PATCH 2/2] x86 tlb: fix tracepoint nr_pages calculation Dave Hansen
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Hansen @ 2014-12-08 19:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dave Hansen, dave.hansen, stable


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) {
_

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] x86 tlb: fix tracepoint nr_pages calculation
  2014-12-08 19:03 [PATCH 1/2] x86 tlb: fix overflow of flush_end in remote tlb flush Dave Hansen
@ 2014-12-08 19:03 ` Dave Hansen
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Hansen @ 2014-12-08 19:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dave Hansen, dave.hansen, stable


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

We calculate nr_pages with f->flush_end and f->flush_start, both
of which are virtual addresses.  However, we only divide
f->flush_start by PAGE_SIZE, and missed f->flush_end.  This patch
adds some parenthesis to catch f->flush_end as well.

nr_pages is only used for a trace point.  This should not have
any functional impact other than keeping the trace point from
spitting out garbage for the flush length.

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

 b/arch/x86/mm/tlb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN arch/x86/mm/tlb.c~x86-tlb-fix-tracepoint-data arch/x86/mm/tlb.c
--- a/arch/x86/mm/tlb.c~x86-tlb-fix-tracepoint-data	2014-12-08 10:58:22.245782512 -0800
+++ b/arch/x86/mm/tlb.c	2014-12-08 10:58:22.248782647 -0800
@@ -129,7 +129,7 @@ static void flush_tlb_func(void *info)
 		} else {
 			unsigned long addr;
 			unsigned long nr_pages =
-				f->flush_end - f->flush_start / PAGE_SIZE;
+				(f->flush_end - f->flush_start) / PAGE_SIZE;
 			addr = f->flush_start;
 			while (addr < f->flush_end) {
 				__flush_tlb_single(addr);
_

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-08 19:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-08 19:03 [PATCH 1/2] x86 tlb: fix overflow of flush_end in remote tlb flush Dave Hansen
2014-12-08 19:03 ` [PATCH 2/2] x86 tlb: fix tracepoint nr_pages calculation Dave Hansen

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