Blame SOURCES/0015-ld.hugetlbfs-powerpc64-Add-support-for-different-hug.patch

0dfa60
From adb3feea5dde087d7bb8017e5b8da2da548473bf Mon Sep 17 00:00:00 2001
0dfa60
Message-Id: <adb3feea5dde087d7bb8017e5b8da2da548473bf.1566225007.git.aquini@redhat.com>
0dfa60
In-Reply-To: <d42f467a923dfc09309acb7a83b42e3285fbd8f4.1566225007.git.aquini@redhat.com>
0dfa60
References: <d42f467a923dfc09309acb7a83b42e3285fbd8f4.1566225007.git.aquini@redhat.com>
0dfa60
From: Sandipan Das <sandipan@linux.ibm.com>
0dfa60
Date: Wed, 12 Jun 2019 12:34:32 +0530
0dfa60
Subject: [RHEL7 PATCH 15/31] ld.hugetlbfs: powerpc64: Add support for
0dfa60
 different huge page sizes
0dfa60
0dfa60
This ensures that the page and slice sizes are determined by
0dfa60
looking at the default huge page size and MMU type rather than
0dfa60
having them hardcoded.
0dfa60
0dfa60
This is important because powerpc64 supports different huge
0dfa60
page sizes based on the MMU type. Hash MMU supports 16MB and
0dfa60
16GB whereas Radix MMU supports 2MB and 1GB.
0dfa60
0dfa60
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
0dfa60
Signed-off-by: Eric B Munson <emunson@mgebm.net>
0dfa60
Signed-off-by: Rafael Aquini <aquini@redhat.com>
0dfa60
---
0dfa60
 ld.hugetlbfs | 17 +++++++++++++++--
0dfa60
 1 file changed, 15 insertions(+), 2 deletions(-)
0dfa60
0dfa60
diff --git a/ld.hugetlbfs b/ld.hugetlbfs
0dfa60
index 388f7b4..6ee8238 100755
0dfa60
--- a/ld.hugetlbfs
0dfa60
+++ b/ld.hugetlbfs
0dfa60
@@ -105,8 +105,16 @@ fi
0dfa60
 
0dfa60
 MB=$((1024*1024))
0dfa60
 case "$EMU" in
0dfa60
-elf32ppclinux|elf64ppc)	HPAGE_SIZE=$((16*$MB)) SLICE_SIZE=$((256*$MB)) ;;
0dfa60
-elf64lppc)		HPAGE_SIZE=$((16*$MB)) SLICE_SIZE=$((256*$MB)) ;;
0dfa60
+elf32ppclinux)		HPAGE_SIZE=$((16*$MB)) SLICE_SIZE=$((256*$MB)) ;;
0dfa60
+elf64ppc|elf64lppc)
0dfa60
+	hpage_kb=$(cat /proc/meminfo  | grep Hugepagesize: | awk '{print $2}')
0dfa60
+	MMU_TYPE=$(cat /proc/cpuinfo  | grep MMU | awk '{ print $3}')
0dfa60
+	HPAGE_SIZE=$((hpage_kb * 1024))
0dfa60
+	if [ "$MMU_TYPE" == "Hash" ] ; then
0dfa60
+		SLICE_SIZE=$((256*$MB))
0dfa60
+	else
0dfa60
+		SLICE_SIZE=$HPAGE_SIZE
0dfa60
+	fi ;;
0dfa60
 elf_i386|elf_x86_64)	HPAGE_SIZE=$((4*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
0dfa60
 elf_s390|elf64_s390)	HPAGE_SIZE=$((1*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
0dfa60
 armelf*_linux_eabi|aarch64elf*|aarch64linux*)
0dfa60
@@ -124,6 +132,11 @@ if [ "$HTLB_ALIGN" == "slice" ]; then
0dfa60
 	case "$EMU" in
0dfa60
 	armelf*_linux_eabi|aarch64elf*|aarch64linux*)	HTLBOPTS="$HTLBOPTS -Ttext-segment=$SLICE_SIZE" ;;
0dfa60
 	elf_i386)		HTLBOPTS="$HTLBOPTS -Ttext-segment=0x08000000" ;;
0dfa60
+	elf64ppc|elf64lppc)
0dfa60
+		if [ "$MMU_TYPE" == "Hash" ] ; then
0dfa60
+			printf -v TEXTADDR "%x" "$SLICE_SIZE"
0dfa60
+			HTLBOPTS="$HTLBOPTS -Ttext-segment=$TEXTADDR"
0dfa60
+		fi ;;
0dfa60
 	esac
0dfa60
 fi
0dfa60
 
0dfa60
-- 
0dfa60
1.8.3.1
0dfa60