From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Andrew Jones <ajones@ventanamicro.com>,
Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
alistair.francis@wdc.com, bmeng@tinylab.org,
liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com,
palmer@rivosinc.com, richard.henderson@linaro.org
Subject: Re: [PATCH v2 1/2] hw/riscv/virt.c: fix non-KVM --enable-debug build
Date: Thu, 31 Aug 2023 14:47:54 +0200 [thread overview]
Message-ID: <292f8ac7-402f-0da1-2f4e-40d5391c861a@linaro.org> (raw)
In-Reply-To: <20230831-d3b40182209cb9054ceaed62@orel>
On 31/8/23 10:42, Andrew Jones wrote:
> On Wed, Aug 30, 2023 at 10:35:02AM -0300, Daniel Henrique Barboza wrote:
>> A build with --enable-debug and without KVM will fail as follows:
>>
>> /usr/bin/ld: libqemu-riscv64-softmmu.fa.p/hw_riscv_virt.c.o: in function `virt_machine_init':
>> ./qemu/build/../hw/riscv/virt.c:1465: undefined reference to `kvm_riscv_aia_create'
>>
>> This happens because the code block with "if virt_use_kvm_aia(s)" isn't
>> being ignored by the debug build, resulting in an undefined reference to
>> a KVM only function.
>>
>> Add a 'kvm_enabled()' conditional together with virt_use_kvm_aia() will
>> make the compiler crop the kvm_riscv_aia_create() call entirely from a
>> non-KVM build. Note that adding the 'kvm_enabled()' conditional inside
>> virt_use_kvm_aia() won't fix the build because this function would need
>> to be inlined multiple times to make the compiler zero out the entire
>> block.
>>
>> While we're at it, use kvm_enabled() in all instances where
>> virt_use_kvm_aia() is checked to allow the compiler to elide these other
>> kvm-only instances as well.
>>
>> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
>> Fixes: dbdb99948e ("target/riscv: select KVM AIA in riscv virt machine")
>> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
>> ---
>> hw/riscv/virt.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
> I think I'd prefer
>
> /* We need this inlined for debug (-O0) builds */
> static inline QEMU_ALWAYS_INLINE bool virt_use_kvm_aia(RISCVVirtState *s)
> {
> return kvm_enabled() && kvm_irqchip_in_kernel() && s->aia_type == VIRT_AIA_TYPE_APLIC_IMSIC;
Generally we should know whether KVM is enabled or not _before_
calling any foo_kvm() code, not after.
> }
next prev parent reply other threads:[~2023-08-31 12:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-30 13:35 [PATCH v2 0/2] riscv: fix --enable-debug in riscv-to-apply.next Daniel Henrique Barboza
2023-08-30 13:35 ` [PATCH v2 1/2] hw/riscv/virt.c: fix non-KVM --enable-debug build Daniel Henrique Barboza
2023-08-30 14:15 ` Richard Henderson
2023-08-30 14:23 ` Philippe Mathieu-Daudé
2023-08-31 8:42 ` Andrew Jones
2023-08-31 9:22 ` Daniel Henrique Barboza
2023-08-31 12:47 ` Philippe Mathieu-Daudé [this message]
2023-08-31 14:20 ` Andrew Jones
2023-08-30 13:35 ` [PATCH v2 2/2] hw/intc/riscv_aplic.c " Daniel Henrique Barboza
2023-08-30 14:13 ` Richard Henderson
2023-08-30 14:24 ` Philippe Mathieu-Daudé
2023-08-31 8:50 ` Andrew Jones
2023-09-01 2:26 ` [PATCH v2 0/2] riscv: fix --enable-debug in riscv-to-apply.next Alistair Francis
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=292f8ac7-402f-0da1-2f4e-40d5391c861a@linaro.org \
--to=philmd@linaro.org \
--cc=ajones@ventanamicro.com \
--cc=alistair.francis@wdc.com \
--cc=bmeng@tinylab.org \
--cc=dbarboza@ventanamicro.com \
--cc=liweiwei@iscas.ac.cn \
--cc=palmer@rivosinc.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=zhiwei_liu@linux.alibaba.com \
/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).