linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86_64: Implement personality ADDR_LIMIT_32BIT
@ 2008-10-03  7:04 Kirill A. Shutemov
  2008-10-03  8:02 ` Ingo Molnar
  0 siblings, 1 reply; 32+ messages in thread
From: Kirill A. Shutemov @ 2008-10-03  7:04 UTC (permalink / raw)
  To: linux-kernel, linux-mm
  Cc: Kirill A. Shutemov, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	Andrew Morton

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 arch/x86/kernel/sys_x86_64.c |   15 +++++++++++----
 include/asm-x86/elf.h        |    4 +++-
 include/asm-x86/processor.h  |    6 ++++--
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index 3b360ef..d6ac928 100644
--- a/arch/x86/kernel/sys_x86_64.c
+++ b/arch/x86/kernel/sys_x86_64.c
@@ -48,7 +48,9 @@ out:
 static void find_start_end(unsigned long flags, unsigned long *begin,
 			   unsigned long *end)
 {
-	if (!test_thread_flag(TIF_IA32) && (flags & MAP_32BIT)) {
+	if (!test_thread_flag(TIF_IA32) &&
+	    ((flags & MAP_32BIT) ||
+	     (current->personality & ADDR_LIMIT_32BIT))) {
 		unsigned long new_begin;
 		/* This is usually used needed to map code in small
 		   model, so it needs to be in the first 31bit. Limit
@@ -94,7 +96,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 		    (!vma || addr + len <= vma->vm_start))
 			return addr;
 	}
-	if (((flags & MAP_32BIT) || test_thread_flag(TIF_IA32))
+	if (((flags & MAP_32BIT) || test_thread_flag(TIF_IA32) ||
+	     (current->personality & ADDR_LIMIT_32BIT))
 	    && len <= mm->cached_hole_size) {
 	        mm->cached_hole_size = 0;
 		mm->free_area_cache = begin;
@@ -150,8 +153,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	if (flags & MAP_FIXED)
 		return addr;
 
-	/* for MAP_32BIT mappings we force the legact mmap base */
-	if (!test_thread_flag(TIF_IA32) && (flags & MAP_32BIT))
+	/* for MAP_32BIT mappings and ADDR_LIMIT_32BIT personality we force the
+	 * legact mmap base
+	 */
+	if (!test_thread_flag(TIF_IA32) &&
+	    ((flags & MAP_32BIT) ||
+	     (current->personality & ADDR_LIMIT_32BIT)))
 		goto bottomup;
 
 	/* requesting a specific address */
diff --git a/include/asm-x86/elf.h b/include/asm-x86/elf.h
index 7be4733..fa39e10 100644
--- a/include/asm-x86/elf.h
+++ b/include/asm-x86/elf.h
@@ -298,7 +298,9 @@ do {									\
 #define VDSO_HIGH_BASE		0xffffe000U /* CONFIG_COMPAT_VDSO address */
 
 /* 1GB for 64bit, 8MB for 32bit */
-#define STACK_RND_MASK (test_thread_flag(TIF_IA32) ? 0x7ff : 0x3fffff)
+#define STACK_RND_MASK ((test_thread_flag(TIF_IA32) || \
+			 current->personality & ADDR_LIMIT_32BIT ) ? \
+			0x7ff : 0x3fffff)
 
 #define ARCH_DLINFO							\
 do {									\
diff --git a/include/asm-x86/processor.h b/include/asm-x86/processor.h
index 4df3e2f..6d7f2f9 100644
--- a/include/asm-x86/processor.h
+++ b/include/asm-x86/processor.h
@@ -904,7 +904,8 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
 #define TASK_SIZE_OF(child)	((test_tsk_thread_flag(child, TIF_IA32)) ? \
 					IA32_PAGE_OFFSET : TASK_SIZE64)
 
-#define STACK_TOP		TASK_SIZE
+#define STACK_TOP		(current->personality & ADDR_LIMIT_32BIT ? \
+					 0x80000000 : TASK_SIZE)
 #define STACK_TOP_MAX		TASK_SIZE64
 
 #define INIT_THREAD  { \
@@ -932,7 +933,8 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
  * This decides where the kernel will search for a free chunk of vm
  * space during mmap's.
  */
-#define TASK_UNMAPPED_BASE	(PAGE_ALIGN(TASK_SIZE / 3))
+#define TASK_UNMAPPED_BASE	(current->personality & ADDR_LIMIT_32BIT ? \
+					0x40000000 : PAGE_ALIGN(TASK_SIZE / 3))
 
 #define KSTK_EIP(task)		(task_pt_regs(task)->ip)
 
-- 
1.5.6.5.GIT


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

end of thread, other threads:[~2008-10-07 15:04 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-03  7:04 [PATCH] x86_64: Implement personality ADDR_LIMIT_32BIT Kirill A. Shutemov
2008-10-03  8:02 ` Ingo Molnar
2008-10-03  9:25   ` Kirill A. Shutemov
2008-10-03 12:44     ` Arjan van de Ven
2008-10-03 12:58       ` Kirill A. Shutemov
2008-10-06  6:13     ` Andi Kleen
2008-10-06  8:17       ` Kirill A. Shutemov
2008-10-06  8:42         ` Andi Kleen
2008-10-06  9:17           ` Kirill A. Shutemov
2008-10-06  9:56             ` Andi Kleen
2008-10-06 10:12               ` Kirill A. Shutemov
2008-10-06 13:26                 ` Andi Kleen
2008-10-06 14:37                   ` [PATCH, RFC] shmat: introduce flag SHM_MAP_HINT Kirill A. Shutemov
2008-10-06 19:29                     ` Andi Kleen
2008-10-07  6:57                       ` Kirill A. Shutemov
2008-10-07  6:57                       ` [PATCH, RFC, v2] " Kirill A. Shutemov
2008-10-07  8:20                         ` Andi Kleen
2008-10-07 10:09                           ` Kirill A. Shutemov
2008-10-07 11:26                             ` Andi Kleen
2008-10-07 11:23                               ` Kirill A. Shutemov
2008-10-07 14:38                               ` Hugh Dickins
2008-10-07 15:10                                 ` Andi Kleen
2008-10-07 11:08                     ` [PATCH, RFC] " KOSAKI Motohiro
2008-10-07 11:21                       ` Andi Kleen
2008-10-07 11:21                         ` Kirill A. Shutemov
2008-10-07 11:26                         ` KOSAKI Motohiro
2008-10-07 11:30                           ` Kirill A. Shutemov
2008-10-07 11:50                             ` Andi Kleen
2008-10-07 11:24                       ` Kirill A. Shutemov
2008-10-07 12:31                         ` Alan Cox
2008-10-07 13:14                           ` Andi Kleen
2008-10-03  9:33   ` [PATCH] x86_64: Implement personality ADDR_LIMIT_32BIT Kirill A. Shutemov

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