@@ -393,7 +393,9 @@ LTP_CHECK_SYSCALL_FCNTL
LTP_CHECK_FSVERITY
AX_CHECK_COMPILE_FLAG([-no-pie], [LTP_CFLAGS_NOPIE=1])
+AX_CHECK_COMPILE_FLAG([-ffixed-ebp], [LTP_CFLAGS_FFIXED_EBP=1])
AC_SUBST([LTP_CFLAGS_NOPIE])
+AC_SUBST([LTP_CFLAGS_FFIXED_EBP])
if test "x$with_numa" = xyes; then
LTP_CHECK_SYSCALL_NUMA
@@ -86,6 +86,7 @@ LDFLAGS += $(WLDFLAGS)
CFLAGS += $(DEBUG_CFLAGS) $(OPT_CFLAGS) $(WCFLAGS) $(STDCFLAGS)
LTP_CFLAGS_NOPIE := @LTP_CFLAGS_NOPIE@
+LTP_CFLAGS_FFIXED_EBP := @LTP_CFLAGS_FFIXED_EBP@
ifeq ($(strip $(HOST_CFLAGS)),)
HOST_CFLAGS := $(CFLAGS)
@@ -24,6 +24,10 @@ endif
ifeq ($(HOST_CPU),x86)
GUEST_CFLAGS += -m32
ASFLAGS += --32
+
+ ifdef LTP_CFLAGS_FFIXED_EBP
+ GUEST_CFLAGS += -ffixed-ebp
+ endif
endif
# Some distros enable -pie by default. That breaks KVM payload linking.
The EBP register points to the stack segment by default but GCC uses it to access data segment without the proper prefix. This works fine on most systems because the stack and data segments are usually identical. However, KVM environment intentionally enforces strict limits on the stack segment and access to the data segment using unprefixed EBP would trigger stack segment fault exception in 32bit LTP builds (stack segment limits are ignored in 64bit mode). Signed-off-by: Martin Doucha <mdoucha@suse.cz> --- Changes since v1: - Detect -ffixed-ebp support in configure script and disable EBP conditionally configure.ac | 2 ++ include/mk/config.mk.in | 1 + testcases/kernel/kvm/Makefile | 4 ++++ 3 files changed, 7 insertions(+)