From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PATCH] target/arm: Provide always-false kvm_arm_*_supported() stubs for usermode
Date: Mon, 14 Jul 2025 08:31:48 -0700 [thread overview]
Message-ID: <0b438773-01b9-42e1-8edf-2330e50387f8@linaro.org> (raw)
In-Reply-To: <20250714135152.1896214-1-peter.maydell@linaro.org>
On 7/14/25 6:51 AM, Peter Maydell wrote:
> If you try to build aarch64-linux-user with clang and --enable-debug then it
> fails to compile:
>
> ld: libqemu-aarch64-linux-user.a.p/target_arm_cpu64.c.o: in function `cpu_arm_set_sve':
> ../../target/arm/cpu64.c:321:(.text+0x1254): undefined reference to `kvm_arm_sve_supported'
>
> This is a regression introduced in commit f86d4220, which switched
> the kvm-stub.c file away from being built for all arm targets to only
> being built for system emulation binaries. It doesn't affect gcc,
> presumably because even at -O0 gcc folds away the always-false
> kvm_enabled() condition but clang does not.
>
> We would prefer not to build kvm-stub.c once for usermode and once
> for system-emulation binaries, and we can't build it just once for
> both because it includes cpu.h. So instead provide always-false
> versions of the five functions that are valid to call without KVM
> support in kvm_arm.h.
>
> Fixes: f86d42205c2eba ("target/arm/meson: accelerator files are not needed in user mode")
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3033
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> I'm never sure when we prefer to use stub-functions in separate C files
> vs when we prefer to have ifdeffed stubs in headers. There are several
> ways we could fix this compile error, so I just picked one...
> ---
> target/arm/kvm_arm.h | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
Thanks Peter, clang with --enable-debug is indeed a combination I didn't
try. I'll test this too now. Going through this topic, yes I noticed
that gcc always folds the any if (0) condition, and, based on a Richard
comment (I can't find now) it seems that we used to rely on that for
other parts of the code.
The fix you propose works well (initial goal was just to remove
CONFIG_KVM, so having CONFIG_USER_ONLY is ok), but I wonder if there is
something specific affecting clang in this case and preventing the folding.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Thanks,
Pierrick
next prev parent reply other threads:[~2025-07-14 16:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 13:51 [PATCH] target/arm: Provide always-false kvm_arm_*_supported() stubs for usermode Peter Maydell
2025-07-14 15:31 ` Pierrick Bouvier [this message]
2025-07-14 15:41 ` Pierrick Bouvier
2025-07-14 15:52 ` Richard Henderson
2025-07-14 17:38 ` Pierrick Bouvier
2025-07-15 20:43 ` Pierrick Bouvier
2025-07-14 19:49 ` Philippe Mathieu-Daudé
2025-07-17 16:56 ` Peter Maydell
2025-07-17 17:05 ` Pierrick Bouvier
2025-07-17 17:12 ` Peter Maydell
2025-07-17 17:29 ` Pierrick Bouvier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0b438773-01b9-42e1-8edf-2330e50387f8@linaro.org \
--to=pierrick.bouvier@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).