Skip to content

Commit 72b0196

Browse files
s390/kpatch-build: Restrict -mno-pic-data-is-text-relative flag
s390 -mno-pic-data-is-text-relative prevents relative addressing between code and data. The cflag option was introduced to avoid PC32 relocation errors when the kpatch text and data segments are placed far apart. However, since the Linux kernel commit c98d2ecae08f ("s390/mm: Uncouple physical vs virtual address spaces"), the kernel, modules, and data segments remain close to each other, and therefore no longer risk PC32 relocation errors. Additionally, with the recent kernel commit 04dabb4261c3 ("s390/bug: Implement __WARN_printf()") git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git for-next branch, it has inline assembly which uses string literals as immediate operands. gcc fails to compile kpatch module when -mno-pic-data-is-text-relative is used. Therefore, restrict the use of -mno-pic-data-is-text-relative to kernels prior to commit c98d2ecae08f. Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
1 parent 7552b46 commit 72b0196

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

kpatch-build/kpatch-build

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,15 @@ use_klp_arch()
269269
fi
270270
}
271271

272+
use_s390_no_pic_data_is_text_relative_flag()
273+
{
274+
if kernel_is_rhel; then
275+
! rhel_kernel_version_gte 5.14.0-596.el9
276+
else
277+
! kernel_version_gte 6.10.0
278+
fi
279+
}
280+
272281
support_klp_replace()
273282
{
274283
if kernel_is_rhel; then
@@ -1285,7 +1294,8 @@ if [[ "$ARCH" = "ppc64le" ]]; then
12851294
fi
12861295

12871296
if [[ "$ARCH" = "s390x" ]]; then
1288-
ARCH_KCFLAGS="-mno-pic-data-is-text-relative -fno-section-anchors"
1297+
ARCH_KCFLAGS="-fno-section-anchors"
1298+
use_s390_no_pic_data_is_text_relative_flag && ARCH_KCFLAGS+=" -mno-pic-data-is-text-relative"
12891299
! kernel_version_gte 6.10.0 && ARCH_KCFLAGS+=" -fPIE"
12901300
fi
12911301

0 commit comments

Comments
 (0)