aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/sys_x86_64.c
diff options
context:
space:
mode:
authorMichel Lespinasse <walken@google.com>2012-12-11 19:01:56 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-11 20:22:25 -0500
commit7d025059650f1c41a427173789ac14b74212b361 (patch)
tree5905f22f0ff11f96850d7caeec90c8ae898c6d47 /arch/x86/kernel/sys_x86_64.c
parentf99024729e689f5de4534fde5400e3b035f068de (diff)
mm: fix cache coloring on x86_64 architecture
Fix the x86-64 cache alignment code to take pgoff into account. Use the x86 and MIPS cache alignment code as the basis for a generic cache alignment function. The old x86 code will always align the mmap to aliasing boundaries, even if the program mmaps the file with a non-zero pgoff. If program A mmaps the file with pgoff 0, and program B mmaps the file with pgoff 1. The old code would align the mmaps, resulting in misaligned pages: A: 0123 B: 123 After this patch, they are aligned so the pages line up: A: 0123 B: 123 Proposed by Rik van Riel. Signed-off-by: Michel Lespinasse <walken@google.com> Cc: Rik van Riel <riel@redhat.com> Cc: Hugh Dickins <hughd@google.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Paul Mundt <lethal@linux-sh.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Chris Metcalf <cmetcalf@tilera.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86/kernel/sys_x86_64.c')
-rw-r--r--arch/x86/kernel/sys_x86_64.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index f00d006d60fd..97ef74b88e0f 100644
--- a/arch/x86/kernel/sys_x86_64.c
+++ b/arch/x86/kernel/sys_x86_64.c
@@ -136,7 +136,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
136 info.low_limit = begin; 136 info.low_limit = begin;
137 info.high_limit = end; 137 info.high_limit = end;
138 info.align_mask = filp ? get_align_mask() : 0; 138 info.align_mask = filp ? get_align_mask() : 0;
139 info.align_offset = 0; 139 info.align_offset = pgoff << PAGE_SHIFT;
140 return vm_unmapped_area(&info); 140 return vm_unmapped_area(&info);
141} 141}
142 142
@@ -175,7 +175,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
175 info.low_limit = PAGE_SIZE; 175 info.low_limit = PAGE_SIZE;
176 info.high_limit = mm->mmap_base; 176 info.high_limit = mm->mmap_base;
177 info.align_mask = filp ? get_align_mask() : 0; 177 info.align_mask = filp ? get_align_mask() : 0;
178 info.align_offset = 0; 178 info.align_offset = pgoff << PAGE_SHIFT;
179 addr = vm_unmapped_area(&info); 179 addr = vm_unmapped_area(&info);
180 if (!(addr & ~PAGE_MASK)) 180 if (!(addr & ~PAGE_MASK))
181 return addr; 181 return addr;