[LTP] [PATCH 1/9] KVM: Disable EBP register use in 32bit code

Petr Vorel pvorel@suse.cz
Mon May 6 21:41:56 CEST 2024


Hi Martin,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

> 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>
> ---
>  testcases/kernel/kvm/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

> diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile
> index ce4a5ede2..c85790e11 100644
> --- a/testcases/kernel/kvm/Makefile
> +++ b/testcases/kernel/kvm/Makefile
> @@ -22,7 +22,7 @@ ifeq ($(HOST_CPU),x86_64)
>  endif

>  ifeq ($(HOST_CPU),x86)
> -	GUEST_CFLAGS += -m32
> +	GUEST_CFLAGS += -m32 -ffixed-ebp

FYI this will fail on 32 bit build on clang:

clang: error: unknown argument: '-ffixed-ebp'

I don't want to block this patchset which brings important test, but it'd be
great to fix it.

Is there clang equivalent? Or is it even needed for clang?

Either way, we need to detect clang. I don't think simple

ifeq ($(CXX),clang)

would be enough, because cc can be alias to clang.

Maybe wrap it with version detection:

ifeq ($(shell $(CC) -v 2>&1 | grep "clang version"), 1)
	GUEST_CFLAGS += -ffixed-ebp
endif

Kind regards,
Petr

>  	ASFLAGS += --32
>  endif


More information about the ltp mailing list