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

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