Re: [LTP] [PATCH] kvm: Fix Nix build failure by moving -fno-stack-protector to CFLAGS

Richard Palethorpe
2023-09-22T08:34:31Z

Hello,

Petr Vorel <petr.vorel@gmail.com> writes:

> Hi all,
>
> [I Cc Fabrice and Buildroot ML]
>
> On Tue, 19 Sept 2023 at 14:51, Martin Doucha <mdoucha@suse.cz> wrote:
>>
>> Hi,
>> pvorel should have a look whether it doesn't break the other systems
>> where -fno-stack-protector is needed, but otherwise:
>
> Yesterday night I tested the current LTP master with ./utils/test-pkg. Some
> Bootlin toolchains keep failing (bootlin-x86-64-musl, bootlin-x86-64-glibc):
>
> CC testcases/kernel/kvm/lib_x86.o
> gbr-test-pkg/bootlin-x86-64-musl/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-musl/11.3.0/../../../../x86_64-buildroot-linux-musl/bin/ld:
> lib_x86.o: in function `kvm_init_guest_vmcb':
> lib_x86.c:(.text+0x7c8): undefined reference to `__stack_chk_fail'
> collect2: error: ld returned 1 exit status
>
> Problems are only on x86_64, other archs (aarch64, riscv64, mipsel, amv7r)
> are OK.

I think only x86_64 is supported.

>
> NOTE: In Buildroot LTP is currently disabled when musl is used due 5.11
> headers requirement for musl toolchain [1], but I temporarily remove this
> requirement to get more testing. That's why there are also musl results.
>
> It looks like this patch actually fixes it, thus:
> Acked-by: Petr Vorel <pvorel@suse.cz>

Right, it's not just Nix then. I will merge it.

>
> There are even more kvm test related results [2], but I suspect they are more
> related to the Buildroot toolchain than LTP itself:
>
> CC testcases/kernel/kvm/lib_guest.o
> bootstrap_x86_64.S: Assembler messages:
> bootstrap_x86_64.S:16: Error: unknown pseudo-op: `.code16'
> bootstrap_x86_64.S:19: Error: unknown mnemonic `cli' -- `cli'
> bootstrap_x86_64.S:21: Error: unknown mnemonic `lgdt' -- `lgdt kvm_gdt32_desc'
> bootstrap_x86_64.S:23: Error: operand 1 must be an integer register --
> `mov $0x11,%eax'
> bootstrap_x86_64.S:24: Error: operand 1 must be an integer register --
> `mov %eax,%cr0'
> bootstrap_x86_64.S:26: Error: unknown mnemonic `jmp' -- `jmp
> $3*8,$protected_mode_entry'
> bootstrap_x86_64.S:28: Error: unknown pseudo-op: `.code32'

For me I would at the least we need V=1 enabled or the names and
versions of the tools being used to guess what is wrong here.

mov $0x11,%eax looks like a really simple op to put 11 in EAX using
AT&T/GAS syntax. If that goes wrong then possibly the wrong syntax is
expected by the assembler or else a previous line is confusing it.

--
Thank you,
Richard.