diff mbox

[3.19.y-ckt,stable] Patch "s390/mm: align 64-bit PIE binaries to 4GB" has been added to the 3.19.y-ckt tree

Message ID 1462376056-12388-1-git-send-email-kamal@canonical.com
State New
Headers show

Commit Message

Kamal Mostafa May 4, 2016, 3:34 p.m. UTC
This is a note to let you know that I have just added a patch titled

    s390/mm: align 64-bit PIE binaries to 4GB

to the linux-3.19.y-queue branch of the 3.19.y-ckt extended stable tree 
which can be found at:

    https://git.launchpad.net/~canonical-kernel/linux/+git/linux-stable-ckt/log/?h=linux-3.19.y-queue

This patch is scheduled to be released in version 3.19.8-ckt21.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.19.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

---8<------------------------------------------------------------

From 6bb57bb08175b353677ae73718e900ec9331d17d Mon Sep 17 00:00:00 2001
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
Date: Thu, 12 Feb 2015 14:17:52 +0100
Subject: s390/mm: align 64-bit PIE binaries to 4GB

commit 4ba2815d3bf38d6a959d2d11b08cf862550dcfcc upstream.

The base address (STACK_TOP / 3 * 2) for a 64-bit program is two thirds
into the 4GB segment at 0x2aa00000000. The randomization added on z13
can eat another 1GB of the remaining 1.33GB to the next 4GB boundary.
In the worst case 300MB are left for the executable + bss which may
cross into the next 4GB segment. This is bad for branch prediction,
therefore align the base address to 4GB to give the program more room
before it crosses the 4GB boundary.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 arch/s390/mm/mmap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--
2.7.4
diff mbox

Patch

diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index d008f638..179a2c2 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -183,7 +183,10 @@  unsigned long randomize_et_dyn(void)
 {
 	unsigned long base;

-	base = (STACK_TOP / 3 * 2) & (~mmap_align_mask << PAGE_SHIFT);
+	base = STACK_TOP / 3 * 2;
+	if (!is_32bit_task())
+		/* Align to 4GB */
+		base &= ~((1UL << 32) - 1);
 	return base + mmap_rnd();
 }