[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] hw/riscv/virt.c: fix non-KVM --enable-debug build
From: |
Daniel Henrique Barboza |
Subject: |
Re: [PATCH 2/2] hw/riscv/virt.c: fix non-KVM --enable-debug build |
Date: |
Tue, 29 Aug 2023 20:09:32 -0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 |
On 8/29/23 11:18, Philippe Mathieu-Daudé wrote:
On 29/8/23 14:21, 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 stub for kvm_riscv_aia_create() in kvm_riscv.h when CONFIG_KVM is
false. Adding it as an inline instead of using kvm-stubs.c will make it
easier in the future to remember to add stubs for kvm functions that are
used in multiple accelerator code.
Fixes: dbdb99948e ("target/riscv: select KVM AIA in riscv virt machine")
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
target/riscv/kvm_riscv.h | 10 ++++++++++
1 file changed, 10 insertions(+)
Similarly:
-- >8 --
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
@@ -79,7 +79,9 @@
/* KVM AIA only supports APLIC MSI. APLIC Wired is always emulated by QEMU. */
static bool virt_use_kvm_aia(RISCVVirtState *s)
{
- return kvm_irqchip_in_kernel() && s->aia_type == VIRT_AIA_TYPE_APLIC_IMSIC;
+ return kvm_enabled()
+ && kvm_irqchip_in_kernel()
+ && s->aia_type == VIRT_AIA_TYPE_APLIC_IMSIC;
}
---
It doesn't work. Same error:
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 388e52a294..ac710006e7 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -79,7 +79,8 @@
/* KVM AIA only supports APLIC MSI. APLIC Wired is always emulated by QEMU. */
static bool virt_use_kvm_aia(RISCVVirtState *s)
{
- return kvm_irqchip_in_kernel() && s->aia_type == VIRT_AIA_TYPE_APLIC_IMSIC;
+ return kvm_enabled() &&
+ kvm_irqchip_in_kernel() && s->aia_type == VIRT_AIA_TYPE_APLIC_IMSIC;
}
static const MemMapEntry virt_memmap[] = {
diff --git a/target/riscv/kvm_riscv.h b/target/riscv/kvm_riscv.h
index 01be45cc69..7d4b7c60e2 100644
--- a/target/riscv/kvm_riscv.h
+++ b/target/riscv/kvm_riscv.h
@@ -22,19 +22,9 @@
void kvm_riscv_init_user_properties(Object *cpu_obj);
void kvm_riscv_reset_vcpu(RISCVCPU *cpu);
void kvm_riscv_set_irq(RISCVCPU *cpu, int irq, int level);
-
-#ifdef CONFIG_KVM
void kvm_riscv_aia_create(MachineState *machine, uint64_t group_shift,
uint64_t aia_irq_num, uint64_t aia_msi_num,
uint64_t aplic_base, uint64_t imsic_base,
uint64_t guest_num);
-#else
-static inline void kvm_riscv_aia_create(MachineState *machine,
- uint64_t group_shift, uint64_t aia_irq_num,
- uint64_t aia_msi_num, uint64_t aplic_base,
- uint64_t imsic_base, uint64_t guest_num) {
- g_assert_not_reached();
-}
-#endif
/usr/bin/ld: libqemu-riscv64-softmmu.fa.p/hw_riscv_virt.c.o: in function
`virt_machine_init':
/home/danielhb/work/qemu/build/../hw/riscv/virt.c:1466: undefined reference to
`kvm_riscv_aia_create'
collect2: error: ld returned 1 exit status
I'm no compiler expert by any means but it seems that the --enable-debug build
does not strip things
out like the usual build does, e.g. it won't elide a 'if kvm_enabled()' block
out by checking that
kvm_enabled() is always false.
Thanks,
Daniel
?
- [PATCH 0/2] riscv: fix --enable-debug in riscv-to-apply.next, Daniel Henrique Barboza, 2023/08/29
- [PATCH 1/2] hw/intc/riscv_aplic.c fix non-KVM --enable-debug build, Daniel Henrique Barboza, 2023/08/29
- [PATCH 2/2] hw/riscv/virt.c: fix non-KVM --enable-debug build, Daniel Henrique Barboza, 2023/08/29
- Re: [PATCH 2/2] hw/riscv/virt.c: fix non-KVM --enable-debug build, Philippe Mathieu-Daudé, 2023/08/29
- Re: [PATCH 2/2] hw/riscv/virt.c: fix non-KVM --enable-debug build,
Daniel Henrique Barboza <=
- Re: [PATCH 2/2] hw/riscv/virt.c: fix non-KVM --enable-debug build, Richard Henderson, 2023/08/29
- Re: [PATCH 2/2] hw/riscv/virt.c: fix non-KVM --enable-debug build, Daniel Henrique Barboza, 2023/08/29
- Re: [PATCH 2/2] hw/riscv/virt.c: fix non-KVM --enable-debug build, Richard Henderson, 2023/08/29
- Re: [PATCH 2/2] hw/riscv/virt.c: fix non-KVM --enable-debug build, Daniel Henrique Barboza, 2023/08/30
- Re: [PATCH 2/2] hw/riscv/virt.c: fix non-KVM --enable-debug build, Richard Henderson, 2023/08/30