From: Andrew Jones <ajones@ventanamicro.com>
To: 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 10:42:33 +0200 [thread overview]
Message-ID: <20230831-d3b40182209cb9054ceaed62@orel> (raw)
In-Reply-To: <20230830133503.711138-2-dbarboza@ventanamicro.com>
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(-)
>
> diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> index 388e52a294..3b259b9305 100644
> --- a/hw/riscv/virt.c
> +++ b/hw/riscv/virt.c
> @@ -782,7 +782,7 @@ static void create_fdt_sockets(RISCVVirtState *s, const MemMapEntry *memmap,
> }
>
> /* KVM AIA only has one APLIC instance */
> - if (virt_use_kvm_aia(s)) {
> + if (kvm_enabled() && virt_use_kvm_aia(s)) {
> create_fdt_socket_aplic(s, memmap, 0,
> msi_m_phandle, msi_s_phandle, phandle,
> &intc_phandles[0], xplic_phandles,
> @@ -808,7 +808,7 @@ static void create_fdt_sockets(RISCVVirtState *s, const MemMapEntry *memmap,
>
> g_free(intc_phandles);
>
> - if (virt_use_kvm_aia(s)) {
> + if (kvm_enabled() && virt_use_kvm_aia(s)) {
> *irq_mmio_phandle = xplic_phandles[0];
> *irq_virtio_phandle = xplic_phandles[0];
> *irq_pcie_phandle = xplic_phandles[0];
> @@ -1461,7 +1461,7 @@ static void virt_machine_init(MachineState *machine)
> }
> }
>
> - if (virt_use_kvm_aia(s)) {
> + if (kvm_enabled() && virt_use_kvm_aia(s)) {
> kvm_riscv_aia_create(machine, IMSIC_MMIO_GROUP_MIN_SHIFT,
> VIRT_IRQCHIP_NUM_SOURCES, VIRT_IRQCHIP_NUM_MSIS,
> memmap[VIRT_APLIC_S].base,
> --
> 2.41.0
>
>
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;
}
assuming that works.
Either way,
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Thanks,
drew
next prev parent reply other threads:[~2023-08-31 8:43 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 [this message]
2023-08-31 9:22 ` Daniel Henrique Barboza
2023-08-31 12:47 ` Philippe Mathieu-Daudé
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=20230831-d3b40182209cb9054ceaed62@orel \
--to=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).