From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] x86_64: Implement personality ADDR_LIMIT_32BIT
Date: Fri, 3 Oct 2008 12:33:34 +0300 [thread overview]
Message-ID: <1223026414-9500-1-git-send-email-kirill@shutemov.name> (raw)
In-Reply-To: <20081003080244.GC25408@elte.hu>
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 | 16 ++++++++++++----
include/asm-x86/elf.h | 4 +++-
include/asm-x86/processor.h | 6 ++++--
3 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index 3b360ef..7f8672d 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,13 @@ 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
+ * legacy 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
prev parent reply other threads:[~2008-10-03 9:32 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Kirill A. Shutemov [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=1223026414-9500-1-git-send-email-kirill@shutemov.name \
--to=kirill@shutemov.name \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/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).